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 monitor turn-on/off on doubleclick #59

Merged
merged 5 commits into from
May 10, 2022
Merged
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
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