display SH1106 added

This commit is contained in:
richonguzman 2023-08-02 00:02:43 -04:00
parent 4337afb0a1
commit 152974f1e3
7 changed files with 133 additions and 57 deletions

View File

@ -1,7 +1,7 @@
{
"beacons": [
{
"callsign": "NOCALL-7",
"callsign": "CD2RXU-6",
"symbol": "[",
"overlay": "/",
"comment": "",
@ -18,7 +18,7 @@
}
},
{
"callsign": "NOCALL-7",
"callsign": "CD2RXU-6",
"symbol": ">",
"overlay": "/",
"comment": "",
@ -35,7 +35,7 @@
}
},
{
"callsign": "NOCALL-7",
"callsign": "CD2RXU-6",
"symbol": "j",
"overlay": "/",
"comment": "",

View File

@ -30,6 +30,7 @@ lib_deps =
peterus/esp-logger @ 1.0.0
lewisxhe/XPowersLib@^0.1.7
h2zero/NimBLE-Arduino@^1.4.1
adafruit/Adafruit SH110X@^2.1.8
check_tool = cppcheck
check_flags =
cppcheck: --suppress=*:*.pio\* --inline-suppr -DCPPCHECK
@ -39,6 +40,10 @@ check_skip_packages = yes
board = ttgo-t-beam
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_0
[env:ttgo-t-beam-v1-SH1106]
board = ttgo-t-beam
build_flags = -Werror -Wall -DTTGO_T_Beam_V1_0_SH1106
[env:ttgo-t-beam-v0_7]
board = ttgo-t-beam
build_flags = -Werror -Wall -DTTGO_T_Beam_V0_7

View File

@ -30,7 +30,7 @@ TinyGPSPlus gps;
NimBLECharacteristic* pCharacteristic;
OneButton userButton = OneButton(BUTTON_PIN, true, true);
String versionDate = "2023.08.01";
String versionDate = "2023.08.01 ";
int myBeaconsIndex = 0;
int myBeaconsSize = Config.beacons.size();
@ -82,7 +82,7 @@ void setup() {
MSG_Utils::loadNumMessages();
GPS_Utils::setup();
LoRa_Utils::setup();
//LoRa_Utils::setup();
WiFi.mode(WIFI_OFF);
btStop();

View File

@ -1,5 +1,9 @@
#include <Adafruit_SSD1306.h>
#ifdef TTGO_T_Beam_V1_0
#include <Adafruit_SSD1306.h>
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
#include <Adafruit_SH110X.h>
#endif
#include <Adafruit_GFX.h>
#include <logger.h>
#include <Wire.h>
@ -27,7 +31,12 @@ const uint8_t *symbolsAPRS[] = {runnerSymbol, carSymbol, jeepSymbol, bikeSymbol
extern logging::Logger logger;
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST);
#ifdef TTGO_T_Beam_V1_0
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RST);
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
Adafruit_SH1106G display(128, 64, &Wire, OLED_RST);
#endif
// cppcheck-suppress unusedFunction
void setup_display() {
@ -40,39 +49,66 @@ void setup_display() {
#endif
Wire.begin(OLED_SDA, OLED_SCL);
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "SSD1306", "allocation failed!");
while (true) {
#ifdef TTGO_T_Beam_V1_0
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "SSD1306", "allocation failed!");
while (true) {
}
}
}
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
if (!display.begin(0x3c, true)) {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, "SH1106", "allocation failed!");
while (true) {
}
}
#endif
display.clearDisplay();
display.setTextColor(WHITE);
#ifdef TTGO_T_Beam_V1_0
display.setTextColor(WHITE);
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
display.setTextColor(SH110X_WHITE);
#endif
display.setTextSize(1);
display.setCursor(0, 0);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#ifdef TTGO_T_Beam_V1_0
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#endif
display.display();
}
// cppcheck-suppress unusedFunction
void display_toggle(bool toggle) {
if (toggle) {
display.ssd1306_command(SSD1306_DISPLAYON);
#ifdef TTGO_T_Beam_V1_0
display.ssd1306_command(SSD1306_DISPLAYON);
#endif
} else {
display.ssd1306_command(SSD1306_DISPLAYOFF);
#ifdef TTGO_T_Beam_V1_0
display.ssd1306_command(SSD1306_DISPLAYOFF);
#endif
}
}
// cppcheck-suppress unusedFunction
void show_display(String header, int wait) {
display.clearDisplay();
display.setTextColor(WHITE);
#ifdef TTGO_T_Beam_V1_0
display.setTextColor(WHITE);
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
display.setTextColor(SH110X_WHITE);
#endif
display.setTextSize(2);
display.setCursor(0, 0);
display.println(header);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#ifdef TTGO_T_Beam_V1_0
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#endif
display.display();
delay(wait);
}
@ -80,15 +116,22 @@ void show_display(String header, int wait) {
// cppcheck-suppress unusedFunction
void show_display(String header, String line1, int wait) {
display.clearDisplay();
display.setTextColor(WHITE);
#ifdef TTGO_T_Beam_V1_0
display.setTextColor(WHITE);
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
display.setTextColor(SH110X_WHITE);
#endif
display.setTextSize(2);
display.setCursor(0, 0);
display.println(header);
display.setTextSize(1);
display.setCursor(0, 16);
display.println(line1);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#ifdef TTGO_T_Beam_V1_0
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#endif
display.display();
delay(wait);
}
@ -96,7 +139,12 @@ void show_display(String header, String line1, int wait) {
// cppcheck-suppress unusedFunction
void show_display(String header, String line1, String line2, int wait) {
display.clearDisplay();
display.setTextColor(WHITE);
#ifdef TTGO_T_Beam_V1_0
display.setTextColor(WHITE);
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
display.setTextColor(SH110X_WHITE);
#endif
display.setTextSize(2);
display.setCursor(0, 0);
display.println(header);
@ -105,8 +153,10 @@ void show_display(String header, String line1, String line2, int wait) {
display.println(line1);
display.setCursor(0, 26);
display.println(line2);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#ifdef TTGO_T_Beam_V1_0
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#endif
display.display();
delay(wait);
}
@ -114,7 +164,12 @@ void show_display(String header, String line1, String line2, int wait) {
// cppcheck-suppress unusedFunction
void show_display(String header, String line1, String line2, String line3, int wait) {
display.clearDisplay();
display.setTextColor(WHITE);
#ifdef TTGO_T_Beam_V1_0
display.setTextColor(WHITE);
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
display.setTextColor(SH110X_WHITE);
#endif
display.setTextSize(2);
display.setCursor(0, 0);
display.println(header);
@ -125,8 +180,10 @@ void show_display(String header, String line1, String line2, String line3, int w
display.println(line2);
display.setCursor(0, 36);
display.println(line3);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#ifdef TTGO_T_Beam_V1_0
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#endif
display.display();
delay(wait);
}
@ -134,7 +191,12 @@ void show_display(String header, String line1, String line2, String line3, int w
// cppcheck-suppress unusedFunction
void show_display(String header, String line1, String line2, String line3, String line4, int wait) {
display.clearDisplay();
display.setTextColor(WHITE);
#ifdef TTGO_T_Beam_V1_0
display.setTextColor(WHITE);
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
display.setTextColor(SH110X_WHITE);
#endif
display.setTextSize(2);
display.setCursor(0, 0);
display.println(header);
@ -147,8 +209,10 @@ void show_display(String header, String line1, String line2, String line3, Strin
display.println(line3);
display.setCursor(0, 46);
display.println(line4);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#ifdef TTGO_T_Beam_V1_0
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#endif
display.display();
delay(wait);
}
@ -156,7 +220,12 @@ void show_display(String header, String line1, String line2, String line3, Strin
// cppcheck-suppress unusedFunction
void show_display(String header, String line1, String line2, String line3, String line4, String line5, int wait) {
display.clearDisplay();
display.setTextColor(WHITE);
#ifdef TTGO_T_Beam_V1_0
display.setTextColor(WHITE);
#endif
#ifdef TTGO_T_Beam_V1_0_SH1106
display.setTextColor(SH110X_WHITE);
#endif
display.setTextSize(2);
display.setCursor(0, 0);
display.println(header);
@ -171,8 +240,10 @@ void show_display(String header, String line1, String line2, String line3, Strin
display.println(line4);
display.setCursor(0, 56);
display.println(line5);
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#ifdef TTGO_T_Beam_V1_0
display.ssd1306_command(SSD1306_SETCONTRAST);
display.ssd1306_command(1);
#endif
if (menuDisplay==0 && Config.showSymbolOnScreen) {
int symbol = 100;

View File

@ -16,7 +16,7 @@
#define GPS_TX 12
#endif
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SH1106)
#define GPS_RX 12
#define GPS_TX 34
#endif

View File

@ -8,7 +8,7 @@ extern logging::Logger logger;
// cppcheck-suppress unusedFunction
bool PowerManagement::begin(TwoWire &port) {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
bool result = axp.begin(port, AXP192_SLAVE_ADDRESS);
if (!result) {
axp.setDCDC1Voltage(3300);
@ -38,7 +38,7 @@ bool PowerManagement::begin(TwoWire &port) {
// cppcheck-suppress unusedFunction
void PowerManagement::activateLoRa() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
#endif
#ifdef TTGO_T_Beam_V1_2
@ -49,7 +49,7 @@ void PowerManagement::activateLoRa() {
// cppcheck-suppress unusedFunction
void PowerManagement::deactivateLoRa() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
#endif
#ifdef TTGO_T_Beam_V1_2
@ -59,7 +59,7 @@ void PowerManagement::deactivateLoRa() {
// cppcheck-suppress unusedFunction
void PowerManagement::activateGPS() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.setPowerOutPut(AXP192_LDO2, AXP202_ON);
#endif
#ifdef TTGO_T_Beam_V1_2
@ -70,7 +70,7 @@ void PowerManagement::activateGPS() {
// cppcheck-suppress unusedFunction
void PowerManagement::deactivateGPS() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF);
#endif
#ifdef TTGO_T_Beam_V1_2
@ -80,35 +80,35 @@ void PowerManagement::deactivateGPS() {
// cppcheck-suppress unusedFunction
void PowerManagement::activateOLED() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON);
#endif
}
// cppcheck-suppress unusedFunction
void PowerManagement::decativateOLED() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF);
#endif
}
// cppcheck-suppress unusedFunction
void PowerManagement::disableChgLed() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.setChgLEDMode(AXP20X_LED_OFF);
#endif
}
// cppcheck-suppress unusedFunction
void PowerManagement::enableChgLed() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.setChgLEDMode(AXP20X_LED_LOW_LEVEL);
#endif
}
// cppcheck-suppress unusedFunction
void PowerManagement::activateMeasurement() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, true);
#endif
#ifdef TTGO_T_Beam_V1_2
@ -122,14 +122,14 @@ void PowerManagement::activateMeasurement() {
// cppcheck-suppress unusedFunction
void PowerManagement::deactivateMeasurement() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
axp.adc1Enable(AXP202_BATT_CUR_ADC1 | AXP202_BATT_VOL_ADC1, false);
#endif
}
// cppcheck-suppress unusedFunction
double PowerManagement::getBatteryVoltage() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
return axp.getBattVoltage() / 1000.0;
#endif
#ifdef TTGO_T_Beam_V1_2
@ -139,7 +139,7 @@ double PowerManagement::getBatteryVoltage() {
// cppcheck-suppress unusedFunction
double PowerManagement::getBatteryChargeDischargeCurrent() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
if (axp.isChargeing()) {
return axp.getBattChargeCurrent();
}
@ -151,7 +151,7 @@ double PowerManagement::getBatteryChargeDischargeCurrent() {
}
bool PowerManagement::isBatteryConnected() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
return axp.isBatteryConnect();
#endif
#ifdef TTGO_T_Beam_V1_2
@ -160,7 +160,7 @@ bool PowerManagement::isBatteryConnected() {
}
bool PowerManagement::isChargeing() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
return axp.isChargeing();
#endif
#ifdef TTGO_T_Beam_V1_2
@ -169,7 +169,7 @@ bool PowerManagement::isChargeing() {
}
void PowerManagement::setup() {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
Wire.begin(SDA, SCL);
if (!begin(Wire)) {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "AXP192", "init done!");
@ -199,7 +199,7 @@ void PowerManagement::setup() {
}
void PowerManagement::lowerCpuFrequency() {
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SH1106)
if (setCpuFrequencyMhz(80)) {
logger.log(logging::LoggerLevel::LOGGER_LEVEL_INFO, "Main", "CPU frequency set to 80MHz");
} else {
@ -221,7 +221,7 @@ void PowerManagement::obtainBatteryInfo() {
if (!(rate_limit_check_battery++ % 60))
BatteryIsConnected = isBatteryConnected();
if (BatteryIsConnected) {
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
batteryVoltage = String(getBatteryVoltage(), 2);
#endif
#ifdef TTGO_T_Beam_V1_2
@ -244,7 +244,7 @@ bool PowerManagement::getBatteryInfoIsConnected() {
}
void PowerManagement::batteryManager() {
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2)
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_2) || defined(TTGO_T_Beam_V1_0_SH1106)
obtainBatteryInfo();
handleChargingLed();
#endif

View File

@ -2,7 +2,7 @@
#define POWER_UTILS_H_
#include <Arduino.h>
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
#include <axp20x.h>
#endif
#ifdef TTGO_T_Beam_V1_2
@ -49,7 +49,7 @@ private:
bool isBatteryConnected();
#ifdef TTGO_T_Beam_V1_0
#if defined(TTGO_T_Beam_V1_0) || defined(TTGO_T_Beam_V1_0_SH1106)
AXP20X_Class axp;
#endif
#ifdef TTGO_T_Beam_V1_2