diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..37a6bca --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "lib"] + path = lib + url = ../LoRa_APRS_Common diff --git a/lib b/lib new file mode 160000 index 0000000..757733b --- /dev/null +++ b/lib @@ -0,0 +1 @@ +Subproject commit 757733be04730095a27be008363b4f51dd68bacb diff --git a/src/configuration.cpp b/src/configuration.cpp deleted file mode 100644 index bbc8d3a..0000000 --- a/src/configuration.cpp +++ /dev/null @@ -1,155 +0,0 @@ -#include - -#include "configuration.h" -#include "logger.h" - -ConfigurationManagement::ConfigurationManagement(String FilePath) - : mFilePath(FilePath) -{ - if(!SPIFFS.begin(true)) - { - logPrintlnE("Mounting SPIFFS was not possible. Trying to format SPIFFS..."); - SPIFFS.format(); - if(!SPIFFS.begin()) - { - logPrintlnE("Formating SPIFFS was not okay!"); - } - } -} - -Configuration ConfigurationManagement::readConfiguration() -{ - File file = SPIFFS.open(mFilePath); - if(!file) - { - logPrintlnE("Failed to open file for reading..."); - return Configuration(); - } - DynamicJsonDocument data(2048); - DeserializationError error = deserializeJson(data, file); - if(error) - { - logPrintlnW("Failed to read file, using default configuration."); - } - //serializeJson(data, Serial); - //Serial.println(); - file.close(); - - Configuration conf; - if(data.containsKey("callsign")) - conf.callsign = data["callsign"].as(); - - conf.wifi.active = data["wifi"]["active"] | false; - JsonArray aps = data["wifi"]["AP"].as(); - for(JsonVariant v : aps) - { - Configuration::Wifi::AP ap; - ap.SSID = v["SSID"].as(); - ap.password = v["password"].as(); - conf.wifi.APs.push_back(ap); - } - if(data.containsKey("beacon") && data["beacon"].containsKey("message")) - conf.beacon.message = data["beacon"]["message"].as(); - conf.beacon.positionLatitude = data["beacon"]["position"]["latitude"] | 0.0; - conf.beacon.positionLongitude = data["beacon"]["position"]["longitude"] | 0.0; - conf.aprs_is.active = data["aprs_is"]["active"] | false; - if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("password")) - conf.aprs_is.password = data["aprs_is"]["password"].as(); - if(data.containsKey("aprs_is") && data["aprs_is"].containsKey("server")) - conf.aprs_is.server = data["aprs_is"]["server"].as(); - conf.aprs_is.port = data["aprs_is"]["port"] | 14580; - conf.aprs_is.beacon = data["aprs_is"]["beacon"] | true; - conf.aprs_is.beaconTimeout = data["aprs_is"]["beacon_timeout"] | 15; - conf.digi.active = data["digi"]["active"] | false; - conf.digi.forwardTimeout = data["digi"]["forward_timeout"] | 5; - conf.digi.beacon = data["digi"]["beacon"] | true; - conf.digi.beaconTimeout = data["digi"]["beacon_timeout"] | 30; - - conf.lora.frequencyRx = data["lora"]["frequency_rx"] | 433775000; - conf.lora.frequencyTx = data["lora"]["frequency_tx"] | 433775000; - conf.lora.power = data["lora"]["power"] | 20; - conf.lora.spreadingFactor = data["lora"]["spreading_factor"] | 12; - conf.lora.signalBandwidth = data["lora"]["signal_bandwidth"] | 125000; - conf.lora.codingRate4 = data["lora"]["coding_rate4"] | 5; - conf.display.alwaysOn = data["display"]["always_on"] | true; - conf.display.timeout = data["display"]["timeout"] | 10; - conf.display.overwritePin = data["display"]["overwrite_pin"] | 0; - - conf.ftp.active = data["ftp"]["active"] | false; - JsonArray users = data["ftp"]["user"].as(); - for(JsonVariant u : users) - { - Configuration::Ftp::User us; - us.name = u["name"].as(); - us.password = u["password"].as(); - conf.ftp.users.push_back(us); - } - if(conf.ftp.users.empty()) - { - Configuration::Ftp::User us; - us.name = "ftp"; - us.password = "ftp"; - conf.ftp.users.push_back(us); - } - - // update config in memory to get the new fields: - writeConfiguration(conf); - - return conf; -} - -void ConfigurationManagement::writeConfiguration(Configuration conf) -{ - File file = SPIFFS.open(mFilePath, "w"); - if(!file) - { - logPrintlnE("Failed to open file for writing..."); - return; - } - DynamicJsonDocument data(2048); - - data["callsign"] = conf.callsign; - data["wifi"]["active"] = conf.wifi.active; - JsonArray aps = data["wifi"].createNestedArray("AP"); - for(Configuration::Wifi::AP ap : conf.wifi.APs) - { - JsonObject v = aps.createNestedObject(); - v["SSID"] = ap.SSID; - v["password"] = ap.password; - } - data["beacon"]["message"] = conf.beacon.message; - data["beacon"]["position"]["latitude"] = conf.beacon.positionLatitude; - data["beacon"]["position"]["longitude"] = conf.beacon.positionLongitude; - data["aprs_is"]["active"] = conf.aprs_is.active; - data["aprs_is"]["password"] = conf.aprs_is.password; - data["aprs_is"]["server"] = conf.aprs_is.server; - data["aprs_is"]["port"] = conf.aprs_is.port; - data["aprs_is"]["beacon"] = conf.aprs_is.beacon; - data["aprs_is"]["beacon_timeout"] = conf.aprs_is.beaconTimeout; - data["digi"]["active"] = conf.digi.active; - data["digi"]["forward_timeout"] = conf.digi.forwardTimeout; - data["digi"]["beacon"] = conf.digi.beacon; - data["digi"]["beacon_timeout"] = conf.digi.beaconTimeout; - data["lora"]["frequency_rx"] = conf.lora.frequencyRx; - data["lora"]["frequency_tx"] = conf.lora.frequencyTx; - data["lora"]["power"] = conf.lora.power; - data["lora"]["spreading_factor"] = conf.lora.spreadingFactor; - data["lora"]["signal_bandwidth"] = conf.lora.signalBandwidth; - data["lora"]["coding_rate4"] = conf.lora.codingRate4; - data["display"]["always_on"] = conf.display.alwaysOn; - data["display"]["timeout"] = conf.display.timeout; - data["display"]["overwrite_pin"] = conf.display.overwritePin; - data["ftp"]["active"] = conf.ftp.active; - JsonArray users = data["ftp"].createNestedArray("user"); - for(Configuration::Ftp::User u : conf.ftp.users) - { - JsonObject v = users.createNestedObject(); - v["name"] = u.name; - v["password"] = u.password; - } - - serializeJson(data, file); - //serializeJson(data, Serial); - //Serial.println(); - file.close(); -} diff --git a/src/configuration.h b/src/configuration.h deleted file mode 100644 index 8e7e101..0000000 --- a/src/configuration.h +++ /dev/null @@ -1,125 +0,0 @@ -#ifndef CONFIGURATION_H_ -#define CONFIGURATION_H_ - -#include - -#include -#include - -class Configuration -{ -public: - class Wifi - { - public: - class AP - { - public: - String SSID; - String password; - }; - - Wifi() : active(false) {} - - bool active; - std::list APs; - }; - - class Beacon - { - public: - Beacon() : message("LoRa iGATE & Digi, Info: github.com/peterus/LoRa_APRS_iGate"), positionLatitude(0.0), positionLongitude(0.0) {} - - String message; - double positionLatitude; - double positionLongitude; - }; - - class APRS_IS - { - public: - APRS_IS() : active(false), server("euro.aprs2.net"), port(14580), beacon(true), beaconTimeout(15) {} - - bool active; - String password; - String server; - int port; - bool beacon; - int beaconTimeout; - }; - - class Digi - { - public: - Digi() : active(false), forwardTimeout(5), beacon(true), beaconTimeout(30) {} - - bool active; - int forwardTimeout; - bool beacon; - int beaconTimeout; - }; - - class LoRa - { - public: - LoRa() : frequencyRx(433775000), frequencyTx(433775000), power(20), spreadingFactor(12), signalBandwidth(125000), codingRate4(5) {} - - long frequencyRx; - long frequencyTx; - int power; - int spreadingFactor; - long signalBandwidth; - int codingRate4; - }; - - class Display - { - public: - Display() : alwaysOn(true), timeout(10), overwritePin(0) {} - - bool alwaysOn; - int timeout; - int overwritePin; - }; - - class Ftp - { - public: - class User - { - public: - String name; - String password; - }; - - Ftp() : active(false) {} - - bool active; - std::list users; - }; - - Configuration() : callsign("NOCALL-10") {}; - - String callsign; - Wifi wifi; - Beacon beacon; - APRS_IS aprs_is; - Digi digi; - LoRa lora; - Display display; - Ftp ftp; -}; - -class ConfigurationManagement -{ -public: - explicit ConfigurationManagement(String FilePath); - - Configuration readConfiguration(); - void writeConfiguration(Configuration conf); - -private: - const String mFilePath; -}; - -#endif diff --git a/src/display.cpp b/src/display.cpp deleted file mode 100644 index 292b63e..0000000 --- a/src/display.cpp +++ /dev/null @@ -1,127 +0,0 @@ - -#include -#include -#include - -#include "display.h" -#include "pins.h" -#include "logger.h" - -Adafruit_SSD1306 display(128, 64, &Wire); - -void setup_display() -{ - Wire.begin(OLED_SDA, OLED_SCL); - if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3c, false, false)) - { - logPrintlnE("SSD1306 allocation failed"); - while (1); - } - logPrintlnI("Display init done!"); -} - -void turn_off_display() -{ - display.ssd1306_command(SSD1306_DISPLAYOFF); -} - -void show_display(String header, int wait) -{ - display.clearDisplay(); - display.setTextColor(WHITE); - display.setTextSize(2); - display.setCursor(0,0); - display.println(header); - display.display(); - delay(wait); -} - -void show_display(String header, String line1, int wait) -{ - display.clearDisplay(); - display.setTextColor(WHITE); - display.setTextSize(2); - display.setCursor(0,0); - display.println(header); - display.setTextSize(1); - display.setCursor(0,16); - display.println(line1); - display.display(); - delay(wait); -} - -void show_display(String header, String line1, String line2, int wait) -{ - display.clearDisplay(); - display.setTextColor(WHITE); - display.setTextSize(2); - display.setCursor(0,0); - display.println(header); - display.setTextSize(1); - display.setCursor(0,16); - display.println(line1); - display.setCursor(0,26); - display.println(line2); - display.display(); - delay(wait); -} - -void show_display(String header, String line1, String line2, String line3, int wait) -{ - display.clearDisplay(); - display.setTextColor(WHITE); - display.setTextSize(2); - display.setCursor(0,0); - display.println(header); - display.setTextSize(1); - display.setCursor(0,16); - display.println(line1); - display.setCursor(0,26); - display.println(line2); - display.setCursor(0,36); - display.println(line3); - display.display(); - delay(wait); -} - -void show_display(String header, String line1, String line2, String line3, String line4, int wait) -{ - display.clearDisplay(); - display.setTextColor(WHITE); - display.setTextSize(2); - display.setCursor(0,0); - display.println(header); - display.setTextSize(1); - display.setCursor(0,16); - display.println(line1); - display.setCursor(0,26); - display.println(line2); - display.setCursor(0,36); - display.println(line3); - display.setCursor(0,46); - display.println(line4); - display.display(); - delay(wait); -} - -void show_display(String header, String line1, String line2, String line3, String line4, String line5, int wait) -{ - display.clearDisplay(); - display.setTextColor(WHITE); - display.setTextSize(2); - display.setCursor(0,0); - display.println(header); - display.setTextSize(1); - display.setCursor(0,16); - display.println(line1); - display.setCursor(0,26); - display.println(line2); - display.setCursor(0,36); - display.println(line3); - display.setCursor(0,46); - display.println(line4); - display.setCursor(0,56); - display.println(line5); - display.display(); - delay(wait); -} diff --git a/src/display.h b/src/display.h deleted file mode 100644 index 2df251a..0000000 --- a/src/display.h +++ /dev/null @@ -1,15 +0,0 @@ - -#ifndef DISPLAY_H_ -#define DISPLAY_H_ - -void setup_display(); -void turn_off_display(); - -void show_display(String header, int wait = 0); -void show_display(String header, String line1, int wait = 0); -void show_display(String header, String line1, String line2, int wait = 0); -void show_display(String header, String line1, String line2, String line3, int wait = 0); -void show_display(String header, String line1, String line2, String line3, String line4, int wait = 0); -void show_display(String header, String line1, String line2, String line3, String line4, String line5, int wait = 0); - -#endif diff --git a/src/logger.cpp b/src/logger.cpp deleted file mode 100644 index 0e63503..0000000 --- a/src/logger.cpp +++ /dev/null @@ -1,248 +0,0 @@ -#include "logger.h" - -#undef LOG_RESET_COLOR -#undef LOG_COLOR_E -#undef LOG_COLOR_W -#undef LOG_COLOR_I -#undef LOG_COLOR_D -#undef LOG_COLOR_V - -#define LOG_COLOR_BLACK "30" -#define LOG_COLOR_RED "31" -#define LOG_COLOR_GREEN "32" -#define LOG_COLOR_BROWN "33" -#define LOG_COLOR_BLUE "34" -#define LOG_COLOR_PURPLE "35" -#define LOG_COLOR_CYAN "36" -#define LOG_COLOR(COLOR) "\033[0;" COLOR "m" -#define LOG_BOLD(COLOR) "\033[1;" COLOR "m" -#define LOG_RESET_COLOR "\033[0m" -#define LOG_COLOR_E LOG_COLOR(LOG_COLOR_RED) -#define LOG_COLOR_W LOG_COLOR(LOG_COLOR_BROWN) -#define LOG_COLOR_I LOG_COLOR(LOG_COLOR_GREEN) -#define LOG_COLOR_D LOG_COLOR(LOG_COLOR_BLUE) -#define LOG_COLOR_V LOG_COLOR(LOG_COLOR_CYAN) - -Logger::Logger() - : _serial(Serial), _level(DEBUG_LEVEL_DEBUG), _printIsNewline(true) -{ -} - -// cppcheck-suppress unusedFunction -void Logger::setSerial(const HardwareSerial & serial) -{ - _serial = serial; -} - -// cppcheck-suppress unusedFunction -void Logger::setDebugLevel(debug_level_t level) -{ - _level = level; -} - -// cppcheck-suppress unusedFunction -void Logger::printA(const String & text, const char * file, uint32_t line) -{ - printStartColor(DEBUG_LEVEL_NONE); - printHeader(DEBUG_LEVEL_NONE, file, line, false); - _serial.print(text); - printEndColor(DEBUG_LEVEL_NONE); -} - -// cppcheck-suppress unusedFunction -void Logger::printE(const String & text, const char * file, uint32_t line) -{ - printStartColor(DEBUG_LEVEL_ERROR); - printHeader(DEBUG_LEVEL_ERROR, file, line, false); - _serial.print(text); - printEndColor(DEBUG_LEVEL_ERROR); -} - -// cppcheck-suppress unusedFunction -void Logger::printlnA(const String & text, const char * file, uint32_t line) -{ - printStartColor(DEBUG_LEVEL_NONE); - printHeader(DEBUG_LEVEL_NONE, file, line, true); - _serial.println(text); - printEndColor(DEBUG_LEVEL_NONE); -} - -// cppcheck-suppress unusedFunction -void Logger::printlnE(const String & text, const char * file, uint32_t line) -{ - printStartColor(DEBUG_LEVEL_ERROR); - printHeader(DEBUG_LEVEL_ERROR, file, line, true); - _serial.println(text); - printEndColor(DEBUG_LEVEL_ERROR); -} - -// cppcheck-suppress unusedFunction -void Logger::printV(const String & text, const char * file, uint32_t line) -{ - if (_level >= DEBUG_LEVEL_VERBOSE) - { - printStartColor(DEBUG_LEVEL_VERBOSE); - printHeader(DEBUG_LEVEL_VERBOSE, file, line, false); - _serial.print(text); - printEndColor(DEBUG_LEVEL_VERBOSE); - } -} - -// cppcheck-suppress unusedFunction -void Logger::printD(const String & text, const char * file, uint32_t line) -{ - if (_level >= DEBUG_LEVEL_DEBUG) - { - printStartColor(DEBUG_LEVEL_DEBUG); - printHeader(DEBUG_LEVEL_DEBUG, file, line, false); - _serial.print(text); - printEndColor(DEBUG_LEVEL_DEBUG); - } -} - -// cppcheck-suppress unusedFunction -void Logger::printI(const String & text, const char * file, uint32_t line) -{ - if (_level >= DEBUG_LEVEL_INFO) - { - printStartColor(DEBUG_LEVEL_INFO); - printHeader(DEBUG_LEVEL_INFO, file, line, false); - _serial.print(text); - printEndColor(DEBUG_LEVEL_INFO); - } -} - -// cppcheck-suppress unusedFunction -void Logger::printW(const String & text, const char * file, uint32_t line) -{ - if (_level >= DEBUG_LEVEL_WARN) - { - printStartColor(DEBUG_LEVEL_WARN); - printHeader(DEBUG_LEVEL_WARN, file, line, false); - _serial.print(text); - printEndColor(DEBUG_LEVEL_WARN); - } -} - -// cppcheck-suppress unusedFunction -void Logger::printlnV(const String & text, const char * file, uint32_t line) -{ - if (_level >= DEBUG_LEVEL_VERBOSE) - { - printStartColor(DEBUG_LEVEL_VERBOSE); - printHeader(DEBUG_LEVEL_VERBOSE, file, line, true); - _serial.println(text); - printEndColor(DEBUG_LEVEL_VERBOSE); - } -} - -// cppcheck-suppress unusedFunction -void Logger::printlnD(const String & text, const char * file, uint32_t line) -{ - if (_level >= DEBUG_LEVEL_DEBUG) - { - printStartColor(DEBUG_LEVEL_DEBUG); - printHeader(DEBUG_LEVEL_DEBUG, file, line, true); - _serial.println(text); - printEndColor(DEBUG_LEVEL_DEBUG); - } -} - -// cppcheck-suppress unusedFunction -void Logger::printlnI(const String & text, const char * file, uint32_t line) -{ - if (_level >= DEBUG_LEVEL_INFO) - { - printStartColor(DEBUG_LEVEL_INFO); - printHeader(DEBUG_LEVEL_INFO, file, line, true); - _serial.println(text); - printEndColor(DEBUG_LEVEL_INFO); - } -} - -// cppcheck-suppress unusedFunction -void Logger::printlnW(const String & text, const char * file, uint32_t line) -{ - if (_level >= DEBUG_LEVEL_WARN) - { - printStartColor(DEBUG_LEVEL_WARN); - printHeader(DEBUG_LEVEL_WARN, file, line, true); - _serial.println(text); - printEndColor(DEBUG_LEVEL_WARN); - } -} - -void Logger::printStartColor(debug_level_t level) -{ - switch (level) - { - case DEBUG_LEVEL_ERROR: - _serial.print(LOG_COLOR_E); - break; - case DEBUG_LEVEL_WARN: - _serial.print(LOG_COLOR_W); - break; - case DEBUG_LEVEL_INFO: - _serial.print(LOG_COLOR_I); - break; - case DEBUG_LEVEL_DEBUG: - _serial.print(LOG_COLOR_D); - break; - case DEBUG_LEVEL_VERBOSE: - _serial.print(LOG_COLOR_V); - break; - default: - break; - } -} - -void Logger::printHeader(debug_level_t level, const char * file, uint32_t line, bool isln) -{ - if (_printIsNewline) - { - Serial.printf("%c %25s %4d : ", levelToChar(level), file, line); - if(!isln) - { - _printIsNewline = false; - } - } - else - { - _printIsNewline = isln; - } -} - -void Logger::printEndColor(debug_level_t level) -{ - switch (level) - { - case DEBUG_LEVEL_ERROR: - case DEBUG_LEVEL_WARN: - case DEBUG_LEVEL_INFO: - case DEBUG_LEVEL_DEBUG: - case DEBUG_LEVEL_VERBOSE: - _serial.print(LOG_RESET_COLOR); - break; - default: - break; - } -} - -char Logger::levelToChar(debug_level_t level) -{ - switch (level) - { - case DEBUG_LEVEL_ERROR: - return 'E'; - case DEBUG_LEVEL_WARN: - return 'W'; - case DEBUG_LEVEL_INFO: - return 'I'; - case DEBUG_LEVEL_DEBUG: - return 'D'; - case DEBUG_LEVEL_VERBOSE: - return 'V'; - default: - return ' '; - } -} diff --git a/src/logger.h b/src/logger.h deleted file mode 100644 index 51ddedb..0000000 --- a/src/logger.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef _LOGGER_H_ -#define _LOGGER_H_ - -#include - -class Logger -{ -public: - enum debug_level_t { - DEBUG_LEVEL_NONE, // No debug output - DEBUG_LEVEL_ERROR, // Critical errors - DEBUG_LEVEL_WARN, // Error conditions but not critical - DEBUG_LEVEL_INFO, // Information messages - DEBUG_LEVEL_DEBUG, // Extra information - default level (if not changed) - DEBUG_LEVEL_VERBOSE, // More information than the usual - DEBUG_LEVELS_SIZE - }; - - static Logger & instance() - { - static Logger _instance; - return _instance; - } - - ~Logger() {} - - void setSerial(const HardwareSerial & serial = Serial); - void setDebugLevel(debug_level_t level); - - // print always: - void printA(const String & text, const char * file, uint32_t line); // always - void printE(const String & text, const char * file, uint32_t line); // error - void printlnA(const String & text, const char * file, uint32_t line); // always with new line - void printlnE(const String & text, const char * file, uint32_t line); // error with new line - - // depending on verbose level: - void printV(const String & text, const char * file, uint32_t line); // verbose - void printD(const String & text, const char * file, uint32_t line); // debug - void printI(const String & text, const char * file, uint32_t line); // information - void printW(const String & text, const char * file, uint32_t line); // warning - - void printlnV(const String & text, const char * file, uint32_t line); // verbose with new line - void printlnD(const String & text, const char * file, uint32_t line); // debug with new line - void printlnI(const String & text, const char * file, uint32_t line); // information with new line - void printlnW(const String & text, const char * file, uint32_t line); // warning with new line - -private: - HardwareSerial & _serial; - debug_level_t _level; - bool _printIsNewline; - - void printStartColor(debug_level_t level); - void printHeader(debug_level_t level, const char * file, uint32_t line, bool isln); - void printEndColor(debug_level_t level); - char levelToChar(debug_level_t level); - - Logger(); - Logger(const Logger &); - Logger & operator = (const Logger &); -}; - -#define logPrintA(text) Logger::instance().printA(text, __FILE__, __LINE__) -#define logPrintE(text) Logger::instance().printE(text, __FILE__, __LINE__) -#define logPrintlnA(text) Logger::instance().printlnA(text, __FILE__, __LINE__) -#define logPrintlnE(text) Logger::instance().printlnE(text, __FILE__, __LINE__) -#define logPrintV(text) Logger::instance().printV(text, __FILE__, __LINE__) -#define logPrintD(text) Logger::instance().printD(text, __FILE__, __LINE__) -#define logPrintI(text) Logger::instance().printI(text, __FILE__, __LINE__) -#define logPrintW(text) Logger::instance().printW(text, __FILE__, __LINE__) -#define logPrintlnV(text) Logger::instance().printlnV(text, __FILE__, __LINE__) -#define logPrintlnD(text) Logger::instance().printlnD(text, __FILE__, __LINE__) -#define logPrintlnI(text) Logger::instance().printlnI(text, __FILE__, __LINE__) -#define logPrintlnW(text) Logger::instance().printlnW(text, __FILE__, __LINE__) - -#endif diff --git a/src/pins.h b/src/pins.h deleted file mode 100644 index 4c764cb..0000000 --- a/src/pins.h +++ /dev/null @@ -1,56 +0,0 @@ -#ifndef PINS_H_ -#define PINS_H_ - -#undef OLED_SDA -#undef OLED_SCL -#undef OLED_RST - -#if defined(HELTEC_WIFI_LORA_32_V1) || defined(HELTEC_WIFI_LORA_32_V2) || defined(TTGO_LORA32_V1) - #define OLED_SDA 4 - #define OLED_SCL 15 -#endif - -#if defined(TTGO_LORA32_V2) || defined(TTGO_T_Beam_V0_7) || defined(TTGO_T_Beam_V1_0) - #define OLED_SDA 21 - #define OLED_SCL 22 -#endif - -#ifdef TRACKERD - #define OLED_SDA 5 - #define OLED_SCL 4 -#endif - -#ifdef ETH_BOARD - #define OLED_SDA 33 - #define OLED_SCL 32 - #define ETH_POWER_PIN -1 - #define ETH_TYPE ETH_PHY_LAN8720 - #define ETH_ADDR 0 - #define ETH_MDC_PIN 23 - #define ETH_MDIO_PIN 18 - #define NRST 5 -#endif - -#ifdef ETH_BOARD_V1_0 - #define ETH_CLK ETH_CLOCK_GPIO17_OUT // TTGO PoE V1.0 -#endif - -#ifdef ETH_BOARD_V1_2 - #define ETH_CLK ETH_CLOCK_GPIO0_OUT // TTGO PoE V1.2 -#endif - - -#undef KEY_BUILTIN -#if defined(TTGO_T_Beam_V0_7) - #define KEY_BUILTIN 39 -#endif - -#if defined(TTGO_T_Beam_V1_0) - #define KEY_BUILTIN 38 -#endif - -#ifndef KEY_BUILTIN - #define KEY_BUILTIN 0 -#endif - -#endif diff --git a/src/power_management.cpp b/src/power_management.cpp deleted file mode 100644 index 8f017b6..0000000 --- a/src/power_management.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -#include "power_management.h" - -// cppcheck-suppress uninitMemberVar -PowerManagement::PowerManagement() -{ -} - -// cppcheck-suppress unusedFunction -bool PowerManagement::begin(TwoWire & port) -{ - bool result = axp.begin(port, AXP192_SLAVE_ADDRESS); - if(!result) - { - axp.setDCDC1Voltage(3300); - } - return result; -} - -// cppcheck-suppress unusedFunction -void PowerManagement::activateLoRa() -{ - axp.setPowerOutPut(AXP192_LDO2, AXP202_ON); -} - -// cppcheck-suppress unusedFunction -void PowerManagement::deactivateLoRa() -{ - axp.setPowerOutPut(AXP192_LDO2, AXP202_OFF); -} - -// cppcheck-suppress unusedFunction -void PowerManagement::activateGPS() -{ - axp.setPowerOutPut(AXP192_LDO3, AXP202_ON); -} - -// cppcheck-suppress unusedFunction -void PowerManagement::deactivateGPS() -{ - axp.setPowerOutPut(AXP192_LDO3, AXP202_OFF); -} - -// cppcheck-suppress unusedFunction -void PowerManagement::activateOLED() -{ - axp.setPowerOutPut(AXP192_DCDC1, AXP202_ON); -} - -// cppcheck-suppress unusedFunction -void PowerManagement::decativateOLED() -{ - axp.setPowerOutPut(AXP192_DCDC1, AXP202_OFF); -} - diff --git a/src/power_management.h b/src/power_management.h deleted file mode 100644 index ecd6cf6..0000000 --- a/src/power_management.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef POWER_MANAGEMENT_H_ -#define POWER_MANAGEMENT_H_ - -#include -#include - -class PowerManagement -{ -public: - PowerManagement(); - bool begin(TwoWire & port); - - void activateLoRa(); - void deactivateLoRa(); - - void activateGPS(); - void deactivateGPS(); - - void activateOLED(); - void decativateOLED(); - -private: - AXP20X_Class axp; -}; - -#endif