Skip to content

Commit 213f01c

Browse files
authored
Merge pull request #443 from fdlamotte/wio_e5_mini_rescue_cli
wio_e5_mini: led and rescue cli
2 parents ba7839a + d94f469 commit 213f01c

File tree

5 files changed

+63
-4
lines changed

5 files changed

+63
-4
lines changed

src/helpers/stm32/STM32Board.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class STM32Board : public mesh::MainBoard {
88
uint8_t startup_reason;
99

1010
public:
11-
void begin() {
11+
virtual void begin() {
1212
startup_reason = BD_STARTUP_NORMAL;
1313
}
1414

@@ -25,5 +25,14 @@ class STM32Board : public mesh::MainBoard {
2525
void reboot() override {
2626
}
2727

28+
#if defined(P_LORA_TX_LED)
29+
void onBeforeTransmit() override {
30+
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED on
31+
}
32+
void onAfterTransmit() override {
33+
digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED off
34+
}
35+
#endif
36+
2837
bool startOTAUpdate(const char* id, char reply[]) override { return false; };
2938
};
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#pragma once
2+
3+
#include <helpers/ui/DisplayDriver.h>
4+
5+
class NullDisplayDriver : public DisplayDriver {
6+
public:
7+
NullDisplayDriver() : DisplayDriver(128, 64) { }
8+
bool begin() { return false; } // not present
9+
10+
bool isOn() override { return false; }
11+
void turnOn() override { }
12+
void turnOff() override { }
13+
void clear() override { }
14+
void startFrame(Color bkg = DARK) override { }
15+
void setTextSize(int sz) override { }
16+
void setColor(Color c) override { }
17+
void setCursor(int x, int y) override { }
18+
void print(const char* str) override { }
19+
void fillRect(int x, int y, int w, int h) override { }
20+
void drawRect(int x, int y, int w, int h) override { }
21+
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override { }
22+
uint16_t getTextWidth(const char* str) override { return 0; }
23+
void endFrame() { }
24+
};

variants/wio-e5-mini/platformio.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ build_flags = ${stm32_base.build_flags}
77
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
88
-D SPI_INTERFACES_COUNT=0
99
-D RX_BOOSTED_GAIN=true
10+
-D P_LORA_TX_LED=LED_RED
11+
-D PIN_USER_BTN=USER_BTN
12+
-D USER_BTN_PRESSED=LOW
1013
-I variants/wio-e5-mini
1114
build_src_filter = ${stm32_base.build_src_filter}
1215
+<../variants/wio-e5-mini>
@@ -27,7 +30,8 @@ extends = lora_e5_mini
2730
build_flags = ${lora_e5_mini.build_flags}
2831
-D LORA_TX_POWER=22
2932
-D MAX_CONTACTS=100
30-
-D MAX_GROUP_CHANNELS=8
33+
-D MAX_GROUP_CHANNELS=8
34+
-D DISPLAY_CLASS=NullDisplayDriver
3135
build_src_filter = ${lora_e5_mini.build_src_filter}
3236
+<../examples/companion_radio/*.cpp>
3337
lib_deps = ${lora_e5_mini.lib_deps}

variants/wio-e5-mini/target.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ static const Module::RfSwitchMode_t rfswitch_table[] = {
2020
VolatileRTCClock rtc_clock;
2121
WIOE5SensorManager sensors;
2222

23+
#ifdef DISPLAY_CLASS
24+
NullDisplayDriver display;
25+
#endif
26+
2327
#ifndef LORA_CR
2428
#define LORA_CR 5
2529
#endif

variants/wio-e5-mini/target.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,38 @@
77
#include <helpers/CustomSTM32WLxWrapper.h>
88
#include <helpers/ArduinoHelpers.h>
99
#include <helpers/SensorManager.h>
10+
#ifdef DISPLAY_CLASS
11+
#include "NullDisplayDriver.h"
12+
#endif
1013

1114
#include <BME280I2C.h>
1215
#include <Wire.h>
1316

17+
#ifdef DISPLAY_CLASS
18+
extern NullDisplayDriver display;
19+
#endif
20+
1421
class WIOE5Board : public STM32Board {
1522
public:
23+
void begin() override {
24+
STM32Board::begin();
25+
26+
pinMode(LED_RED, OUTPUT);
27+
digitalWrite(LED_RED, HIGH);
28+
pinMode(USER_BTN, INPUT_PULLUP);
29+
}
30+
1631
const char* getManufacturerName() const override {
1732
return "Seeed Wio E5 mini";
1833
}
1934

2035
uint16_t getBattMilliVolts() override {
2136
analogReadResolution(12);
22-
uint32_t raw = analogRead(PIN_A3);
23-
return raw;
37+
uint32_t raw = 0;
38+
for (int i=0; i<8;i++) {
39+
raw += analogRead(PIN_A3);
40+
}
41+
return ((double)raw) * 1.73 * 5 * 1000 / 8 / 4096;
2442
}
2543
};
2644

0 commit comments

Comments
 (0)