Skip to content

Commit

Permalink
setting orientation for display OLED/ TFT
Browse files Browse the repository at this point in the history
  • Loading branch information
ohAnd committed Sep 4, 2024
1 parent 576f95f commit ecfc935
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 41 deletions.
1 change: 1 addition & 0 deletions include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct UserConfig
boolean remoteDisplayActive = false; // remote display to get data from mqtt

uint8_t displayConnected = 0; // OLED default
uint16_t displayOrientation = 0; // OLED 0,180 degrees - TFT 0,90,180,270 degrees

boolean wifiAPstart = true;
int selectedUpdateChannel = 0; // 0 - release 1 - snapshot
Expand Down
6 changes: 3 additions & 3 deletions include/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#define VERSION "1.9.622_localDev"
#define BUILDTIME "03.09.2024 - 23:07:43"
#define BUILDTIMESTAMP "1725397663"
#define VERSION "1.9.639_localDev"
#define BUILDTIME "04.09.2024 - 12:15:16"
#define BUILDTIMESTAMP "1725444916"
8 changes: 4 additions & 4 deletions include/version.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"version": "1.9.622_localDev",
"versiondate": "03.09.2024 - 23:07:43",
"linksnapshot": "https://github.com/ohAnd/dtuGateway/releases/download/snapshot/dtuGateway_snapshot_1.9.622_localDev.bin",
"link": "https://github.com/ohAnd/dtuGateway/releases/latest/download/dtuGateway_release_1.9.622_localDev.bin"
"version": "1.9.639_localDev",
"versiondate": "04.09.2024 - 12:15:16",
"linksnapshot": "https://github.com/ohAnd/dtuGateway/releases/download/snapshot/dtuGateway_snapshot_1.9.639_localDev.bin",
"link": "https://github.com/ohAnd/dtuGateway/releases/latest/download/dtuGateway_release_1.9.639_localDev.bin"
}
70 changes: 37 additions & 33 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,39 +92,43 @@ So I decided to put this abstraction in an **ESP8266** to have a stable abstract
- TFT - a green inner ring and the name 'dutMonitor' will identify as a remote display

