Skip to content

Commit

Permalink
Merge pull request #59 from kornherp/display_toggle
Browse files Browse the repository at this point in the history
add monitor turn-on/off on doubleclick
  • Loading branch information
peterus authored May 10, 2022
2 parents 94ae1e2 + 2d04389 commit 0c95ed4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/LoRa_APRS_Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ OneButton userButton = OneButton(BUTTON_PIN, true, true);
HardwareSerial ss(1);
TinyGPSPlus gps;

void setup_gps();
void load_config();
void setup_lora();
void setup_gps();

String create_lat_aprs(RawDegrees lat);
String create_long_aprs(RawDegrees lng);
Expand All @@ -36,7 +36,8 @@ String createTimeString(time_t t);
String getSmartBeaconState();
String padding(unsigned int number, unsigned int width);

static bool send_update = true;
static bool send_update = true;
static bool display_toggle_value = true;

static void handle_tx_click() {
send_update = true;
Expand All @@ -47,6 +48,14 @@ static void handle_next_beacon() {
show_display(BeaconMan.getCurrentBeaconConfig()->callsign, BeaconMan.getCurrentBeaconConfig()->message, 2000);
}

static void toggle_display() {
display_toggle_value = !display_toggle_value;
display_toggle(display_toggle_value);
if (display_toggle_value) {
setup_display();
}
}

// cppcheck-suppress unusedFunction
void setup() {
Serial.begin(115200);
Expand Down Expand Up @@ -91,6 +100,7 @@ void setup() {
if (Config.button.alt_message) {
userButton.attachLongPressStart(handle_next_beacon);
}
userButton.attachDoubleClick(toggle_display);

logPrintlnI("Smart Beacon is " + getSmartBeaconState());
show_display("INFO", "Smart Beacon is " + getSmartBeaconState(), 1000);
Expand Down
12 changes: 12 additions & 0 deletions src/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ void setup_display() {
display.display();
}

// cppcheck-suppress unusedFunction
void display_toggle(bool toggle) {
logPrintI("Toggling display: ");
if (toggle) {
logPrintlnI("On");
display.ssd1306_command(SSD1306_DISPLAYON);
} else {
logPrintlnI("Off");
display.ssd1306_command(SSD1306_DISPLAYOFF);
}
}

// cppcheck-suppress unusedFunction
void show_display(String header, int wait) {
display.clearDisplay();
Expand Down
1 change: 1 addition & 0 deletions src/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#define DISPLAY_H_

void setup_display();
void display_toggle(bool toggle);

void show_display(String header, int wait = 0);
void show_display(String header, String line1, int wait = 0);
Expand Down

0 comments on commit 0c95ed4

Please sign in to comment.