/********************************* IR DECODE *********************************/
#define IR_FRAME_BITS 48 // Total bits of one frame data
#define IR_FRAME_BYTES (IR_FRAME_BITS/8) // Length of one frame data
uint8_t ir_bits_cnt; // Counter for data bits
uint8_t ir_data[IR_FRAME_BYTES];// Ir data buffer
uint8_t ir_data_ptr;
bit ir_data_ready; // 1-Data be ready
while (1) {
if (refresh_timeslice < LED_NUM) {
// Leds's turn, refresh Led display
LED_EN_COM(refresh_timeslice);
LED_SET_DATA(led_data[refresh_timeslice]);
} else {
// Keypad's turn, read keypad value
LED_DIS_ALL_COMS(); // First disable all Leds
_pb = 0xff; // Pull-High port(b)
_pbc= 0x7e; // Set port(b) to be input mode
tx_data = _pb; // Save status of port(b) to tx_data
// Refresh LOCK-Led's status
LOCK = lock_status;
}
if (ir_data_ready) {
// Keycode is valid?
if ((ir_data[0] == ir_custom_code[0]) && (ir_data[1] == ir_custom_code[1])
&&(ir_data[2] == ir_custom_code[2]) && (ir_data[3] == ir_custom_code[3])
&&(ir_data[4] == ir_keyvalue_pwr[0])&& (ir_data[5] == ir_keyvalue_pwr[1])) {
// Check whether Key-PWR is pressed repeatedly.
if (pwr_flag == 0) {
STANDBY = ~STANDBY;