Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ROTATE_180 constant that rotates the screen 180 degrees to allow screen to be mounted inverted #173

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@

.DS_Store
.vscode/c_cpp_properties.json
.vscode/arduino.json
build/
20 changes: 19 additions & 1 deletion esp8266-weather-station-color.ino
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,9 @@ void setup() {
digitalWrite(TFT_LED, HIGH); // HIGH to Turn on;

gfx.init();
#ifdef ROTATE_180
gfx.setRotation(2); // Flip the screen 180
#endif
gfx.fillBuffer(MINI_BLACK);
gfx.commit();

Expand Down Expand Up @@ -823,7 +826,7 @@ void loadPropertiesFromSpiffs() {
Serial.println("Effective properties now as follows:");
Serial.println("\tssid: " + WIFI_SSID);
Serial.println("\tpassword: " + WIFI_PASS);
Serial.println("\timezone: " + TIMEZONE);
Serial.println("\ttimezone: " + TIMEZONE);
Serial.println("\tOWM API key: " + OPEN_WEATHER_MAP_API_KEY);
Serial.println("\tOWM location id: " + OPEN_WEATHER_MAP_LOCATION_ID);
Serial.println("\tlocation name: " + DISPLAYED_LOCATION_NAME);
Expand All @@ -848,6 +851,7 @@ uint8_t changeScreen(TS_Point p, uint8_t screen) {
// if (p.x <= dividerMiddle) Serial.print(" right "); // <= 120
// Serial.println();

#ifndef ROTATE_180
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I personally don't like inverted if/else conditions. Can you start with the truthy condition (ifdef)?

if (p.y < dividerTop) { // top -> change 12/24h style
IS_STYLE_12HR = !IS_STYLE_12HR;
} else if (p.y > dividerBottom) { // bottom -> go to screen 0
Expand All @@ -860,5 +864,19 @@ uint8_t changeScreen(TS_Point p, uint8_t screen) {
} else { // right -> next screen
page = (page + 1) % screenCount;
}
#else
if (p.y > dividerBottom) { // top -> change 12/24h style
IS_STYLE_12HR = !IS_STYLE_12HR;
} else if (p.y < dividerTop) { // bottom -> go to screen 0
page = 0;
} else if (p.x < dividerMiddle) { // left -> previous page
if (page == 0) { // Note type is unsigned
page = screenCount; // Last screen is max -1
}
page--;
} else { // right -> next screen
page = (page + 1) % screenCount;
}
#endif
return page;
}
1 change: 1 addition & 0 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ const char MOON_ICONS_SOUTH_WAXING[] = {64, 77, 76, 75, 74, 73, 72, 71, 70, 69,
#define TOUCH_CS D3
#define TOUCH_IRQ D4

//#define ROTATE_180

/***************************
* End Settings
Expand Down