From 7475e3c1053f10b5b942c20ad8aa55ea649a74c7 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 9 May 2021 10:31:42 +0800 Subject: [PATCH 1/3] give more margin for heltec no battery voltage --- geeksville-private/TODO.md | 13 +++++++------ src/Power.cpp | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/geeksville-private/TODO.md b/geeksville-private/TODO.md index 7dbf5b0f..51f136e7 100644 --- a/geeksville-private/TODO.md +++ b/geeksville-private/TODO.md @@ -4,17 +4,18 @@ You probably don't care about this section - skip to the next one. ## before next release +* fix python tool problem +* fix ttgo eink screen +* make native sim not touch hardware +* reenable sim in CI builds +* figure our wss for mqtt.meshtastic - use cloudflare? 2052 ws, 2053 crypt +* release android APK - fix recent 1.2.28 crash report * turn on setTx(timeout) and state = setDioIrqParams(SX126X_IRQ_TX_DONE | SX126X_IRQ_TIMEOUT, SX126X_IRQ_TX_DONE | SX126X_IRQ_TIMEOUT); in sx1262 code * pine64 lora module -* nrf52 USB is unreliable while sleeping? * @havealoha fixedposition not working -* merge https://meshtastic.discourse.group/t/spanish-translation-update/2986/5 * @luxonn reports that after a while the android app stops showing new messages -* nrf52 shows as "sleeping" in android app? (but led is blinking) * ask for vercel access -* fix heltec battery scaling -* check android 1.2.20 usage, possibly release to general -* release android APK +* finish plan for riot.im * add rak4600 support (with rf95 radio and limited ram) diff --git a/src/Power.cpp b/src/Power.cpp index 2ff783ad..1f484871 100644 --- a/src/Power.cpp +++ b/src/Power.cpp @@ -129,7 +129,9 @@ class AnalogBatteryLevel : public HasBatteryLevel private: /// If we see a battery voltage higher than physics allows - assume charger is pumping /// in power - const float fullVolt = 4200, emptyVolt = 3270, chargingVolt = 4210, noBatVolt = 2100; + + /// For heltecs with no battery connected, the measured voltage is 2204, so raising to 2230 from 2100 + const float fullVolt = 4200, emptyVolt = 3270, chargingVolt = 4210, noBatVolt = 2230; float last_read_value = 0.0; uint32_t last_read_time_ms = 0; } analogLevel; From 2e832774a23a269944ef11d642f302ec54099c23 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sun, 9 May 2021 10:56:28 +0800 Subject: [PATCH 2/3] provide short versions to android --- bin/build-all.sh | 4 +++- bin/buildinfo.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/build-all.sh b/bin/build-all.sh index 6a1cf983..8137745e 100755 --- a/bin/build-all.sh +++ b/bin/build-all.sh @@ -2,7 +2,8 @@ set -e -VERSION=`bin/buildinfo.py` +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=tbeam @@ -91,6 +92,7 @@ Generated by bin/buildall.sh --> $VERSION + $SHORT_VERSION XML diff --git a/bin/buildinfo.py b/bin/buildinfo.py index 1dc5d98e..6b123c9c 100755 --- a/bin/buildinfo.py +++ b/bin/buildinfo.py @@ -1,7 +1,9 @@ #!/usr/bin/env python3 import configparser +import sys from readprops import readProps verObj = readProps('version.properties') -print(f"{verObj['long']}") +propName = sys.argv[1] +print(f"{verObj[propName]}") From 7f51517961107b0bf0432ba73b23252f3b566853 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Tue, 11 May 2021 09:44:41 +0800 Subject: [PATCH 3/3] 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 8137745e..096488f2 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 51f136e7..4955ace8 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 7296a606..833645b8 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 5be5307c..dfcfba8d 160000 --- a/proto +++ b/proto @@ -1 +1 @@ -Subproject commit 5be5307c906f1275e4134f839b1d93283484932e +Subproject commit dfcfba8d1a6bad4233436c39f0571df878f8d2d2 diff --git a/src/Power.cpp b/src/Power.cpp index 1f484871..945c9bad 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 63ec177d..2080e6e3 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 fda4c5d9..44b55685 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,