//------------------- use left as cancel ------------------- menu_element_class * left_action() { #ifdef CORE_ATMEGA #elif defined SIDE_ATMEGA data->lcd->clear(); #endif enter_action(); return this; }
//------------------- undo ------------------- menu_element_class * left_action() { if(locked) { locked = false; for(byte i = 0; i < cnst::name_length - 1; ++i) { data->tier_name[data->map[target]][i] = backup[i]; } } #ifdef SIDE_ATMEGA data->lcd->clear(); #endif enter_action(); return this; }
//------------------- save ------------------- menu_element_class * right_action() { if(locked) { #ifdef CORE_ATMEGA for(byte i = 0; i < cnst::name_length - 1; ++i) { data->disk->write(eeprom::name_start_adr + data->map[target] * cnst::name_length + i , data->tier_name[data->map[target]][i]); } delayMs(cnst::watch_time); #elif defined SIDE_ATMEGA data->lcd->clear(); data->lcd->print(text::get(text::renameDone)); print(); delay(cnst::watch_time); data->lcd->clear(); #endif locked = false; enter_action(); } else { locked = true; for(byte i = 0; i < cnst::name_length - 1; ++i) { backup[i] = data->tier_name[data->map[target]][i]; } #ifdef CORE_ATMEGA #elif defined SIDE_ATMEGA data->lcd->clear(); data->lcd->print(text::get(text::editName)); print(); #endif } return this; }
void ResState::change( State new_state, Activity new_act ) { bool statechange = false, actchange = false; int now; if( new_state != r_state ) { statechange = true; } if( new_act != r_act ) { actchange = true; } if( ! (actchange || statechange) ) { return; // If we're not changing anything, return } // leave_action and enter_action return TRUE if they result in // a state or activity change. In these cases, we want to // abort the current state change. if( leave_action( r_state, r_act, new_state, new_act, statechange ) ) { return; } if( statechange && !actchange ) { dprintf( D_ALWAYS, "Changing state: %s -> %s\n", state_to_string(r_state), state_to_string(new_state) ); } else if (actchange && !statechange ) { dprintf( D_ALWAYS, "Changing activity: %s -> %s\n", activity_to_string(r_act), activity_to_string(new_act) ); } else { dprintf( D_ALWAYS, "Changing state and activity: %s/%s -> %s/%s\n", state_to_string(r_state), activity_to_string(r_act), state_to_string(new_state), activity_to_string(new_act) ); } now = time( NULL ); // Record the time we spent in the previous state updateHistoryTotals(now); if( statechange ) { m_stime = now; // Also reset activity time m_atime = now; r_state = new_state; if( r_state == r_destination ) { // We've reached our destination, so we can reset it. r_destination = no_state; } } if( actchange ) { r_act_was_benchmark = ( r_act == benchmarking_act ); r_act = new_act; m_atime = now; } if( enter_action( r_state, r_act, statechange, actchange ) ) { return; } // Update resource availability statistics on state changes rip->r_avail_stats.update( r_state, r_act ); // Note our current state and activity in the classad this->publish( rip->r_classad, A_ALL ); // We want to update the CM on every state or activity change rip->update(); #if HAVE_BACKFILL /* in the case of Backfill/Idle, we do *not* want to do the following check for idleness or retirement, we just want to let the usual polling interval cover our next eval(). so, if we're in Backfill, we can immediately return now... */ if( r_state == backfill_state ) { return; } #endif /* HAVE_BACKFILL */ if( r_act == retiring_act || r_act == idle_act ) { // When we enter retirement or idleness, check right away to // see if we should be preempting instead. this->eval(); } return; }