Skip to content

Commit 36ced04

Browse files
committed
Try tyeth pio ini
1 parent 0511abd commit 36ced04

28 files changed

+175
-99
lines changed

examples/Wippersnapper_demo/Wippersnapper_demo.ino

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ void setup() {
2626
Serial.begin(115200);
2727
//while (!Serial) delay(10);
2828

29+
WS_DEBUG_HEAP("boot");
30+
2931
wipper.connect();
3032

3133
}

platformio.ini

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,33 @@ board_build.eesz=4M2M
515515
board_build.filesystem = littlefs
516516
upload_port = COM19
517517

518+
; Adafruit Feather HUZZAH ESP8266 Debug
519+
[env:huzzah_esp8266_debug]
520+
extends=common:esp8266
521+
board = huzzah
522+
board_build.f_cpu = 80000000L
523+
build_type = debug
524+
; Arduino CLI uses this from adafruit_ci#ci-wippersnapper
525+
; esp8266:esp8266:huzzah:xtal=80,vt=flash,exception=disabled,stacksmash=disabled,ssl=all,mmu=4816,non32xfer=fast,eesz=4M2M,ip=lm2f,dbg=Disabled,lvl=None____,wipe=none,baud=115200
526+
build_flags =
527+
-Wl,--gc-sections
528+
-Wl,-Map=output_8266_debug.map
529+
-DARDUINO_ESP8266_ADAFRUIT_HUZZAH
530+
-DDEBUG_ESP_PORT=Serial
531+
-DPIO_FRAMEWORK_ARDUINO_LWIP2_LOW_MEMORY
532+
-DVTABLES_IN_FLASH
533+
-DNO_EXCEPTIONS
534+
-DNO_STACK_SMASH_PROTECTION
535+
-DSSL_ALL
536+
-DMMU_4816
537+
-DNON32XFER_FAST
538+
-DDEBUG_ENABLED
539+
-DDEBUG_LEVEL_NONE
540+
-DPIO_FRAMEWORK_ARDUINO_MMU_CACHE16_IRAM48_SECHEAP_SHARED ; 16KB cache + 48KB IRAM + 2nd heap (shared)
541+
board_build.eesz=4M2M
542+
board_build.filesystem = littlefs
543+
monitor_filters = esp8266_exception_decoder
544+
518545
; SAMD51 Boards ;
519546

520547
; Adafruit PyPortal M4

