From 17a126238260323aa55a6895c18248d0aef4170e Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 27 Jun 2021 10:56:28 -0700 Subject: [PATCH] pull in new epaper lib (which required importing configuration.h everywhere for dumb reasons) --- platformio.ini | 4 +- src/BluetoothCommon.cpp | 1 + src/FSCommon.cpp | 1 + src/OSTimer.cpp | 2 +- src/Observer.cpp | 1 + src/Power.cpp | 1 + src/PowerFSM.cpp | 3 +- src/RedirectablePrint.cpp | 2 +- src/SPILock.cpp | 1 + src/SerialConsole.cpp | 3 +- src/airtime.cpp | 2 +- src/concurrency/BinarySemaphoreFreeRTOS.cpp | 2 +- src/concurrency/BinarySemaphorePosix.cpp | 2 +- src/concurrency/InterruptableDelay.cpp | 2 +- src/concurrency/Lock.cpp | 1 + src/concurrency/LockGuard.cpp | 1 + src/concurrency/NotifiedWorkerThread.cpp | 2 +- src/concurrency/OSThread.cpp | 2 +- src/gps/Air530GPS.cpp | 1 + src/gps/GPS.cpp | 3 +- src/gps/NMEAGPS.cpp | 2 +- src/gps/UBloxGPS.cpp | 1 + src/graphics/EInkDisplay2.cpp | 110 ++++++++++++++++++++ src/graphics/EInkDisplay2.h | 48 +++++++++ src/graphics/Screen.cpp | 3 +- src/main.cpp | 3 +- src/mesh/Channels.cpp | 1 + src/mesh/CryptoEngine.cpp | 2 +- src/mesh/DSRRouter.cpp | 2 +- src/mesh/FloodingRouter.cpp | 2 +- src/mesh/MeshPacketQueue.cpp | 1 + src/mesh/MeshPlugin.cpp | 1 + src/mesh/MeshService.cpp | 3 +- src/mesh/NodeDB.cpp | 4 +- src/mesh/PacketHistory.cpp | 2 +- src/mesh/PhoneAPI.cpp | 1 + src/mesh/ProtobufPlugin.cpp | 1 + src/mesh/RF95Interface.cpp | 2 +- src/mesh/RadioInterface.cpp | 3 +- src/mesh/RadioLibInterface.cpp | 2 +- src/mesh/RadioLibRF95.cpp | 1 + src/mesh/ReliableRouter.cpp | 2 +- src/mesh/Router.cpp | 2 +- src/mesh/SX1262Interface.cpp | 2 +- src/nrf52/BQ25713.cpp | 100 ------------------ src/nrf52/BQ25713.h | 22 ---- src/nrf52/NRF52Bluetooth.cpp | 2 +- src/nrf52/NRF52CryptoEngine.cpp | 3 +- src/nrf52/alloc.cpp | 1 + src/nrf52/main-nrf52.cpp | 2 +- src/plugins/AdminPlugin.cpp | 2 +- src/plugins/ExternalNotificationPlugin.cpp | 2 +- src/plugins/NodeInfoPlugin.cpp | 2 +- src/plugins/Plugins.cpp | 1 + src/plugins/PositionPlugin.cpp | 2 +- src/plugins/RemoteHardwarePlugin.cpp | 2 +- src/plugins/ReplyPlugin.cpp | 2 +- src/plugins/RoutingPlugin.cpp | 2 +- src/plugins/SerialPlugin.cpp | 2 +- src/sleep.cpp | 2 +- 60 files changed, 215 insertions(+), 172 deletions(-) create mode 100644 src/graphics/EInkDisplay2.cpp create mode 100644 src/graphics/EInkDisplay2.h delete mode 100644 src/nrf52/BQ25713.cpp delete mode 100644 src/nrf52/BQ25713.h diff --git a/platformio.ini b/platformio.ini index f58514fef..036f0574b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -357,11 +357,11 @@ board = t-echo # add our variants files to the include and src paths # define build flags for the TFT_eSPI library - NOTE: WE NOT LONGER USE TFT_eSPI, it was for an earlier version of the TTGO eink screens # -DBUSY_PIN=3 -DRST_PIN=2 -DDC_PIN=28 -DCS_PIN=30 -build_flags = ${nrf52_base.build_flags} -Ivariants/t-echo +build_flags = ${nrf52_base.build_flags} -Ivariants/t-echo src_filter = ${nrf52_base.src_filter} +<../variants/t-echo> lib_deps = ${nrf52840_base.lib_deps} - https://github.com/geeksville/EPD_Libraries.git + https://github.com/geeksville/GxEPD2.git ;upload_protocol = fs ; First prototype eink/nrf52840/sx1262 device (removed from build because didn't ship in quantity) diff --git a/src/BluetoothCommon.cpp b/src/BluetoothCommon.cpp index a12a52cf9..0eda2080e 100644 --- a/src/BluetoothCommon.cpp +++ b/src/BluetoothCommon.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "BluetoothCommon.h" // NRF52 wants these constants as byte arrays diff --git a/src/FSCommon.cpp b/src/FSCommon.cpp index 2ce7f0bbe..ac87ba05a 100644 --- a/src/FSCommon.cpp +++ b/src/FSCommon.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "FSCommon.h" void fsInit() diff --git a/src/OSTimer.cpp b/src/OSTimer.cpp index 9be4bd3db..f2b38f17c 100644 --- a/src/OSTimer.cpp +++ b/src/OSTimer.cpp @@ -1,5 +1,5 @@ -#include "OSTimer.h" #include "configuration.h" +#include "OSTimer.h" /** * Schedule a callback to run. The callback must _not_ block, though it is called from regular thread level (not ISR) diff --git a/src/Observer.cpp b/src/Observer.cpp index 1025f8bc0..6d1124684 100644 --- a/src/Observer.cpp +++ b/src/Observer.cpp @@ -1,2 +1,3 @@ +#include "configuration.h" #include "Observer.h" diff --git a/src/Power.cpp b/src/Power.cpp index 945c9bad3..e4f66df44 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "power.h" #include "NodeDB.h" #include "PowerFSM.h" diff --git a/src/PowerFSM.cpp b/src/PowerFSM.cpp index e101c494b..53ba66aa2 100644 --- a/src/PowerFSM.cpp +++ b/src/PowerFSM.cpp @@ -1,9 +1,8 @@ - +#include "configuration.h" #include "PowerFSM.h" #include "GPS.h" #include "MeshService.h" #include "NodeDB.h" -#include "configuration.h" #include "graphics/Screen.h" #include "main.h" #include "sleep.h" diff --git a/src/RedirectablePrint.cpp b/src/RedirectablePrint.cpp index 3f920f641..8cbff9691 100644 --- a/src/RedirectablePrint.cpp +++ b/src/RedirectablePrint.cpp @@ -1,7 +1,7 @@ +#include "configuration.h" #include "RedirectablePrint.h" #include "RTC.h" #include "concurrency/OSThread.h" -#include "configuration.h" #include #include #include diff --git a/src/SPILock.cpp b/src/SPILock.cpp index 43d841fc8..06163f67a 100644 --- a/src/SPILock.cpp +++ b/src/SPILock.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "SPILock.h" #include #include diff --git a/src/SerialConsole.cpp b/src/SerialConsole.cpp index 7435981ea..8f652e3fd 100644 --- a/src/SerialConsole.cpp +++ b/src/SerialConsole.cpp @@ -1,8 +1,7 @@ +#include "configuration.h" #include "SerialConsole.h" #include "NodeDB.h" #include "PowerFSM.h" -#include "configuration.h" -#include #define Port Serial diff --git a/src/airtime.cpp b/src/airtime.cpp index 8d1800d52..221ba1193 100644 --- a/src/airtime.cpp +++ b/src/airtime.cpp @@ -1,5 +1,5 @@ +#include "configuration.h" #include "airtime.h" -#include #define periodsToLog 48 diff --git a/src/concurrency/BinarySemaphoreFreeRTOS.cpp b/src/concurrency/BinarySemaphoreFreeRTOS.cpp index 3d8097455..96c647756 100644 --- a/src/concurrency/BinarySemaphoreFreeRTOS.cpp +++ b/src/concurrency/BinarySemaphoreFreeRTOS.cpp @@ -1,5 +1,5 @@ -#include "concurrency/BinarySemaphoreFreeRTOS.h" #include "configuration.h" +#include "concurrency/BinarySemaphoreFreeRTOS.h" #include #ifdef HAS_FREE_RTOS diff --git a/src/concurrency/BinarySemaphorePosix.cpp b/src/concurrency/BinarySemaphorePosix.cpp index 44cd741f1..0de52b322 100644 --- a/src/concurrency/BinarySemaphorePosix.cpp +++ b/src/concurrency/BinarySemaphorePosix.cpp @@ -1,5 +1,5 @@ -#include "concurrency/BinarySemaphorePosix.h" #include "configuration.h" +#include "concurrency/BinarySemaphorePosix.h" #ifndef HAS_FREE_RTOS diff --git a/src/concurrency/InterruptableDelay.cpp b/src/concurrency/InterruptableDelay.cpp index 80743cc22..fa664e7bb 100644 --- a/src/concurrency/InterruptableDelay.cpp +++ b/src/concurrency/InterruptableDelay.cpp @@ -1,5 +1,5 @@ -#include "concurrency/InterruptableDelay.h" #include "configuration.h" +#include "concurrency/InterruptableDelay.h" namespace concurrency { diff --git a/src/concurrency/Lock.cpp b/src/concurrency/Lock.cpp index ffe997f8d..bcf92496e 100644 --- a/src/concurrency/Lock.cpp +++ b/src/concurrency/Lock.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "Lock.h" #include diff --git a/src/concurrency/LockGuard.cpp b/src/concurrency/LockGuard.cpp index 56e8ac877..1c4d9e2e6 100644 --- a/src/concurrency/LockGuard.cpp +++ b/src/concurrency/LockGuard.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "LockGuard.h" namespace concurrency { diff --git a/src/concurrency/NotifiedWorkerThread.cpp b/src/concurrency/NotifiedWorkerThread.cpp index 78c15a6d0..a7f8fe49a 100644 --- a/src/concurrency/NotifiedWorkerThread.cpp +++ b/src/concurrency/NotifiedWorkerThread.cpp @@ -1,5 +1,5 @@ -#include "NotifiedWorkerThread.h" #include "configuration.h" +#include "NotifiedWorkerThread.h" #include "main.h" #include diff --git a/src/concurrency/OSThread.cpp b/src/concurrency/OSThread.cpp index 4bde72b07..88c21d1c5 100644 --- a/src/concurrency/OSThread.cpp +++ b/src/concurrency/OSThread.cpp @@ -1,5 +1,5 @@ -#include "OSThread.h" #include "configuration.h" +#include "OSThread.h" #include namespace concurrency diff --git a/src/gps/Air530GPS.cpp b/src/gps/Air530GPS.cpp index 857118963..46070eb30 100644 --- a/src/gps/Air530GPS.cpp +++ b/src/gps/Air530GPS.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "Air530GPS.h" #include diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index 080dd0eea..4446540a3 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -1,8 +1,7 @@ - +#include "configuration.h" #include "GPS.h" #include "NodeDB.h" #include "RTC.h" -#include "configuration.h" #include "sleep.h" #include diff --git a/src/gps/NMEAGPS.cpp b/src/gps/NMEAGPS.cpp index bd58b5254..db7c328e4 100644 --- a/src/gps/NMEAGPS.cpp +++ b/src/gps/NMEAGPS.cpp @@ -1,6 +1,6 @@ +#include "configuration.h" #include "NMEAGPS.h" #include "RTC.h" -#include "configuration.h" static int32_t toDegInt(RawDegrees d) { diff --git a/src/gps/UBloxGPS.cpp b/src/gps/UBloxGPS.cpp index 632f5d5c9..91c895a1b 100644 --- a/src/gps/UBloxGPS.cpp +++ b/src/gps/UBloxGPS.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "UBloxGPS.h" #include "RTC.h" #include "error.h" diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp new file mode 100644 index 000000000..51ac3d702 --- /dev/null +++ b/src/graphics/EInkDisplay2.cpp @@ -0,0 +1,110 @@ +#include "configuration.h" + +#ifdef HAS_EINK2 +#include "EInkDisplay.h" +#include "SPILock.h" +#include + +#define COLORED 0 +#define UNCOLORED 1 + +#define INK COLORED // Black ink +#define PAPER UNCOLORED // 'paper' background colour + +#define EPD_WIDTH 200 // FIXME +#define EPD_HEIGHT 200 + +EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl) +{ + setGeometry(GEOMETRY_RAWMODE, EPD_WIDTH, EPD_HEIGHT); + // setGeometry(GEOMETRY_RAWMODE, 128, 64); // old resolution + // setGeometry(GEOMETRY_128_64); // We originally used this because I wasn't sure if rawmode worked - it does +} + +// FIXME quick hack to limit drawing to a very slow rate +uint32_t lastDrawMsec; + +/** + * Force a display update if we haven't drawn within the specified msecLimit + */ +bool EInkDisplay::forceDisplay(uint32_t msecLimit) +{ + // No need to grab this lock because we are on our own SPI bus + // concurrency::LockGuard g(spiLock); + + uint32_t now = millis(); + uint32_t sinceLast = now - lastDrawMsec; + + if (sinceLast > msecLimit || lastDrawMsec == 0) { + lastDrawMsec = now; + + // FIXME - only draw bits have changed (use backbuf similar to the other displays) + // tft.drawBitmap(0, 0, buffer, 128, 64, TFT_YELLOW, TFT_BLACK); + for (uint8_t y = 0; y < displayHeight; y++) { + for (uint8_t x = 0; x < displayWidth; x++) { + + // get src pixel in the page based ordering the OLED lib uses FIXME, super inefficent + auto b = buffer[x + (y / 8) * displayWidth]; + auto isset = b & (1 << (y & 7)); + // frame.drawPixel(x, y, isset ? INK : PAPER); + } + } + + DEBUG_MSG("Updating eink... "); + // ePaper.Reset(); // wake the screen from sleep + // updateDisplay(); // Send image to display and refresh + // Put screen to sleep to save power + // ePaper.Sleep(); + DEBUG_MSG("done\n"); + + return true; + } else { + // DEBUG_MSG("Skipping eink display\n"); + return false; + } +} + +// Write the buffer to the display memory +void EInkDisplay::display(void) +{ + // We don't allow regular 'dumb' display() calls to draw on eink until we've shown + // at least one forceDisplay() keyframe. This prevents flashing when we should the critical + // bootscreen (that we want to look nice) + if (lastDrawMsec) + forceDisplay(slowUpdateMsec); // Show the first screen a few seconds after boot, then slower +} + +// Send a command to the display (low level function) +void EInkDisplay::sendCommand(uint8_t com) +{ + (void)com; + // Drop all commands to device (we just update the buffer) +} + +// Connect to the display +bool EInkDisplay::connect() +{ + DEBUG_MSG("Doing EInk init\n"); + +#ifdef PIN_EINK_PWR_ON + digitalWrite(PIN_EINK_PWR_ON, HIGH); // If we need to assert a pin to power external peripherals + pinMode(PIN_EINK_PWR_ON, OUTPUT); +#endif + +#ifdef PIN_EINK_EN + // backlight power, HIGH is backlight on, LOW is off + digitalWrite(PIN_EINK_EN, LOW); + pinMode(PIN_EINK_EN, OUTPUT); +#endif + + // Initialise the ePaper library + // FIXME - figure out how to use lut_partial_update + if (false) { + DEBUG_MSG("ePaper init failed\n"); + return false; + } else { + return true; + } +} + +#endif diff --git a/src/graphics/EInkDisplay2.h b/src/graphics/EInkDisplay2.h new file mode 100644 index 000000000..18b900305 --- /dev/null +++ b/src/graphics/EInkDisplay2.h @@ -0,0 +1,48 @@ +#pragma once + +#include + +/** + * An adapter class that allows using the TFT_eSPI library as if it was an OLEDDisplay implementation. + * + * Remaining TODO: + * optimize display() to only draw changed pixels (see other OLED subclasses for examples) + * implement displayOn/displayOff to turn off the TFT device (and backlight) + * Use the fast NRF52 SPI API rather than the slow standard arduino version + * + * turn radio back on - currently with both on spi bus is fucked? or are we leaving chip select asserted? + */ +class EInkDisplay : public OLEDDisplay +{ + /// How often should we update the display + /// thereafter we do once per 5 minutes + uint32_t slowUpdateMsec = 5 * 60 * 1000; + + public: + /* constructor + FIXME - the parameters are not used, just a temporary hack to keep working like the old displays + */ + EInkDisplay(uint8_t address, int sda, int scl); + + // Write the buffer to the display memory (for eink we only do this occasionally) + virtual void display(void); + + /** + * Force a display update if we haven't drawn within the specified msecLimit + * + * @return true if we did draw the screen + */ + bool forceDisplay(uint32_t msecLimit = 1000); + + protected: + // the header size of the buffer used, e.g. for the SPI command header + virtual int getBufferOffset(void) { return 0; } + + // Send a command to the display (low level function) + virtual void sendCommand(uint8_t com); + + // Connect to the display + virtual bool connect(); +}; + + diff --git a/src/graphics/Screen.cpp b/src/graphics/Screen.cpp index 332b9d6d7..476880942 100644 --- a/src/graphics/Screen.cpp +++ b/src/graphics/Screen.cpp @@ -19,14 +19,13 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ - +#include "configuration.h" #include #include "GPS.h" #include "MeshService.h" #include "NodeDB.h" #include "Screen.h" -#include "configuration.h" #include "fonts.h" #include "gps/RTC.h" #include "graphics/images.h" diff --git a/src/main.cpp b/src/main.cpp index 1bf8bbcb1..eecdd0bf1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ - +#include "configuration.h" #include "GPS.h" #include "MeshRadio.h" #include "MeshService.h" @@ -6,7 +6,6 @@ #include "PowerFSM.h" #include "airtime.h" #include "buzz.h" -#include "configuration.h" #include "error.h" #include "power.h" // #include "rom/rtc.h" diff --git a/src/mesh/Channels.cpp b/src/mesh/Channels.cpp index 1e49d9319..652fe99a2 100644 --- a/src/mesh/Channels.cpp +++ b/src/mesh/Channels.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "Channels.h" #include "CryptoEngine.h" #include "NodeDB.h" diff --git a/src/mesh/CryptoEngine.cpp b/src/mesh/CryptoEngine.cpp index 59cb7ad8f..9783f6255 100644 --- a/src/mesh/CryptoEngine.cpp +++ b/src/mesh/CryptoEngine.cpp @@ -1,5 +1,5 @@ -#include "CryptoEngine.h" #include "configuration.h" +#include "CryptoEngine.h" void CryptoEngine::setKey(const CryptoKey &k) { diff --git a/src/mesh/DSRRouter.cpp b/src/mesh/DSRRouter.cpp index f7d8588e4..c2a170ec7 100644 --- a/src/mesh/DSRRouter.cpp +++ b/src/mesh/DSRRouter.cpp @@ -1,5 +1,5 @@ -#include "DSRRouter.h" #include "configuration.h" +#include "DSRRouter.h" /* when we receive any packet diff --git a/src/mesh/FloodingRouter.cpp b/src/mesh/FloodingRouter.cpp index 491501e91..fa37aa504 100644 --- a/src/mesh/FloodingRouter.cpp +++ b/src/mesh/FloodingRouter.cpp @@ -1,5 +1,5 @@ -#include "FloodingRouter.h" #include "configuration.h" +#include "FloodingRouter.h" #include "mesh-pb-constants.h" FloodingRouter::FloodingRouter() {} diff --git a/src/mesh/MeshPacketQueue.cpp b/src/mesh/MeshPacketQueue.cpp index 6c964e509..5043a1d81 100644 --- a/src/mesh/MeshPacketQueue.cpp +++ b/src/mesh/MeshPacketQueue.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "MeshPacketQueue.h" #include diff --git a/src/mesh/MeshPlugin.cpp b/src/mesh/MeshPlugin.cpp index a31a7b499..65cb4ce36 100644 --- a/src/mesh/MeshPlugin.cpp +++ b/src/mesh/MeshPlugin.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "MeshPlugin.h" #include "Channels.h" #include "MeshService.h" diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index 4a42f7716..fbc4031b1 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -1,5 +1,4 @@ - -#include +#include "configuration.h" #include #include diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index f6833d867..a2639cf67 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -1,5 +1,4 @@ - -#include +#include "configuration.h" #include #include "FS.h" @@ -14,7 +13,6 @@ #include "PowerFSM.h" #include "RTC.h" #include "Router.h" -#include "configuration.h" #include "error.h" #include "main.h" #include "mesh-pb-constants.h" diff --git a/src/mesh/PacketHistory.cpp b/src/mesh/PacketHistory.cpp index be5a0abc3..6a2cb2c9b 100644 --- a/src/mesh/PacketHistory.cpp +++ b/src/mesh/PacketHistory.cpp @@ -1,5 +1,5 @@ -#include "PacketHistory.h" #include "configuration.h" +#include "PacketHistory.h" #include "mesh-pb-constants.h" PacketHistory::PacketHistory() diff --git a/src/mesh/PhoneAPI.cpp b/src/mesh/PhoneAPI.cpp index 8869a8222..4f434fa1f 100644 --- a/src/mesh/PhoneAPI.cpp +++ b/src/mesh/PhoneAPI.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "PhoneAPI.h" #include "Channels.h" #include "GPS.h" diff --git a/src/mesh/ProtobufPlugin.cpp b/src/mesh/ProtobufPlugin.cpp index 36728c3cd..9cb4b9c2d 100644 --- a/src/mesh/ProtobufPlugin.cpp +++ b/src/mesh/ProtobufPlugin.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "ProtobufPlugin.h" diff --git a/src/mesh/RF95Interface.cpp b/src/mesh/RF95Interface.cpp index ea3fd0f70..8ba3b6e29 100644 --- a/src/mesh/RF95Interface.cpp +++ b/src/mesh/RF95Interface.cpp @@ -1,8 +1,8 @@ +#include "configuration.h" #include "RF95Interface.h" #include "MeshRadio.h" // kinda yucky, but we need to know which region we are in #include "RadioLibRF95.h" #include "error.h" -#include #define MAX_POWER 20 // if we use 20 we are limited to 1% duty cycle or hw might overheat. For continuous operation set a limit of 17 diff --git a/src/mesh/RadioInterface.cpp b/src/mesh/RadioInterface.cpp index 5e63352c9..7551473c8 100644 --- a/src/mesh/RadioInterface.cpp +++ b/src/mesh/RadioInterface.cpp @@ -1,4 +1,4 @@ - +#include "configuration.h" #include "RadioInterface.h" #include "Channels.h" #include "MeshRadio.h" @@ -6,7 +6,6 @@ #include "NodeDB.h" #include "Router.h" #include "assert.h" -#include "configuration.h" #include "sleep.h" #include #include diff --git a/src/mesh/RadioLibInterface.cpp b/src/mesh/RadioLibInterface.cpp index e8c15fbe9..cb77d9ec3 100644 --- a/src/mesh/RadioLibInterface.cpp +++ b/src/mesh/RadioLibInterface.cpp @@ -1,10 +1,10 @@ +#include "configuration.h" #include "RadioLibInterface.h" #include "MeshTypes.h" #include "NodeDB.h" #include "SPILock.h" #include "error.h" #include "mesh-pb-constants.h" -#include #include #include diff --git a/src/mesh/RadioLibRF95.cpp b/src/mesh/RadioLibRF95.cpp index 0551e7377..364a7591f 100644 --- a/src/mesh/RadioLibRF95.cpp +++ b/src/mesh/RadioLibRF95.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "RadioLibRF95.h" #define RF95_CHIP_VERSION 0x12 diff --git a/src/mesh/ReliableRouter.cpp b/src/mesh/ReliableRouter.cpp index 7570ab654..c7f77e5d7 100644 --- a/src/mesh/ReliableRouter.cpp +++ b/src/mesh/ReliableRouter.cpp @@ -1,7 +1,7 @@ +#include "configuration.h" #include "ReliableRouter.h" #include "MeshPlugin.h" #include "MeshTypes.h" -#include "configuration.h" #include "mesh-pb-constants.h" // ReliableRouter::ReliableRouter() {} diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index f58ff6a45..1c5d70101 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -1,9 +1,9 @@ +#include "configuration.h" #include "Router.h" #include "Channels.h" #include "CryptoEngine.h" #include "NodeDB.h" #include "RTC.h" -#include "configuration.h" #include "main.h" #include "mesh-pb-constants.h" #include "plugins/RoutingPlugin.h" diff --git a/src/mesh/SX1262Interface.cpp b/src/mesh/SX1262Interface.cpp index 0a0f92b5f..8af6d0c15 100644 --- a/src/mesh/SX1262Interface.cpp +++ b/src/mesh/SX1262Interface.cpp @@ -1,6 +1,6 @@ +#include "configuration.h" #include "SX1262Interface.h" #include "error.h" -#include // Particular boards might define a different max power based on what their hardware can do #ifndef SX1262_MAX_POWER diff --git a/src/nrf52/BQ25713.cpp b/src/nrf52/BQ25713.cpp deleted file mode 100644 index 2018ea7da..000000000 --- a/src/nrf52/BQ25713.cpp +++ /dev/null @@ -1,100 +0,0 @@ -#include "BQ25713.h" -#include "configuration.h" - -#include - -#ifdef BQ25703A_ADDR - -const uint8_t BQ25713::devAddr = BQ25703A_ADDR; - -bool BQ25713::setup() -{ - DEBUG_MSG("Init BQ25713\n"); - - // if(!writeReg(0x34,0x9034)) return false; - // - // if(!writeReg(0x34,0x8034)) return false; - - if (!writeReg(0x00, 0x0F0A)) - return false; // Config Charge Option 0 - - if (!writeReg(0x02, 0x0224)) // 512mA, FIXME, this seems to be setting a number of bits marked as reserved, why? - return false; // Config Charge Current - - if (!writeReg(0x04, 0x1070)) // about 4.29V - return false; // Config Charge Voltage - - if (!writeReg(0x06, 0x099C)) - return false; // Config OTG Voltage - - if (!writeReg(0x08, 0x5000)) - return false; // Config OTG Current - - // if(!writeReg(0x0A,0x0100)) return false;//Config Input Voltage - - if (!writeReg(0x0C, 0x1800)) // 4.2Vish FIXME, we could lower this? - return false; // Config Minimum System Voltage - - if (!writeReg(0x0E, 0x4900)) - return false; // Config Input Current - - if (!writeReg(0x30, 0xE210)) - return false; // Config Charge Option 1 - - if (!writeReg(0x32, 0x32BF)) - return false; // Config Charge Option 2 - - if (!writeReg(0x34, 0x0834)) - return false; // Config Charge Option 3 - - if (!writeReg(0x36, 0x4A65)) - return false; // Config Prochot Option 0 - - if (!writeReg(0x38, 0x81FF)) - return false; // Config Prochot Option 1 - - if (!writeReg(0x3A, 0xA0FF)) - return false; // Config ADC Option - - return true; -} - -uint16_t BQ25713::readReg(uint8_t reg) -{ - Wire.beginTransmission(devAddr); - Wire.write(reg); - byte err = Wire.endTransmission(); - if (!err) { - int readLen = 2; - Wire.requestFrom(devAddr, (int)(readLen + 1)); - if (Wire.available() >= readLen) { - uint8_t lsb = Wire.read(), msb = Wire.read(); - - return (((uint16_t)msb) << 8) + lsb; - } else - return 0; - } else { - return 0; - } -} - -bool BQ25713::writeReg(uint8_t reg, uint16_t v) -{ - Wire.beginTransmission(devAddr); - Wire.write(reg); - Wire.write(v & 0xff); - Wire.write((v >> 8) & 0xff); - byte err = Wire.endTransmission(); // 0 for success - - if (!err) { - // Do a test readback for early debugging - uint16_t found = readReg(reg); - if (found != v) { - DEBUG_MSG("Readback reg=0x%0x test failed, expected 0x%0x, found 0x%0x!\n", reg, v, found); - return true; // claim success - FIXME - } - } - return !err; -} - -#endif \ No newline at end of file diff --git a/src/nrf52/BQ25713.h b/src/nrf52/BQ25713.h deleted file mode 100644 index 7dd62bac1..000000000 --- a/src/nrf52/BQ25713.h +++ /dev/null @@ -1,22 +0,0 @@ -#pragma once - -#include - -/** - * Driver class to control/monitor BQ25713 charge controller - */ -class BQ25713 { - static const uint8_t devAddr; - -public: - - /// Return true for success - bool setup(); - -private: - uint16_t readReg(uint8_t reg); - - /// Return true for success - bool writeReg(uint8_t reg, uint16_t v); -}; - diff --git a/src/nrf52/NRF52Bluetooth.cpp b/src/nrf52/NRF52Bluetooth.cpp index b9f0acb57..efe8dc6e1 100644 --- a/src/nrf52/NRF52Bluetooth.cpp +++ b/src/nrf52/NRF52Bluetooth.cpp @@ -1,6 +1,6 @@ +#include "configuration.h" #include "NRF52Bluetooth.h" #include "BluetoothCommon.h" -#include "configuration.h" #include "main.h" #include "mesh/PhoneAPI.h" #include "mesh/mesh-pb-constants.h" diff --git a/src/nrf52/NRF52CryptoEngine.cpp b/src/nrf52/NRF52CryptoEngine.cpp index 431fa2e9c..435925f9c 100644 --- a/src/nrf52/NRF52CryptoEngine.cpp +++ b/src/nrf52/NRF52CryptoEngine.cpp @@ -1,6 +1,5 @@ - -#include "CryptoEngine.h" #include "configuration.h" +#include "CryptoEngine.h" #include "ocrypto_aes_ctr.h" class NRF52CryptoEngine : public CryptoEngine diff --git a/src/nrf52/alloc.cpp b/src/nrf52/alloc.cpp index ddbbdab05..0a610bbe3 100644 --- a/src/nrf52/alloc.cpp +++ b/src/nrf52/alloc.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "rtos.h" #include #include diff --git a/src/nrf52/main-nrf52.cpp b/src/nrf52/main-nrf52.cpp index 802c8f9d7..6325bac8c 100644 --- a/src/nrf52/main-nrf52.cpp +++ b/src/nrf52/main-nrf52.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include #include #include @@ -6,7 +7,6 @@ #include #include "NRF52Bluetooth.h" -#include "configuration.h" #include "error.h" #ifdef BQ25703A_ADDR diff --git a/src/plugins/AdminPlugin.cpp b/src/plugins/AdminPlugin.cpp index 9c560fdb1..f998a3de1 100644 --- a/src/plugins/AdminPlugin.cpp +++ b/src/plugins/AdminPlugin.cpp @@ -1,9 +1,9 @@ +#include "configuration.h" #include "AdminPlugin.h" #include "Channels.h" #include "MeshService.h" #include "NodeDB.h" #include "Router.h" -#include "configuration.h" #include "main.h" #ifdef PORTDUINO diff --git a/src/plugins/ExternalNotificationPlugin.cpp b/src/plugins/ExternalNotificationPlugin.cpp index d5ad167b6..9d201cfc7 100644 --- a/src/plugins/ExternalNotificationPlugin.cpp +++ b/src/plugins/ExternalNotificationPlugin.cpp @@ -1,9 +1,9 @@ +#include "configuration.h" #include "ExternalNotificationPlugin.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" #include "Router.h" -#include "configuration.h" #include //#include diff --git a/src/plugins/NodeInfoPlugin.cpp b/src/plugins/NodeInfoPlugin.cpp index 5111d7b87..ea8a97c9e 100644 --- a/src/plugins/NodeInfoPlugin.cpp +++ b/src/plugins/NodeInfoPlugin.cpp @@ -1,9 +1,9 @@ +#include "configuration.h" #include "NodeInfoPlugin.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" #include "Router.h" -#include "configuration.h" #include "main.h" NodeInfoPlugin *nodeInfoPlugin; diff --git a/src/plugins/Plugins.cpp b/src/plugins/Plugins.cpp index ca4cb52f4..2a9e326d5 100644 --- a/src/plugins/Plugins.cpp +++ b/src/plugins/Plugins.cpp @@ -1,3 +1,4 @@ +#include "configuration.h" #include "plugins/ExternalNotificationPlugin.h" #include "plugins/NodeInfoPlugin.h" #include "plugins/PositionPlugin.h" diff --git a/src/plugins/PositionPlugin.cpp b/src/plugins/PositionPlugin.cpp index 2aaa31a5e..adf6a05cb 100644 --- a/src/plugins/PositionPlugin.cpp +++ b/src/plugins/PositionPlugin.cpp @@ -1,9 +1,9 @@ +#include "configuration.h" #include "PositionPlugin.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" #include "Router.h" -#include "configuration.h" PositionPlugin *positionPlugin; diff --git a/src/plugins/RemoteHardwarePlugin.cpp b/src/plugins/RemoteHardwarePlugin.cpp index d31e70608..9068b14d9 100644 --- a/src/plugins/RemoteHardwarePlugin.cpp +++ b/src/plugins/RemoteHardwarePlugin.cpp @@ -1,9 +1,9 @@ +#include "configuration.h" #include "RemoteHardwarePlugin.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" #include "Router.h" -#include "configuration.h" #include "main.h" #define NUM_GPIOS 64 diff --git a/src/plugins/ReplyPlugin.cpp b/src/plugins/ReplyPlugin.cpp index 69903aa36..b0aa08673 100644 --- a/src/plugins/ReplyPlugin.cpp +++ b/src/plugins/ReplyPlugin.cpp @@ -1,6 +1,6 @@ +#include "configuration.h" #include "ReplyPlugin.h" #include "MeshService.h" -#include "configuration.h" #include "main.h" #include diff --git a/src/plugins/RoutingPlugin.cpp b/src/plugins/RoutingPlugin.cpp index e04239b27..d4f6f9254 100644 --- a/src/plugins/RoutingPlugin.cpp +++ b/src/plugins/RoutingPlugin.cpp @@ -1,8 +1,8 @@ +#include "configuration.h" #include "RoutingPlugin.h" #include "MeshService.h" #include "NodeDB.h" #include "Router.h" -#include "configuration.h" #include "main.h" RoutingPlugin *routingPlugin; diff --git a/src/plugins/SerialPlugin.cpp b/src/plugins/SerialPlugin.cpp index a79982129..687df0184 100644 --- a/src/plugins/SerialPlugin.cpp +++ b/src/plugins/SerialPlugin.cpp @@ -1,9 +1,9 @@ +#include "configuration.h" #include "SerialPlugin.h" #include "MeshService.h" #include "NodeDB.h" #include "RTC.h" #include "Router.h" -#include "configuration.h" #include #include diff --git a/src/sleep.cpp b/src/sleep.cpp index 1021041a2..44720b4c5 100644 --- a/src/sleep.cpp +++ b/src/sleep.cpp @@ -1,9 +1,9 @@ +#include "configuration.h" #include "sleep.h" #include "GPS.h" #include "MeshRadio.h" #include "MeshService.h" #include "NodeDB.h" -#include "configuration.h" #include "error.h" #include "main.h" #include "target_specific.h"