mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
Merge pull request #1122 from fschrempf/xiao-nrf-ui-and-power-optimizations
Companion Power Optimizations and UI Support for XIAO NRF52
This commit is contained in:
commit
c17bd5d6fc
14 changed files with 64 additions and 7 deletions
|
|
@ -618,7 +618,7 @@ void UITask::userLedHandler() {
|
|||
led_state = 0;
|
||||
next_led_change = cur_time + LED_CYCLE_MILLIS - last_led_increment;
|
||||
}
|
||||
digitalWrite(PIN_STATUS_LED, led_state);
|
||||
digitalWrite(PIN_STATUS_LED, led_state == LED_STATE_ON);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -650,6 +650,7 @@ void UITask::shutdown(bool restart){
|
|||
_board->reboot();
|
||||
} else {
|
||||
_display->turnOff();
|
||||
radio_driver.powerOff();
|
||||
_board->powerOff();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -269,7 +269,7 @@ void UITask::userLedHandler() {
|
|||
state = 0;
|
||||
next_change = cur_time + LED_CYCLE_MILLIS - last_increment;
|
||||
}
|
||||
digitalWrite(PIN_STATUS_LED, state);
|
||||
digitalWrite(PIN_STATUS_LED, state == LED_STATE_ON);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -292,10 +292,12 @@ void UITask::shutdown(bool restart){
|
|||
|
||||
#endif // PIN_BUZZER
|
||||
|
||||
if (restart)
|
||||
if (restart) {
|
||||
_board->reboot();
|
||||
else
|
||||
} else {
|
||||
radio_driver.powerOff();
|
||||
_board->powerOff();
|
||||
}
|
||||
}
|
||||
|
||||
void UITask::loop() {
|
||||
|
|
|
|||
|
|
@ -19,4 +19,7 @@ public:
|
|||
int sf = ((CustomSX1262 *)_radio)->spreadingFactor;
|
||||
return packetScoreInt(snr, sf, packet_len);
|
||||
}
|
||||
virtual void powerOff() override {
|
||||
((CustomSX1262 *)_radio)->sleep(false);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public:
|
|||
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board) : _radio(&radio), _board(&board) { n_recv = n_sent = 0; }
|
||||
|
||||
void begin() override;
|
||||
virtual void powerOff() { _radio->sleep(); }
|
||||
int recvRaw(uint8_t* bytes, int sz) override;
|
||||
uint32_t getEstAirtimeFor(int len_bytes) override;
|
||||
bool startSendRaw(const uint8_t* bytes, int len) override;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
|||
void T114Board::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
NRF_POWER->DCDCEN = 1;
|
||||
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,13 @@ public:
|
|||
}
|
||||
|
||||
void powerOff() override {
|
||||
#ifdef LED_PIN
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
#endif
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
pinMode(GPS_EN, OUTPUT);
|
||||
digitalWrite(GPS_EN, LOW);
|
||||
#endif
|
||||
sd_power_system_off();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
|||
void RAKWismeshTagBoard::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
NRF_POWER->DCDCEN = 1;
|
||||
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
pinMode(PIN_USER_BTN, INPUT_PULLUP);
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@
|
|||
#define LED_BLUE (36)
|
||||
#define LED_GREEN (35)
|
||||
|
||||
//#define PIN_STATUS_LED LED_BLUE
|
||||
#define PIN_STATUS_LED LED_BLUE
|
||||
#define LED_BUILTIN LED_GREEN
|
||||
#define LED_PIN LED_GREEN
|
||||
#define LED_STATE_ON HIGH
|
||||
|
|
|
|||
|
|
@ -23,11 +23,16 @@ static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
|
|||
void XiaoNrf52Board::begin() {
|
||||
// for future use, sub-classes SHOULD call this from their begin()
|
||||
startup_reason = BD_STARTUP_NORMAL;
|
||||
NRF_POWER->DCDCEN = 1;
|
||||
|
||||
pinMode(PIN_VBAT, INPUT);
|
||||
pinMode(VBAT_ENABLE, OUTPUT);
|
||||
digitalWrite(VBAT_ENABLE, HIGH);
|
||||
|
||||
#ifdef PIN_USER_BTN
|
||||
pinMode(PIN_USER_BTN, INPUT);
|
||||
#endif
|
||||
|
||||
#if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
|
||||
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -46,6 +46,24 @@ public:
|
|||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
// set led on and wait for button release before poweroff
|
||||
digitalWrite(PIN_LED, LOW);
|
||||
#ifdef PIN_USER_BTN
|
||||
while(digitalRead(PIN_USER_BTN) == LOW);
|
||||
#endif
|
||||
digitalWrite(LED_GREEN, HIGH);
|
||||
digitalWrite(LED_BLUE, HIGH);
|
||||
digitalWrite(PIN_LED, HIGH);
|
||||
|
||||
#ifdef PIN_USER_BTN
|
||||
// configure button press to wake up when in powered off state
|
||||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(g_ADigitalPinMap[PIN_USER_BTN]), NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
|
||||
#endif
|
||||
|
||||
sd_power_system_off();
|
||||
}
|
||||
|
||||
bool startOTAUpdate(const char* id, char reply[]) override;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -26,10 +26,13 @@ build_flags = ${nrf52_base.build_flags}
|
|||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D PIN_WIRE_SCL=D6
|
||||
-D PIN_WIRE_SDA=D7
|
||||
-D PIN_USER_BTN=PIN_BUTTON1
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/sensors>
|
||||
+<../variants/xiao_nrf52>
|
||||
+<helpers/ui/NullDisplayDriver.cpp>
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
lib_deps = ${nrf52_base.lib_deps}
|
||||
|
|
@ -41,6 +44,7 @@ board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
|
|||
board_upload.maximum_size = 708608
|
||||
build_flags =
|
||||
${Xiao_nrf52.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
|
|
@ -52,6 +56,7 @@ build_flags =
|
|||
build_src_filter = ${Xiao_nrf52.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps =
|
||||
${Xiao_nrf52.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
|
@ -62,6 +67,7 @@ board_build.ldscript = boards/nrf52840_s140_v7_extrafs.ld
|
|||
board_upload.maximum_size = 708608
|
||||
build_flags =
|
||||
${Xiao_nrf52.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D QSPIFLASH=1
|
||||
|
|
@ -70,6 +76,7 @@ build_flags =
|
|||
build_src_filter = ${Xiao_nrf52.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps =
|
||||
${Xiao_nrf52.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
#include "target.h"
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
XiaoNrf52Board board;
|
||||
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,11 @@
|
|||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/NullDisplayDriver.h>
|
||||
extern DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
extern XiaoNrf52Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
|
|
|
|||
|
|
@ -34,11 +34,12 @@ extern "C"
|
|||
#define LED_RED (11)
|
||||
#define LED_GREEN (13)
|
||||
#define LED_BLUE (12)
|
||||
#define PIN_STATUS_LED (LED_BLUE)
|
||||
|
||||
#define LED_STATE_ON (1) // State when LED is litted
|
||||
#define LED_STATE_ON (0) // State when LED is on
|
||||
|
||||
// Buttons
|
||||
#define PIN_BUTTON1 (PINS_COUNT)
|
||||
#define PIN_BUTTON1 (0)
|
||||
|
||||
// Digital PINs
|
||||
static const uint8_t D0 = 0 ;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue