128 lines
3.7 KiB
C++
128 lines
3.7 KiB
C++
#include "gui.h"
|
|
|
|
c_onScreenButton ma20("20m", (uint8_t)mA20, LocBottom, BUTTON1);
|
|
c_onScreenButton ma200("200m", (uint8_t)mA200, LocBottom, BUTTON2);
|
|
c_onScreenButton ma1000("1A", (uint8_t)mA1000, LocBottom, BUTTON3);
|
|
c_onScreenButton mauto("Auto", (uint8_t)mAuto, LocBottom, BUTTON4);
|
|
c_onScreenButton bsetup("Conf", 5, LocBottom, 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;
|
|
|
|
displayState CurrentGuiState;
|
|
|
|
void initGui(void)
|
|
{
|
|
log_i("Init GUI: ");
|
|
uint16_t screenwidth = getDisplayWidth() - 1;
|
|
uint16_t buttonwidth = ((screenwidth / mLast) - CONTROLLOFFSET * 2) - 1;
|
|
uint16_t currentWidth = 0;
|
|
uint16_t ypos = getDisplayHeight() - 1 - CONTROLSLINE_H + 2;
|
|
|
|
//setup bottom buttons
|
|
ma20.begin(currentWidth, ypos, buttonwidth, CONTROLSLINE_H + 6, CONTROLRADIUS);
|
|
ma200.begin(currentWidth += (buttonwidth - 1), ypos, buttonwidth, CONTROLSLINE_H + CONTROLRADIUS, CONTROLRADIUS);
|
|
ma1000.begin(currentWidth += (buttonwidth - 1), ypos, buttonwidth, CONTROLSLINE_H + CONTROLRADIUS, CONTROLRADIUS);
|
|
mauto.begin(currentWidth += (buttonwidth - 1), ypos, buttonwidth, CONTROLSLINE_H + CONTROLRADIUS, CONTROLRADIUS);
|
|
bsetup.begin(currentWidth += (buttonwidth - 1), ypos, buttonwidth, CONTROLSLINE_H + CONTROLRADIUS, CONTROLRADIUS);
|
|
|
|
//setup right side indicators
|
|
uint16_t currentYpos = 0;
|
|
uint16_t IndicatorXpos = screenwidth - INDICATORWIDTH - (INDICATORWIDTH / 2);
|
|
|
|
errorState.begin(IndicatorXpos, currentYpos, INDICATORWIDTH, INDICATORHEIGHT, INDICATORRADIUS);
|
|
okState.begin(IndicatorXpos, currentYpos += (INDICATORHEIGHT - 1), INDICATORWIDTH, INDICATORHEIGHT, INDICATORRADIUS);
|
|
openState.begin(IndicatorXpos, currentYpos += (INDICATORHEIGHT - 1), INDICATORWIDTH, INDICATORHEIGHT, INDICATORRADIUS);
|
|
wifiState.begin(IndicatorXpos, currentYpos += (INDICATORHEIGHT - 1), INDICATORWIDTH, INDICATORHEIGHT, INDICATORRADIUS);
|
|
|
|
//fill vector
|
|
log_i("Store");
|
|
MainScreen.push_back(ma20);
|
|
MainScreen.push_back(ma200);
|
|
MainScreen.push_back(ma1000);
|
|
MainScreen.push_back(mauto);
|
|
MainScreen.push_back(bsetup);
|
|
|
|
MainScreen.push_back(errorState);
|
|
MainScreen.push_back(okState);
|
|
MainScreen.push_back(openState);
|
|
MainScreen.push_back(wifiState);
|
|
|
|
for (auto &&button : MainScreen)
|
|
{
|
|
button.setVisible(true);
|
|
}
|
|
|
|
CurrentGuiState = mainscreen;
|
|
|
|
log_i("OK");
|
|
}
|
|
|
|
void drawMainSceenButtons()
|
|
{
|
|
//draw controlstrip indicators
|
|
for (auto &&thismode : MainScreen)
|
|
{
|
|
thismode.setState((thismode.getIndex() == (uint8_t)getMeasureMode()));
|
|
thismode.drawButton();
|
|
}
|
|
}
|
|
|
|
void drawMainscreenValues()
|
|
{
|
|
if (getDisplay() == NULL)
|
|
{
|
|
return;
|
|
}
|
|
|
|
drawDashedHLine(0, 12, 220);
|
|
drawDashedVLine(40, 12, 33);
|
|
u8g2_SetFont(getDisplay(),FONT8);
|
|
u8g2_DrawStr(getDisplay(), 5, 8, "Fs:100Hz LP");
|
|
|
|
u8g2_SetFont(getDisplay(), FONT24);
|
|
|
|
u8g2_DrawStr(getDisplay(), 60, 45, String(getValue()).c_str());
|
|
|
|
//u8g2_DrawStr(getDisplay(), 60, 45);
|
|
uint16_t stringwidth = u8g2_GetStrWidth(getDisplay(), showValue("", getValue(), "").c_str());
|
|
u8g2_SetFont(getDisplay(), u8g2_font_8x13_t_symbols);
|
|
u8g2_DrawUTF8(getDisplay(), 60 + stringwidth + 3, 43, "mΩ");
|
|
//drawProgressBar(0, 40, 127, 5, getBar());
|
|
}
|
|
|
|
void drawMainScreen()
|
|
{
|
|
drawMainSceenButtons();
|
|
drawMainscreenValues();
|
|
}
|
|
|
|
void handleGUIButtons(void)
|
|
{
|
|
for (auto &&i : MainScreen)
|
|
{
|
|
i.handle();
|
|
}
|
|
}
|
|
|
|
void handleGui(void)
|
|
{
|
|
clearDisplay();
|
|
switch (CurrentGuiState)
|
|
{
|
|
case mainscreen:
|
|
{
|
|
drawMainScreen();
|
|
}
|
|
break;
|
|
|
|
case setupscreen:
|
|
{
|
|
}
|
|
break;
|
|
}
|
|
}
|