static void SetOnOffTimeState_substateFinished (e_MenuStates finishedState, const void* result) { if( finishedState == MS_enterTime) { const DATETIME* time = result; DATETIME dt = *time; g_params->autoOffTimes[mode_setOnOffTimeState.currentTimeToSet].h = dt.hh; g_params->autoOffTimes[mode_setOnOffTimeState.currentTimeToSet].m = dt.mm; ++mode_setOnOffTimeState.currentTimeToSet; if( UI_AUTOOFFTIMES_COUNT == mode_setOnOffTimeState.currentTimeToSet ) { DisplayState dispData; dispData = display_getNumberDisplayState(g_params->useAutoOffAnimation+1); display_setDisplayState(dispData, dispData); if(g_params->useAutoOffAnimation) { g_animPreview = 1; } else { g_animPreview = 0; } }else{ dt.hh = g_params->autoOffTimes[mode_setOnOffTimeState.currentTimeToSet].h; dt.mm = g_params->autoOffTimes[mode_setOnOffTimeState.currentTimeToSet].m; addSubState(MS_setOnOffTime, MS_enterTime, &dt); } } }
static void SetSystemTimeState_enter( const void* param ) { log_state("SST\n"); addSubState(MS_setSystemTime, MS_enterTime, &g_dateTime ); mode_setSystemTimeState.prohibitLeave = TRUE; }
static void SetOnOffTimeState_enter( const void* param ) { DATETIME dt = {0,0,0,0,0,0,0}; dt.hh = g_params->autoOffTimes[0].h; dt.mm = g_params->autoOffTimes[0].m; log_state("SOOT\n"); mode_setOnOffTimeState.currentTimeToSet = 0; addSubState(MS_setOnOffTime , MS_enterTime , &dt); mode_setOnOffTimeState.prohibitLeave = TRUE; }
static void NormalState_enter( const void* param ) { log_state("nm\n"); #if (MONO_COLOR_CLOCK != 1) pwm_set_color_step( g_params->colorPresets[g_params->curColorProfile].r, g_params->colorPresets[g_params->curColorProfile].g, g_params->colorPresets[g_params->curColorProfile].b); if( ((uint16_t)param) != 0 ){ addSubState(MS_normalMode, MS_showNumber, (void*)(((uint16_t)g_params->curColorProfile+1)) ); /* doulbe cast to avoid warning */ } #else dispInternalTime( &g_dateTime, 0); // force update of display (in multicolor this is done on substate exit) #endif }
/** * @brief Handles the given user command * * This handles the given user command (user_command_t) either by processing * it directly, or by passing it over to the actual handler using * UserState_HandleUserCommand(). * * g_eepromSaveDelay and g_checkIfAutoOffDelay get reset every time this * function is called to make sure the appropriate functionality works as * intended. * * @param user_command The user command that should be handled * * @see UserState_HandleUserCommand() * @see g_eepromSaveDelay * @see g_checkIfAutoOffDelay */ void handle_user_command(user_command_t user_command) { if (UC_ONOFF == user_command) { log_state("OF\n"); if (user_power_state < UPS_AUTO_OFF) { user_power_state = UPS_MANUAL_OFF; pwm_off(); } else { if (user_power_state == UPS_MANUAL_OFF) { user_power_state = UPS_NORMAL_ON; } else { user_power_state = UPS_OVERRIDE_ON; } pwm_on(); user_setNewTime(NULL); } preferences_save(); } else { int8_t i; bool handled = false; for (i = g_topOfStack - 1; i >= 0 && !handled; --i) { handled |= UserState_HandleUserCommand(g_stateStack[i], user_command); } if (!handled) { if (UC_BRIGHTNESS_UP == user_command) { log_state("B+\n"); pwm_increase_brightness(); } else if (UC_BRIGHTNESS_DOWN == user_command) { log_state("B-\n"); pwm_decrease_brightness(); } else if (UC_NORMAL_MODE == user_command) { addSubState(-1, MS_normalMode, (void*)1); } else if (UC_SET_TIME == user_command) { addState(MS_setSystemTime, NULL); } else if (UC_SET_ONOFF_TIMES == user_command) { addState(MS_setOnOffTime, NULL); } else if (UC_DEMO_MODE == user_command) { menu_state_t curTop = user_get_current_menu_state(); log_state("BS\n"); if (MS_demoMode == curTop) { quitMyself(MS_demoMode, NULL); } else { addState(MS_demoMode, NULL); } } else if (UC_CALIB_BRIGHTNESS == user_command) { pwm_modifyLdrBrightness2pwmStep(); // Indicate the change to user if (pwm_is_enabled()) { pwm_off(); _delay_ms(USER_VISUAL_INDICATION_TOGGLE_MS); pwm_on(); } } else if (UC_PULSE_MODE == user_command) { menu_state_t curTop = user_get_current_menu_state(); log_state("PLS\n"); if (MS_pulse == curTop) { leaveSubState(g_topOfStack - 1); } else { if ((MS_normalMode == curTop) #if (ENABLE_RGB_SUPPORT == 1) || (MS_hueMode == curTop) #endif ) { addState(MS_pulse, NULL); } } DISPLAY_SPECIAL_USER_COMMANDS_HANDLER #if (ENABLE_RGB_SUPPORT == 1) } else if (UC_HUE_MODE == user_command) { log_state("HM"); addSubState(-1, MS_hueMode, NULL); #endif #if (ENABLE_DCF_SUPPORT == 1) } else if (UC_DCF_GET_TIME == user_command) { log_state("DCF\n"); dcf77_enable(); #endif #if (ENABLE_AMBILIGHT_SUPPORT == 1) } else if (UC_AMBILIGHT == user_command) { log_state("AL\n"); PIN(USER_AMBILIGHT) |= _BV(BIT(USER_AMBILIGHT)); #endif #if (ENABLE_BLUETOOTH_SUPPORT == 1) } else if (UC_BLUETOOTH == user_command) { log_state("BT\n"); PIN(USER_BLUETOOTH) |= _BV(BIT(USER_BLUETOOTH)); #endif #if (ENABLE_AUXPOWER_SUPPORT == 1) } else if (UC_AUXPOWER == user_command) { log_state("AUX\n"); PIN(USER_AUXPOWER) |= _BV(BIT(USER_AUXPOWER)); #endif } else { return; } }