From 7f51517961107b0bf0432ba73b23252f3b566853 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Tue, 11 May 2021 09:44:41 +0800 Subject: [PATCH] better support for heltec --- bin/build-all.sh | 2 +- geeksville-private/TODO.md | 3 ++- platformio.ini | 26 ++++++++++++++++++-------- proto | 2 +- src/Power.cpp | 5 +++-- src/configuration.h | 21 +++++++++++++++++++-- src/mesh/generated/mesh.pb.h | 3 ++- 7 files changed, 46 insertions(+), 16 deletions(-) diff --git a/bin/build-all.sh b/bin/build-all.sh index 8137745e9..096488f22 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -5,7 +5,7 @@ set -e VERSION=`bin/buildinfo.py long` SHORT_VERSION=`bin/buildinfo.py short` -BOARDS_ESP32="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec tbeam0.7" +BOARDS_ESP32="tlora-v2 tlora-v1 tlora_v1_3 tlora-v2-1-1.6 tbeam heltec-v2.0 heltec-v2.1 tbeam0.7" #BOARDS_ESP32=tbeam # FIXME note nrf52840dk build is for some reason only generating a BIN file but not a HEX file nrf52840dk-geeksville is fine diff --git a/geeksville-private/TODO.md b/geeksville-private/TODO.md index 51f136e78..4955ace87 100644 --- a/geeksville-private/TODO.md +++ b/geeksville-private/TODO.md @@ -4,8 +4,9 @@ You probably don't care about this section - skip to the next one. ## before next release -* fix python tool problem +* fix python tool problem with windows and the heartbeat * fix ttgo eink screen +* fix this sleep problem: https://meshtastic.discourse.group/t/new-device-release-1-2-30-ready-for-alpha-testing/3272/13?u=geeksville * make native sim not touch hardware * reenable sim in CI builds * figure our wss for mqtt.meshtastic - use cloudflare? 2052 ws, 2053 crypt diff --git a/platformio.ini b/platformio.ini index 7296a6069..833645b84 100644 --- a/platformio.ini +++ b/platformio.ini @@ -11,7 +11,7 @@ [platformio] default_envs = tbeam ;default_envs = tbeam0.7 -;default_envs = heltec +;default_envs = heltec-v2.0 ;default_envs = tlora-v1 ;default_envs = tlora_v1_3 ;default_envs = tlora-v2 @@ -151,10 +151,19 @@ board = ttgo-t-beam build_flags = ${esp32_base.build_flags} -D TBEAM_V07 -[env:heltec] +[env:heltec-v2.0] ;build_type = debug ; to make it possible to step through our jtag debugger extends = esp32_base board = heltec_wifi_lora_32_V2 +build_flags = + ${esp32_base.build_flags} -D HELTEC_V2_0 + +[env:heltec-v2.1] +;build_type = debug ; to make it possible to step through our jtag debugger +extends = esp32_base +board = heltec_wifi_lora_32_V2 +build_flags = + ${esp32_base.build_flags} -D HELTEC_V2_1 [env:tlora-v1] extends = esp32_base @@ -184,13 +193,13 @@ build_flags = ; The Heltec Cubecell plus ; IMPORTANT NOTE: This target doesn't yet work and probably won't ever work. I'm keeping it around for now. ; For more details see my post in the forum. -[env:cubecellplus] -platform = https://github.com/HelTecAutomation/platform-asrmicro650x.git ; we use top-of-tree because stable version has too many bugs - asrmicro650x -board = cubecell_board_plus +;[env:cubecellplus] +;platform = https://github.com/HelTecAutomation/platform-asrmicro650x.git ; we use top-of-tree because stable version has too many bugs - asrmicro650x +;board = cubecell_board_plus ; FIXME, bug in cubecell arduino - they are supposed to set ARDUINO -build_flags = ${arduino_base.build_flags} -DARDUINO=100 -Isrc/cubecell -src_filter = - ${arduino_base.src_filter} - - +;build_flags = ${arduino_base.build_flags} -DARDUINO=100 -Isrc/cubecell +;src_filter = +; ${arduino_base.src_filter} - - ; Common settings for NRF52 based targets [nrf52_base] @@ -312,6 +321,7 @@ 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 +; Note, this board is not yet supported! It will not work without futher development. ; THIS IS UNTESTED (I don't have this board), but other developers can use it as a starting point [env:rak4600] extends = nrf52_base diff --git a/proto b/proto index 5be5307c9..dfcfba8d1 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 5be5307c906f1275e4134f839b1d93283484932e +Subproject commit dfcfba8d1a6bad4233436c39f0571df878f8d2d2 diff --git a/src/Power.cpp b/src/Power.cpp index 1f4848713..945c9bad3 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -102,7 +102,8 @@ class AnalogBatteryLevel : public HasBatteryLevel last_read_time_ms = millis(); uint32_t raw = analogRead(BATTERY_PIN); float scaled = 1000.0 * ADC_MULTIPLIER * (AREF_VOLTAGE / 1024.0) * raw; - // DEBUG_MSG("raw val=%u scaled=%u\n", raw, (uint32_t)(scaled)); + + // DEBUG_MSG("battery gpio %d raw val=%u scaled=%u\n", BATTERY_PIN, raw, (uint32_t)(scaled)); last_read_value = scaled; return scaled; } else { @@ -141,7 +142,7 @@ Power::Power() : OSThread("Power") {} bool Power::analogInit() { #ifdef BATTERY_PIN - DEBUG_MSG("Using analog input for battery level\n"); + DEBUG_MSG("Using analog input %d for battery level\n", BATTERY_PIN); // disable any internal pullups pinMode(BATTERY_PIN, INPUT); diff --git a/src/configuration.h b/src/configuration.h index 63ec177d9..2080e6e31 100644 --- a/src/configuration.h +++ b/src/configuration.h @@ -227,8 +227,6 @@ along with this program. If not, see . #define GPS_TX_PIN 15 #elif defined(ARDUINO_HELTEC_WIFI_LORA_32_V2) -// This string must exactly match the case used in release file names or the android updater won't work -#define HW_VENDOR HardwareModel_HELTEC // the default ESP32 Pin of 15 is the Oled SCL, set to 36 and 37 and works fine. // Tested on Neo6m module. @@ -256,6 +254,25 @@ along with this program. If not, see . #define LORA_DIO1 35 // Not really used #define LORA_DIO2 34 // Not really used +// ratio of voltage divider = 3.20 (R1=100k, R2=220k) +#define ADC_MULTIPLIER 3.2 + +#ifdef HELTEC_V2_0 +// This string must exactly match the case used in release file names or the android updater won't work +#define HW_VENDOR HardwareModel_HELTEC_V2_0 + +#define BATTERY_PIN 13 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage + +#endif + +#ifdef HELTEC_V2_1 +// This string must exactly match the case used in release file names or the android updater won't work +#define HW_VENDOR HardwareModel_HELTEC_V2_1 + +#define BATTERY_PIN 37 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage + +#endif + #elif defined(TLORA_V1) // This string must exactly match the case used in release file names or the android updater won't work #define HW_VENDOR HardwareModel_TLORA_V1 diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index fda4c5d90..44b55685b 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -17,11 +17,12 @@ typedef enum _HardwareModel { HardwareModel_TLORA_V1 = 2, HardwareModel_TLORA_V2_1_1p6 = 3, HardwareModel_TBEAM = 4, - HardwareModel_HELTEC = 5, + HardwareModel_HELTEC_V2_0 = 5, HardwareModel_TBEAM0p7 = 6, HardwareModel_T_ECHO = 7, HardwareModel_TLORA_V1_1p3 = 8, HardwareModel_RAK4631 = 9, + HardwareModel_HELTEC_V2_1 = 10, HardwareModel_LORA_RELAY_V1 = 32, HardwareModel_NRF52840DK = 33, HardwareModel_PPR = 34,