added config screen, added game

This commit is contained in:
2022-04-14 17:01:26 +02:00
parent e9582a6dbf
commit 89561ba8d9
18 changed files with 1163 additions and 152 deletions

View File

@@ -1,76 +1,66 @@
#include "screen_main.h"
c_onScreenButton ma20("20m", mA20, LocBottom, BUTTON1);
c_onScreenButton ma200("200m", mA200, LocBottom, BUTTON2);
c_onScreenButton ma1000("1A", mA1000, LocBottom, BUTTON3);
c_onScreenButton mauto("Auto", mAuto, LocBottom, BUTTON4);
c_onScreenButton bsetup("Conf", 5, LocBottom, BUTTON5);
void setma20(void)
{
setMeasureMode(e_measureMode::mA20);
}
void setma200(void)
{
setMeasureMode(e_measureMode::mA200);
}
void setma1000(void)
{
setMeasureMode(e_measureMode::mA1000);
}
void setmAuto(void)
{
setMeasureMode(e_measureMode::mAuto);
}
void buttonSetup(void)
{
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 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;
//std::vector<c_onScreenButton*> MainScreen;
screen_c mainScreen(e_displayState::mainscreen, 5);
const e_displayState thisScreen = e_displayState::mainscreen;
void initDisplayMain(void)
{
log_i("Setup main screen : ");
uint16_t screenwidth = getDisplay()->getDisplayWidth();
uint16_t buttonwidth = ((screenwidth / mLast) - CONTROLLOFFSET * 2 + 1);
uint16_t currentWidth = 0;
uint16_t ypos = getDisplay()->getDisplayHeight() - 1 - CONTROLSLINE_H + 2;
log_i("buttons: screenW=%d, buttonW=%d, ypos=%d", screenwidth, buttonwidth, ypos);
// 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;
log_i("indicators: indicW=%d, indicH=%d ypos,%d", INDICATORWIDTH, INDICATORHEIGHT, IndicatorXpos);
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 main screen items");
MainScreen.push_back(&ma20);
MainScreen.push_back(&ma200);
MainScreen.push_back(&ma1000);
MainScreen.push_back(&mauto);
MainScreen.push_back(&bsetup);
mainScreen.addItem(&ma20);
mainScreen.addItem(&ma200);
mainScreen.addItem(&ma1000);
mainScreen.addItem(&mauto);
mainScreen.addItem(&bsetup);
MainScreen.push_back(&errorState);
MainScreen.push_back(&okState);
MainScreen.push_back(&openState);
MainScreen.push_back(&wifiState);
mainScreen.addItem(&errorState);
mainScreen.addItem(&okState);
mainScreen.addItem(&openState);
mainScreen.addItem(&wifiState);
for (auto &&button : MainScreen)
{
button->setVisible(true);
}
mainScreen.begin();
log_i("mainscreen OK");
}
void ScreenMainDrawButtons(void)
{
// draw controlstrip indicators
for (auto &&thismode : MainScreen)
{
thismode->setDisplayState((thismode->getIndex() == (uint8_t)getMeasureMode()));
thismode->drawButton();
}
}
void ScreenMainDrawValues(void)
{
if (getDisplay() == NULL)
@@ -92,16 +82,10 @@ void ScreenMainDrawValues(void)
getDisplay()->drawUTF8(60 + stringwidth + 3, 43, "mΩ");
}
e_displayState ScreenMainHandle(void)
void ScreenMainHandle(void)
{
for (auto &&i : MainScreen)
{
i->handle();
}
if(bsetup.getState())
{
return e_displayState::setupscreen;
}
return thisScreen;
mainScreen.activateModeButton();
mainScreen.handle();
mainScreen.draw();
ScreenMainDrawValues();
}