src/Wippersnapper.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ Wippersnapper::~Wippersnapper() {
9595
*/
9696
/**************************************************************************/
9797
void Wippersnapper::provision() {
98+
// Note: Serial not initialized yet, cannot use WS_DEBUG_HEAP here
99+
98100
// Obtain device's MAC address
99101
getMacAddr();
100102

@@ -120,6 +122,7 @@ void Wippersnapper::provision() {
120122
setStatusLEDBrightness(WS._config.status_pixel_brightness);
121123
// Set device's wireless credentials
122124
set_ssid_pass();
125+
// Note: Serial not initialized yet, cannot use WS_DEBUG_HEAP here
123126
}
124127

125128
/**************************************************************************/
@@ -2788,6 +2791,7 @@ void printDeviceInfo() {
27882791
*/
27892792
/**************************************************************************/
27902793
void Wippersnapper::connect() {
2794+
WS_DEBUG_HEAP("connect-start");
27912795
WS_DEBUG_PRINTLN("Adafruit.io WipperSnapper");
27922796

27932797
// Dump device info to the serial monitor
@@ -2841,6 +2845,7 @@ void Wippersnapper::connect() {
28412845
statusLEDFade(GREEN, 3);
28422846
WS_DEBUG_PRINTLN(
28432847
"Registration and configuration complete!\nRunning application...");
2848+
WS_DEBUG_HEAP("connect-end");
28442849
}
28452850

28462851
/**************************************************************************/
@@ -2888,6 +2893,8 @@ void Wippersnapper::publishPinConfigComplete() {
28882893
*/
28892894
/**************************************************************************/
28902895
ws_status_t Wippersnapper::run() {
2896+
WS_DEBUG_HEAP("loop");
2897+
28912898
// Check networking
28922899
runNetFSM();
28932900
WS.feedWDT();

src/Wippersnapper.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,29 @@
7474
#define WS_DEBUG_PRINTHEX(...) \
7575
{ WS_PRINTER.print(__VA_ARGS__, HEX); } ///< Prints in hexadecimal
7676

77+
// ESP8266 heap monitoring macro
78+
#ifdef ARDUINO_ARCH_ESP8266
79+
#define WS_HEAP_TOTAL 81920 ///< ESP8266 total heap size in bytes
80+
#define WS_DEBUG_HEAP(label) \
81+
{ \
82+
uint32_t freeHeap = ESP.getFreeHeap(); \
83+
uint8_t freePct = (freeHeap * 100) / WS_HEAP_TOTAL; \
84+
WS_DEBUG_PRINT("[HEAP] "); \
85+
WS_DEBUG_PRINT(label); \
86+
WS_DEBUG_PRINT(": "); \
87+
WS_DEBUG_PRINTVAR(freeHeap); \
88+
WS_DEBUG_PRINT("B ("); \
89+
WS_DEBUG_PRINTVAR(freePct); \
90+
WS_DEBUG_PRINT("%) frag="); \
91+
WS_DEBUG_PRINTVAR(ESP.getHeapFragmentation()); \
92+
WS_DEBUG_PRINT("% maxblk="); \
93+
WS_DEBUG_PRINTLNVAR(ESP.getMaxFreeBlockSize()); \
94+
}
95+
#else
96+
#define WS_DEBUG_HEAP(label) \
97+
{} ///< No-op for non-ESP8266 platforms
98+
#endif
99+
77100
#else
78101
#define WS_DEBUG_PRINT(...) \
79102
{} ///< Disabled debug output
@@ -85,6 +108,8 @@
85108
{} ///< Disabled debug output
86109
#define WS_DEBUG_PRINTHEX(...) \
87110
{} ///< Disabled debug output
111+
#define WS_DEBUG_HEAP(label) \
112+
{} ///< Disabled heap debug output
88113
#endif
89114

90115
#define WS_DELAY_WITH_WDT(timeout) \

src/components/analogIO/Wippersnapper_AnalogIO.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void Wippersnapper_AnalogIO::initAnalogInputPin(
162162
}
163163
}
164164
WS_DEBUG_PRINT("Configured Analog Input pin with polling time (ms):");
165-
WS_DEBUG_PRINTLN(periodMs);
165+
WS_DEBUG_PRINTLNVAR(periodMs);
166166
}
167167

168168
/***********************************************************************************/
@@ -194,7 +194,7 @@ void Wippersnapper_AnalogIO::disableAnalogInPin(int pin) {
194194
void Wippersnapper_AnalogIO::deinitAnalogPin(
195195
wippersnapper_pin_v1_ConfigurePinRequest_Direction direction, int pin) {
196196
WS_DEBUG_PRINT("Deinitializing analog pin A");
197-
WS_DEBUG_PRINTLN(pin);
197+
WS_DEBUG_PRINTLNVAR(pin);
198198
if (direction ==
199199
wippersnapper_pin_v1_ConfigurePinRequest_Direction_DIRECTION_INPUT) {
200200
WS_DEBUG_PRINTLN("Deinitialized analog input pin obj.");
@@ -391,7 +391,7 @@ void Wippersnapper_AnalogIO::update() {
391391
if (_analog_input_pins[i].period != 0L &&
392392
timerExpired(millis(), _analog_input_pins[i])) {
393393
WS_DEBUG_PRINT("Executing periodic event on A");
394-
WS_DEBUG_PRINTLN(_analog_input_pins[i].pinName);
394+
WS_DEBUG_PRINTLNVAR(_analog_input_pins[i].pinName);
395395

396396
// Read from analog pin
397397
if (_analog_input_pins[i].readMode ==

src/components/digitalIO/Wippersnapper_DigitalGPIO.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void Wippersnapper_DigitalGPIO::initDigitalPin(
7373
pinMode(pinName, OUTPUT);
7474

7575
WS_DEBUG_PRINT("Configured digital output pin on D");
76-
WS_DEBUG_PRINTLN(pinName);
76+
WS_DEBUG_PRINTLNVAR(pinName);
7777

7878
// Initialize LOW
7979
#if defined(ARDUINO_ESP8266_ADAFRUIT_HUZZAH)
@@ -88,7 +88,7 @@ void Wippersnapper_DigitalGPIO::initDigitalPin(
8888
direction ==
8989
wippersnapper_pin_v1_ConfigurePinRequest_Direction_DIRECTION_INPUT) {
9090
WS_DEBUG_PRINT("Configuring digital input pin on D");
91-
WS_DEBUG_PRINT(pinName);
91+
WS_DEBUG_PRINTVAR(pinName);
9292

9393
if (pull == wippersnapper_pin_v1_ConfigurePinRequest_Pull_PULL_UP) {
9494
WS_DEBUG_PRINTLN("with internal pull-up enabled");
@@ -101,7 +101,7 @@ void Wippersnapper_DigitalGPIO::initDigitalPin(
101101
// Period is in seconds, cast it to long and convert it to milliseconds
102102
long periodMs = (long)period * 1000;
103103
WS_DEBUG_PRINT("Interval (ms):");
104-
WS_DEBUG_PRINTLN(periodMs);
104+
WS_DEBUG_PRINTLNVAR(periodMs);
105105

106106
// get current time
107107
ulong curTime = millis() - 1;
@@ -134,7 +134,7 @@ void Wippersnapper_DigitalGPIO::deinitDigitalPin(
134134
wippersnapper_pin_v1_ConfigurePinRequest_Direction direction,
135135
uint8_t pinName) {
136136
WS_DEBUG_PRINT("Deinitializing digital pin ");
137-
WS_DEBUG_PRINTLN(pinName);
137+
WS_DEBUG_PRINTLNVAR(pinName);
138138

139139
if (direction ==
140140
wippersnapper_pin_v1_ConfigurePinRequest_Direction_DIRECTION_INPUT) {
@@ -186,9 +186,9 @@ int Wippersnapper_DigitalGPIO::digitalReadSvc(int pinName) {
186186
/*******************************************************************************/
187187
void Wippersnapper_DigitalGPIO::digitalWriteSvc(uint8_t pinName, int pinValue) {
188188
WS_DEBUG_PRINT("Digital Pin Event: Set ");
189-
WS_DEBUG_PRINT(pinName);
189+
WS_DEBUG_PRINTVAR(pinName);
190190
WS_DEBUG_PRINT(" to ");
191-
WS_DEBUG_PRINTLN(pinValue);
191+
WS_DEBUG_PRINTLNVAR(pinValue);
192192

193193
// Write to the GPIO pin
194194
#if defined(ARDUINO_ESP8266_ADAFRUIT_HUZZAH)
@@ -220,7 +220,7 @@ void Wippersnapper_DigitalGPIO::processDigitalInputs() {
220220
_digital_input_pins[i].period &&
221221
_digital_input_pins[i].period != 0L) {
222222
WS_DEBUG_PRINT("Executing periodic event on D");
223-
WS_DEBUG_PRINTLN(_digital_input_pins[i].pinName);
223+
WS_DEBUG_PRINTLNVAR(_digital_input_pins[i].pinName);
224224
// read the pin
225225
int pinVal = digitalReadSvc(_digital_input_pins[i].pinName);
226226

@@ -255,7 +255,7 @@ void Wippersnapper_DigitalGPIO::processDigitalInputs() {
255255
// only send on-change
256256
if (pinVal != _digital_input_pins[i].prvPinVal) {
257257
WS_DEBUG_PRINT("Executing state-based event on D");
258-
WS_DEBUG_PRINTLN(_digital_input_pins[i].pinName);
258+
WS_DEBUG_PRINTLNVAR(_digital_input_pins[i].pinName);
259259

260260
// Create new signal message
261261
wippersnapper_signal_v1_CreateSignalRequest _outgoingSignalMsg =

src/components/display/assets/icons.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* @brief cloud-thin-full icon from FontAwesome (16x16px)
2121
*/
22-
const unsigned char epd_bmp_cloud_online[] = {
22+
const unsigned char epd_bmp_cloud_online[] PROGMEM = {
2323
0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x0d, 0xc0, 0x18, 0x78, 0x10,
2424
0x0c, 0x30, 0x04, 0x70, 0x0c, 0xc0, 0x06, 0xc0, 0x03, 0xc0, 0x03,
2525
0x40, 0x03, 0x70, 0x06, 0x3f, 0xfc, 0x00, 0x00, 0x00, 0x00};
@@ -35,39 +35,39 @@ const unsigned char epd_bmp_cloud_offline[] PROGMEM = {
3535
/**
3636
* @brief wifi-thin-full icon from FontAwesome (16x16px)
3737
*/
38-
const unsigned char epd_bmp_wifi_full[] = {
38+
const unsigned char epd_bmp_wifi_full[] PROGMEM = {
3939
0x00, 0x00, 0x00, 0x00, 0x07, 0xe0, 0x3c, 0x3c, 0x70, 0x0e, 0xc0,
4040
0x03, 0x03, 0xc0, 0x0f, 0xf0, 0x1c, 0x38, 0x18, 0x18, 0x00, 0x00,
4141
0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00};
4242

4343
/**
4444
* @brief wifi-fair-thin-full icon from FontAwesome (16x16px)
4545
*/
46-
const unsigned char epd_bmp_wifi_fair[] = {
46+
const unsigned char epd_bmp_wifi_fair[] PROGMEM = {
4747
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
4848
0x00, 0x03, 0xc0, 0x0f, 0xf0, 0x1c, 0x38, 0x18, 0x18, 0x00, 0x00,
4949
0x03, 0xc0, 0x03, 0xc0, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00};
5050

5151
/**
5252
* @brief wifi-weak-thin-full icon from FontAwesome (16x16px)
5353
*/
54-
const unsigned char epd_bmp_wifi_weak[] = {
54+
const unsigned char epd_bmp_wifi_weak[] PROGMEM = {
5555
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5656
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
5757
0x03, 0xc0, 0x03, 0xc0, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00};
5858

5959
/**
6060
* @brief wifi-slash-thin-full icon from FontAwesome (16x16px)
6161
*/
62-
const unsigned char epd_bmp_wifi_no_signal[] = {
62+
const unsigned char epd_bmp_wifi_no_signal[] PROGMEM = {
6363
0x00, 0x00, 0x40, 0x00, 0x27, 0xc0, 0x1e, 0x38, 0x68, 0x00, 0x44,
6464
0x03, 0x03, 0x00, 0x01, 0xe0, 0x08, 0x90, 0x00, 0x40, 0x00, 0x20,
6565
0x01, 0x90, 0x03, 0x88, 0x01, 0x84, 0x00, 0x02, 0x00, 0x00};
6666

6767
/**
6868
* @brief battery-full-thin-full icon from FontAwesome (16x16px)
6969
*/
70-
const unsigned char epd_bmp_bat_full[] = {
70+
const unsigned char epd_bmp_bat_full[] PROGMEM = {
7171
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0xc0, 0x06, 0xff,
7272
0xfa, 0xf0, 0x0b, 0xf0, 0x0b, 0xf0, 0x0b, 0xf0, 0x0b, 0xff, 0xfa,
7373
0xc0, 0x06, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

src/components/display/assets/splash.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
/**
2020
* @brief Wippersnapper logo, 296x128px
2121
*/
22-
const unsigned char tft_bmp_logo_240135[] = {
22+
const unsigned char tft_bmp_logo_240135[] PROGMEM = {
2323
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2424
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2525
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -965,7 +965,7 @@ const unsigned char tft_bmp_logo_240240[] PROGMEM = {
965965
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
966966

967967
// 'adafruit_wippersnapper_logo', ePD Magtag, 296x128px
968-
static const unsigned char epd_bitmap_ws_logo_296128[] = {
968+
static const unsigned char epd_bitmap_ws_logo_296128[] PROGMEM = {
969969
// 'adafruit_wippersnapper_logo, 296x128px
970970
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
971971
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

src/components/display/controller.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ bool DisplayController::Handle_Display_AddOrReplace(
4141
wippersnapper_display_v1_DisplayAddOrReplace *msgAdd) {
4242
DisplayHardware *display = new DisplayHardware(msgAdd->name);
4343
WS_DEBUG_PRINT("[display] Adding or replacing display: ");
44-
WS_DEBUG_PRINTLN(msgAdd->name);
44+
WS_DEBUG_PRINTLNVAR(msgAdd->name);
4545

4646
// Does this display hw instance already exist?
4747
DisplayHardware *existingDisplay = findDisplay(msgAdd->name);
@@ -144,7 +144,7 @@ bool DisplayController::Handle_Display_Write(
144144

145145
// Write the message to the display
146146
WS_DEBUG_PRINT("[display] Writing message to display: ");
147-
WS_DEBUG_PRINTLN(msgWrite->message);
147+
WS_DEBUG_PRINTLNVAR(msgWrite->message);
148148
WS.runNetFSM();
149149
display->writeMessage(msgWrite->message);
150150
WS.runNetFSM();

src/components/display/drivers/dispDrvBase.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
#ifndef WS_DISP_DRV_BASE_H
1616
#define WS_DISP_DRV_BASE_H
1717

18+
#ifndef ARDUINO_ARCH_ESP8266
1819
#include "../assets/icons.h"
1920
#include "../assets/splash.h"
21+
#endif
2022
#include "Adafruit_ThinkInk.h"
2123
#include "Wippersnapper.h"
2224

0 commit comments

Comments
 (0)