void ICACHE_FLASH_ATTR check_door_status_cb(void *arg) { os_timer_disarm(&check_door_status_timer); if (!easygpio_inputGet(DOOR_STATUS_IO)) { easygpio_outputSet(JIDIANQI_IO, 1); } os_timer_arm(&check_door_status_timer, CHECK_DOOR_DELAY, 1); }
void ICACHE_FLASH_ATTR switchTimerCb(uint32_t *args) { const swOnMax = 100; const swOffMax = 5; static int switchPulseCount; static enum { IDLE, ON, OFF } switchState = IDLE; if (!easygpio_inputGet(SWITCH)) { // Switch is active LOW switch (switchState) { case IDLE: switchState = ON; switchCount++; switchPulseCount = 1; break; case ON: if (++switchCount > swOnMax) switchCount = swOnMax; break; case OFF: switchState = ON; switchCount = 0; switchPulseCount++; break; default: switchState = IDLE; break; } } else { switch (switchState) { case IDLE: break; case ON: switchCount = 0; switchState = OFF; break; case OFF: if (++switchCount > swOffMax) { switchState = IDLE; switchAction(switchPulseCount); INFOP("SW action %d, light %d\n", switchPulseCount, lightCount); switchPulseCount = 0; } break; default: switchState = IDLE; break; } } if (lightCount >= 1) lightCount--; else lightOff(); }
void ICACHE_FLASH_ATTR printOutputs(void) { int idx; for (idx=PIR1; idx<=PIR2; idx++) { os_printf("PIR[%d]: %d (%d)\n", idx, pirFanStatus[idx], easygpio_inputGet(pirPins[idx])); } os_printf("OP: "); for (idx = 0; idx < OUTPUTS; idx++) { os_printf("%d [%d] ", currentOutputs[idx], outputOverrides[idx]); } os_printf("\n"); }
static void ICACHE_FLASH_ATTR switchTimerCb(uint32_t *args) { // 100mS const int swOnMax = 100; const int swOffMax = 5; static int switchPulseCount; static enum { IDLE, ON, OFF } switchState = IDLE; if (!easygpio_inputGet(SWITCH)) { // Switch is active LOW switch (switchState) { case IDLE: switchState = ON; switchCount++; switchPulseCount = 1; break; case ON: if (++switchCount > swOnMax) switchCount = swOnMax; break; case OFF: switchState = ON; switchCount = 0; switchPulseCount++; break; default: switchState = IDLE; break; } } else { switch (switchState) { case IDLE: break; case ON: switchCount = 0; switchState = OFF; break; case OFF: if (++switchCount > swOffMax) { switchState = IDLE; if (SwitchActionCb) SwitchActionCb(switchPulseCount); switchPulseCount = 0; } break; default: switchState = IDLE; break; } } }
bool ICACHE_FLASH_ATTR switchInConfigMode(void) { return easygpio_inputGet(TOGGLE); }
bool ICACHE_FLASH_ATTR pirState(enum pir_t pir) { return easygpio_inputGet(pirPins[pir]); }