Skip to content

Commit

Permalink
display: add ability to flip display
Browse files Browse the repository at this point in the history
  • Loading branch information
vooon committed Mar 3, 2021
1 parent 8479b5e commit 227517b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ constexpr auto INFLUX_ADDR = "influx-addr";
constexpr auto INFLUX_PORT = "influx-port";
constexpr auto BOOT_COUNTER = "boot-cnt";
constexpr auto BLE_PUBLISH_RAW = "ble-publish-raw";
constexpr auto DISPLAY_FLIP_V = "display-flip-v";
constexpr auto DISPLAY_FLIP_H = "display-flip-h";

wl::vCredencials wl::credencials;
String mqtt::client_id;
Expand All @@ -31,6 +33,8 @@ bool pref::portal_enabled = true;
String influx::addr;
uint16_t influx::port;
bool ble::publish_raw = false;
bool display::flip_v = true;
bool display::flip_h = false;

static Preferences m_pref;

Expand Down Expand Up @@ -75,6 +79,9 @@ static void init_gparameters()

influx::port = influx::D_PORT;

display::flip_v = true;
display::flip_h = false;

wl::credencials.clear();
}

Expand Down Expand Up @@ -124,6 +131,10 @@ static void update_gparameters()
influx::addr = prefs[INFLUX_ADDR] | "";
influx::port = prefs[INFLUX_PORT] | influx::D_PORT;

// Display
display::flip_v = prefs[DISPLAY_FLIP_V] | true;
display::flip_h = prefs[DISPLAY_FLIP_H] | false;

// WiFi credencials
for (size_t i = 0; i < wl::CRED_MAX; i++) {
String ssid, passwd;
Expand Down
5 changes: 5 additions & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ namespace ble {
extern bool publish_raw;
};

namespace display {
extern bool flip_v;
extern bool flip_h;
};

void init();
String get_hostname();
void reset_and_die();
Expand Down
5 changes: 4 additions & 1 deletion src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ static void disp_thd(void *arg)
display::have_display = true;

m_dis.init();
m_dis.flipScreenVertically();

if (config::display::flip_v) m_dis.flipScreenVertically();
if (config::display::flip_h) m_dis.mirrorScreen();

m_dis.setFont(Orbitron_Medium_16);

m_dis.display();
Expand Down

0 comments on commit 227517b

Please sign in to comment.