Strategy::statusType doStrategy() { Screen::keyboardButton = BUTTON_NONE; bool run = true; uint16_t newMesurmentData = 0; Strategy::statusType status = Strategy::RUNNING; strategyPowerOn(); do { Screen::keyboardButton = Keyboard::getPressedWithSpeed(); Screen::doStrategy(); if(run) { status = Monitor::run(); run = analizeStrategyStatus(status); if(run && newMesurmentData != AnalogInputs::getFullMeasurementCount()) { newMesurmentData = AnalogInputs::getFullMeasurementCount(); status = strategyDoStrategy(); run = analizeStrategyStatus(status); } } if(!run && exitImmediately && status != Strategy::ERROR) break; } while(Screen::keyboardButton != BUTTON_STOP); strategyPowerOff(); return status; }
bool analizeStrategyStatus(Strategy::statusType status) { bool run = true; if(status == Strategy::ERROR) { strategyPowerOff(); chargingMonitorError(); run = false; } if(status == Strategy::COMPLETE) { strategyPowerOff(); if(!exitImmediately) chargingComplete(); run = false; } return run; }
Strategy::statusType doStrategy(const Screen::ScreenType chargeScreens[], bool exitImmediately) { uint8_t key; bool run = true; uint16_t newMesurmentData = 0; Strategy::statusType status = Strategy::RUNNING; strategyPowerOn(); Screen::powerOn(); Monitor::powerOn(); lcdClear(); uint8_t screen_nr = 0; do { if(!PolarityCheck::runReversedPolarityInfo()) { Screen::display(pgm::read(&chargeScreens[screen_nr])); } { //change displayed screen key = Keyboard::getPressedWithSpeed(); if(key == BUTTON_INC && pgm::read(&chargeScreens[screen_nr+1]) != Screen::ScreenEnd) { #ifndef ENABLE_T_INTERNAL //TODO: after program complete, reconnect battery but wrong cell measurement if disconnected if(status == Strategy::COMPLETE) {hardware::setBatteryOutput(true); } // ADD THIS LINE TO TURN ON THE FAN #endif #ifdef ENABLE_SCREENANIMATION Screen::displayAnimation(); #endif screen_nr++; } if(key == BUTTON_DEC && screen_nr > 0) { #ifdef ENABLE_SCREENANIMATION Screen::displayAnimation(); #endif screen_nr--; } } if(run) { status = Monitor::run(); run = analizeStrategyStatus(status, exitImmediately); if(run && newMesurmentData != AnalogInputs::getFullMeasurementCount()) { newMesurmentData = AnalogInputs::getFullMeasurementCount(); status = strategyDoStrategy(); run = analizeStrategyStatus(status, exitImmediately); } } if(!run && exitImmediately) return status; } while(key != BUTTON_STOP); Screen::powerOff(); strategyPowerOff(); return status; }
bool analizeStrategyStatus(Strategy::statusType status, bool exitImmediately) { bool run = true; if(status == Strategy::ERROR) { Screen::powerOff(); strategyPowerOff(); AnalogInputs::powerOff(); //disconnect the battery (pin12 off) chargingMonitorError(); run = false; } if(status == Strategy::COMPLETE) { Screen::powerOff(); strategyPowerOff(); if(!exitImmediately) chargingComplete(); run = false; } return run; }
Strategy::statusType doStrategy(const Screen::ScreenType chargeScreens[]) { uint8_t key; bool run = true; uint16_t newMesurmentData = 0; Strategy::statusType status = Strategy::RUNNING; strategyPowerOn(); lcdClear(); uint8_t screen_nr = 0; do { if(!PolarityCheck::runReversedPolarityInfo()) { Screen::display(pgm::read(&chargeScreens[screen_nr])); } { //change displayed screen key = Keyboard::getPressedWithSpeed(); if(key == BUTTON_INC && pgm::read(&chargeScreens[screen_nr+1]) != Screen::ScreenEnd) { #ifdef ENABLE_SCREEN_ANIMATION Screen::displayAnimation(); #endif screen_nr++; } if(key == BUTTON_DEC && screen_nr > 0) { #ifdef ENABLE_SCREEN_ANIMATION Screen::displayAnimation(); #endif screen_nr--; } } if(run) { status = Monitor::run(); run = analizeStrategyStatus(status); if(run && newMesurmentData != AnalogInputs::getFullMeasurementCount()) { newMesurmentData = AnalogInputs::getFullMeasurementCount(); status = strategyDoStrategy(); run = analizeStrategyStatus(status); } } if(!run && exitImmediately) return status; } while(key != BUTTON_STOP); strategyPowerOff(); return status; }
void chargingEnd() { strategyPowerOff(); Monitor::powerOff(); lcdClear(); }