Skip to content

Commit

Permalink
bugfix #20 / bugfix #17 / oled disable feature & oled wakeup button /…
Browse files Browse the repository at this point in the history
… oled POS info page
  • Loading branch information
roema committed Aug 1, 2021
1 parent ac7d9b0 commit 7221af6
Show file tree
Hide file tree
Showing 10 changed files with 897 additions and 819 deletions.
930 changes: 467 additions & 463 deletions ognbase/APRS.cpp

Large diffs are not rendered by default.

54 changes: 46 additions & 8 deletions ognbase/OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
#include "logos.h"

SSD1306Wire display(SSD1306_OLED_I2C_ADDR, SDA, SCL, GEOMETRY_128_64, I2C_TWO, 400000); // ADDRESS, SDA, SCL
bool display_init = false;

bool display_init = false;
bool display_enabled = true;

int rssi = 0;
int oled_site = 0;
Expand Down Expand Up @@ -83,14 +85,22 @@ void OLED_write(char* text, short x, short y, bool clear)
}
}

void OLED_clear()
void OLED_disable()
{
if (display_init)
display.clear();
display.clear();
display.displayOff();
display_enabled = false;
}

void OLED_enable()
{
display_enabled = true;
}

void OLED_draw_Bitmap(int16_t x, int16_t y, uint8_t bm, bool clear)
{
if (!display_enabled){return;}

display.displayOn();
if (clear)
display.clear();
Expand All @@ -109,6 +119,8 @@ void OLED_draw_Bitmap(int16_t x, int16_t y, uint8_t bm, bool clear)

void OLED_info(bool ntp)
{
if (!display_enabled){return;}

char buf[64];
uint32_t disp_value;

Expand Down Expand Up @@ -252,17 +264,43 @@ void OLED_info(bool ntp)
snprintf(buf, sizeof(buf), "connected to %s", WiFi.SSID());
display.drawString(0, 54, buf);

display.display();
display.displayOn();
oled_site = 3;
return;
}

if (oled_site == 3)
{
display.clear();
snprintf(buf, sizeof(buf), "POSITION DATA");
display.drawString(0, 0, buf);

snprintf(buf, sizeof(buf), "LAT: %.4f", ThisAircraft.latitude);
display.drawString(0, 9, buf);

snprintf(buf, sizeof(buf), "LON:: %.4f", ThisAircraft.longitude);
display.drawString(0, 18, buf);

snprintf(buf, sizeof(buf), "ALT: %.2f", ThisAircraft.altitude);
display.drawString(0, 27, buf);

snprintf(buf, sizeof(buf), "GEOID: %.2f", ThisAircraft.geoid_separation);
display.drawString(0, 36, buf);

snprintf(buf, sizeof(buf), "GPS-FIX: %s", isValidFix() ? "true" : "false");
display.drawString(0, 45, buf);

display.display();
if (beers_show)
oled_site = 3;
oled_site = 4;
else
oled_site = 0;
display.displayOn();
return;
}

}

if (oled_site == 3)
if (oled_site == 4)
{
String beer_supporters[] = {"guy", "jozef", "camille"};
display.clear();
Expand Down
81 changes: 42 additions & 39 deletions ognbase/OLED.h
Original file line number Diff line number Diff line change
@@ -1,39 +1,42 @@
/*
* OLEDHelper.h
* Copyright (C) 2019-2021 Linar Yusupov
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef OLEDHELPER_H
#define OLEDHELPER_H

#include "SSD1306Wire.h"

#define SSD1306_OLED_I2C_ADDR 0x3C

byte OLED_setup(void);

void OLED_write(char *, short, short, bool);

void OLED_clear(void);

void OLED_bar(uint8_t, uint8_t);
void OLED_info(bool);

void OLED_update(void);

void OLED_draw_Bitmap(int16_t, int16_t, uint8_t, bool);

#endif /* OLEDHELPER_H */
/*
* OLEDHelper.h
* Copyright (C) 2019-2021 Linar Yusupov
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef OLEDHELPER_H
#define OLEDHELPER_H

#include "SSD1306Wire.h"

#define SSD1306_OLED_I2C_ADDR 0x3C

byte OLED_setup(void);

void OLED_write(char *, short, short, bool);

void OLED_clear(void);

void OLED_bar(uint8_t, uint8_t);
void OLED_info(bool);

void OLED_update(void);

void OLED_disable(void);
void OLED_enable(void);

void OLED_draw_Bitmap(int16_t, int16_t, uint8_t, bool);

#endif /* OLEDHELPER_H */
36 changes: 27 additions & 9 deletions ognbase/Web.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,14 +216,26 @@ void Web_setup(ufo_t* this_aircraft)
String station_addr = String(this_aircraft->addr, HEX);
station_addr.toUpperCase();

/*Bugfix Issue 20*/
String pos_lat = "";
String pos_lon = "";
String pos_alt = "";
String pos_geo = "";

pos_lat.concat(ogn_lat);
pos_lon.concat(ogn_lon);
pos_alt.concat(ogn_alt);
pos_geo.concat(ogn_geoid_separation);
/*END Bugfix*/

snprintf(offset, size, index_html,
station_addr,
SOFTRF_FIRMWARE_VERSION,
ogn_callsign,
String(ogn_lat, 5),
String(ogn_lon, 5),
String(ogn_alt),
String(ogn_geoid_separation),
pos_lat,
pos_lon,
pos_alt,
pos_geo,
String(ogn_range),
(ogn_band == RF_BAND_AUTO ? "selected" : ""), RF_BAND_AUTO,
(ogn_band == RF_BAND_EU ? "selected" : ""), RF_BAND_EU,
Expand Down Expand Up @@ -263,7 +275,9 @@ void Web_setup(ufo_t* this_aircraft)
(ogn_istealthbit == false ? "selected" : ""), "False",

ogn_ssid[0].c_str(),
ogn_wpass[0].c_str(),

/*Hide Wifi Password*/
"hidepass",

(ogn_sleepmode == 0 ? "selected" : ""), "Disabled",
(ogn_sleepmode == 1 ? "selected" : ""), "Full",
Expand Down Expand Up @@ -317,7 +331,7 @@ void Web_setup(ufo_t* this_aircraft)
// Send a GET request to <ESP_IP>/get?inputString=<inputMessage>
wserver.on("/get", HTTP_GET, [](AsyncWebServerRequest* request) {
if (request->hasParam("callsign"))
ogn_callsign = request->getParam("callsign")->value();
ogn_callsign = request->getParam("callsign")->value().c_str();
if (request->hasParam("ogn_lat"))
ogn_lat = request->getParam("ogn_lat")->value().toFloat();

Expand Down Expand Up @@ -364,10 +378,14 @@ void Web_setup(ufo_t* this_aircraft)
// settings->sxlna = request->getParam("ogn_agc")->value().toInt();

if (request->hasParam("ogn_ssid"))
ogn_ssid[0] = request->getParam("ogn_ssid")->value();
ogn_ssid[0] = request->getParam("ogn_ssid")->value().c_str();

if (request->hasParam("ogn_wifi_password"))
ogn_wpass[0] = request->getParam("ogn_wifi_password")->value();
if (request->hasParam("ogn_wifi_password")){
if (request->getParam("ogn_wifi_password")->value() != "hidepass"){
ogn_wpass[0] = request->getParam("ogn_wifi_password")->value().c_str();
}
}

//geoid_separation
if (request->hasParam("ogn_geoid"))
ogn_geoid_separation = request->getParam("ogn_geoid")->value().toInt();
Expand Down
Loading

0 comments on commit 7221af6

Please sign in to comment.