void calibrateI(bool charging, uint8_t point, AnalogInputs::ValueType current) { AnalogInputs::ValueType maxValue; AnalogInputs::Name name1; AnalogInputs::Name name2; AnalogInputs::CalibrationPoint pName1; AnalogInputs::CalibrationPoint pName2; Program::dischargeOutputCapacitor(); AnalogInputs::powerOn(); if(testVout(false)) { if(charging) { maxValue = SMPS_UPPERBOUND_VALUE; name1 = AnalogInputs::IsmpsSet; name2 = AnalogInputs::Ismps; SMPS::powerOn(); hardware::setVoutCutoff(MAX_CHARGE_V); } else { name1 = AnalogInputs::IdischargeSet; name2 = AnalogInputs::Idischarge; maxValue = DISCHARGER_UPPERBOUND_VALUE; Discharger::powerOn(); } getCalibrationPoint(pName1, name1, point); getCalibrationPoint(pName2, name2, point); CurrentMenu menu(name1, name2, point, maxValue); int8_t index; do { menu.refreshValue(pName1); index = menu.runSimple(true); if(index < 0) break; if(index == 0) { setCurrentValue(name1, menu.value_); if(menu.runEdit()) { AnalogInputs::doFullMeasurement(); pName1.y = current; pName1.x = menu.value_; pName2.y = current; pName2.x = AnalogInputs::getAvrADCValue(name2); } setCurrentValue(name1, 0); } } while(true); if(charging) SMPS::powerOff(); else Discharger::powerOff(); //Info: we save eeprom data only when no current is flowing AnalogInputs::setCalibrationPoint(name1, point, pName1); AnalogInputs::setCalibrationPoint(name2, point, pName2); eeprom::restoreCalibrationCRC(); } AnalogInputs::powerOff(); }
void calibrateVoltage() { calibrationPoint = 1; AnalogInputs::powerOn(); if(testVout(true)) { runCalibrationMenu(editVoltageData, voltageName, voltageName2); } AnalogInputs::powerOff(); }
void calibrateVoltage() { calibrationPoint = 1; Program::dischargeOutputCapacitor(); AnalogInputs::powerOn(); if(testVout(true)) { runCalibrationMenu(editVoltageData, voltageName, voltageName2); } AnalogInputs::powerOff(); }
static void currentCalibration(uint8_t point) { AnalogInputs::CalibrationPoint pSet; AnalogInputs::CalibrationPoint p; bool save = false; Program::dischargeOutputCapacitor(); AnalogInputs::powerOn(); if(testVout(false)) { getCalibrationPoint(pSet, gNameSet_, point); getCalibrationPoint(p, gName_, point); EditMenu::initialize(currentData, editCallback); gIexpected_ = pSet.y; int8_t index; do { gValue_ = pSet.x; index = EditMenu::run(true); if(index < 0) break; else if(index == 0) { powerOnCurrent(); setCurrentValue(gValue_); if(EditMenu::runEdit()) { AnalogInputs::doFullMeasurement(); pSet.y = gIexpected_; pSet.x = gValue_; p.y = gIexpected_; p.x = AnalogInputs::getAvrADCValue(gName_); save = true; } setCurrentValue(0); powerOffCurrent(); } else if(index == 2 && !EditMenu::runEdit()) { gIexpected_ = pSet.y; } } while(true); //Info: we save eeprom data only when no current is flowing if(save) { AnalogInputs::setCalibrationPoint(gNameSet_, point, pSet); AnalogInputs::setCalibrationPoint(gName_, point, p); eeprom::restoreCalibrationCRC(); } } AnalogInputs::powerOff(); }
void calibrateI(bool charging, uint8_t point, AnalogInputs::ValueType current) { AnalogInputs::ValueType maxValue; AnalogInputs::Name name1; AnalogInputs::Name name2; if(testVout()) { if(charging) { maxValue = SMPS_UPPERBOUND_VALUE; name1 = AnalogInputs::IsmpsValue; name2 = AnalogInputs::Ismps; SMPS::powerOn(); } else { name1 = AnalogInputs::IdischargeValue; name2 = AnalogInputs::Idischarge; maxValue = DISCHARGER_UPPERBOUND_VALUE; Discharger::powerOn(); } CurrentMenu menu(name1, point, maxValue); int8_t index; do { menu.refreshValue(); index = menu.runSimple(true); if(index < 0) break; if(index == 0) { setCurrentValue(name1, menu.value_); if(menu.runEdit(index)) { AnalogInputs::doFullMeasurement(); AnalogInputs::CalibrationPoint p; p.y = current; p.x = menu.value_; AnalogInputs::setCalibrationPoint(name1, point, p); p.x = AnalogInputs::getAvrADCValue(name2); AnalogInputs::setCalibrationPoint(name2, point, p); } setCurrentValue(name1, 0); } } while(true); if(charging) SMPS::powerOff(); else Discharger::powerOff(); } }
void calibrateVoltage() { if(testVout()) { VoltageMenu v(voltageMenu, voltageName, 9); int8_t index; do { index = v.runSimple(true); if(index < 0) break; AnalogInputs::Name Vinput = pgm::read(&voltageName[index]); if(index <= MAX_BANANCE_CELLS && AnalogInputs::isConnected(Vinput)) { AnalogInputs::doFullMeasurement(); AnalogInputs::on_ = false; if(v.runEdit(index)) saveVoltage(true, Vinput,pgm::read(&voltageName2[index])); AnalogInputs::on_ = true; } } while(true); } }