Skip to content

Commit 662dddc

Browse files
committed
Add battery level icons + disable battery WDT
1 parent 0618e6d commit 662dddc

File tree

7 files changed

+374
-26
lines changed

7 files changed

+374
-26
lines changed

platformio.ini

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ lib_deps =
7373
adafruit/Adafruit BME680 Library
7474
adafruit/Adafruit MAX1704X
7575
adafruit/Adafruit ADT7410 Library
76-
adafruit/Adafruit GFX Library
76+
; adafruit/Adafruit GFX Library
77+
https://github.com/adafruit/Adafruit-GFX-Library.git#nesso
7778
adafruit/Adafruit STMPE610
7879
adafruit/Adafruit TouchScreen
7980
adafruit/Adafruit MQTT Library
@@ -84,7 +85,8 @@ lib_deps =
8485
adafruit/Adafruit SH110X
8586
adafruit/Adafruit SSD1306
8687
adafruit/Adafruit EPD
87-
adafruit/Adafruit ST7735 and ST7789 Library
88+
; adafruit/Adafruit ST7735 and ST7789 Library
89+
https://github.com/adafruit/Adafruit-ST7735-Library.git#ExpanderPin
8890
https://github.com/tyeth/omron-devhub_d6t-arduino.git
8991
https://github.com/pstolarz/OneWireNg.git
9092
; COMMENT OUT FOR RP2040/RP2350 BOARDS
@@ -205,18 +207,19 @@ board_build.partitions = min_spiffs.csv
205207
[env:arduino_nesso_n1]
206208
extends = common:esp32
207209
board = arduino_nesso_n1
210+
; build_type = release
208211
build_type = debug
209-
; debug_tool = esp-builtin
210212
; upload_protocol = esp-builtin
211-
; debug_init_break = tbreak setup
213+
; debug_tool = esp-builtin
214+
; debug_init_break = tbreak provision
212215
build_flags =
213216
-DARDUINO_ARDUINO_NESSO_N1
214217
; -DDEBUG=1
215-
; -DARDUINO_USB_MODE=1
216-
; -DARDUINO_USB_CDC_ON_BOOT=1
217-
; -DESP_LOG_LEVEL=5
218-
; -DARDUINO_LOG_LEVEL=5
219-
; -DCORE_DEBUG_LEVEL=5
218+
-DARDUINO_USB_MODE=1
219+
-DARDUINO_USB_CDC_ON_BOOT=1
220+
-DESP_LOG_LEVEL=5
221+
-DARDUINO_LOG_LEVEL=5
222+
-DCORE_DEBUG_LEVEL=5
220223
; -DMQTT_DEBUG=1
221224
board_build.filesystem = littlefs
222225
board_build.partitions = huge_app.csv

src/Wippersnapper.cpp

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,49 @@ void Wippersnapper::provision() {
9898
// Obtain device's MAC address
9999
getMacAddr();
100100

101+
// Board specific initializations
102+
#ifdef ARDUINO_ARDUINO_NESSO_N1
103+
Wire.begin(SDA, SCL, 100000);
104+
105+
// verify chip id 0x49 at 0x0Ah
106+
Wire.beginTransmission(0x49);
107+
Wire.write(0x0A);
108+
Wire.endTransmission();
109+
Wire.requestFrom(0x49, 1);
110+
uint8_t chipId = Wire.read();
111+
if (chipId != 0x49) {
112+
WS_DEBUG_PRINTLN("ERROR: AW32001E not found on I2C bus!");
113+
Wire.endTransmission();
114+
Wire.end();
115+
} else {
116+
WS_DEBUG_PRINTLN("AW32001E detected on I2C bus.");
117+
// Disable AW32001E watchdog timer, read 05h, & 0x1F, write back
118+
Wire.beginTransmission(0x49);
119+
Wire.write(0x05);
120+
Wire.endTransmission();
121+
Wire.requestFrom(0x49, 1);
122+
uint8_t regVal = Wire.read();
123+
Wire.endTransmission();
124+
WS_DEBUG_PRINTLN("AW32001E WDT reg before disable: " + String(regVal, BIN));
125+
delay(10);
126+
regVal &=
127+
0b00011111; // Clear bits 5:6 to disable Watchdog timer, 7 for discharge
128+
Wire.beginTransmission(0x49);
129+
Wire.write(0x05);
130+
Wire.write(regVal);
131+
Wire.endTransmission();
132+
Wire.end();
133+
delay(10);
134+
135+
battery.enableCharge();
136+
}
137+
138+
// // digitalWrite(LORA_ENABLE, FALSE);
139+
// // digitalWrite(LORA_LNA_ENABLE, FALSE);
140+
// // digitalWrite(GROVE_POWER_EN, TRUE);
141+
// delay(10);
142+
#endif
143+
101144
// Initialize the status LED for signaling FS errors
102145
initStatusLED();
103146

@@ -2272,7 +2315,7 @@ bool Wippersnapper::generateWSTopics() {
22722315
strlen(_device_uid) + strlen("/wprsnpr/") +
22732316
strlen(TOPIC_SIGNALS) + strlen("broker/uart") + 1;
22742317

2275-
// Allocate memory for dynamic MQTT topic
2318+
// Allocate memory for dynamic MQTT topic
22762319
#ifdef USE_PSRAM
22772320
WS._topic_signal_uart_brkr = (char *)ps_malloc(topicLen);
22782321
#else
@@ -2301,7 +2344,7 @@ bool Wippersnapper::generateWSTopics() {
23012344
strlen("/wprsnpr/") + strlen(TOPIC_SIGNALS) +
23022345
strlen("device/uart") + 1;
23032346

2304-
// Allocate memory for dynamic MQTT topic
2347+
// Allocate memory for dynamic MQTT topic
23052348
#ifdef USE_PSRAM
23062349
WS._topic_signal_uart_device = (char *)ps_malloc(topicLen);
23072350
#else
@@ -2325,7 +2368,7 @@ bool Wippersnapper::generateWSTopics() {
23252368
strlen("/wprsnpr/") + strlen(TOPIC_SIGNALS) + strlen("broker") +
23262369
strlen(TOPIC_DISPLAY) + 1;
23272370

2328-
// Pre-allocate memory for topic
2371+
// Pre-allocate memory for topic
23292372
#ifdef USE_PSRAM
23302373
WS._topic_signal_display_brkr = (char *)ps_malloc(topicLen);
23312374
#else
@@ -2356,7 +2399,7 @@ bool Wippersnapper::generateWSTopics() {
23562399
strlen("/wprsnpr/") + strlen(TOPIC_SIGNALS) + strlen("device") +
23572400
strlen(TOPIC_DISPLAY) + 1;
23582401

2359-
// Allocate memory for dynamic MQTT topic
2402+
// Allocate memory for dynamic MQTT topic
23602403
#ifdef USE_PSRAM
23612404
WS._topic_signal_display_device = (char *)ps_malloc(topicLen);
23622405
#else

src/Wippersnapper.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ class ws_pixels;
241241
class ws_uart;
242242
class DisplayController;
243243

244+
#ifdef ARDUINO_ARDUINO_NESSO_N1
245+
static NessoBattery battery; ///< Nesso-N1 Battery instance
246+
#endif
247+
248+
244249
/**************************************************************************/
245250
/*!
246251
@brief Class that provides storage and functions for the Adafruit IO

0 commit comments

Comments
 (0)