Skip to content

Commit

Permalink
Add flip screen advanced config (Closes #61)
Browse files Browse the repository at this point in the history
  • Loading branch information
4m1g0 committed Mar 1, 2021
1 parent ff6d9e2 commit 987e09f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
13 changes: 11 additions & 2 deletions tinyGS/src/ConfigManager/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ ConfigManager::ConfigManager()
groupAdvanced.addItem(&modemParam);
groupAdvanced.addItem(&advancedConfigParam);
addParameterGroup(&groupAdvanced);

}

void ConfigManager::handleRoot()
Expand Down Expand Up @@ -370,6 +369,9 @@ boolean ConfigManager::init()
boardDetection();
}

if (strlen(advancedConfig))
parseAdvancedConf();

return validConfig;
}

Expand Down Expand Up @@ -450,10 +452,17 @@ void ConfigManager::parseAdvancedConf()

size_t size = 512;
DynamicJsonDocument doc(size);
deserializeJson(doc, advancedConfig);
deserializeJson(doc, (const char*)advancedConfig);

if (doc.containsKey(F("dmode")))
{
Log::setLogLevel(doc["dmode"]);
}

Serial.print("FlipOled ");
if (doc.containsKey(F("flipOled")))
{
advancedConf.flipOled = doc["flipOled"];
Serial.println(advancedConf.flipOled);
}
}
7 changes: 7 additions & 0 deletions tinyGS/src/ConfigManager/ConfigManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ typedef struct {
String BOARD;
} board_type;

typedef struct {
uint8_t flipOled = true;
} AdvancedConfig;


class ConfigManager : public IotWebConf2
{
public:
Expand Down Expand Up @@ -148,6 +153,7 @@ class ConfigManager : public IotWebConf2
bool isConnected() { return getState() == IOTWEBCONF_STATE_ONLINE; };
bool isApMode() { return (getState() != IOTWEBCONF_STATE_CONNECTING && getState() != IOTWEBCONF_STATE_ONLINE); }
board_type getBoardConfig(){ return boards[getBoard()]; }
bool getFlipOled(){ return advancedConf.flipOled; }


private:
Expand Down Expand Up @@ -193,6 +199,7 @@ class ConfigManager : public IotWebConf2
#endif
GSConfigHtmlFormatProvider gsConfigHtmlFormatProvider;
board_type boards[NUM_BOARDS];
AdvancedConfig advancedConf;

char latitude[COORDINATE_LENGTH] = "";
char longitude[COORDINATE_LENGTH] = "";
Expand Down
8 changes: 7 additions & 1 deletion tinyGS/src/Display/Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,13 @@ void displayInit()
delay(50);
digitalWrite(board.OLED__RST, HIGH);
display->init();
display->flipScreenVertically();

if (ConfigManager::getInstance().getFlipOled())
{
display->flipScreenVertically();
Serial.println("Flip");
}

}

void msOverlay(OLEDDisplay *display, OLEDDisplayUiState* state)
Expand Down

0 comments on commit 987e09f

Please sign in to comment.