#### display support
- selectable (and storable) over advanced web config[^2] or per serial com and at directly at start up coming from factory mode ( [see first-setup-with-access-point](#first-setup-with-access-point) )

`selectDisplay 0` = OLED (default)

`selectDisplay 1` = round TFT

- display SSH1106 OLED 1,3" 128x64 (other sizes with same driver (SSH1106) and resolution should also directly work)

<img src="doc/images/dtuGateay_OLED_firstStart.jpg" alt="drawdtuGateay_OLED_firstStarting" width="180"/>
<img src="doc/images/dtuGateay_OLED.jpg" alt="dtuGateay_OLED" width="180"/>

- segmented in 3 parts
- header:
- left: wifi quality dtuGateway to local wifi
- mid: current time of dtuGateway
- right: wifi quality of dtu connection to local wifi
- main:
- small left: current power limit of inverter
- big mid/ right: current power of inverter
- footer:
- left: current daily yield
- right: current total yield
- additonal features
- small screensaver to prevent burn-in effect with steady components on the screen (shifting the whole screen every minute with 1 pixel in a 4 step rotation)
- smooth brightness control for changed main value - increase to max after change and then dimmming smooth back to the default level

- display GC9A01 round TFT 1,28" 240x240

<img src="doc/images/roundTFT_firstSTart.jpg" alt="roundTFT_firstSTart" width="180"/>
<img src="doc/images/roundTFT.jpg" alt="roundTFT" width="180"/>

- setup screen for first start (factory mode)
- status screen with the (current) most important data
- common
- selectable (and storable) via advanced web config[^2] or per serial com and at directly at start up coming from factory mode ( [see first-setup-with-access-point](#first-setup-with-access-point) )

`selectDisplay 0` = OLED (default)

`selectDisplay 1` = round TFT
- setting the orientation of the display via advanced web config[^2]
- OLED - 0 and 180 degrees are supported
- TFT - 0, 90, 180, 270 degrees are supported
- display hardware types
- display SSH1106 OLED 1,3" 128x64 (other sizes with same driver (SSH1106) and resolution should also directly work)

<img src="doc/images/dtuGateay_OLED_firstStart.jpg" alt="drawdtuGateay_OLED_firstStarting" width="180"/>
<img src="doc/images/dtuGateay_OLED.jpg" alt="dtuGateay_OLED" width="180"/>

- segmented in 3 parts
- header:
- left: wifi quality dtuGateway to local wifi
- mid: current time of dtuGateway
- right: wifi quality of dtu connection to local wifi
- main:
- small left: current power limit of inverter
- big mid/ right: current power of inverter
- footer:
- left: current daily yield
- right: current total yield
- additonal features
- small screensaver to prevent burn-in effect with steady components on the screen (shifting the whole screen every minute with 1 pixel in a 4 step rotation)
- smooth brightness control for changed main value - increase to max after change and then dimmming smooth back to the default level

- display GC9A01 round TFT 1,28" 240x240

<img src="doc/images/roundTFT_firstSTart.jpg" alt="roundTFT_firstSTart" width="180"/>
<img src="doc/images/roundTFT.jpg" alt="roundTFT" width="180"/>

- setup screen for first start (factory mode)
- status screen with the (current) most important data
### regarding base framework

- serving own access point in factory mode for first setup
Expand Down
4 changes: 4 additions & 0 deletions src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ void UserConfigManager::printConfigdata()

Serial.print(F("display connected: \t"));
Serial.println(userConfig.displayConnected);
Serial.print(F("display orientation: \t"));
Serial.println(userConfig.displayOrientation);
Serial.print(F("--------------------------------------\n"));
}

Expand Down Expand Up @@ -196,6 +198,7 @@ JsonDocument UserConfigManager::mappingStructToJson(const UserConfig &config)
doc["remoteDisplay"]["Active"] = config.remoteDisplayActive;

doc["display"]["type"] = config.displayConnected;
doc["display"]["orientation"] = config.displayOrientation;

doc["local"]["selectedUpdateChannel"] = config.selectedUpdateChannel;
doc["local"]["wifiAPstart"] = config.wifiAPstart;
Expand Down Expand Up @@ -232,6 +235,7 @@ void UserConfigManager::mappingJsonToStruct(JsonDocument doc)
userConfig.remoteDisplayActive = doc["remoteDisplay"]["Active"].as<bool>();

userConfig.displayConnected = doc["display"]["type"];
userConfig.displayOrientation = doc["display"]["orientation"];

userConfig.selectedUpdateChannel = doc["local"]["selectedUpdateChannel"];
userConfig.wifiAPstart = doc["local"]["wifiAPstart"];
Expand Down
4 changes: 4 additions & 0 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Display::~Display()
void Display::setup()
{
u8g2.begin();
if(userConfig.displayOrientation == 180)
u8g2.setDisplayRotation(U8G2_R2);
else
u8g2.setDisplayRotation(U8G2_R0);
Serial.println(F("OLED display:\t initialized"));
}

Expand Down
11 changes: 10 additions & 1 deletion src/displayTFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ DisplayTFT::DisplayTFT() {}
void DisplayTFT::setup()
{
tft.init();
tft.setRotation(0);
uint16_t orientation = userConfig.displayOrientation;
if (orientation >= 0 && orientation < 90)
orientation = 0;
else if (orientation >= 90 && orientation < 180)
orientation = 1;
else if (orientation >= 180 && orientation < 270)
orientation = 2;
else if (orientation >= 270 && orientation < 360)
orientation = 3;
tft.setRotation(orientation);
tft.fillScreen(TFT_BLACK);
Serial.println(F("TFT display initialized"));
}
Expand Down

0 comments on commit ecfc935

Please sign in to comment.