FEATURE: Link pointers to manual calibration config
This commit is contained in:
parent
7738e7d1ee
commit
02c604021a
@ -194,6 +194,8 @@ int main(void) {
|
|||||||
|
|
||||||
//Instantiate Input and Output modules
|
//Instantiate Input and Output modules
|
||||||
io::PressureChannel tankLevel0(&hadc1, MPWR0_GPIO_Port, MPWR0_Pin, 50);
|
io::PressureChannel tankLevel0(&hadc1, MPWR0_GPIO_Port, MPWR0_Pin, 50);
|
||||||
|
tankLevel0.LinkCalibConfig(globalConfig.TankCalibLow.getLink(), globalConfig.TankCalibHigh.getLink());
|
||||||
|
|
||||||
io::GPIChannel refillBlocker0(GPI0_GPIO_Port, GPI0_Pin);
|
io::GPIChannel refillBlocker0(GPI0_GPIO_Port, GPI0_Pin);
|
||||||
io::RelayChannel tankPump(OCHAN0_GPIO_Port, OCHAN0_Pin, true, io::RelayChannel::state::OFF);
|
io::RelayChannel tankPump(OCHAN0_GPIO_Port, OCHAN0_Pin, true, io::RelayChannel::state::OFF);
|
||||||
io::RelayChannel refillPump(OCHAN1_GPIO_Port, OCHAN1_Pin, false, io::RelayChannel::state::OFF);
|
io::RelayChannel refillPump(OCHAN1_GPIO_Port, OCHAN1_Pin, false, io::RelayChannel::state::OFF);
|
||||||
@ -214,19 +216,24 @@ int main(void) {
|
|||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
|
||||||
|
display.LCDSetBacklight(false);
|
||||||
display.LCDSetCursor(0,0);
|
display.LCDSetCursor(0,0);
|
||||||
display.LCDSendCString(const_cast<char *>(std::string("Tank: " + std::to_string(tankLevel0.getPercent()) + " %").c_str()));
|
display.LCDSendCString(const_cast<char *>(std::string("Tank: " + std::to_string(tankLevel0.getPercent()) + " %").c_str()));
|
||||||
|
|
||||||
display.LCDSetCursor(0, 1);
|
display.LCDSetCursor(0, 1);
|
||||||
if(tankLevel0.getPercent() < globalConfig.TankMinLevel.getValue()) {
|
if(tankLevel0.getPercent() < globalConfig.TankMinLevel.getValue()) {
|
||||||
display.LCDSendCString(const_cast<char *>(std::string("Tank Wassermangel").c_str()));
|
display.LCDSendCString(const_cast<char *>(std::string("Tank Wassermangel ").c_str()));
|
||||||
} else {
|
} else {
|
||||||
display.LCDSendCString(const_cast<char *>(std::string("Tank Normal").c_str()));
|
display.LCDSendCString(const_cast<char *>(std::string("Tank Normal ").c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
display.LCDSetCursor(0,2);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(rot_button) {
|
if(rot_button) {
|
||||||
|
display.LCDSetBacklight(true);
|
||||||
rot_button = false;
|
rot_button = false;
|
||||||
last_menu_retrigger = HAL_GetTick();
|
last_menu_retrigger = HAL_GetTick();
|
||||||
while(true) {
|
while(true) {
|
||||||
|
@ -30,13 +30,15 @@ namespace floatpump::io {
|
|||||||
|
|
||||||
void calibrateHigh();
|
void calibrateHigh();
|
||||||
|
|
||||||
|
void LinkCalibConfig(uint16_t *low, uint16_t *high);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const uint16_t m_avg_size = 50;
|
const uint16_t m_avg_size = 50;
|
||||||
const uint16_t m_avg_delay = 10;
|
const uint16_t m_avg_delay = 10;
|
||||||
const uint16_t m_cooldown = 500;
|
const uint16_t m_cooldown = 500;
|
||||||
|
|
||||||
uint16_t m_lowcalib = 0;
|
uint16_t *m_lowcalib = new uint16_t(0);
|
||||||
uint16_t m_highcalib = 65535;
|
uint16_t *m_highcalib = new uint16_t(65535);
|
||||||
|
|
||||||
uint16_t m_raw = 0;
|
uint16_t m_raw = 0;
|
||||||
int8_t m_percent = 0;
|
int8_t m_percent = 0;
|
||||||
|
@ -25,7 +25,7 @@ namespace floatpump::io {
|
|||||||
|
|
||||||
m_raw = average / m_avg_size;
|
m_raw = average / m_avg_size;
|
||||||
|
|
||||||
m_percent = (int8_t) (((m_raw - m_lowcalib) * 100) / (m_highcalib - m_lowcalib));
|
m_percent = (int8_t) (((m_raw - *m_lowcalib) * 100) / (*m_highcalib - *m_lowcalib));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,20 +42,25 @@ namespace floatpump::io {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PressureChannel::calibrateManualLow(uint16_t low) {
|
void PressureChannel::calibrateManualLow(uint16_t low) {
|
||||||
m_lowcalib = low;
|
*m_lowcalib = low;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PressureChannel::calibrateManualHigh(uint16_t high) {
|
void PressureChannel::calibrateManualHigh(uint16_t high) {
|
||||||
m_highcalib = high;
|
*m_highcalib = high;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PressureChannel::calibrateLow() {
|
void PressureChannel::calibrateLow() {
|
||||||
poll();
|
poll();
|
||||||
m_lowcalib = m_raw;
|
*m_lowcalib = m_raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PressureChannel::calibrateHigh() {
|
void PressureChannel::calibrateHigh() {
|
||||||
poll();
|
poll();
|
||||||
m_highcalib = m_raw;
|
*m_highcalib = m_raw;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PressureChannel::LinkCalibConfig(uint16_t *low, uint16_t *high) {
|
||||||
|
m_lowcalib = low;
|
||||||
|
m_highcalib = high;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user