From 23272daffeab50e141ecf155683aaccb19d2066b Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Mon, 27 Mar 2023 14:09:22 -0500 Subject: [PATCH 01/18] Threshold based smart position broadcasts (#2388) * Overhaul smart broadcast with new thresholds * Fixed badly spelt protos * That's not the right thing * Format specifiers * Fmt * Units * Default distance threshold of 100 --- protobufs | 2 +- src/mesh/NodeDB.cpp | 6 +-- src/mesh/generated/meshtastic/config.pb.h | 16 +++++-- src/mesh/generated/meshtastic/deviceonly.pb.h | 2 +- src/mesh/generated/meshtastic/localonly.pb.h | 2 +- src/modules/PositionModule.cpp | 43 ++++++++----------- 6 files changed, 36 insertions(+), 35 deletions(-) diff --git a/protobufs b/protobufs index a73083db5..2b55d8421 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit a73083db549d7f0a4e47b0ebd5e6d363f130fcf9 +Subproject commit 2b55d8421b2f872f8c50e001bd107a2bc56a5157 diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 5aa0ca458..3a7055aed 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -165,6 +165,8 @@ void NodeDB::installDefaultConfig() config.lora.hop_limit = HOP_RELIABLE; config.position.gps_enabled = true; config.position.position_broadcast_smart_enabled = true; + config.position.broadcast_smart_minimum_distance = 100; + config.position.broadcast_smart_minimum_interval_secs = 30; if (config.device.role != meshtastic_Config_DeviceConfig_Role_ROUTER) config.device.node_info_broadcast_secs = 3 * 60 * 60; config.device.serial_enabled = true; @@ -231,9 +233,7 @@ void NodeDB::installRoleDefaults(meshtastic_Config_DeviceConfig_Role role) } else if (role == meshtastic_Config_DeviceConfig_Role_REPEATER) { config.display.screen_on_secs = 1; } else if (role == meshtastic_Config_DeviceConfig_Role_TRACKER) { - config.position.position_broadcast_smart_enabled = false; - config.position.position_broadcast_secs = 120; - config.position.gps_update_interval = 60; + config.position.gps_update_interval = 30; } else if (role == meshtastic_Config_DeviceConfig_Role_SENSOR) { moduleConfig.telemetry.environment_measurement_enabled = true; moduleConfig.telemetry.environment_update_interval = 300; diff --git a/src/mesh/generated/meshtastic/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h index fd949cde9..34f013250 100644 --- a/src/mesh/generated/meshtastic/config.pb.h +++ b/src/mesh/generated/meshtastic/config.pb.h @@ -262,6 +262,10 @@ typedef struct _meshtastic_Config_PositionConfig { uint32_t rx_gpio; /* (Re)define GPS_TX_PIN for your board. */ uint32_t tx_gpio; + /* The minimum distance in meters traveled (since the last send) before we can send a position to the mesh if position_broadcast_smart_enabled */ + uint32_t broadcast_smart_minimum_distance; + /* The minumum number of seconds (since the last send) before we can send a position to the mesh if position_broadcast_smart_enabled */ + uint32_t broadcast_smart_minimum_interval_secs; } meshtastic_Config_PositionConfig; /* Power Config\ @@ -524,7 +528,7 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_Config_init_default {0, {meshtastic_Config_DeviceConfig_init_default}} #define meshtastic_Config_DeviceConfig_init_default {_meshtastic_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_RebroadcastMode_MIN, 0} -#define meshtastic_Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_NetworkConfig_init_default {0, "", "", "", 0, _meshtastic_Config_NetworkConfig_AddressMode_MIN, false, meshtastic_Config_NetworkConfig_IpV4Config_init_default, ""} #define meshtastic_Config_NetworkConfig_IpV4Config_init_default {0, 0, 0, 0} @@ -533,7 +537,7 @@ extern "C" { #define meshtastic_Config_BluetoothConfig_init_default {0, _meshtastic_Config_BluetoothConfig_PairingMode_MIN, 0} #define meshtastic_Config_init_zero {0, {meshtastic_Config_DeviceConfig_init_zero}} #define meshtastic_Config_DeviceConfig_init_zero {_meshtastic_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_RebroadcastMode_MIN, 0} -#define meshtastic_Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0} +#define meshtastic_Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_NetworkConfig_init_zero {0, "", "", "", 0, _meshtastic_Config_NetworkConfig_AddressMode_MIN, false, meshtastic_Config_NetworkConfig_IpV4Config_init_zero, ""} #define meshtastic_Config_NetworkConfig_IpV4Config_init_zero {0, 0, 0, 0} @@ -558,6 +562,8 @@ extern "C" { #define meshtastic_Config_PositionConfig_position_flags_tag 7 #define meshtastic_Config_PositionConfig_rx_gpio_tag 8 #define meshtastic_Config_PositionConfig_tx_gpio_tag 9 +#define meshtastic_Config_PositionConfig_broadcast_smart_minimum_distance_tag 10 +#define meshtastic_Config_PositionConfig_broadcast_smart_minimum_interval_secs_tag 11 #define meshtastic_Config_PowerConfig_is_power_saving_tag 1 #define meshtastic_Config_PowerConfig_on_battery_shutdown_after_secs_tag 2 #define meshtastic_Config_PowerConfig_adc_multiplier_override_tag 3 @@ -653,7 +659,9 @@ X(a, STATIC, SINGULAR, UINT32, gps_update_interval, 5) \ X(a, STATIC, SINGULAR, UINT32, gps_attempt_time, 6) \ X(a, STATIC, SINGULAR, UINT32, position_flags, 7) \ X(a, STATIC, SINGULAR, UINT32, rx_gpio, 8) \ -X(a, STATIC, SINGULAR, UINT32, tx_gpio, 9) +X(a, STATIC, SINGULAR, UINT32, tx_gpio, 9) \ +X(a, STATIC, SINGULAR, UINT32, broadcast_smart_minimum_distance, 10) \ +X(a, STATIC, SINGULAR, UINT32, broadcast_smart_minimum_interval_secs, 11) #define meshtastic_Config_PositionConfig_CALLBACK NULL #define meshtastic_Config_PositionConfig_DEFAULT NULL @@ -758,7 +766,7 @@ extern const pb_msgdesc_t meshtastic_Config_BluetoothConfig_msg; #define meshtastic_Config_LoRaConfig_size 77 #define meshtastic_Config_NetworkConfig_IpV4Config_size 20 #define meshtastic_Config_NetworkConfig_size 195 -#define meshtastic_Config_PositionConfig_size 42 +#define meshtastic_Config_PositionConfig_size 54 #define meshtastic_Config_PowerConfig_size 43 #define meshtastic_Config_size 198 diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index c43777bdf..dbda5b239 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -188,7 +188,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg; /* Maximum encoded size of messages (where known) */ #define meshtastic_ChannelFile_size 638 #define meshtastic_DeviceState_size 22040 -#define meshtastic_OEMStore_size 3008 +#define meshtastic_OEMStore_size 3020 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/localonly.pb.h b/src/mesh/generated/meshtastic/localonly.pb.h index 41d6d70aa..f31e47f20 100644 --- a/src/mesh/generated/meshtastic/localonly.pb.h +++ b/src/mesh/generated/meshtastic/localonly.pb.h @@ -156,7 +156,7 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg; #define meshtastic_LocalModuleConfig_fields &meshtastic_LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define meshtastic_LocalConfig_size 442 +#define meshtastic_LocalConfig_size 454 #define meshtastic_LocalModuleConfig_size 420 #ifdef __cplusplus diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index d923dad8a..92a8b4c0c 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -144,10 +144,10 @@ int32_t PositionModule::runOnce() // We limit our GPS broadcasts to a max rate uint32_t now = millis(); - uint32_t intervalMs = config.position.position_broadcast_secs > 0 ? config.position.position_broadcast_secs * 1000 - : default_broadcast_interval_secs * 1000; - if (lastGpsSend == 0 || (now - lastGpsSend) >= intervalMs) { + uint32_t intervalMs = getConfiguredOrDefaultMs(config.position.position_broadcast_secs, default_broadcast_interval_secs); + uint32_t msSinceLastSend = now - lastGpsSend; + if (lastGpsSend == 0 || msSinceLastSend >= intervalMs) { // Only send packets if the channel is less than 40% utilized. if (airTime->isTxAllowedChannelUtil()) { if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) { @@ -165,39 +165,32 @@ int32_t PositionModule::runOnce() } } } else if (config.position.position_broadcast_smart_enabled) { - - // Only send packets if the channel is less than 25% utilized. - if (airTime->isTxAllowedChannelUtil(true)) { - + // Only send packets if the channel is less than 25% utilized or we're a tracker. + if (airTime->isTxAllowedChannelUtil(config.device.role != meshtastic_Config_DeviceConfig_Role_TRACKER)) { meshtastic_NodeInfo *node2 = service.refreshMyNodeInfo(); // should guarantee there is now a position if (node2->has_position && (node2->position.latitude_i != 0 || node2->position.longitude_i != 0)) { // The minimum distance to travel before we are able to send a new position packet. - const uint32_t distanceTravelMinimum = 30; + const uint32_t distanceTravelThreshold = + config.position.broadcast_smart_minimum_distance > 0 ? config.position.broadcast_smart_minimum_distance : 100; - // The minimum time that would pass before we are able to send a new position packet. - const uint32_t timeTravelMinimum = 30; + // The minimum time (in seconds) that would pass before we are able to send a new position packet. + const uint32_t minimumTimeThreshold = + getConfiguredOrDefaultMs(config.position.broadcast_smart_minimum_interval_secs, 30); // Determine the distance in meters between two points on the globe - float distance = GeoCoord::latLongToMeter(lastGpsLatitude * 1e-7, lastGpsLongitude * 1e-7, - node->position.latitude_i * 1e-7, node->position.longitude_i * 1e-7); + float distanceTraveledSinceLastSend = + GeoCoord::latLongToMeter(lastGpsLatitude * 1e-7, lastGpsLongitude * 1e-7, node->position.latitude_i * 1e-7, + node->position.longitude_i * 1e-7); - // Yes, this has a bunch of magic numbers. Sorry. This is to make the scale non-linear. - const float distanceTravelMath = 1203 / (sqrt(pow(myNodeInfo.bitrate, 1.5) / 1.1)); - uint32_t distanceTravelThreshold = - (distanceTravelMath >= distanceTravelMinimum) ? distanceTravelMath : distanceTravelMinimum; - - // Yes, this has a bunch of magic numbers. Sorry. - uint32_t timeTravel = - ((1500 / myNodeInfo.bitrate) >= timeTravelMinimum) ? (1500 / myNodeInfo.bitrate) : timeTravelMinimum; - // If the distance traveled since the last update is greater than distanceTravelMinimum meters - // and it's been at least timeTravelMinimum seconds since the last update - if ((abs(distance) >= distanceTravelThreshold) && (now - lastGpsSend) >= (timeTravel * 1000)) { + if ((abs(distanceTraveledSinceLastSend) >= distanceTravelThreshold) && msSinceLastSend >= minimumTimeThreshold) { bool requestReplies = currentGeneration != radioGeneration; currentGeneration = radioGeneration; - LOG_INFO("Sending smart pos@%x:6 to mesh (wantReplies=%d, d=%d, dtt=%d, tt=%d)\n", node2->position.timestamp, - requestReplies, distance, distanceTravelThreshold, timeTravel); + LOG_INFO("Sending smart pos@%x:6 to mesh (distanceTraveled=%fm, minDistanceThreshold=%im, timeElapsed=%ims, " + "minTimeInterval=%ims)\n", + node2->position.timestamp, abs(distanceTraveledSinceLastSend), distanceTravelThreshold, + msSinceLastSend, minimumTimeThreshold); sendOurPosition(NODENUM_BROADCAST, requestReplies); // Set the current coords as our last ones, after we've compared distance with current and decided to send From 1e54a5d45c3aa2b85c652a1f3e519b9dcba60f77 Mon Sep 17 00:00:00 2001 From: thebentern Date: Mon, 27 Mar 2023 19:44:59 +0000 Subject: [PATCH 02/18] [create-pull-request] automated change --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index e5f585ef7..a59ad1d56 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 1 -build = 5 +build = 6 From 9a9279dd784892f52427cccf401849870c4002a4 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Tue, 28 Mar 2023 15:32:05 +0200 Subject: [PATCH 03/18] Add files via upload --- boards/my-esp32s3-diy-oled.json | 53 +++++++++++++++++++++++++++++++++ boards/my_esp32s3_diy_eink.json | 53 +++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 boards/my-esp32s3-diy-oled.json create mode 100644 boards/my_esp32s3_diy_eink.json diff --git a/boards/my-esp32s3-diy-oled.json b/boards/my-esp32s3-diy-oled.json new file mode 100644 index 000000000..a72a5e1fa --- /dev/null +++ b/boards/my-esp32s3-diy-oled.json @@ -0,0 +1,53 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=0", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=0" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "my-esp32s3-diy-oled" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Clone ESP32-S3-DevKitC-1 v1.1 (16 MB FLASH, 8 MB PSRAM)", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} diff --git a/boards/my_esp32s3_diy_eink.json b/boards/my_esp32s3_diy_eink.json new file mode 100644 index 000000000..baff689fd --- /dev/null +++ b/boards/my_esp32s3_diy_eink.json @@ -0,0 +1,53 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi" + }, + "core": "esp32", + "extra_flags": [ + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=0", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=0" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0x303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "my_esp32s3_diy_eink" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "default_tool": "esp-builtin", + "onboard_tools": [ + "esp-builtin" + ], + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Clone ESP32-S3-DevKitC-1 v1.1 (16 MB FLASH, 8 MB PSRAM)", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "use_1200bps_touch": true, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://docs.espressif.com/projects/esp-idf/en/latest/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html", + "vendor": "Espressif" +} From 790df42987586c6936c59553289ee4a455311db3 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Tue, 28 Mar 2023 15:32:56 +0200 Subject: [PATCH 04/18] Add files via upload --- .../MakePython_nRF52840_eink/platformio.ini | 12 + variants/MakePython_nRF52840_eink/variant.cpp | 43 ++++ variants/MakePython_nRF52840_eink/variant.h | 159 +++++++++++++ .../MakePython_nRF52840_oled/platformio.ini | 9 + variants/MakePython_nRF52840_oled/variant.cpp | 43 ++++ variants/MakePython_nRF52840_oled/variant.h | 139 ++++++++++++ variants/m5stack-stamp-c3/pins_arduino.h | 32 +++ variants/m5stack-stamp-c3/platformio.ini | 12 + variants/m5stack-stamp-c3/variant.h | 72 ++++++ variants/my_esp32s3_diy_eink/pins_arduino.h | 36 +++ variants/my_esp32s3_diy_eink/platformio.ini | 27 +++ variants/my_esp32s3_diy_eink/variant.h | 57 +++++ variants/my_esp32s3_diy_oled/pins_arduino.h | 36 +++ variants/my_esp32s3_diy_oled/platformio.ini | 22 ++ variants/my_esp32s3_diy_oled/variant.h | 57 +++++ variants/rak4631_epaper_onrxtx/platformio.ini | 15 ++ variants/rak4631_epaper_onrxtx/variant.cpp | 41 ++++ variants/rak4631_epaper_onrxtx/variant.h | 210 ++++++++++++++++++ 18 files changed, 1022 insertions(+) create mode 100644 variants/MakePython_nRF52840_eink/platformio.ini create mode 100644 variants/MakePython_nRF52840_eink/variant.cpp create mode 100644 variants/MakePython_nRF52840_eink/variant.h create mode 100644 variants/MakePython_nRF52840_oled/platformio.ini create mode 100644 variants/MakePython_nRF52840_oled/variant.cpp create mode 100644 variants/MakePython_nRF52840_oled/variant.h create mode 100644 variants/m5stack-stamp-c3/pins_arduino.h create mode 100644 variants/m5stack-stamp-c3/platformio.ini create mode 100644 variants/m5stack-stamp-c3/variant.h create mode 100644 variants/my_esp32s3_diy_eink/pins_arduino.h create mode 100644 variants/my_esp32s3_diy_eink/platformio.ini create mode 100644 variants/my_esp32s3_diy_eink/variant.h create mode 100644 variants/my_esp32s3_diy_oled/pins_arduino.h create mode 100644 variants/my_esp32s3_diy_oled/platformio.ini create mode 100644 variants/my_esp32s3_diy_oled/variant.h create mode 100644 variants/rak4631_epaper_onrxtx/platformio.ini create mode 100644 variants/rak4631_epaper_onrxtx/variant.cpp create mode 100644 variants/rak4631_epaper_onrxtx/variant.h diff --git a/variants/MakePython_nRF52840_eink/platformio.ini b/variants/MakePython_nRF52840_eink/platformio.ini new file mode 100644 index 000000000..49200a02b --- /dev/null +++ b/variants/MakePython_nRF52840_eink/platformio.ini @@ -0,0 +1,12 @@ +[env:makerpython_nrf52840_sx1280_eink] +extends = nrf52840_base +board = nordic_pca10059 +build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_eink -D PRIVATE_HW + -D PIN_EINK_EN +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/MakePython_nRF52840_eink> +lib_deps = + ${nrf52840_base.lib_deps} + caveman99/ESP32 Codec2@^1.0.1 + zinggjm/GxEPD2@^1.4.9 +debug_tool = jlink +upload_port = /dev/ttyACM4 diff --git a/variants/MakePython_nRF52840_eink/variant.cpp b/variants/MakePython_nRF52840_eink/variant.cpp new file mode 100644 index 000000000..5b9288319 --- /dev/null +++ b/variants/MakePython_nRF52840_eink/variant.cpp @@ -0,0 +1,43 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library 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 Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = + { + // P0 + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/variants/MakePython_nRF52840_eink/variant.h b/variants/MakePython_nRF52840_eink/variant.h new file mode 100644 index 000000000..8cf1f7dd9 --- /dev/null +++ b/variants/MakePython_nRF52840_eink/variant.h @@ -0,0 +1,159 @@ +#ifndef _VARIANT_MAKERPYTHON_NRF82540_EINK_ +#define _VARIANT_MAKERPYTHON_NRF82540_EINK_ + +#define MAKERPYTHON + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +#define RADIOLIB_GODMODE + +// LEDs +#define PIN_LED1 (32 + 10) // LED P1.15 +#define PIN_LED2 (-1) // + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_GREEN PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 0 // State when LED is litted + +/* + * Buttons + */ + +#define PIN_BUTTON1 (32 + 15) // P1.15 Built in button + +/* + * Analog pins + */ +#define PIN_A0 (-1) + +static const uint8_t A0 = PIN_A0; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (-1) // AREF Not yet used + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (-1) +#define PIN_SERIAL1_TX (-1) + +// Connected to Jlink CDC +#define PIN_SERIAL2_RX (-1) +#define PIN_SERIAL2_TX (-1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 2 +// here +//#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (0 + 31) // MISO P0.31 +#define PIN_SPI_MOSI (0 + 30) // MOSI P0.30 +#define PIN_SPI_SCK (0 + 29) // SCK P0.29 + +// here +#define PIN_SPI1_MISO (-1) // +#define PIN_SPI1_MOSI (0 + 28) // EPD_MOSI P0.10 +#define PIN_SPI1_SCK (0 + 2) // EPD_SCLK P0.09 + +static const uint8_t SS = (32 + 15); // LORA_CS P1.15 +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +// here +/* + * eink display pins + */ + +//#define PIN_EINK_EN (-1) +#define PIN_EINK_CS (0 + 3) // EPD_CS +#define PIN_EINK_BUSY (32 + 11) // EPD_BUSY +#define PIN_EINK_DC (32 + 13) // EPD_D/C +#define PIN_EINK_RES (-1) // Not used +#define PIN_EINK_SCLK (0 + 2) // EPD_SCLK +#define PIN_EINK_MOSI (0 + 28) // EPD_MOSI + +#define USE_EINK + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (0 + 21) // SDA +#define PIN_WIRE_SCL (0 + 22) // SCL + +// E-Byte E28 2.4 Ghz LoRa module +#define USE_SX1280 +#define LORA_RESET (0 + 5) +#define SX128X_CS (0 + 23) +#define SX128X_DIO1 (0 + 4) +#define SX128X_BUSY (0 + 7) +//#define SX128X_TXEN (32 + 9) +//#define SX128X_RXEN (0 + 12) +#define SX128X_RESET LORA_RESET + +#define PIN_GPS_EN (-1) +#define PIN_GPS_PPS (-1) // Pulse per second input from the GPS + +#define GPS_RX_PIN PIN_SERIAL1_RX +#define GPS_TX_PIN PIN_SERIAL1_TX + +// Battery +// The battery sense is hooked to pin A0 (5) +#define BATTERY_PIN PIN_A0 +// and has 12 bit resolution +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION 4096.0 +// Definition of milliVolt per LSB => 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 +#define VBAT_MV_PER_LSB (0.73242188F) +// Voltage divider value => 1.5M + 1M voltage divider on VBAT = (1.5M / (1M + 1.5M)) +#define VBAT_DIVIDER (0.4F) +// Compensation factor for the VBAT divider +#define VBAT_DIVIDER_COMP (1.73) +// Fixed calculation of milliVolt from compensation value +#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) +#undef AREF_VOLTAGE +#define AREF_VOLTAGE 3.0 +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER VBAT_DIVIDER_COMP // REAL_VBAT_MV_PER_LSB +#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif diff --git a/variants/MakePython_nRF52840_oled/platformio.ini b/variants/MakePython_nRF52840_oled/platformio.ini new file mode 100644 index 000000000..ad5474d7d --- /dev/null +++ b/variants/MakePython_nRF52840_oled/platformio.ini @@ -0,0 +1,9 @@ +[env:makerpython_nrf52840_sx1280_oled] +extends = nrf52840_base +board = nordic_pca10059 +build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_oled -D PRIVATE_HW +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/MakePython_nRF52840_oled> +lib_deps = + ${nrf52840_base.lib_deps} + caveman99/ESP32 Codec2@^1.0.1 +debug_tool = jlink diff --git a/variants/MakePython_nRF52840_oled/variant.cpp b/variants/MakePython_nRF52840_oled/variant.cpp new file mode 100644 index 000000000..5b9288319 --- /dev/null +++ b/variants/MakePython_nRF52840_oled/variant.cpp @@ -0,0 +1,43 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + This library 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 Lesser General Public License for more details. + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "wiring_constants.h" +#include "wiring_digital.h" +#include "nrf.h" + +const uint32_t g_ADigitalPinMap[] = + { + // P0 + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, + 40, 41, 42, 43, 44, 45, 46, 47}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/variants/MakePython_nRF52840_oled/variant.h b/variants/MakePython_nRF52840_oled/variant.h new file mode 100644 index 000000000..ac54c1531 --- /dev/null +++ b/variants/MakePython_nRF52840_oled/variant.h @@ -0,0 +1,139 @@ +#ifndef _VARIANT_MAKERPYTHON_NRF82540_OLED_ +#define _VARIANT_MAKERPYTHON_NRF82540_OLED_ + +#define MAKERPYTHON + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +#define RADIOLIB_GODMODE + +// LEDs +#define PIN_LED1 (32 + 10) // LED P1.15 +#define PIN_LED2 (-1) // + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_GREEN PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 0 // State when LED is litted + +/* + * Buttons + */ + +#define PIN_BUTTON1 (32 + 15) // P1.15 Built in button + +/* + * Analog pins + */ +#define PIN_A0 (-1) + +static const uint8_t A0 = PIN_A0; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (-1) // AREF Not yet used + + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (-1) +#define PIN_SERIAL1_TX (-1) + +// Connected to Jlink CDC +#define PIN_SERIAL2_RX (-1) +#define PIN_SERIAL2_TX (-1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 1 + +#define PIN_SPI_MISO (0 + 31) // MISO P0.31 +#define PIN_SPI_MOSI (0 + 30) // MOSI P0.30 +#define PIN_SPI_SCK (0 + 29) // SCK P0.29 + +static const uint8_t SS = (32 + 15); // LORA_CS P1.15 +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (0 + 26) // SDA +#define PIN_WIRE_SCL (0 + 27) // SCL + +// E-Byte E28 2.4 Ghz LoRa module +#define USE_SX1280 +#define LORA_RESET (0 + 5) +#define SX128X_CS (0 + 23) +#define SX128X_DIO1 (0 + 4) +#define SX128X_BUSY (0 + 7) +//#define SX128X_TXEN (32 + 9) +//#define SX128X_RXEN (0 + 12) +#define SX128X_RESET LORA_RESET + + +#define PIN_GPS_EN (-1) +#define PIN_GPS_PPS (-1) // Pulse per second input from the GPS + +#define GPS_RX_PIN PIN_SERIAL1_RX +#define GPS_TX_PIN PIN_SERIAL1_TX + +// Battery +// The battery sense is hooked to pin A0 (5) +#define BATTERY_PIN PIN_A0 +// and has 12 bit resolution +#define BATTERY_SENSE_RESOLUTION_BITS 12 +#define BATTERY_SENSE_RESOLUTION 4096.0 +// Definition of milliVolt per LSB => 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 +#define VBAT_MV_PER_LSB (0.73242188F) +// Voltage divider value => 1.5M + 1M voltage divider on VBAT = (1.5M / (1M + 1.5M)) +#define VBAT_DIVIDER (0.4F) +// Compensation factor for the VBAT divider +#define VBAT_DIVIDER_COMP (1.73) +// Fixed calculation of milliVolt from compensation value +#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) +#undef AREF_VOLTAGE +#define AREF_VOLTAGE 3.0 +#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +#define ADC_MULTIPLIER VBAT_DIVIDER_COMP //REAL_VBAT_MV_PER_LSB +#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif diff --git a/variants/m5stack-stamp-c3/pins_arduino.h b/variants/m5stack-stamp-c3/pins_arduino.h new file mode 100644 index 000000000..38ef9934e --- /dev/null +++ b/variants/m5stack-stamp-c3/pins_arduino.h @@ -0,0 +1,32 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define EXTERNAL_NUM_INTERRUPTS 22 +#define NUM_DIGITAL_PINS 22 +#define NUM_ANALOG_INPUTS 6 + +#define analogInputToDigitalPin(p) (((p) < NUM_ANALOG_INPUTS) ? (esp32_adc2gpio[(p)]) : -1) +#define digitalPinToInterrupt(p) (((p) < NUM_DIGITAL_PINS) ? (p) : -1) +#define digitalPinHasPWM(p) (p < EXTERNAL_NUM_INTERRUPTS) + +static const uint8_t TX = -1; // 21; +static const uint8_t RX = -1; // 20; + +static const uint8_t SDA = 1; +static const uint8_t SCL = 0; + +static const uint8_t SS = 7; +static const uint8_t MOSI = 6; +static const uint8_t MISO = 5; +static const uint8_t SCK = 4; + +static const uint8_t A0 = 0; +static const uint8_t A1 = 1; +static const uint8_t A2 = 2; +static const uint8_t A3 = 3; +static const uint8_t A4 = 4; +static const uint8_t A5 = 5; + +#endif /* Pins_Arduino_h */ diff --git a/variants/m5stack-stamp-c3/platformio.ini b/variants/m5stack-stamp-c3/platformio.ini new file mode 100644 index 000000000..b7cec5552 --- /dev/null +++ b/variants/m5stack-stamp-c3/platformio.ini @@ -0,0 +1,12 @@ +[env:m5stack-stamp-c3] +extends = esp32c3_base +board = esp32-c3-devkitm-1 +board_level = extra +build_flags = + ${esp32_base.build_flags} + -D PRIVATE_HW + -I variants/m5stack-stamp-c3 +monitor_speed = 115200 +upload_protocol = esptool +upload_port = /dev/ttyACM2 +upload_speed = 921600 diff --git a/variants/m5stack-stamp-c3/variant.h b/variants/m5stack-stamp-c3/variant.h new file mode 100644 index 000000000..b1a192af5 --- /dev/null +++ b/variants/m5stack-stamp-c3/variant.h @@ -0,0 +1,72 @@ +#define I2C_SDA 1 +#define I2C_SCL 0 + +#define BUTTON_PIN 3 // M5Stack STAMP C3 built in button +#define BUTTON_NEED_PULLUP + +//#define HAS_SCREEN 0 +#define HAS_GPS 0 +#undef GPS_RX_PIN +#undef GPS_TX_PIN + +#undef RF95_SCK +#undef RF95_MISO +#undef RF95_MOSI +#undef RF95_NSS + +// Adafruit RFM95W OK +// https://www.adafruit.com/product/3072 +#define USE_RF95 +#define RF95_SCK 4 +#define RF95_MISO 5 +#define RF95_MOSI 6 +#define RF95_NSS 7 +#define LORA_DIO0 10 +#define LORA_RESET 8 +#define LORA_DIO1 RADIOLIB_NC +#define LORA_DIO2 RADIOLIB_NC + +// WaveShare Core1262-868M OK +// https://www.waveshare.com/wiki/Core1262-868M +//#define USE_SX1262 +//#define RF95_SCK 4 +//#define RF95_MISO 5 +//#define RF95_MOSI 6 +//#define RF95_NSS 7 +//#define LORA_DIO0 RADIOLIB_NC +//#define LORA_RESET 8 +//#define LORA_DIO1 10 +//#define LORA_DIO2 RADIOLIB_NC +//#define LORA_BUSY 18 +//#define SX126X_CS RF95_NSS +//#define SX126X_DIO1 LORA_DIO1 +//#define SX126X_BUSY LORA_BUSY +//#define SX126X_RESET LORA_RESET +//#define SX126X_E22 + +// SX128X 2.4 Ghz LoRa module Not OK - RadioLib issue ? still to confirm +//#define USE_SX1280 +//#define RF95_SCK 4 +//#define RF95_MISO 5 +//#define RF95_MOSI 6 +//#define RF95_NSS 7 +//#define LORA_DIO0 -1 +//#define LORA_DIO1 10 +//#define LORA_DIO2 21 +//#define LORA_RESET 8 +//#define LORA_BUSY 1 +//#define SX128X_CS RF95_NSS +//#define SX128X_DIO1 LORA_DIO1 +//#define SX128X_BUSY LORA_BUSY +//#define SX128X_RESET LORA_RESET +//#define SX128X_MAX_POWER 10 + +// Not yet tested +//#define USE_EINK +//#define PIN_EINK_EN -1 // N/C +//#define PIN_EINK_CS 9 // EPD_CS +//#define PIN_EINK_BUSY 18 // EPD_BUSY +//#define PIN_EINK_DC 19 // EPD_D/C +//#define PIN_EINK_RES -1 // Connected but not needed +//#define PIN_EINK_SCLK 4 // EPD_SCLK +//#define PIN_EINK_MOSI 6 // EPD_MOSI \ No newline at end of file diff --git a/variants/my_esp32s3_diy_eink/pins_arduino.h b/variants/my_esp32s3_diy_eink/pins_arduino.h new file mode 100644 index 000000000..fc71c914d --- /dev/null +++ b/variants/my_esp32s3_diy_eink/pins_arduino.h @@ -0,0 +1,36 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1) +#define digitalPinToInterrupt(p) (((p)<48)?(p):-1) +#define digitalPinHasPWM(p) (p < 46) + +// The default Wire will be mapped to PMU and RTC +static const uint8_t SDA = 18; +static const uint8_t SCL = 17; + +// Default SPI will be mapped to Radio +static const uint8_t MISO = 3; +static const uint8_t SCK = 5; +static const uint8_t MOSI = 6; +static const uint8_t SS = 7; + + + +//#define SPI_MOSI (11) +//#define SPI_SCK (14) +//#define SPI_MISO (2) +//#define SPI_CS (13) + +//#define SDCARD_CS SPI_CS + +#endif /* Pins_Arduino_h */ diff --git a/variants/my_esp32s3_diy_eink/platformio.ini b/variants/my_esp32s3_diy_eink/platformio.ini new file mode 100644 index 000000000..3df33c90d --- /dev/null +++ b/variants/my_esp32s3_diy_eink/platformio.ini @@ -0,0 +1,27 @@ +[env:my-esp32s3-diy-eink] +extends = esp32s3_base +board = my_esp32s3_diy_eink +board_build.arduino.memory_type = dio_opi +board_build.mcu = esp32s3 +board_build.f_cpu = 240000000L +upload_protocol = esptool +upload_port = /dev/ttyACM1 +upload_speed = 921600 +platform_packages = + tool-esptoolpy@^1.40500.0 +lib_deps = + ${esp32_base.lib_deps} + caveman99/ESP32 Codec2@^1.0.1 + zinggjm/GxEPD2@^1.5.1 + adafruit/Adafruit NeoPixel@^1.10.7 +build_unflags = -DARDUINO_USB_MODE=1 +build_flags = + ;${esp32_base.build_flags} -D MY_ESP32S3_DIY -I variants/my_esp32s3_diy_eink + ${esp32_base.build_flags} -D PRIVATE_HW -I variants/my_esp32s3_diy_eink + -Dmy + -DTECHO_DISPLAY_MODEL=GxEPD2_290_T5D + -DEPD_HEIGHT=128 + -DEPD_WIDTH=296 + -DBOARD_HAS_PSRAM + -mfix-esp32-psram-cache-issue + -DARDUINO_USB_MODE=0 diff --git a/variants/my_esp32s3_diy_eink/variant.h b/variants/my_esp32s3_diy_eink/variant.h new file mode 100644 index 000000000..20b1c8908 --- /dev/null +++ b/variants/my_esp32s3_diy_eink/variant.h @@ -0,0 +1,57 @@ +#define HAS_GPS 0 +#undef GPS_RX_PIN +#undef GPS_TX_PIN + +//#define HAS_SCREEN 0 +//#define HAS_SDCARD +//#define SDCARD_USE_SPI1 + +//#define USE_SSD1306 + +#define I2C_SDA 18 //1 // I2C pins for this board +#define I2C_SCL 17 //2 + +//#define LED_PIN 38 // This is a RGB LED not a standard LED + +#define BUTTON_PIN 0 // This is the BOOT button +#define BUTTON_NEED_PULLUP + + +//#define USE_RF95 // RFM95/SX127x +//#define USE_SX1262 +#define USE_SX1280 + +#define RF95_MISO 3 +#define RF95_SCK 5 +#define RF95_MOSI 6 +#define RF95_NSS 7 + +#define LORA_RESET 8 +#define LORA_DIO1 16 + +#ifdef USE_SX1262 +#define SX126X_CS RF95_NSS // FIXME - we really should define LORA_CS instead +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY 15 +#define SX126X_RESET LORA_RESET +#define SX126X_RXEN 4 +#define SX126X_TXEN 9 +#endif + +#ifdef USE_SX1280 +#define SX128X_CS RF95_NSS +#define SX128X_DIO1 LORA_DIO1 +#define SX128X_BUSY 15 +#define SX128X_RESET LORA_RESET +#endif + +#define USE_EINK + /* + * eink display pins + */ +#define PIN_EINK_CS 13 +#define PIN_EINK_BUSY 2 +#define PIN_EINK_DC 1 +#define PIN_EINK_RES (-1) +#define PIN_EINK_SCLK 5 +#define PIN_EINK_MOSI 6 diff --git a/variants/my_esp32s3_diy_oled/pins_arduino.h b/variants/my_esp32s3_diy_oled/pins_arduino.h new file mode 100644 index 000000000..fc71c914d --- /dev/null +++ b/variants/my_esp32s3_diy_oled/pins_arduino.h @@ -0,0 +1,36 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1) +#define digitalPinToInterrupt(p) (((p)<48)?(p):-1) +#define digitalPinHasPWM(p) (p < 46) + +// The default Wire will be mapped to PMU and RTC +static const uint8_t SDA = 18; +static const uint8_t SCL = 17; + +// Default SPI will be mapped to Radio +static const uint8_t MISO = 3; +static const uint8_t SCK = 5; +static const uint8_t MOSI = 6; +static const uint8_t SS = 7; + + + +//#define SPI_MOSI (11) +//#define SPI_SCK (14) +//#define SPI_MISO (2) +//#define SPI_CS (13) + +//#define SDCARD_CS SPI_CS + +#endif /* Pins_Arduino_h */ diff --git a/variants/my_esp32s3_diy_oled/platformio.ini b/variants/my_esp32s3_diy_oled/platformio.ini new file mode 100644 index 000000000..42bf97770 --- /dev/null +++ b/variants/my_esp32s3_diy_oled/platformio.ini @@ -0,0 +1,22 @@ +[env:my-esp32s3-diy-oled] +extends = esp32s3_base +board = my-esp32s3-diy-oled +board_build.arduino.memory_type = dio_opi +board_build.mcu = esp32s3 +board_build.f_cpu = 240000000L +upload_protocol = esptool +upload_port = /dev/ttyACM0 +upload_speed = 921600 +platform_packages = + tool-esptoolpy@^1.40500.0 +lib_deps = + ${esp32_base.lib_deps} + caveman99/ESP32 Codec2@^1.0.1 + adafruit/Adafruit NeoPixel@^1.10.7 +build_unflags = -DARDUINO_USB_MODE=1 +build_flags = + ;${esp32_base.build_flags} -D MY_ESP32S3_DIY -I variants/my_esp32s3_diy_oled + ${esp32_base.build_flags} -D PRIVATE_HW -I variants/my_esp32s3_diy_oled + -DBOARD_HAS_PSRAM + -mfix-esp32-psram-cache-issue + -DARDUINO_USB_MODE=0 diff --git a/variants/my_esp32s3_diy_oled/variant.h b/variants/my_esp32s3_diy_oled/variant.h new file mode 100644 index 000000000..d87c1e985 --- /dev/null +++ b/variants/my_esp32s3_diy_oled/variant.h @@ -0,0 +1,57 @@ +#define HAS_GPS 0 +#undef GPS_RX_PIN +#undef GPS_TX_PIN + +//#define HAS_SCREEN 0 +//#define HAS_SDCARD +//#define SDCARD_USE_SPI1 + +#define USE_SSD1306 + +#define I2C_SDA 18 //1 // I2C pins for this board +#define I2C_SCL 17 //2 + +//#define LED_PIN 38 // This is a RGB LED not a standard LED + +#define BUTTON_PIN 0 // This is the BOOT button +#define BUTTON_NEED_PULLUP + + +//#define USE_RF95 // RFM95/SX127x +//#define USE_SX1262 +#define USE_SX1280 + +#define RF95_MISO 3 +#define RF95_SCK 5 +#define RF95_MOSI 6 +#define RF95_NSS 7 + +#define LORA_RESET 8 +#define LORA_DIO1 16 + +#ifdef USE_SX1262 +#define SX126X_CS RF95_NSS // FIXME - we really should define LORA_CS instead +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY 15 +#define SX126X_RESET LORA_RESET +#define SX126X_RXEN 4 +#define SX126X_TXEN 9 +#endif + +#ifdef USE_SX1280 +#define SX128X_CS RF95_NSS +#define SX128X_DIO1 LORA_DIO1 +#define SX128X_BUSY 15 +#define SX128X_RESET LORA_RESET +#endif + +//#define USE_EINK + /* + * eink display pins + */ +//#define PIN_EINK_CS 13 +//#define PIN_EINK_BUSY 2 +//#define PIN_EINK_DC 1 +//#define PIN_EINK_RES (-1) +//#define PIN_EINK_SCLK 5 +//#define PIN_EINK_MOSI 6 diff --git a/variants/rak4631_epaper_onrxtx/platformio.ini b/variants/rak4631_epaper_onrxtx/platformio.ini new file mode 100644 index 000000000..257a3f7ff --- /dev/null +++ b/variants/rak4631_epaper_onrxtx/platformio.ini @@ -0,0 +1,15 @@ +; The very slick RAK wireless RAK 4631 / 4630 board - Firmware for 5005 with the RAK 14000 ePaper +[env:rak4631_eink_onrxtx] +extends = nrf52840_base +board = wiscore_rak4631 +build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631_epaper -D RAK_4631 + -D PIN_EINK_EN=34 +build_src_filter = ${nrf52_base.build_src_filter} +<../variants/rak4631_epaper_onrxtx> +lib_deps = + ${nrf52840_base.lib_deps} + zinggjm/GxEPD2@^1.5.1 + melopero/Melopero RV3028@^1.1.0 +debug_tool = jlink +; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) +;upload_protocol = jlink +upload_port = /dev/ttyACM3 \ No newline at end of file diff --git a/variants/rak4631_epaper_onrxtx/variant.cpp b/variants/rak4631_epaper_onrxtx/variant.cpp new file mode 100644 index 000000000..75cca1dc3 --- /dev/null +++ b/variants/rak4631_epaper_onrxtx/variant.cpp @@ -0,0 +1,41 @@ +/* + Copyright (c) 2014-2015 Arduino LLC. All right reserved. + Copyright (c) 2016 Sandeep Mistry All right reserved. + Copyright (c) 2018, Adafruit Industries (adafruit.com) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "variant.h" +#include "nrf.h" +#include "wiring_constants.h" +#include "wiring_digital.h" + +const uint32_t g_ADigitalPinMap[] = { + // P0 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}; + +void initVariant() +{ + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); + + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); +} diff --git a/variants/rak4631_epaper_onrxtx/variant.h b/variants/rak4631_epaper_onrxtx/variant.h new file mode 100644 index 000000000..44db0b7f0 --- /dev/null +++ b/variants/rak4631_epaper_onrxtx/variant.h @@ -0,0 +1,210 @@ +#ifndef _VARIANT_RAK4630_ +#define _VARIANT_RAK4630_ + +#define RAK4630 + +/** Master clock frequency */ +#define VARIANT_MCK (64000000ul) + +#define USE_LFXO // Board uses 32khz crystal for LF +// define USE_LFRC // Board uses RC for LF + +/*---------------------------------------------------------------------------- + * Headers + *----------------------------------------------------------------------------*/ + +#include "WVariant.h" + +#ifdef __cplusplus +extern "C" { +#endif // __cplusplus + +// Number of pins defined in PinDescription array +#define PINS_COUNT (48) +#define NUM_DIGITAL_PINS (48) +#define NUM_ANALOG_INPUTS (6) +#define NUM_ANALOG_OUTPUTS (0) + +// LEDs +#define PIN_LED1 (35) +#define PIN_LED2 (36) + +#define LED_BUILTIN PIN_LED1 +#define LED_CONN PIN_LED2 + +#define LED_GREEN PIN_LED1 +#define LED_BLUE PIN_LED2 + +#define LED_STATE_ON 1 // State when LED is litted + +/* + * Buttons + */ + +#define PIN_BUTTON1 9 // Pin for button on E-ink button module or IO expansion +#define BUTTON_NEED_PULLUP +//#define PIN_BUTTON2 12 + +/* + * Analog pins + */ +#define PIN_A0 (-1) //(5) +#define PIN_A1 (31) +#define PIN_A2 (28) +#define PIN_A3 (29) +#define PIN_A4 (30) +#define PIN_A5 (31) +#define PIN_A6 (0xff) +#define PIN_A7 (0xff) + +static const uint8_t A0 = PIN_A0; +static const uint8_t A1 = PIN_A1; +static const uint8_t A2 = PIN_A2; +static const uint8_t A3 = PIN_A3; +static const uint8_t A4 = PIN_A4; +static const uint8_t A5 = PIN_A5; +static const uint8_t A6 = PIN_A6; +static const uint8_t A7 = PIN_A7; +#define ADC_RESOLUTION 14 + +// Other pins +#define PIN_AREF (2) +//#define PIN_NFC1 (9) +//#define PIN_NFC2 (10) + +static const uint8_t AREF = PIN_AREF; + +/* + * Serial interfaces + */ +#define PIN_SERIAL1_RX (-1) +#define PIN_SERIAL1_TX (-1) + +// Connected to Jlink CDC +#define PIN_SERIAL2_RX (-1) +#define PIN_SERIAL2_TX (-1) + +/* + * SPI Interfaces + */ +#define SPI_INTERFACES_COUNT 2 + +#define PIN_SPI_MISO (45) +#define PIN_SPI_MOSI (44) +#define PIN_SPI_SCK (43) + +#define PIN_SPI1_MISO (-1) +#define PIN_SPI1_MOSI (0 + 13) +#define PIN_SPI1_SCK (0 + 14) + +static const uint8_t SS = 42; +static const uint8_t MOSI = PIN_SPI_MOSI; +static const uint8_t MISO = PIN_SPI_MISO; +static const uint8_t SCK = PIN_SPI_SCK; + +/* + * eink display pins + */ + +#define USE_EINK + +#define PIN_EINK_CS (0 + 16) // TX1 +#define PIN_EINK_BUSY (0 + 15) // RX1 +#define PIN_EINK_DC (0 + 17) // IO1 +//#define PIN_EINK_RES (-1) //first try without RESET then connect it to AIN (AIN0 5 ) +#define PIN_EINK_RES (0 + 5) // 2.13 BN Display needs RESET +#define PIN_EINK_SCLK (0 + 14) // SCL +#define PIN_EINK_MOSI (0 + 13) // SDA + +// Controls power for the eink display - Board power is enabled either by VBUS from USB or the CPU asserting PWR_ON +// FIXME - I think this is actually just the board power enable - it enables power to the CPU also +// #define PIN_EINK_PWR_ON (-1) + +/* + * Wire Interfaces + */ +#define WIRE_INTERFACES_COUNT 1 + +#define PIN_WIRE_SDA (13) +#define PIN_WIRE_SCL (14) + +/* @note RAK5005-O GPIO mapping to RAK4631 GPIO ports + RAK5005-O <-> nRF52840 + IO1 <-> P0.17 (Arduino GPIO number 17) + IO2 <-> P1.02 (Arduino GPIO number 34) + IO3 <-> P0.21 (Arduino GPIO number 21) + IO4 <-> P0.04 (Arduino GPIO number 4) + IO5 <-> P0.09 (Arduino GPIO number 9) + IO6 <-> P0.10 (Arduino GPIO number 10) + IO7 <-> P0.28 (Arduino GPIO number 28) + SW1 <-> P0.01 (Arduino GPIO number 1) + A0 <-> P0.04/AIN2 (Arduino Analog A2 + A1 <-> P0.31/AIN7 (Arduino Analog A7 + SPI_CS <-> P0.26 (Arduino GPIO number 26) + */ + +// RAK4630 LoRa module +#define USE_SX1262 +#define SX126X_CS (42) +#define SX126X_DIO1 (47) +#define SX126X_BUSY (46) +#define SX126X_RESET (38) +// #define SX126X_TXEN (39) +// #define SX126X_RXEN (37) +#define SX126X_POWER_EN (37) +#define SX126X_E22 // DIO2 controlls an antenna switch and the TCXO voltage is controlled by DIO3 + +// enables 3.3V periphery like GPS or IO Module +#define PIN_3V3_EN (34) + +// NO GPS +#undef GPS_RX_PIN +#undef GPS_TX_PIN + +// RAK1910 GPS module +// If using the wisblock GPS module and pluged into Port A on WisBlock base +// IO1 is hooked to PPS (pin 12 on header) = gpio 17 +// IO2 is hooked to GPS RESET = gpio 34, but it can not be used to this because IO2 is ALSO used to control 3V3_S power (1 is on). +// Therefore must be 1 to keep peripherals powered +// Power is on the controllable 3V3_S rail +// #define PIN_GPS_RESET (34) +//#define PIN_GPS_EN PIN_3V3_EN +//#define PIN_GPS_PPS (17) // Pulse per second input from the GPS + +//#define GPS_RX_PIN PIN_SERIAL1_RX +//#define GPS_TX_PIN PIN_SERIAL1_TX + +// RAK12002 RTC Module +#define RV3028_RTC (uint8_t)0b1010010 + +// Battery +// The battery sense is hooked to pin A0 (5) +//#define BATTERY_PIN PIN_A0 +// and has 12 bit resolution +//#define BATTERY_SENSE_RESOLUTION_BITS 12 +//#define BATTERY_SENSE_RESOLUTION 4096.0 +// Definition of milliVolt per LSB => 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096 +//#define VBAT_MV_PER_LSB (0.73242188F) +// Voltage divider value => 1.5M + 1M voltage divider on VBAT = (1.5M / (1M + 1.5M)) +//#define VBAT_DIVIDER (0.4F) +// Compensation factor for the VBAT divider +//#define VBAT_DIVIDER_COMP (1.73) +// Fixed calculation of milliVolt from compensation value +//#define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB) +//#undef AREF_VOLTAGE +//#define AREF_VOLTAGE 3.0 +//#define VBAT_AR_INTERNAL AR_INTERNAL_3_0 +//#define ADC_MULTIPLIER VBAT_DIVIDER_COMP // REAL_VBAT_MV_PER_LSB +//#define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) + +//#define HAS_RTC 1 + +#ifdef __cplusplus +} +#endif + +/*---------------------------------------------------------------------------- + * Arduino objects - C++ only + *----------------------------------------------------------------------------*/ + +#endif From 1968f3c45b543ce81cca5deb98d471833803b797 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Tue, 28 Mar 2023 15:33:37 +0200 Subject: [PATCH 05/18] Delete EInkDisplay2.cpp --- src/graphics/EInkDisplay2.cpp | 229 ---------------------------------- 1 file changed, 229 deletions(-) delete mode 100644 src/graphics/EInkDisplay2.cpp diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp deleted file mode 100644 index a705b90b8..000000000 --- a/src/graphics/EInkDisplay2.cpp +++ /dev/null @@ -1,229 +0,0 @@ -#include "configuration.h" - -#ifdef USE_EINK -#include "EInkDisplay2.h" -#include "GxEPD2_BW.h" -#include "SPILock.h" -#include "main.h" -#include - -#define COLORED GxEPD_BLACK -#define UNCOLORED GxEPD_WHITE - -#if defined(TTGO_T_ECHO) -#define TECHO_DISPLAY_MODEL GxEPD2_154_D67 -#elif defined(RAK4630) - -// GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 - changed from GxEPD2_213_B74 - which was not going to give partial update -// support -#define TECHO_DISPLAY_MODEL GxEPD2_213_BN - -// 4.2 inch 300x400 - GxEPD2_420_M01 -//#define TECHO_DISPLAY_MODEL GxEPD2_420_M01 - -// 2.9 inch 296x128 - GxEPD2_290_T5D -//#define TECHO_DISPLAY_MODEL GxEPD2_290_T5D - -// 1.54 inch 200x200 - GxEPD2_154_M09 -//#define TECHO_DISPLAY_MODEL GxEPD2_154_M09 - -#elif defined(PCA10059) - -// 4.2 inch 300x400 - GxEPD2_420_M01 -#define TECHO_DISPLAY_MODEL GxEPD2_420_M01 - -#elif defined(M5_COREINK) -// M5Stack CoreInk -// 1.54 inch 200x200 - GxEPD2_154_M09 -#define TECHO_DISPLAY_MODEL GxEPD2_154_M09 - -#endif - -GxEPD2_BW *adafruitDisplay; - -EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY geometry, HW_I2C i2cBus) -{ -#if defined(TTGO_T_ECHO) - setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT); -#elif defined(RAK4630) - - // GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 - setGeometry(GEOMETRY_RAWMODE, 250, 122); - - // GxEPD2_420_M01 - // setGeometry(GEOMETRY_RAWMODE, 300, 400); - - // GxEPD2_290_T5D - // setGeometry(GEOMETRY_RAWMODE, 296, 128); - - // GxEPD2_154_M09 - // setGeometry(GEOMETRY_RAWMODE, 200, 200); - -#elif defined(PCA10059) - - // GxEPD2_420_M01 - setGeometry(GEOMETRY_RAWMODE, 300, 400); - -#elif defined(M5_COREINK) - - // M5Stack_CoreInk 200x200 - // 1.54 inch 200x200 - GxEPD2_154_M09 - setGeometry(GEOMETRY_RAWMODE, EPD_HEIGHT, EPD_WIDTH); - -#endif - // 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 (adafruitDisplay && (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 (uint32_t y = 0; y < displayHeight; y++) { - for (uint32_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)); - adafruitDisplay->drawPixel(x, y, isset ? COLORED : UNCOLORED); - } - } - - LOG_DEBUG("Updating E-Paper... "); - -#if defined(TTGO_T_ECHO) - // ePaper.Reset(); // wake the screen from sleep - adafruitDisplay->display(false); // FIXME, use partial update mode -#elif defined(RAK4630) - - // RAK14000 2.13 inch b/w 250x122 actually now does support partial updates - - // Full update mode (slow) - // adafruitDisplay->display(false); // FIXME, use partial update mode - - // Only enable for e-Paper with support for partial updates and comment out above adafruitDisplay->display(false); - // 1.54 inch 200x200 - GxEPD2_154_M09 - // 2.13 inch 250x122 - GxEPD2_213_BN - // 2.9 inch 296x128 - GxEPD2_290_T5D - // 4.2 inch 300x400 - GxEPD2_420_M01 - adafruitDisplay->nextPage(); - -#elif defined(PCA10059) || defined(M5_COREINK) - adafruitDisplay->nextPage(); -#endif - - // Put screen to sleep to save power (possibly not necessary because we already did poweroff inside of display) - adafruitDisplay->hibernate(); - LOG_DEBUG("done\n"); - - return true; - } else { - // LOG_DEBUG("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) -} - -void EInkDisplay::setDetected(uint8_t detected) -{ - (void)detected; -} - -// Connect to the display -bool EInkDisplay::connect() -{ - LOG_INFO("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 - -#if defined(TTGO_T_ECHO) - { - auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY, SPI1); - - adafruitDisplay = new GxEPD2_BW(*lowLevel); - adafruitDisplay->init(); - adafruitDisplay->setRotation(3); - } -#elif defined(RAK4630) - { - if (eink_found) { - auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); - - adafruitDisplay = new GxEPD2_BW(*lowLevel); - - adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0)); - - // RAK14000 2.13 inch b/w 250x122 does actually now support partial updates - adafruitDisplay->setRotation(3); - // Partial update support for 1.54, 2.13 RAK14000 b/w , 2.9 and 4.2 - // adafruitDisplay->setRotation(1); - adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight); - } else { - (void)adafruitDisplay; - } - } -#elif defined(PCA10059) - { - auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); - adafruitDisplay = new GxEPD2_BW(*lowLevel); - adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0)); - adafruitDisplay->setRotation(3); - adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight); - } -#elif defined(M5_COREINK) - auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); - adafruitDisplay = new GxEPD2_BW(*lowLevel); - adafruitDisplay->init(115200, true, 40, false, SPI, SPISettings(4000000, MSBFIRST, SPI_MODE0)); - adafruitDisplay->setRotation(0); - adafruitDisplay->setPartialWindow(0, 0, EPD_WIDTH, EPD_HEIGHT); -#endif - - // adafruitDisplay->setFullWindow(); - // adafruitDisplay->fillScreen(UNCOLORED); - // adafruitDisplay->drawCircle(100, 100, 20, COLORED); - // adafruitDisplay->display(false); - - return true; -} - -#endif From fdb09d4fbab7e14f2ed88be219157c5c5a72983e Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Tue, 28 Mar 2023 15:33:49 +0200 Subject: [PATCH 06/18] Add files via upload --- src/graphics/EInkDisplay2.cpp | 246 ++++++++++++++++++++++++++++++++++ 1 file changed, 246 insertions(+) create mode 100644 src/graphics/EInkDisplay2.cpp diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp new file mode 100644 index 000000000..269e19968 --- /dev/null +++ b/src/graphics/EInkDisplay2.cpp @@ -0,0 +1,246 @@ +#include "configuration.h" + +#ifdef USE_EINK +#include "EInkDisplay2.h" +#include "GxEPD2_BW.h" +#include "SPILock.h" +#include "main.h" +#include + +#define COLORED GxEPD_BLACK +#define UNCOLORED GxEPD_WHITE + +#if defined(TTGO_T_ECHO) +#define TECHO_DISPLAY_MODEL GxEPD2_154_D67 +#elif defined(RAK4630) || defined(MAKERPYTHON) + +// GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 - changed from GxEPD2_213_B74 - which was not going to give partial update +// support +#define TECHO_DISPLAY_MODEL GxEPD2_213_BN + +// 4.2 inch 300x400 - GxEPD2_420_M01 +//#define TECHO_DISPLAY_MODEL GxEPD2_420_M01 + +// 2.9 inch 296x128 - GxEPD2_290_T5D +//#define TECHO_DISPLAY_MODEL GxEPD2_290_T5D + +// 1.54 inch 200x200 - GxEPD2_154_M09 +//#define TECHO_DISPLAY_MODEL GxEPD2_154_M09 + +#elif defined(PCA10059) + +// 4.2 inch 300x400 - GxEPD2_420_M01 +#define TECHO_DISPLAY_MODEL GxEPD2_420_M01 + +#elif defined(M5_COREINK) +// M5Stack CoreInk +// 1.54 inch 200x200 - GxEPD2_154_M09 +#define TECHO_DISPLAY_MODEL GxEPD2_154_M09 + +#endif + +GxEPD2_BW *adafruitDisplay; + +EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY geometry, HW_I2C i2cBus) +{ +#if defined(TTGO_T_ECHO) + setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT); +#elif defined(RAK4630) || defined(MAKERPYTHON) + + // GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 + // setGeometry(GEOMETRY_RAWMODE, 250, 122); + + // GxEPD2_420_M01 + // setGeometry(GEOMETRY_RAWMODE, 300, 400); + + // GxEPD2_290_T5D + setGeometry(GEOMETRY_RAWMODE, 296, 128); + + // GxEPD2_154_M09 + // setGeometry(GEOMETRY_RAWMODE, 200, 200); + +#elif defined(PCA10059) + + // GxEPD2_420_M01 + setGeometry(GEOMETRY_RAWMODE, 300, 400); + +#elif defined(M5_COREINK) + + // M5Stack_CoreInk 200x200 + // 1.54 inch 200x200 - GxEPD2_154_M09 + setGeometry(GEOMETRY_RAWMODE, EPD_HEIGHT, EPD_WIDTH); +#elif defined(my) + + // GxEPD2_290_T5D + setGeometry(GEOMETRY_RAWMODE, 296, 128); + LOG_DEBUG("GEOMETRY_RAWMODE, 296, 128\n"); + +#endif + // 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 (adafruitDisplay && (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 (uint32_t y = 0; y < displayHeight; y++) { + for (uint32_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)); + adafruitDisplay->drawPixel(x, y, isset ? COLORED : UNCOLORED); + } + } + + LOG_DEBUG("Updating E-Paper... "); + +#if defined(TTGO_T_ECHO) + // ePaper.Reset(); // wake the screen from sleep + adafruitDisplay->display(false); // FIXME, use partial update mode +#elif defined(RAK4630) || defined(MAKERPYTHON) + + // RAK14000 2.13 inch b/w 250x122 actually now does support partial updates + + // Full update mode (slow) + // adafruitDisplay->display(false); // FIXME, use partial update mode + + // Only enable for e-Paper with support for partial updates and comment out above adafruitDisplay->display(false); + // 1.54 inch 200x200 - GxEPD2_154_M09 + // 2.13 inch 250x122 - GxEPD2_213_BN + // 2.9 inch 296x128 - GxEPD2_290_T5D + // 4.2 inch 300x400 - GxEPD2_420_M01 + adafruitDisplay->nextPage(); + +#elif defined(PCA10059) || defined(M5_COREINK) + adafruitDisplay->nextPage(); + +#elif defined(PRIVATE_HW) || defined(my) + adafruitDisplay->nextPage(); + +#endif + + // Put screen to sleep to save power (possibly not necessary because we already did poweroff inside of display) + adafruitDisplay->hibernate(); + LOG_DEBUG("done\n"); + + return true; + } else { + // LOG_DEBUG("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) +} + +void EInkDisplay::setDetected(uint8_t detected) +{ + (void)detected; +} + +// Connect to the display +bool EInkDisplay::connect() +{ + LOG_INFO("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 + +#if defined(TTGO_T_ECHO) + { + auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY, SPI1); + + adafruitDisplay = new GxEPD2_BW(*lowLevel); + adafruitDisplay->init(); + adafruitDisplay->setRotation(3); + } +#elif defined(RAK4630) || defined(MAKERPYTHON) + { + if (eink_found) { + auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); + + adafruitDisplay = new GxEPD2_BW(*lowLevel); + + adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0)); + + // RAK14000 2.13 inch b/w 250x122 does actually now support partial updates + adafruitDisplay->setRotation(3); + // Partial update support for 1.54, 2.13 RAK14000 b/w , 2.9 and 4.2 + // adafruitDisplay->setRotation(1); + adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight); + } else { + (void)adafruitDisplay; + } + } +#elif defined(PCA10059) + { + auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); + adafruitDisplay = new GxEPD2_BW(*lowLevel); + adafruitDisplay->init(115200, true, 10, false, SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0)); + adafruitDisplay->setRotation(3); + adafruitDisplay->setPartialWindow(0, 0, displayWidth, displayHeight); + } +#elif defined(M5_COREINK) + auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); + adafruitDisplay = new GxEPD2_BW(*lowLevel); + adafruitDisplay->init(115200, true, 40, false, SPI, SPISettings(4000000, MSBFIRST, SPI_MODE0)); + adafruitDisplay->setRotation(0); + adafruitDisplay->setPartialWindow(0, 0, EPD_WIDTH, EPD_HEIGHT); +#elif defined(my) + { + auto lowLevel = new TECHO_DISPLAY_MODEL(PIN_EINK_CS, PIN_EINK_DC, PIN_EINK_RES, PIN_EINK_BUSY); + adafruitDisplay = new GxEPD2_BW(*lowLevel); + adafruitDisplay->init(115200, true, 40, false, SPI, SPISettings(4000000, MSBFIRST, SPI_MODE0)); + adafruitDisplay->setRotation(1); + adafruitDisplay->setPartialWindow(0, 0, EPD_WIDTH, EPD_HEIGHT); + } +#endif + + // adafruitDisplay->setFullWindow(); + // adafruitDisplay->fillScreen(UNCOLORED); + // adafruitDisplay->drawCircle(100, 100, 20, COLORED); + // adafruitDisplay->display(false); + + return true; +} + +#endif \ No newline at end of file From 9f940139a0f46d3da30a6ad4d69bde0539e74601 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Tue, 28 Mar 2023 15:49:01 +0200 Subject: [PATCH 07/18] Update platformio.ini --- variants/MakePython_nRF52840_eink/platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/variants/MakePython_nRF52840_eink/platformio.ini b/variants/MakePython_nRF52840_eink/platformio.ini index 49200a02b..825566146 100644 --- a/variants/MakePython_nRF52840_eink/platformio.ini +++ b/variants/MakePython_nRF52840_eink/platformio.ini @@ -1,4 +1,5 @@ [env:makerpython_nrf52840_sx1280_eink] +board_level = extra extends = nrf52840_base board = nordic_pca10059 build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_eink -D PRIVATE_HW From 044ef75fefedb6203e1983dededa1989432ca005 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Tue, 28 Mar 2023 15:49:05 +0200 Subject: [PATCH 08/18] Update platformio.ini --- variants/MakePython_nRF52840_oled/platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/variants/MakePython_nRF52840_oled/platformio.ini b/variants/MakePython_nRF52840_oled/platformio.ini index ad5474d7d..35011fb09 100644 --- a/variants/MakePython_nRF52840_oled/platformio.ini +++ b/variants/MakePython_nRF52840_oled/platformio.ini @@ -1,4 +1,5 @@ [env:makerpython_nrf52840_sx1280_oled] +board_level = extra extends = nrf52840_base board = nordic_pca10059 build_flags = ${nrf52840_base.build_flags} -Ivariants/MakePython_nRF52840_oled -D PRIVATE_HW From b9b1cce6a5d91db6bb9b6623c6d50b1aad6cad8c Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Tue, 28 Mar 2023 15:49:10 +0200 Subject: [PATCH 09/18] Update platformio.ini --- variants/my_esp32s3_diy_eink/platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/variants/my_esp32s3_diy_eink/platformio.ini b/variants/my_esp32s3_diy_eink/platformio.ini index 3df33c90d..01376f256 100644 --- a/variants/my_esp32s3_diy_eink/platformio.ini +++ b/variants/my_esp32s3_diy_eink/platformio.ini @@ -1,4 +1,5 @@ [env:my-esp32s3-diy-eink] +board_level = extra extends = esp32s3_base board = my_esp32s3_diy_eink board_build.arduino.memory_type = dio_opi From c55751964e0834bdfcbffca29635206ca1ee600c Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Tue, 28 Mar 2023 15:49:14 +0200 Subject: [PATCH 10/18] Update platformio.ini --- variants/my_esp32s3_diy_oled/platformio.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/variants/my_esp32s3_diy_oled/platformio.ini b/variants/my_esp32s3_diy_oled/platformio.ini index 42bf97770..189e87fba 100644 --- a/variants/my_esp32s3_diy_oled/platformio.ini +++ b/variants/my_esp32s3_diy_oled/platformio.ini @@ -1,4 +1,5 @@ [env:my-esp32s3-diy-oled] +board_level = extra extends = esp32s3_base board = my-esp32s3-diy-oled board_build.arduino.memory_type = dio_opi From 7930aa1635f5b5c5cbfb0f5c099dd2e67fe118cd Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Tue, 28 Mar 2023 15:49:20 +0200 Subject: [PATCH 11/18] Update platformio.ini --- variants/rak4631_epaper_onrxtx/platformio.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/variants/rak4631_epaper_onrxtx/platformio.ini b/variants/rak4631_epaper_onrxtx/platformio.ini index 257a3f7ff..920380011 100644 --- a/variants/rak4631_epaper_onrxtx/platformio.ini +++ b/variants/rak4631_epaper_onrxtx/platformio.ini @@ -1,5 +1,6 @@ ; The very slick RAK wireless RAK 4631 / 4630 board - Firmware for 5005 with the RAK 14000 ePaper [env:rak4631_eink_onrxtx] +board_level = extra extends = nrf52840_base board = wiscore_rak4631 build_flags = ${nrf52840_base.build_flags} -Ivariants/rak4631_epaper -D RAK_4631 @@ -12,4 +13,4 @@ lib_deps = debug_tool = jlink ; If not set we will default to uploading over serial (first it forces bootloader entry by talking 1200bps to cdcacm) ;upload_protocol = jlink -upload_port = /dev/ttyACM3 \ No newline at end of file +upload_port = /dev/ttyACM3 From 82ba59765c4cd172db9a09a493fa9d46bfb5c233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 29 Mar 2023 13:07:27 +0200 Subject: [PATCH 12/18] trunk it baby --- boards/my-esp32s3-diy-oled.json | 24 +++------- boards/my_esp32s3_diy_eink.json | 24 +++------- variants/MakePython_nRF52840_eink/variant.cpp | 27 +++++------- variants/MakePython_nRF52840_oled/variant.cpp | 27 +++++------- variants/MakePython_nRF52840_oled/variant.h | 44 +++++++++---------- variants/my_esp32s3_diy_eink/pins_arduino.h | 20 ++++----- variants/my_esp32s3_diy_eink/variant.h | 29 ++++++------ variants/my_esp32s3_diy_oled/pins_arduino.h | 20 ++++----- variants/my_esp32s3_diy_oled/variant.h | 19 ++++---- 9 files changed, 96 insertions(+), 138 deletions(-) diff --git a/boards/my-esp32s3-diy-oled.json b/boards/my-esp32s3-diy-oled.json index a72a5e1fa..69a24be0e 100644 --- a/boards/my-esp32s3-diy-oled.json +++ b/boards/my-esp32s3-diy-oled.json @@ -1,6 +1,6 @@ { "build": { - "arduino":{ + "arduino": { "ldscript": "esp32s3_out.ld", "memory_type": "qio_opi" }, @@ -15,34 +15,22 @@ "f_cpu": "240000000L", "f_flash": "80000000L", "flash_mode": "qio", - "hwids": [ - [ - "0x303A", - "0x1001" - ] - ], + "hwids": [["0x303A", "0x1001"]], "mcu": "esp32s3", "variant": "my-esp32s3-diy-oled" }, - "connectivity": [ - "wifi" - ], + "connectivity": ["wifi"], "debug": { "default_tool": "esp-builtin", - "onboard_tools": [ - "esp-builtin" - ], + "onboard_tools": ["esp-builtin"], "openocd_target": "esp32s3.cfg" }, - "frameworks": [ - "arduino", - "espidf" - ], + "frameworks": ["arduino", "espidf"], "name": "Clone ESP32-S3-DevKitC-1 v1.1 (16 MB FLASH, 8 MB PSRAM)", "upload": { "flash_size": "16MB", "maximum_ram_size": 327680, - "maximum_size": 16777216, + "maximum_size": 16777216, "use_1200bps_touch": true, "wait_for_upload_port": true, "require_upload_port": true, diff --git a/boards/my_esp32s3_diy_eink.json b/boards/my_esp32s3_diy_eink.json index baff689fd..432424f6e 100644 --- a/boards/my_esp32s3_diy_eink.json +++ b/boards/my_esp32s3_diy_eink.json @@ -1,6 +1,6 @@ { "build": { - "arduino":{ + "arduino": { "ldscript": "esp32s3_out.ld", "memory_type": "qio_opi" }, @@ -15,34 +15,22 @@ "f_cpu": "240000000L", "f_flash": "80000000L", "flash_mode": "qio", - "hwids": [ - [ - "0x303A", - "0x1001" - ] - ], + "hwids": [["0x303A", "0x1001"]], "mcu": "esp32s3", "variant": "my_esp32s3_diy_eink" }, - "connectivity": [ - "wifi" - ], + "connectivity": ["wifi"], "debug": { "default_tool": "esp-builtin", - "onboard_tools": [ - "esp-builtin" - ], + "onboard_tools": ["esp-builtin"], "openocd_target": "esp32s3.cfg" }, - "frameworks": [ - "arduino", - "espidf" - ], + "frameworks": ["arduino", "espidf"], "name": "Clone ESP32-S3-DevKitC-1 v1.1 (16 MB FLASH, 8 MB PSRAM)", "upload": { "flash_size": "16MB", "maximum_ram_size": 327680, - "maximum_size": 16777216, + "maximum_size": 16777216, "use_1200bps_touch": true, "wait_for_upload_port": true, "require_upload_port": true, diff --git a/variants/MakePython_nRF52840_eink/variant.cpp b/variants/MakePython_nRF52840_eink/variant.cpp index 5b9288319..8c6bf039c 100644 --- a/variants/MakePython_nRF52840_eink/variant.cpp +++ b/variants/MakePython_nRF52840_eink/variant.cpp @@ -16,28 +16,23 @@ */ #include "variant.h" +#include "nrf.h" #include "wiring_constants.h" #include "wiring_digital.h" -#include "nrf.h" -const uint32_t g_ADigitalPinMap[] = - { - // P0 - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, +const uint32_t g_ADigitalPinMap[] = { + // P0 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - // P1 - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47}; + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}; void initVariant() { - // LED1 & LED2 - pinMode(PIN_LED1, OUTPUT); - ledOff(PIN_LED1); + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); - pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2); + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); } diff --git a/variants/MakePython_nRF52840_oled/variant.cpp b/variants/MakePython_nRF52840_oled/variant.cpp index 5b9288319..8c6bf039c 100644 --- a/variants/MakePython_nRF52840_oled/variant.cpp +++ b/variants/MakePython_nRF52840_oled/variant.cpp @@ -16,28 +16,23 @@ */ #include "variant.h" +#include "nrf.h" #include "wiring_constants.h" #include "wiring_digital.h" -#include "nrf.h" -const uint32_t g_ADigitalPinMap[] = - { - // P0 - 0, 1, 2, 3, 4, 5, 6, 7, - 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, +const uint32_t g_ADigitalPinMap[] = { + // P0 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - // P1 - 32, 33, 34, 35, 36, 37, 38, 39, - 40, 41, 42, 43, 44, 45, 46, 47}; + // P1 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47}; void initVariant() { - // LED1 & LED2 - pinMode(PIN_LED1, OUTPUT); - ledOff(PIN_LED1); + // LED1 & LED2 + pinMode(PIN_LED1, OUTPUT); + ledOff(PIN_LED1); - pinMode(PIN_LED2, OUTPUT); - ledOff(PIN_LED2); + pinMode(PIN_LED2, OUTPUT); + ledOff(PIN_LED2); } diff --git a/variants/MakePython_nRF52840_oled/variant.h b/variants/MakePython_nRF52840_oled/variant.h index ac54c1531..2f4323dd8 100644 --- a/variants/MakePython_nRF52840_oled/variant.h +++ b/variants/MakePython_nRF52840_oled/variant.h @@ -28,8 +28,8 @@ extern "C" { #define RADIOLIB_GODMODE // LEDs -#define PIN_LED1 (32 + 10) // LED P1.15 -#define PIN_LED2 (-1) // +#define PIN_LED1 (32 + 10) // LED P1.15 +#define PIN_LED2 (-1) // #define LED_BUILTIN PIN_LED1 #define LED_CONN PIN_LED2 @@ -37,25 +37,24 @@ extern "C" { #define LED_GREEN PIN_LED1 #define LED_BLUE PIN_LED2 -#define LED_STATE_ON 0 // State when LED is litted +#define LED_STATE_ON 0 // State when LED is litted /* * Buttons */ -#define PIN_BUTTON1 (32 + 15) // P1.15 Built in button +#define PIN_BUTTON1 (32 + 15) // P1.15 Built in button /* * Analog pins */ -#define PIN_A0 (-1) +#define PIN_A0 (-1) static const uint8_t A0 = PIN_A0; #define ADC_RESOLUTION 14 // Other pins -#define PIN_AREF (-1) // AREF Not yet used - +#define PIN_AREF (-1) // AREF Not yet used static const uint8_t AREF = PIN_AREF; @@ -74,11 +73,11 @@ static const uint8_t AREF = PIN_AREF; */ #define SPI_INTERFACES_COUNT 1 -#define PIN_SPI_MISO (0 + 31) // MISO P0.31 -#define PIN_SPI_MOSI (0 + 30) // MOSI P0.30 -#define PIN_SPI_SCK (0 + 29) // SCK P0.29 +#define PIN_SPI_MISO (0 + 31) // MISO P0.31 +#define PIN_SPI_MOSI (0 + 30) // MOSI P0.30 +#define PIN_SPI_SCK (0 + 29) // SCK P0.29 -static const uint8_t SS = (32 + 15); // LORA_CS P1.15 +static const uint8_t SS = (32 + 15); // LORA_CS P1.15 static const uint8_t MOSI = PIN_SPI_MOSI; static const uint8_t MISO = PIN_SPI_MISO; static const uint8_t SCK = PIN_SPI_SCK; @@ -88,22 +87,21 @@ static const uint8_t SCK = PIN_SPI_SCK; */ #define WIRE_INTERFACES_COUNT 1 -#define PIN_WIRE_SDA (0 + 26) // SDA -#define PIN_WIRE_SCL (0 + 27) // SCL +#define PIN_WIRE_SDA (0 + 26) // SDA +#define PIN_WIRE_SCL (0 + 27) // SCL // E-Byte E28 2.4 Ghz LoRa module #define USE_SX1280 -#define LORA_RESET (0 + 5) -#define SX128X_CS (0 + 23) -#define SX128X_DIO1 (0 + 4) -#define SX128X_BUSY (0 + 7) -//#define SX128X_TXEN (32 + 9) -//#define SX128X_RXEN (0 + 12) +#define LORA_RESET (0 + 5) +#define SX128X_CS (0 + 23) +#define SX128X_DIO1 (0 + 4) +#define SX128X_BUSY (0 + 7) +//#define SX128X_TXEN (32 + 9) +//#define SX128X_RXEN (0 + 12) #define SX128X_RESET LORA_RESET - -#define PIN_GPS_EN (-1) -#define PIN_GPS_PPS (-1) // Pulse per second input from the GPS +#define PIN_GPS_EN (-1) +#define PIN_GPS_PPS (-1) // Pulse per second input from the GPS #define GPS_RX_PIN PIN_SERIAL1_RX #define GPS_TX_PIN PIN_SERIAL1_TX @@ -125,7 +123,7 @@ static const uint8_t SCK = PIN_SPI_SCK; #undef AREF_VOLTAGE #define AREF_VOLTAGE 3.0 #define VBAT_AR_INTERNAL AR_INTERNAL_3_0 -#define ADC_MULTIPLIER VBAT_DIVIDER_COMP //REAL_VBAT_MV_PER_LSB +#define ADC_MULTIPLIER VBAT_DIVIDER_COMP // REAL_VBAT_MV_PER_LSB #define VBAT_RAW_TO_SCALED(x) (REAL_VBAT_MV_PER_LSB * x) #ifdef __cplusplus diff --git a/variants/my_esp32s3_diy_eink/pins_arduino.h b/variants/my_esp32s3_diy_eink/pins_arduino.h index fc71c914d..1f276899c 100644 --- a/variants/my_esp32s3_diy_eink/pins_arduino.h +++ b/variants/my_esp32s3_diy_eink/pins_arduino.h @@ -7,24 +7,22 @@ #define USB_PID 0x1001 #define EXTERNAL_NUM_INTERRUPTS 46 -#define NUM_DIGITAL_PINS 48 -#define NUM_ANALOG_INPUTS 20 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 -#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1) -#define digitalPinToInterrupt(p) (((p)<48)?(p):-1) -#define digitalPinHasPWM(p) (p < 46) +#define analogInputToDigitalPin(p) (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) +#define digitalPinToInterrupt(p) (((p) < 48) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 46) // The default Wire will be mapped to PMU and RTC static const uint8_t SDA = 18; static const uint8_t SCL = 17; // Default SPI will be mapped to Radio -static const uint8_t MISO = 3; -static const uint8_t SCK = 5; -static const uint8_t MOSI = 6; -static const uint8_t SS = 7; - - +static const uint8_t MISO = 3; +static const uint8_t SCK = 5; +static const uint8_t MOSI = 6; +static const uint8_t SS = 7; //#define SPI_MOSI (11) //#define SPI_SCK (14) diff --git a/variants/my_esp32s3_diy_eink/variant.h b/variants/my_esp32s3_diy_eink/variant.h index 20b1c8908..288daf9ff 100644 --- a/variants/my_esp32s3_diy_eink/variant.h +++ b/variants/my_esp32s3_diy_eink/variant.h @@ -8,23 +8,22 @@ //#define USE_SSD1306 -#define I2C_SDA 18 //1 // I2C pins for this board -#define I2C_SCL 17 //2 +#define I2C_SDA 18 // 1 // I2C pins for this board +#define I2C_SCL 17 // 2 //#define LED_PIN 38 // This is a RGB LED not a standard LED -#define BUTTON_PIN 0 // This is the BOOT button +#define BUTTON_PIN 0 // This is the BOOT button #define BUTTON_NEED_PULLUP - //#define USE_RF95 // RFM95/SX127x //#define USE_SX1262 #define USE_SX1280 -#define RF95_MISO 3 -#define RF95_SCK 5 -#define RF95_MOSI 6 -#define RF95_NSS 7 +#define RF95_MISO 3 +#define RF95_SCK 5 +#define RF95_MOSI 6 +#define RF95_NSS 7 #define LORA_RESET 8 #define LORA_DIO1 16 @@ -46,12 +45,12 @@ #endif #define USE_EINK - /* +/* * eink display pins */ -#define PIN_EINK_CS 13 -#define PIN_EINK_BUSY 2 -#define PIN_EINK_DC 1 -#define PIN_EINK_RES (-1) -#define PIN_EINK_SCLK 5 -#define PIN_EINK_MOSI 6 +#define PIN_EINK_CS 13 +#define PIN_EINK_BUSY 2 +#define PIN_EINK_DC 1 +#define PIN_EINK_RES (-1) +#define PIN_EINK_SCLK 5 +#define PIN_EINK_MOSI 6 diff --git a/variants/my_esp32s3_diy_oled/pins_arduino.h b/variants/my_esp32s3_diy_oled/pins_arduino.h index fc71c914d..1f276899c 100644 --- a/variants/my_esp32s3_diy_oled/pins_arduino.h +++ b/variants/my_esp32s3_diy_oled/pins_arduino.h @@ -7,24 +7,22 @@ #define USB_PID 0x1001 #define EXTERNAL_NUM_INTERRUPTS 46 -#define NUM_DIGITAL_PINS 48 -#define NUM_ANALOG_INPUTS 20 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 -#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1) -#define digitalPinToInterrupt(p) (((p)<48)?(p):-1) -#define digitalPinHasPWM(p) (p < 46) +#define analogInputToDigitalPin(p) (((p) < 20) ? (analogChannelToDigitalPin(p)) : -1) +#define digitalPinToInterrupt(p) (((p) < 48) ? (p) : -1) +#define digitalPinHasPWM(p) (p < 46) // The default Wire will be mapped to PMU and RTC static const uint8_t SDA = 18; static const uint8_t SCL = 17; // Default SPI will be mapped to Radio -static const uint8_t MISO = 3; -static const uint8_t SCK = 5; -static const uint8_t MOSI = 6; -static const uint8_t SS = 7; - - +static const uint8_t MISO = 3; +static const uint8_t SCK = 5; +static const uint8_t MOSI = 6; +static const uint8_t SS = 7; //#define SPI_MOSI (11) //#define SPI_SCK (14) diff --git a/variants/my_esp32s3_diy_oled/variant.h b/variants/my_esp32s3_diy_oled/variant.h index d87c1e985..9eda00791 100644 --- a/variants/my_esp32s3_diy_oled/variant.h +++ b/variants/my_esp32s3_diy_oled/variant.h @@ -8,23 +8,22 @@ #define USE_SSD1306 -#define I2C_SDA 18 //1 // I2C pins for this board -#define I2C_SCL 17 //2 +#define I2C_SDA 18 // 1 // I2C pins for this board +#define I2C_SCL 17 // 2 //#define LED_PIN 38 // This is a RGB LED not a standard LED -#define BUTTON_PIN 0 // This is the BOOT button +#define BUTTON_PIN 0 // This is the BOOT button #define BUTTON_NEED_PULLUP - //#define USE_RF95 // RFM95/SX127x //#define USE_SX1262 #define USE_SX1280 -#define RF95_MISO 3 -#define RF95_SCK 5 -#define RF95_MOSI 6 -#define RF95_NSS 7 +#define RF95_MISO 3 +#define RF95_SCK 5 +#define RF95_MOSI 6 +#define RF95_NSS 7 #define LORA_RESET 8 #define LORA_DIO1 16 @@ -46,12 +45,12 @@ #endif //#define USE_EINK - /* +/* * eink display pins */ //#define PIN_EINK_CS 13 //#define PIN_EINK_BUSY 2 //#define PIN_EINK_DC 1 //#define PIN_EINK_RES (-1) -//#define PIN_EINK_SCLK 5 +//#define PIN_EINK_SCLK 5 //#define PIN_EINK_MOSI 6 From 26d18244f00f8d8f14934a6805570a628e34a65c Mon Sep 17 00:00:00 2001 From: sbias Date: Wed, 29 Mar 2023 13:51:22 +0200 Subject: [PATCH 13/18] Add nodedb channel handling (#2384) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * send ourNodeInfo to channel we got a message we heared someone new * store node-channel into nodeDB * use channel from nodeDb to send local messages * update protobufs * fmt and fix braces * respect requested channel for local send, only store channel while getting a nodeinfo packet --------- Co-authored-by: Thomas Göttgens Co-authored-by: Ben Meadors --- src/mesh/MeshService.cpp | 12 ++++++------ src/mesh/NodeDB.cpp | 15 ++++++++++++++- src/mesh/NodeDB.h | 3 +++ src/mesh/Router.cpp | 4 ++++ src/modules/NodeInfoModule.cpp | 7 ++++++- src/modules/NodeInfoModule.h | 2 +- src/modules/PositionModule.cpp | 5 ++++- src/modules/PositionModule.h | 2 +- 8 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/mesh/MeshService.cpp b/src/mesh/MeshService.cpp index ee4ddcd77..6a49294cd 100644 --- a/src/mesh/MeshService.cpp +++ b/src/mesh/MeshService.cpp @@ -77,8 +77,8 @@ int MeshService::handleFromRadio(const meshtastic_MeshPacket *mp) nodeDB.updateFrom(*mp); // update our DB state based off sniffing every RX packet from the radio if (mp->which_payload_variant == meshtastic_MeshPacket_decoded_tag && !nodeDB.getNode(mp->from)->has_user && nodeInfoModule) { - LOG_INFO("Heard a node we don't know, sending NodeInfo and asking for a response.\n"); - nodeInfoModule->sendOurNodeInfo(mp->from, true); + LOG_INFO("Heard a node on channel %d we don't know, sending NodeInfo and asking for a response.\n", mp->channel); + nodeInfoModule->sendOurNodeInfo(mp->from, true, mp->channel); } printPacket("Forwarding to phone", mp); @@ -242,13 +242,13 @@ void MeshService::sendNetworkPing(NodeNum dest, bool wantReplies) if (node->has_position && (node->position.latitude_i != 0 || node->position.longitude_i != 0)) { if (positionModule) { - LOG_INFO("Sending position ping to 0x%x, wantReplies=%d\n", dest, wantReplies); - positionModule->sendOurPosition(dest, wantReplies); + LOG_INFO("Sending position ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel); + positionModule->sendOurPosition(dest, wantReplies, node->channel); } } else { if (nodeInfoModule) { - LOG_INFO("Sending nodeinfo ping to 0x%x, wantReplies=%d\n", dest, wantReplies); - nodeInfoModule->sendOurNodeInfo(dest, wantReplies); + LOG_INFO("Sending nodeinfo ping to 0x%x, wantReplies=%d, channel=%d\n", dest, wantReplies, node->channel); + nodeInfoModule->sendOurNodeInfo(dest, wantReplies, node->channel); } } } diff --git a/src/mesh/NodeDB.cpp b/src/mesh/NodeDB.cpp index 3a7055aed..c620295c2 100644 --- a/src/mesh/NodeDB.cpp +++ b/src/mesh/NodeDB.cpp @@ -721,7 +721,7 @@ void NodeDB::updateUser(uint32_t nodeId, const meshtastic_User &p) void NodeDB::updateFrom(const meshtastic_MeshPacket &mp) { if (mp.which_payload_variant == meshtastic_MeshPacket_decoded_tag && mp.from) { - LOG_DEBUG("Update DB node 0x%x, rx_time=%u\n", mp.from, mp.rx_time); + LOG_DEBUG("Update DB node 0x%x, rx_time=%u, channel=%d\n", mp.from, mp.rx_time, mp.channel); meshtastic_NodeInfo *info = getOrCreateNode(getFrom(&mp)); if (!info) { @@ -733,9 +733,22 @@ void NodeDB::updateFrom(const meshtastic_MeshPacket &mp) if (mp.rx_snr) info->snr = mp.rx_snr; // keep the most recent SNR we received for this node. + + if (mp.decoded.portnum == meshtastic_PortNum_NODEINFO_APP) { + info->channel = mp.channel; + } } } +uint8_t NodeDB::getNodeChannel(NodeNum n) +{ + meshtastic_NodeInfo *info = getNode(n); + if (!info) { + return 0; // defaults to PRIMARY + } + return info->channel; +} + /// Find a node in our DB, return null for missing /// NOTE: This function might be called from an ISR meshtastic_NodeInfo *NodeDB::getNode(NodeNum n) diff --git a/src/mesh/NodeDB.h b/src/mesh/NodeDB.h index 6ab4c46e5..2822ffbf6 100644 --- a/src/mesh/NodeDB.h +++ b/src/mesh/NodeDB.h @@ -113,6 +113,9 @@ class NodeDB /// pick a provisional nodenum we hope no one is using void pickNewNodeNum(); + // get channel channel index we heard a nodeNum on, defaults to 0 if not found + uint8_t getNodeChannel(NodeNum n); + /// Find a node in our DB, return null for missing meshtastic_NodeInfo *getNode(NodeNum n); diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index fc38f9f5e..db0509aca 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -173,6 +173,10 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src) handleReceived(p, src); } + if (p->channel) // don't override if a channel was requested + p->channel = nodeDB.getNodeChannel(p->to); + LOG_DEBUG("localSend to channel %d\n", p->channel); + return send(p); } } diff --git a/src/modules/NodeInfoModule.cpp b/src/modules/NodeInfoModule.cpp index 004ad75f0..cf8c17c3b 100644 --- a/src/modules/NodeInfoModule.cpp +++ b/src/modules/NodeInfoModule.cpp @@ -27,7 +27,7 @@ bool NodeInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, mes return false; // Let others look at this message also if they want } -void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies) +void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies, uint8_t channel) { // cancel any not yet sent (now stale) position packets if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal) @@ -38,6 +38,11 @@ void NodeInfoModule::sendOurNodeInfo(NodeNum dest, bool wantReplies) p->to = dest; p->decoded.want_response = wantReplies; p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; + if (channel > 0) { + LOG_DEBUG("sending ourNodeInfo to channel %d\n", channel); + p->channel = channel; + } + prevPacketId = p->id; service.sendToMesh(p); diff --git a/src/modules/NodeInfoModule.h b/src/modules/NodeInfoModule.h index 900d5983d..b10cccdf1 100644 --- a/src/modules/NodeInfoModule.h +++ b/src/modules/NodeInfoModule.h @@ -20,7 +20,7 @@ class NodeInfoModule : public ProtobufModule, private concurren /** * Send our NodeInfo into the mesh */ - void sendOurNodeInfo(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + void sendOurNodeInfo(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false, uint8_t channel = 0); protected: /** Called to handle a particular incoming message diff --git a/src/modules/PositionModule.cpp b/src/modules/PositionModule.cpp index 92a8b4c0c..ade96fb8a 100644 --- a/src/modules/PositionModule.cpp +++ b/src/modules/PositionModule.cpp @@ -120,7 +120,7 @@ meshtastic_MeshPacket *PositionModule::allocReply() return allocDataProtobuf(p); } -void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies) +void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies, uint8_t channel) { // cancel any not yet sent (now stale) position packets if (prevPacketId) // if we wrap around to zero, we'll simply fail to cancel in that rare case (no big deal) @@ -135,6 +135,9 @@ void PositionModule::sendOurPosition(NodeNum dest, bool wantReplies) p->priority = meshtastic_MeshPacket_Priority_BACKGROUND; prevPacketId = p->id; + if (channel > 0) + p->channel = channel; + service.sendToMesh(p, RX_SRC_LOCAL, true); } diff --git a/src/modules/PositionModule.h b/src/modules/PositionModule.h index 8e9c37087..aaa5c76c5 100644 --- a/src/modules/PositionModule.h +++ b/src/modules/PositionModule.h @@ -29,7 +29,7 @@ class PositionModule : public ProtobufModule, private concu /** * Send our position into the mesh */ - void sendOurPosition(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false); + void sendOurPosition(NodeNum dest = NODENUM_BROADCAST, bool wantReplies = false, uint8_t channel = 0); protected: /** Called to handle a particular incoming message From 2edc35d34ba0b36ada3de9bab9bea941711d1428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 29 Mar 2023 15:14:48 +0200 Subject: [PATCH 14/18] Logic Late-Fix to the last PR --- src/mesh/Router.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesh/Router.cpp b/src/mesh/Router.cpp index db0509aca..b3aee4e7d 100644 --- a/src/mesh/Router.cpp +++ b/src/mesh/Router.cpp @@ -173,9 +173,10 @@ ErrorCode Router::sendLocal(meshtastic_MeshPacket *p, RxSource src) handleReceived(p, src); } - if (p->channel) // don't override if a channel was requested + if (!p->channel) { // don't override if a channel was requested p->channel = nodeDB.getNodeChannel(p->to); - LOG_DEBUG("localSend to channel %d\n", p->channel); + LOG_DEBUG("localSend to channel %d\n", p->channel); + } return send(p); } From 5679a82195130765322dbed4695143115e847d4b Mon Sep 17 00:00:00 2001 From: Ben Meadors Date: Wed, 29 Mar 2023 13:04:02 -0500 Subject: [PATCH 15/18] Support double tap as button press for supported accelerometers (#2393) * For Garth * Push it real good * Wut * Double tap * Move disable logic * Actually return * Reinitialize setClick in thread body * Initialize later so that we actually have nodedb on init * Fixes --- protobufs | 2 +- src/AccelerometerThread.h | 37 ++++++++++++++++--- src/main.cpp | 11 ++++-- src/mesh/generated/meshtastic/config.pb.h | 12 ++++-- src/mesh/generated/meshtastic/deviceonly.pb.h | 2 +- src/mesh/generated/meshtastic/localonly.pb.h | 2 +- src/modules/Telemetry/DeviceTelemetry.cpp | 2 +- 7 files changed, 50 insertions(+), 18 deletions(-) diff --git a/protobufs b/protobufs index 2b55d8421..ef83ba1d9 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 2b55d8421b2f872f8c50e001bd107a2bc56a5157 +Subproject commit ef83ba1d913941e8cb9a5a5973009c37765c46fa diff --git a/src/AccelerometerThread.h b/src/AccelerometerThread.h index 94129630d..875ca2e22 100644 --- a/src/AccelerometerThread.h +++ b/src/AccelerometerThread.h @@ -7,6 +7,9 @@ #include #include +#define ACCELEROMETER_CHECK_INTERVAL_MS 100 +#define ACCELEROMETER_CLICK_THRESHOLD 40 + namespace concurrency { class AccelerometerThread : public concurrency::OSThread @@ -14,10 +17,18 @@ class AccelerometerThread : public concurrency::OSThread public: AccelerometerThread(ScanI2C::DeviceType type = ScanI2C::DeviceType::NONE) : OSThread("AccelerometerThread") { - if (accelerometer_found.port == ScanI2C::I2CPort::NO_I2C || !config.display.wake_on_tap_or_motion) { + if (accelerometer_found.port == ScanI2C::I2CPort::NO_I2C) { + LOG_DEBUG("AccelerometerThread disabling due to no sensors found\n"); disable(); return; } + + if (!config.display.wake_on_tap_or_motion && !config.device.double_tap_as_button_press) { + LOG_DEBUG("AccelerometerThread disabling due to no interested configurations\n"); + disable(); + return; + } + accleremoter_type = type; LOG_DEBUG("AccelerometerThread initializing\n"); @@ -32,9 +43,8 @@ class AccelerometerThread : public concurrency::OSThread } else if (accleremoter_type == ScanI2C::DeviceType::LIS3DH && lis.begin(accelerometer_found.address)) { LOG_DEBUG("LIS3DH initializing\n"); lis.setRange(LIS3DH_RANGE_2_G); - // Adjust threshhold, higher numbers are less sensitive - lis.setClick(1, 80); + lis.setClick(config.device.double_tap_as_button_press ? 2 : 1, ACCELEROMETER_CLICK_THRESHOLD); } } @@ -46,19 +56,34 @@ class AccelerometerThread : public concurrency::OSThread if (accleremoter_type == ScanI2C::DeviceType::MPU6050 && mpu.getMotionInterruptStatus()) { wakeScreen(); } else if (accleremoter_type == ScanI2C::DeviceType::LIS3DH && lis.getClick() > 0) { - wakeScreen(); + uint8_t click = lis.getClick(); + if (!config.device.double_tap_as_button_press) { + wakeScreen(); + } + + if (config.device.double_tap_as_button_press && (click & 0x20)) { + buttonPress(); + return 500; + } } - return 100; + return ACCELEROMETER_CHECK_INTERVAL_MS; } private: void wakeScreen() { - LOG_DEBUG("Tap or motion detected. Turning on screen\n"); if (powerFSM.getState() == &stateDARK) { + LOG_INFO("Tap or motion detected. Turning on screen\n"); powerFSM.trigger(EVENT_INPUT); } } + + void buttonPress() + { + LOG_DEBUG("Double-tap detected. Firing button press\n"); + powerFSM.trigger(EVENT_PRESS); + } + ScanI2C::DeviceType accleremoter_type; Adafruit_MPU6050 mpu; Adafruit_LIS3DH lis; diff --git a/src/main.cpp b/src/main.cpp index 9e657e7ee..bd35bdaec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -357,14 +357,11 @@ void setup() * nodeTelemetrySensorsMap singleton. This wraps that logic in a temporary scope to declare the temporary field * "found". */ + #if !defined(ARCH_PORTDUINO) auto acc_info = i2cScanner->firstAccelerometer(); accelerometer_found = acc_info.type != ScanI2C::DeviceType::NONE ? acc_info.address : accelerometer_found; - LOG_DEBUG("acc_info = %i\n", acc_info.type); - if (acc_info.type != ScanI2C::DeviceType::NONE) { - accelerometerThread = new AccelerometerThread(acc_info.type); - } #endif #define STRING(S) #S @@ -446,6 +443,12 @@ void setup() screen_model = meshtastic_Config_DisplayConfig_OledType_OLED_SH1107; // keep dimension of 128x64 #endif +#if !defined(ARCH_PORTDUINO) + if (acc_info.type != ScanI2C::DeviceType::NONE) { + accelerometerThread = new AccelerometerThread(acc_info.type); + } +#endif + // Init our SPI controller (must be before screen and lora) initSPI(); #ifndef ARCH_ESP32 diff --git a/src/mesh/generated/meshtastic/config.pb.h b/src/mesh/generated/meshtastic/config.pb.h index 34f013250..e3b6e242d 100644 --- a/src/mesh/generated/meshtastic/config.pb.h +++ b/src/mesh/generated/meshtastic/config.pb.h @@ -231,6 +231,8 @@ typedef struct _meshtastic_Config_DeviceConfig { /* Send our nodeinfo this often Defaults to 900 Seconds (15 minutes) */ uint32_t node_info_broadcast_secs; + /* Treat double tap interrupt on supported accelerometers as a button press if set to true */ + bool double_tap_as_button_press; } meshtastic_Config_DeviceConfig; /* Position Config */ @@ -527,7 +529,7 @@ extern "C" { /* Initializer values for message structs */ #define meshtastic_Config_init_default {0, {meshtastic_Config_DeviceConfig_init_default}} -#define meshtastic_Config_DeviceConfig_init_default {_meshtastic_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_RebroadcastMode_MIN, 0} +#define meshtastic_Config_DeviceConfig_init_default {_meshtastic_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_RebroadcastMode_MIN, 0, 0} #define meshtastic_Config_PositionConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_PowerConfig_init_default {0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_NetworkConfig_init_default {0, "", "", "", 0, _meshtastic_Config_NetworkConfig_AddressMode_MIN, false, meshtastic_Config_NetworkConfig_IpV4Config_init_default, ""} @@ -536,7 +538,7 @@ extern "C" { #define meshtastic_Config_LoRaConfig_init_default {0, _meshtastic_Config_LoRaConfig_ModemPreset_MIN, 0, 0, 0, 0, _meshtastic_Config_LoRaConfig_RegionCode_MIN, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}} #define meshtastic_Config_BluetoothConfig_init_default {0, _meshtastic_Config_BluetoothConfig_PairingMode_MIN, 0} #define meshtastic_Config_init_zero {0, {meshtastic_Config_DeviceConfig_init_zero}} -#define meshtastic_Config_DeviceConfig_init_zero {_meshtastic_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_RebroadcastMode_MIN, 0} +#define meshtastic_Config_DeviceConfig_init_zero {_meshtastic_Config_DeviceConfig_Role_MIN, 0, 0, 0, 0, _meshtastic_Config_DeviceConfig_RebroadcastMode_MIN, 0, 0} #define meshtastic_Config_PositionConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_PowerConfig_init_zero {0, 0, 0, 0, 0, 0, 0, 0} #define meshtastic_Config_NetworkConfig_init_zero {0, "", "", "", 0, _meshtastic_Config_NetworkConfig_AddressMode_MIN, false, meshtastic_Config_NetworkConfig_IpV4Config_init_zero, ""} @@ -553,6 +555,7 @@ extern "C" { #define meshtastic_Config_DeviceConfig_buzzer_gpio_tag 5 #define meshtastic_Config_DeviceConfig_rebroadcast_mode_tag 6 #define meshtastic_Config_DeviceConfig_node_info_broadcast_secs_tag 7 +#define meshtastic_Config_DeviceConfig_double_tap_as_button_press_tag 8 #define meshtastic_Config_PositionConfig_position_broadcast_secs_tag 1 #define meshtastic_Config_PositionConfig_position_broadcast_smart_enabled_tag 2 #define meshtastic_Config_PositionConfig_fixed_position_tag 3 @@ -646,7 +649,8 @@ X(a, STATIC, SINGULAR, BOOL, debug_log_enabled, 3) \ X(a, STATIC, SINGULAR, UINT32, button_gpio, 4) \ X(a, STATIC, SINGULAR, UINT32, buzzer_gpio, 5) \ X(a, STATIC, SINGULAR, UENUM, rebroadcast_mode, 6) \ -X(a, STATIC, SINGULAR, UINT32, node_info_broadcast_secs, 7) +X(a, STATIC, SINGULAR, UINT32, node_info_broadcast_secs, 7) \ +X(a, STATIC, SINGULAR, BOOL, double_tap_as_button_press, 8) #define meshtastic_Config_DeviceConfig_CALLBACK NULL #define meshtastic_Config_DeviceConfig_DEFAULT NULL @@ -761,7 +765,7 @@ extern const pb_msgdesc_t meshtastic_Config_BluetoothConfig_msg; /* Maximum encoded size of messages (where known) */ #define meshtastic_Config_BluetoothConfig_size 10 -#define meshtastic_Config_DeviceConfig_size 26 +#define meshtastic_Config_DeviceConfig_size 28 #define meshtastic_Config_DisplayConfig_size 28 #define meshtastic_Config_LoRaConfig_size 77 #define meshtastic_Config_NetworkConfig_IpV4Config_size 20 diff --git a/src/mesh/generated/meshtastic/deviceonly.pb.h b/src/mesh/generated/meshtastic/deviceonly.pb.h index dbda5b239..40523a07a 100644 --- a/src/mesh/generated/meshtastic/deviceonly.pb.h +++ b/src/mesh/generated/meshtastic/deviceonly.pb.h @@ -188,7 +188,7 @@ extern const pb_msgdesc_t meshtastic_OEMStore_msg; /* Maximum encoded size of messages (where known) */ #define meshtastic_ChannelFile_size 638 #define meshtastic_DeviceState_size 22040 -#define meshtastic_OEMStore_size 3020 +#define meshtastic_OEMStore_size 3022 #ifdef __cplusplus } /* extern "C" */ diff --git a/src/mesh/generated/meshtastic/localonly.pb.h b/src/mesh/generated/meshtastic/localonly.pb.h index f31e47f20..cf97544e0 100644 --- a/src/mesh/generated/meshtastic/localonly.pb.h +++ b/src/mesh/generated/meshtastic/localonly.pb.h @@ -156,7 +156,7 @@ extern const pb_msgdesc_t meshtastic_LocalModuleConfig_msg; #define meshtastic_LocalModuleConfig_fields &meshtastic_LocalModuleConfig_msg /* Maximum encoded size of messages (where known) */ -#define meshtastic_LocalConfig_size 454 +#define meshtastic_LocalConfig_size 456 #define meshtastic_LocalModuleConfig_size 420 #ifdef __cplusplus diff --git a/src/modules/Telemetry/DeviceTelemetry.cpp b/src/modules/Telemetry/DeviceTelemetry.cpp index 69de4bf1b..199a90209 100644 --- a/src/modules/Telemetry/DeviceTelemetry.cpp +++ b/src/modules/Telemetry/DeviceTelemetry.cpp @@ -10,7 +10,7 @@ #include #include -#define MAGIC_USB_BATTERY_LEVEL 111 +#define MAGIC_USB_BATTERY_LEVEL 101 int32_t DeviceTelemetryModule::runOnce() { From bf1fbc6c0d75e769c312cf47df191f6c96027743 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 29 Mar 2023 19:19:19 -0500 Subject: [PATCH 16/18] [create-pull-request] automated change (#2395) Co-authored-by: thebentern --- version.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.properties b/version.properties index a59ad1d56..b26a5f4c0 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,4 @@ [VERSION] major = 2 minor = 1 -build = 6 +build = 7 From 657f22d05893f80e0a98132de82ecc2b7b455c86 Mon Sep 17 00:00:00 2001 From: Mark Trevor Birss Date: Wed, 29 Mar 2023 14:09:27 +0200 Subject: [PATCH 17/18] Update EInkDisplay2.cpp --- src/graphics/EInkDisplay2.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 269e19968..0b3c95ba4 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -12,7 +12,7 @@ #if defined(TTGO_T_ECHO) #define TECHO_DISPLAY_MODEL GxEPD2_154_D67 -#elif defined(RAK4630) || defined(MAKERPYTHON) +#elif defined(RAK4630) // GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 - changed from GxEPD2_213_B74 - which was not going to give partial update // support @@ -27,6 +27,10 @@ // 1.54 inch 200x200 - GxEPD2_154_M09 //#define TECHO_DISPLAY_MODEL GxEPD2_154_M09 +#elif defined(MAKERPYTHON) +// 2.9 inch 296x128 - GxEPD2_290_T5D +#define TECHO_DISPLAY_MODEL GxEPD2_290_T5D + #elif defined(PCA10059) // 4.2 inch 300x400 - GxEPD2_420_M01 @@ -45,20 +49,23 @@ EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY { #if defined(TTGO_T_ECHO) setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT); -#elif defined(RAK4630) || defined(MAKERPYTHON) +#elif defined(RAK4630) // GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 - // setGeometry(GEOMETRY_RAWMODE, 250, 122); + setGeometry(GEOMETRY_RAWMODE, 250, 122); // GxEPD2_420_M01 // setGeometry(GEOMETRY_RAWMODE, 300, 400); // GxEPD2_290_T5D - setGeometry(GEOMETRY_RAWMODE, 296, 128); + //setGeometry(GEOMETRY_RAWMODE, 296, 128); // GxEPD2_154_M09 // setGeometry(GEOMETRY_RAWMODE, 200, 200); - +#elif defined(MAKERPYTHON) + // GxEPD2_290_T5D + setGeometry(GEOMETRY_RAWMODE, 296, 128); + #elif defined(PCA10059) // GxEPD2_420_M01 @@ -243,4 +250,4 @@ bool EInkDisplay::connect() return true; } -#endif \ No newline at end of file +#endif From 3f07251d233748c866075ba0f467aa71b22c2800 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20G=C3=B6ttgens?= Date: Wed, 29 Mar 2023 14:48:38 +0200 Subject: [PATCH 18/18] fmt --- src/graphics/EInkDisplay2.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/graphics/EInkDisplay2.cpp b/src/graphics/EInkDisplay2.cpp index 0b3c95ba4..048e8dd6e 100644 --- a/src/graphics/EInkDisplay2.cpp +++ b/src/graphics/EInkDisplay2.cpp @@ -49,7 +49,7 @@ EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY { #if defined(TTGO_T_ECHO) setGeometry(GEOMETRY_RAWMODE, TECHO_DISPLAY_MODEL::WIDTH, TECHO_DISPLAY_MODEL::HEIGHT); -#elif defined(RAK4630) +#elif defined(RAK4630) // GxEPD2_213_BN - RAK14000 2.13 inch b/w 250x122 setGeometry(GEOMETRY_RAWMODE, 250, 122); @@ -58,14 +58,14 @@ EInkDisplay::EInkDisplay(uint8_t address, int sda, int scl, OLEDDISPLAY_GEOMETRY // setGeometry(GEOMETRY_RAWMODE, 300, 400); // GxEPD2_290_T5D - //setGeometry(GEOMETRY_RAWMODE, 296, 128); + // setGeometry(GEOMETRY_RAWMODE, 296, 128); // GxEPD2_154_M09 // setGeometry(GEOMETRY_RAWMODE, 200, 200); #elif defined(MAKERPYTHON) // GxEPD2_290_T5D setGeometry(GEOMETRY_RAWMODE, 296, 128); - + #elif defined(PCA10059) // GxEPD2_420_M01