release to henk

This commit is contained in:
2022-04-16 21:57:01 +02:00
parent 351d3e44d3
commit c503f35e3f
18 changed files with 261 additions and 165 deletions

View File

@@ -1,45 +1,92 @@
#include "screen_main.h"
void setma20(void)
screen_c mainScreen(e_displayState::mainscreen, 5);
const e_displayState thisScreen = e_displayState::mainscreen;
bool WarningActive = false;
bool confirmed = false;
uint16_t timer = 0;
void button1(void) // yes
{
setMeasureMode(e_measureMode::mA20);
if (WarningActive)
{
screenMainSetWarning(false);
setMeasureMode(e_measureMode::mA1000);
}
else
{
setMeasureMode(e_measureMode::mA20);
}
}
void setma200(void)
void button2(void) // no
{
setMeasureMode(e_measureMode::mA200);
if (WarningActive)
{
screenMainSetWarning(false);
}
else
{
setMeasureMode(e_measureMode::mA200);
}
}
void setma1000(void)
void button3(void)
{
setMeasureMode(e_measureMode::mA1000);
if (!WarningActive)
{
screenMainSetWarning(true);
}
}
void setmAuto(void)
void button4(void)
{
setMeasureMode(e_measureMode::mAuto);
if (!WarningActive)
{
clearStats();
}
}
void buttonSetup(void)
void button5(void)
{
setDisplayState(e_displayState::setupscreen);
log_i("Conf button pressed, go to setupscreen");
if (!WarningActive)
{
setDisplayState(e_displayState::setupscreen);
log_i("Conf button pressed, go to setupscreen");
}
}
c_onScreenButton ma20("20m", mA20, LocBottom, BUTTON1, &setma20);
c_onScreenButton ma200("200m", mA200, LocBottom, BUTTON2, &setma200);
c_onScreenButton ma1000("1A", mA1000, LocBottom, BUTTON3, &setma1000);
c_onScreenButton mauto("Auto", mAuto, LocBottom, BUTTON4, &setmAuto);
c_onScreenButton bsetup("Conf", 5, LocBottom, BUTTON5, &buttonSetup);
c_onScreenButton ma20("20m", mA20, LocBottom, BUTTON1, &button1);
c_onScreenButton ma200("200m", mA200, LocBottom, BUTTON2, &button2);
c_onScreenButton ma1000("1A", mA1000, LocBottom, BUTTON3, &button3);
c_onScreenButton mauto("Reset", 4, LocBottom, BUTTON4, &button4);
c_onScreenButton bsetup("Conf", 5, LocBottom, BUTTON5, &button5);
c_onScreenButton errorState("ER", 6, LocRight, &getErrorState);
c_onScreenButton okState("OK", 7, LocRight, &getOkState);
c_onScreenButton openState("Open", 8, LocRight, &getOpenState);
c_onScreenButton wifiState("Wifi", 9, LocRight, &getWifiState);
//std::vector<c_onScreenButton*> MainScreen;
screen_c mainScreen(e_displayState::mainscreen, 5);
const e_displayState thisScreen = e_displayState::mainscreen;
void screenMainSetWarning(bool warning)
{
if (warning)
{
WarningActive = true;
ma20.setAltName("Yes");
ma200.setAltName("No");
ma1000.setAltName("");
mauto.setAltName("");
bsetup.setAltName("");
}
else
{
WarningActive = false;
ma20.clearAltName();
ma200.clearAltName();
ma1000.clearAltName();
mauto.clearAltName();
bsetup.clearAltName();
}
}
void initDisplayMain(void)
{
@@ -61,31 +108,76 @@ void initDisplayMain(void)
log_i("mainscreen OK");
}
void ScreenMainDrawValues(void)
void screenMainDrawLayout(void)
{
if (getDisplay() == NULL)
{
return;
}
drawDashedHLine(0, 12, 220);
drawDashedVLine(40, 12, 33);
getDisplay()->setFont(FONT8);
getDisplay()->drawStr(5, 8, "Fs:100Hz LP");
uint16_t rate = float(1 / getSampleRate());
getDisplay()->setCursor(5, 8);
getDisplay()->printf("Fs:%dHz", rate);
getDisplay()->setCursor(170, 8);
getDisplay()->printf("loop=%dms", timer);
}
void ScreenMainDrawValues(void)
{
getDisplay()->setFont(FONT24);
getDisplay()->setCursor(60, 45);
getDisplay()->printf("%4.2f", getValue());
getDisplay()->printf("%4.3f", getValue());
uint16_t stringwidth = getDisplay()->getStrWidth(drawValue("", getValue(), "").c_str());
getDisplay()->setFont(u8g2_font_8x13_t_symbols);
getDisplay()->drawUTF8(60 + stringwidth + 3, 43, "m");
getDisplay()->drawUTF8(78 + stringwidth + 3, 43, "");
getDisplay()->setFont(FONT8);
// getDisplay()->drawUTF8(60 + stringwidth + 3, 43, "v");
getDisplay()->setCursor(168, 27);
getDisplay()->printf("Min: %4.2f", getADCMin());
getDisplay()->setCursor(168, 36);
getDisplay()->printf("Avg: %4.2f", getADCavg());
getDisplay()->setCursor(168, 45);
getDisplay()->printf("Max: %4.2f", getADCMax());
}
void screenMaindrawWarning(void)
{
getDisplay()->setFont(FONT16);
getDisplay()->setCursor(42, 32);
getDisplay()->printf("WARNING!");
getDisplay()->setCursor(42, 45);
getDisplay()->printf("Confirm to use 1A mode");
}
void screenMainDrawInfo(void)
{
screenMainDrawLayout();
if (WarningActive)
{
screenMaindrawWarning();
}
else
{
ScreenMainDrawValues();
}
}
void setTimer(uint16_t newtimer)
{
timer = newtimer;
}
void ScreenMainHandle(void)
{
mainScreen.activateModeButton();
if (getDisplay() == NULL)
{
log_e("Display is NULL");
return;
}
mainScreen.activateModeButton(WarningActive);
mainScreen.handle();
mainScreen.draw();
ScreenMainDrawValues();
screenMainDrawInfo();
}