static uint8_t EnterTimeState_handleIr(  uint8_t cmdCode )
{
  uint8_t caller = g_stateStack[ g_currentIdxs[MS_enterTime] - 1];
  if(    (   (MS_setSystemTime == caller) 
          && (UI_SET_TIME      == cmdCode))
      || (   (MS_setOnOffTime    == caller) 
          && (UI_SET_ONOFF_TIMES == cmdCode)))
  {
    if( ETS_hour == mode_enterTimeState.curSubState ){
      log_time("TM\n");
      mode_enterTimeState.curSubState = ETS_minutes;
    }else if( ETS_minutes == mode_enterTimeState.curSubState){
      log_time("TS\n");
      mode_enterTimeState.time.ss = 0;
      mode_enterTimeState.prohibitLeave = FALSE;
      pwm_release_brightness();
      quitMyself(MS_enterTime, &(mode_enterTimeState.time));
      return TRUE;
    }
  }else if(    UI_UP   == cmdCode
            || UI_DOWN == cmdCode)
  {
    log_state("CHS\n");
    int8_t dir = UI_UP == cmdCode?1:-1;
    if( ETS_hour == mode_enterTimeState.curSubState )
    {
      incDecRangeOverflow(&(mode_enterTimeState.time.hh), dir, 23);
      if(   mode_enterTimeState.time.hh >=USER_ENTERTIME_DAY_NIGHT_CHANGE_HOUR 
         && mode_enterTimeState.time.hh < USER_ENTERTIME_DAY_NIGHT_CHANGE_HOUR+12 )
      {
        pwm_lock_brightness_val(USER_ENTERTIME_DAY_BRIGHTNESS);
      }else{
        pwm_lock_brightness_val(USER_ENTERTIME_NIGHT_BRIGHTNESS);
      }
    }else if( ETS_minutes == mode_enterTimeState.curSubState){
      if( MS_setOnOffTime == caller ){
        dir *= USER_ENTER_ONOFF_TIME_STEP;
      }
      incDecRangeOverflow(&(mode_enterTimeState.time.mm), dir, 59);
    }

  }else{
    //return FALSE;
  }
  dispInternalTime(&mode_enterTimeState.time, 
                   ((ETS_hour == mode_enterTimeState.curSubState)
                    ? display_getHoursMask()
                    : display_getMinuteMask()
                    ) | display_getTimeSetIndicatorMask()) ;

  return 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
}
static void EnterTimeState_enter( const void* param )
{
  log_time("TH\n");
  mode_enterTimeState.time = *((DATETIME*)param);
  mode_enterTimeState.curSubState = ETS_hour;
  mode_enterTimeState.prohibitLeave = TRUE;

  if(   mode_enterTimeState.time.hh >=USER_ENTERTIME_DAY_NIGHT_CHANGE_HOUR 
     && mode_enterTimeState.time.hh < USER_ENTERTIME_DAY_NIGHT_CHANGE_HOUR+12 )
  {
    pwm_lock_brightness_val(USER_ENTERTIME_DAY_BRIGHTNESS);
  }else{
    pwm_lock_brightness_val(USER_ENTERTIME_NIGHT_BRIGHTNESS);
  }
  dispInternalTime( &mode_enterTimeState.time, display_getHoursMask()|display_getTimeSetIndicatorMask() );
}
Example #4
0
/**
 * @brief Makes the given state to quit itself
 *
 * This will invoke leaveSubState() on the current index of the given mode
 * (g_currentIdxs). It will then reset the display state, and invoke
 * UserState_SubstateFinished() on the "parent" of the state just left.
 *
 * This is expected to be used on states that have fulfilled their actual task,
 * and want to hand over control to the "parent" again.
 *
 * @param state The state that should leave itself
 * @param result Result to be handed over to the "parent", might be NULL
 *
 * @see leaveSubState()
 * @see g_currentIdxs
 * @see UserState_SubstateFinished()
 */
void quitMyself(menu_state_t state, const void* result)
{

    bool success;
    int8_t currentIdx = g_currentIdxs[state];

    log_state("quit self\n");

    success = leaveSubState(currentIdx);

    if (!success) {

        log_state("ERROR: leaving substates failed\n");

    }

    dispInternalTime(datetime_get(), 0);
    UserState_SubstateFinished(g_stateStack[currentIdx - 1], state, result);

    log_state("quit self finished\n");

}