mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-09-14 15:16:40 +00:00
Merge remote-tracking branch 'upstream/dev' into rak-ethernet
# Conflicts: # examples/companion_radio/main.cpp
This commit is contained in:
@@ -47,7 +47,7 @@ public:
|
||||
uint32_t button_pin = PIN_BUTTON1;
|
||||
nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
|
||||
nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
uint32_t button_pin = PIN_BUTTON1;
|
||||
nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
|
||||
nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
uint32_t button_pin = PIN_BUTTON1;
|
||||
nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
|
||||
nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -38,7 +38,7 @@ public:
|
||||
uint32_t button_pin = PIN_BUTTON1;
|
||||
nrf_gpio_cfg_input(button_pin, NRF_GPIO_PIN_PULLUP);
|
||||
nrf_gpio_cfg_sense_set(button_pin, NRF_GPIO_PIN_SENSE_LOW);
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -20,33 +20,6 @@ void HeltecE213Board::begin() {
|
||||
}
|
||||
}
|
||||
|
||||
void HeltecE213Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
void HeltecE213Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t HeltecE213Board::getBattMilliVolts() {
|
||||
analogReadResolution(10);
|
||||
digitalWrite(PIN_ADC_CTRL, HIGH);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
class HeltecE213Board : public ESP32Board {
|
||||
|
||||
@@ -13,8 +12,6 @@ public:
|
||||
HeltecE213Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
|
||||
|
||||
void begin();
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override ;
|
||||
};
|
||||
|
||||
@@ -20,33 +20,6 @@ void HeltecE290Board::begin() {
|
||||
}
|
||||
}
|
||||
|
||||
void HeltecE290Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
void HeltecE290Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t HeltecE290Board::getBattMilliVolts() {
|
||||
analogReadResolution(10);
|
||||
digitalWrite(PIN_ADC_CTRL, HIGH);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
class HeltecE290Board : public ESP32Board {
|
||||
|
||||
@@ -13,8 +12,6 @@ public:
|
||||
HeltecE290Board() : periph_power(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE) { }
|
||||
|
||||
void begin();
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override ;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[Heltec_mesh_solar]
|
||||
extends = nrf52_base
|
||||
board = heltec_mesh_solar
|
||||
platform_packages = framework-arduinoadafruitnrf52
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I src/helpers/nrf52
|
||||
@@ -14,6 +13,11 @@ build_flags = ${nrf52_base.build_flags}
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D HAS_EXTERNAL_WATCHDOG
|
||||
-D EXTERNAL_WATCHDOG_DONE_PIN=9
|
||||
-D EXTERNAL_WATCHDOG_WAKE_PIN=10
|
||||
-D EXTERNAL_WATCHDOG_FEED_INTERVAL_MS=480000 ; 8 minute feed interval, safely inside the hardware watchdog timeout
|
||||
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<../variants/heltec_mesh_solar>
|
||||
|
||||
@@ -13,6 +13,7 @@ VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||
SolarSensorManager sensors = SolarSensorManager(nmea);
|
||||
SolarExternalWatchdog external_watchdog;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
@@ -106,3 +107,34 @@ bool SolarSensorManager::setSettingValue(const char* name, const char* value) {
|
||||
}
|
||||
return false; // not supported
|
||||
}
|
||||
|
||||
bool SolarExternalWatchdog::begin() {
|
||||
last_feed_watchdog = 0;
|
||||
pinMode(EXTERNAL_WATCHDOG_WAKE_PIN, INPUT);
|
||||
pinMode(EXTERNAL_WATCHDOG_DONE_PIN, OUTPUT);
|
||||
delay(1);
|
||||
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
|
||||
delay(1);
|
||||
feed();
|
||||
return true;
|
||||
}
|
||||
void SolarExternalWatchdog::loop() {
|
||||
if (millis() - last_feed_watchdog >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
|
||||
feed();
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long SolarExternalWatchdog::getIntervalMs() const {
|
||||
unsigned long elapsed_ms = millis() - last_feed_watchdog;
|
||||
if (elapsed_ms >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
|
||||
return 0;
|
||||
}
|
||||
return EXTERNAL_WATCHDOG_FEED_INTERVAL_MS - elapsed_ms;
|
||||
}
|
||||
|
||||
void SolarExternalWatchdog::feed() {
|
||||
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, HIGH);
|
||||
delay(1);
|
||||
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
|
||||
last_feed_watchdog = millis();
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#include <helpers/ExternalWatchdogManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/ST7789Display.h>
|
||||
#endif
|
||||
@@ -30,10 +31,20 @@ public:
|
||||
bool setSettingValue(const char* name, const char* value) override;
|
||||
};
|
||||
|
||||
class SolarExternalWatchdog : public ExternalWatchdogManager {
|
||||
public:
|
||||
SolarExternalWatchdog() {}
|
||||
bool begin() override;
|
||||
void loop() override;
|
||||
unsigned long getIntervalMs() const override;
|
||||
void feed() override;
|
||||
};
|
||||
|
||||
extern MeshSolarBoard board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SolarSensorManager sensors;
|
||||
extern SolarExternalWatchdog external_watchdog;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
#define PIN_SERIAL1_RX (37)
|
||||
#define PIN_SERIAL1_TX (39)
|
||||
|
||||
#define PIN_SERIAL2_RX (9)
|
||||
#define PIN_SERIAL2_TX (10)
|
||||
#define PIN_SERIAL2_RX (-1)
|
||||
#define PIN_SERIAL2_TX (-1)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// I2C pin definition
|
||||
|
||||
@@ -112,13 +112,9 @@ void T096Board::variant_shutdown() {
|
||||
}
|
||||
|
||||
void T096Board::powerOff() {
|
||||
#if ENV_INCLUDE_GPS == 1
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
|
||||
#endif
|
||||
loRaFEMControl.setSleepModeEnable();
|
||||
variant_shutdown();
|
||||
sd_power_system_off();
|
||||
loRaFEMControl.setSleepModeEnable();
|
||||
nrf_gpio_cfg_default(PIN_GPS_EN); // 363uA down to 39uA
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
|
||||
const char* T096Board::getManufacturerName() const {
|
||||
|
||||
@@ -51,7 +51,7 @@ build_src_filter = ${nrf52_base.build_src_filter}
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
${sensor_base.lib_deps}
|
||||
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
|
||||
bodmer/TFT_eSPI @ ^2.4.31
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
|
||||
@@ -81,34 +81,6 @@ uint16_t T1Board::getBattMilliVolts() {
|
||||
}
|
||||
|
||||
void T1Board::variant_shutdown() {
|
||||
nrf_gpio_cfg_default(PIN_TFT_CS);
|
||||
nrf_gpio_cfg_default(PIN_TFT_DC);
|
||||
nrf_gpio_cfg_default(PIN_TFT_SDA);
|
||||
nrf_gpio_cfg_default(PIN_TFT_SCL);
|
||||
nrf_gpio_cfg_default(PIN_TFT_RST);
|
||||
nrf_gpio_cfg_default(PIN_TFT_LEDA_CTL);
|
||||
nrf_gpio_cfg_default(PIN_TFT_VDD_CTL);
|
||||
|
||||
nrf_gpio_cfg_default(PIN_WIRE_SDA);
|
||||
nrf_gpio_cfg_default(PIN_WIRE_SCL);
|
||||
|
||||
nrf_gpio_cfg_default(LORA_CS);
|
||||
nrf_gpio_cfg_default(SX126X_DIO1);
|
||||
nrf_gpio_cfg_default(SX126X_BUSY);
|
||||
nrf_gpio_cfg_default(SX126X_RESET);
|
||||
nrf_gpio_cfg_default(PIN_SPI_MISO);
|
||||
nrf_gpio_cfg_default(PIN_SPI_MOSI);
|
||||
nrf_gpio_cfg_default(PIN_SPI_SCK);
|
||||
|
||||
nrf_gpio_cfg_default(PIN_SPI1_MOSI);
|
||||
nrf_gpio_cfg_default(PIN_SPI1_SCK);
|
||||
|
||||
nrf_gpio_cfg_default(PIN_GPS_RESET);
|
||||
nrf_gpio_cfg_default(PIN_GPS_EN);
|
||||
nrf_gpio_cfg_default(PIN_GPS_PPS);
|
||||
nrf_gpio_cfg_default(PIN_GPS_RX);
|
||||
nrf_gpio_cfg_default(PIN_GPS_TX);
|
||||
|
||||
nrf_gpio_cfg_default(PIN_BUZZER_VOLTAGE_MULTIPLIER_1);
|
||||
nrf_gpio_cfg_default(PIN_BUZZER_VOLTAGE_MULTIPLIER_2);
|
||||
|
||||
@@ -127,7 +99,7 @@ void T1Board::variant_shutdown() {
|
||||
|
||||
void T1Board::powerOff() {
|
||||
variant_shutdown();
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
|
||||
const char* T1Board::getManufacturerName() const {
|
||||
|
||||
@@ -33,7 +33,7 @@ void T114Board::initiateShutdown(uint8_t reason) {
|
||||
#endif // NRF52_POWER_MANAGEMENT
|
||||
|
||||
void T114Board::begin() {
|
||||
NRF52Board::begin();
|
||||
NRF52BoardDCDC::begin();
|
||||
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
|
||||
|
||||
@@ -50,10 +50,7 @@ public:
|
||||
#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();
|
||||
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1);
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||
#else
|
||||
EnvironmentSensorManager sensors;
|
||||
|
||||
@@ -20,33 +20,6 @@ void HeltecT190Board::begin() {
|
||||
}
|
||||
}
|
||||
|
||||
void HeltecT190Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
void HeltecT190Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t HeltecT190Board::getBattMilliVolts() {
|
||||
analogReadResolution(10);
|
||||
digitalWrite(PIN_ADC_CTRL, HIGH);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
class HeltecT190Board : public ESP32Board {
|
||||
|
||||
@@ -13,8 +12,6 @@ public:
|
||||
HeltecT190Board() : periph_power(PIN_VEXT_EN,PIN_VEXT_EN_ACTIVE) { }
|
||||
|
||||
void begin();
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override ;
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
#include "HeltecTowerV2Board.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
|
||||
extern void variant_shutdown();
|
||||
|
||||
#ifdef NRF52_POWER_MANAGEMENT
|
||||
const PowerMgtConfig power_config = {
|
||||
.lpcomp_ain_channel = PWRMGT_LPCOMP_AIN,
|
||||
.lpcomp_refsel = PWRMGT_LPCOMP_REFSEL,
|
||||
.voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK
|
||||
};
|
||||
|
||||
void HeltecTowerV2Board::initiateShutdown(uint8_t reason) {
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
|
||||
pinMode(PIN_GPS_STANDBY, OUTPUT);
|
||||
digitalWrite(PIN_GPS_STANDBY, LOW);
|
||||
pinMode(PIN_GPS_RESET, OUTPUT);
|
||||
digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE);
|
||||
loRaFEMControl.setSleepModeEnable();
|
||||
|
||||
bool enable_lpcomp = (reason == SHUTDOWN_REASON_LOW_VOLTAGE ||
|
||||
reason == SHUTDOWN_REASON_BOOT_PROTECT);
|
||||
pinMode(PIN_BAT_CTL, OUTPUT);
|
||||
digitalWrite(PIN_BAT_CTL, enable_lpcomp ? HIGH : LOW);
|
||||
|
||||
if (enable_lpcomp) {
|
||||
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel);
|
||||
}
|
||||
|
||||
variant_shutdown();
|
||||
enterSystemOff(reason);
|
||||
}
|
||||
#endif
|
||||
|
||||
void HeltecTowerV2Board::begin() {
|
||||
NRF52Board::begin();
|
||||
|
||||
pinMode(P_LORA_TX_LED, OUTPUT);
|
||||
digitalWrite(P_LORA_TX_LED, !LED_STATE_ON);
|
||||
|
||||
pinMode(PIN_BAT_CTL, OUTPUT);
|
||||
digitalWrite(PIN_BAT_CTL, LOW);
|
||||
|
||||
#ifdef NRF52_POWER_MANAGEMENT
|
||||
checkBootVoltage(&power_config);
|
||||
#endif
|
||||
|
||||
Wire.setPins(PIN_BOARD_SDA, PIN_BOARD_SCL);
|
||||
Wire.begin();
|
||||
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
|
||||
pinMode(PIN_GPS_RESET, OUTPUT);
|
||||
digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE);
|
||||
pinMode(PIN_GPS_STANDBY, OUTPUT);
|
||||
digitalWrite(PIN_GPS_STANDBY, HIGH);
|
||||
loRaFEMControl.init();
|
||||
}
|
||||
|
||||
void HeltecTowerV2Board::onBeforeTransmit() {
|
||||
digitalWrite(P_LORA_TX_LED, LED_STATE_ON);
|
||||
loRaFEMControl.setTxModeEnable();
|
||||
}
|
||||
|
||||
void HeltecTowerV2Board::onAfterTransmit() {
|
||||
digitalWrite(P_LORA_TX_LED, !LED_STATE_ON);
|
||||
loRaFEMControl.setRxModeEnable();
|
||||
}
|
||||
|
||||
uint16_t HeltecTowerV2Board::getBattMilliVolts() {
|
||||
analogReadResolution(12);
|
||||
analogReference(VBAT_AR_INTERNAL);
|
||||
pinMode(PIN_VBAT_READ, INPUT);
|
||||
pinMode(PIN_BAT_CTL, OUTPUT);
|
||||
digitalWrite(PIN_BAT_CTL, HIGH);
|
||||
|
||||
delay(10);
|
||||
int adcvalue = analogRead(PIN_VBAT_READ);
|
||||
digitalWrite(PIN_BAT_CTL, LOW);
|
||||
|
||||
return (uint16_t)((float)adcvalue * MV_LSB * ADC_MULTIPLIER);
|
||||
}
|
||||
|
||||
const char* HeltecTowerV2Board::getManufacturerName() const {
|
||||
return "Heltec Tower V2";
|
||||
}
|
||||
|
||||
void HeltecTowerV2Board::powerOff() {
|
||||
pinMode(PIN_GPS_EN, OUTPUT);
|
||||
digitalWrite(PIN_GPS_EN, !PIN_GPS_EN_ACTIVE);
|
||||
pinMode(PIN_GPS_STANDBY, OUTPUT);
|
||||
digitalWrite(PIN_GPS_STANDBY, LOW);
|
||||
pinMode(PIN_GPS_RESET, OUTPUT);
|
||||
digitalWrite(PIN_GPS_RESET, GPS_RESET_MODE);
|
||||
loRaFEMControl.setSleepModeEnable();
|
||||
pinMode(PIN_BAT_CTL, OUTPUT);
|
||||
digitalWrite(PIN_BAT_CTL, LOW);
|
||||
variant_shutdown();
|
||||
sd_power_system_off();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <MeshCore.h>
|
||||
#include <helpers/NRF52Board.h>
|
||||
#include "LoRaFEMControl.h"
|
||||
|
||||
class HeltecTowerV2Board : public NRF52BoardDCDC {
|
||||
protected:
|
||||
#ifdef NRF52_POWER_MANAGEMENT
|
||||
void initiateShutdown(uint8_t reason) override;
|
||||
#endif
|
||||
|
||||
public:
|
||||
LoRaFEMControl loRaFEMControl;
|
||||
|
||||
HeltecTowerV2Board() : NRF52Board("TOWER_V2_OTA") {}
|
||||
void begin();
|
||||
void onBeforeTransmit() override;
|
||||
void onAfterTransmit() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override;
|
||||
void powerOff() override;
|
||||
};
|
||||
@@ -0,0 +1,40 @@
|
||||
#include "LoRaFEMControl.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "variant.h"
|
||||
|
||||
static void enableFEMPower() {
|
||||
bool wasOff = digitalRead(LORA_KCT8103L_EN) != HIGH;
|
||||
digitalWrite(LORA_KCT8103L_EN, HIGH);
|
||||
if (wasOff) {
|
||||
delay(5);
|
||||
}
|
||||
}
|
||||
|
||||
void LoRaFEMControl::init() {
|
||||
pinMode(LORA_KCT8103L_EN, OUTPUT);
|
||||
digitalWrite(LORA_KCT8103L_EN, HIGH);
|
||||
delay(1);
|
||||
pinMode(LORA_KCT8103L_TX_RX, OUTPUT);
|
||||
digitalWrite(LORA_KCT8103L_TX_RX, LOW);
|
||||
}
|
||||
|
||||
void LoRaFEMControl::setSleepModeEnable() {
|
||||
pinMode(LORA_KCT8103L_EN, OUTPUT);
|
||||
digitalWrite(LORA_KCT8103L_EN, LOW);
|
||||
}
|
||||
|
||||
void LoRaFEMControl::setTxModeEnable() {
|
||||
enableFEMPower();
|
||||
digitalWrite(LORA_KCT8103L_TX_RX, HIGH);
|
||||
}
|
||||
|
||||
void LoRaFEMControl::setRxModeEnable() {
|
||||
enableFEMPower();
|
||||
digitalWrite(LORA_KCT8103L_TX_RX, LOW);
|
||||
}
|
||||
|
||||
void LoRaFEMControl::setRxModeEnableWhenMCUSleep() {
|
||||
enableFEMPower();
|
||||
digitalWrite(LORA_KCT8103L_TX_RX, LOW);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
class LoRaFEMControl {
|
||||
public:
|
||||
LoRaFEMControl() {}
|
||||
virtual ~LoRaFEMControl() {}
|
||||
|
||||
void init();
|
||||
void setSleepModeEnable();
|
||||
void setTxModeEnable();
|
||||
void setRxModeEnable();
|
||||
void setRxModeEnableWhenMCUSleep();
|
||||
};
|
||||
@@ -0,0 +1,104 @@
|
||||
[Heltec_tower_v2]
|
||||
extends = nrf52_base
|
||||
board = heltec_tower_v2
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include
|
||||
-I lib/nrf52/s140_nrf52_6.1.1_API/include/nrf52
|
||||
-I variants/heltec_tower_v2
|
||||
-D HELTEC_TOWER_V2
|
||||
-D NRF52_POWER_MANAGEMENT
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=12
|
||||
-D MAX_LORA_TX_POWER=22 ; Max SX1262 output -> ~29dBm at antenna
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
build_src_filter = ${nrf52_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/sensors>
|
||||
+<../variants/heltec_tower_v2>
|
||||
lib_deps =
|
||||
${nrf52_base.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
[env:Heltec_tower_v2_repeater]
|
||||
extends = Heltec_tower_v2
|
||||
build_src_filter = ${Heltec_tower_v2.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
build_flags =
|
||||
${Heltec_tower_v2.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_Tower_V2 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=50
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
||||
[env:Heltec_tower_v2_room_server]
|
||||
extends = Heltec_tower_v2
|
||||
build_src_filter = ${Heltec_tower_v2.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
build_flags =
|
||||
${Heltec_tower_v2.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_Tower_V2 Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
|
||||
[env:Heltec_tower_v2_companion_radio_ble]
|
||||
extends = Heltec_tower_v2
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${Heltec_tower_v2.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Heltec_tower_v2.build_src_filter}
|
||||
+<helpers/nrf52/SerialBLEInterface.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_tower_v2.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_tower_v2_companion_radio_usb]
|
||||
extends = Heltec_tower_v2
|
||||
board_build.ldscript = boards/nrf52840_s140_v6_extrafs.ld
|
||||
board_upload.maximum_size = 712704
|
||||
build_flags =
|
||||
${Heltec_tower_v2.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
; -D BLE_PIN_CODE=123456
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${Heltec_tower_v2.build_src_filter}
|
||||
+<helpers/nrf52/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${Heltec_tower_v2.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:Heltec_tower_v2_kiss_modem]
|
||||
extends = Heltec_tower_v2
|
||||
build_src_filter = ${Heltec_tower_v2.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
@@ -0,0 +1,64 @@
|
||||
#include "target.h"
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <helpers/ArduinoHelpers.h>
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
HeltecTowerV2Board board;
|
||||
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
VolatileRTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||
TowerV2ExternalWatchdog external_watchdog;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
rtc_clock.begin(Wire);
|
||||
return radio.std_init(&SPI);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng);
|
||||
}
|
||||
|
||||
bool TowerV2ExternalWatchdog::begin() {
|
||||
last_feed_watchdog = 0;
|
||||
pinMode(EXTERNAL_WATCHDOG_WAKE_PIN, INPUT);
|
||||
pinMode(EXTERNAL_WATCHDOG_DONE_PIN, OUTPUT);
|
||||
delay(1);
|
||||
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
|
||||
delay(1);
|
||||
feed();
|
||||
return true;
|
||||
}
|
||||
|
||||
void TowerV2ExternalWatchdog::loop() {
|
||||
if (millis() - last_feed_watchdog >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
|
||||
feed();
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long TowerV2ExternalWatchdog::getIntervalMs() const {
|
||||
unsigned long elapsed_ms = millis() - last_feed_watchdog;
|
||||
if (elapsed_ms >= EXTERNAL_WATCHDOG_FEED_INTERVAL_MS) {
|
||||
return 0;
|
||||
}
|
||||
return EXTERNAL_WATCHDOG_FEED_INTERVAL_MS - elapsed_ms;
|
||||
}
|
||||
|
||||
void TowerV2ExternalWatchdog::feed() {
|
||||
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, HIGH);
|
||||
delay(1);
|
||||
digitalWrite(EXTERNAL_WATCHDOG_DONE_PIN, LOW);
|
||||
last_feed_watchdog = millis();
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <HeltecTowerV2Board.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#include <helpers/ExternalWatchdogManager.h>
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#include "helpers/ui/NullDisplayDriver.h"
|
||||
#endif
|
||||
|
||||
class TowerV2ExternalWatchdog : public ExternalWatchdogManager {
|
||||
public:
|
||||
TowerV2ExternalWatchdog() {}
|
||||
bool begin() override;
|
||||
void loop() override;
|
||||
unsigned long getIntervalMs() const override;
|
||||
void feed() override;
|
||||
};
|
||||
|
||||
extern HeltecTowerV2Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
extern TowerV2ExternalWatchdog external_watchdog;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
@@ -0,0 +1,42 @@
|
||||
#include "variant.h"
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "nrf.h"
|
||||
#include "wiring_constants.h"
|
||||
#include "wiring_digital.h"
|
||||
|
||||
const uint32_t g_ADigitalPinMap[] = {
|
||||
0xff, 0xff, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
|
||||
14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
|
||||
27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39,
|
||||
40, 41, 42, 43, 44, 45, 46, 47
|
||||
};
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void variant_shutdown()
|
||||
{
|
||||
nrf_gpio_cfg_default(PIN_GPS_EN);
|
||||
nrf_gpio_cfg_default(PIN_GPS_PPS);
|
||||
nrf_gpio_cfg_default(PIN_GPS_RESET);
|
||||
nrf_gpio_cfg_default(PIN_GPS_STANDBY);
|
||||
nrf_gpio_cfg_default(GPS_RX_PIN);
|
||||
nrf_gpio_cfg_default(GPS_TX_PIN);
|
||||
pinMode(LORA_KCT8103L_EN, OUTPUT);
|
||||
digitalWrite(LORA_KCT8103L_EN, LOW);
|
||||
nrf_gpio_cfg_default(LORA_KCT8103L_TX_RX);
|
||||
nrf_gpio_cfg_default(RF_PA_DETECT_PIN);
|
||||
nrf_gpio_cfg_default(SX126X_CS);
|
||||
nrf_gpio_cfg_default(SX126X_DIO1);
|
||||
nrf_gpio_cfg_default(SX126X_BUSY);
|
||||
nrf_gpio_cfg_default(SX126X_RESET);
|
||||
nrf_gpio_cfg_default(PIN_SPI_MISO);
|
||||
nrf_gpio_cfg_default(PIN_SPI_MOSI);
|
||||
nrf_gpio_cfg_default(PIN_SPI_SCK);
|
||||
nrf_gpio_cfg_default(PIN_LED);
|
||||
detachInterrupt(PIN_GPS_PPS);
|
||||
detachInterrupt(PIN_BUTTON1);
|
||||
}
|
||||
@@ -0,0 +1,108 @@
|
||||
#pragma once
|
||||
|
||||
#include "WVariant.h"
|
||||
|
||||
#define USE_LFXO
|
||||
#define VARIANT_MCK (64000000ul)
|
||||
|
||||
#define PINS_COUNT (48)
|
||||
#define NUM_DIGITAL_PINS (48)
|
||||
#define NUM_ANALOG_INPUTS (1)
|
||||
#define NUM_ANALOG_OUTPUTS (0)
|
||||
|
||||
#define WIRE_INTERFACES_COUNT (1)
|
||||
#define PIN_WIRE_SDA (0 + 30)
|
||||
#define PIN_WIRE_SCL (0 + 5)
|
||||
#define PIN_BOARD_SDA PIN_WIRE_SDA
|
||||
#define PIN_BOARD_SCL PIN_WIRE_SCL
|
||||
|
||||
#define SPI_INTERFACES_COUNT (1)
|
||||
#define PIN_SPI_MISO (0 + 23)
|
||||
#define PIN_SPI_MOSI (0 + 22)
|
||||
#define PIN_SPI_SCK (0 + 19)
|
||||
#define PIN_SPI_NSS LORA_CS
|
||||
|
||||
#define LED_BUILTIN (32 + 15)
|
||||
#define PIN_LED LED_BUILTIN
|
||||
#define LED_RED (-1)
|
||||
#define LED_GREEN (-1)
|
||||
#define LED_BLUE (-1)
|
||||
#define LED_PIN (-1)
|
||||
#define P_LORA_TX_LED LED_BUILTIN
|
||||
#define LED_STATE_ON LOW
|
||||
|
||||
#define PIN_BUTTON1 (32 + 10)
|
||||
#define BUTTON_PIN PIN_BUTTON1
|
||||
#define PIN_USER_BTN BUTTON_PIN
|
||||
|
||||
#define USE_SX1262
|
||||
#define SX126X_CS (0 + 24)
|
||||
#define LORA_CS SX126X_CS
|
||||
#define SX126X_DIO1 (0 + 20)
|
||||
#define SX126X_BUSY (0 + 17)
|
||||
#define SX126X_RESET (0 + 25)
|
||||
#define SX126X_DIO2_AS_RF_SWITCH
|
||||
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
||||
|
||||
#define P_LORA_NSS LORA_CS
|
||||
#define P_LORA_DIO_1 SX126X_DIO1
|
||||
#define P_LORA_BUSY SX126X_BUSY
|
||||
#define P_LORA_RESET SX126X_RESET
|
||||
#define P_LORA_MISO PIN_SPI_MISO
|
||||
#define P_LORA_MOSI PIN_SPI_MOSI
|
||||
#define P_LORA_SCLK PIN_SPI_SCK
|
||||
|
||||
#define USE_KCT8103L_PA_ONLY
|
||||
#define LORA_KCT8103L_EN (0 + 15)
|
||||
#define LORA_KCT8103L_TX_RX (0 + 16)
|
||||
#define LORA_PA_POWER LORA_KCT8103L_EN
|
||||
#define RF_PA_DETECT_PIN (0 + 13)
|
||||
#define RF_PA_HIGH_POWER_VALUE HIGH
|
||||
|
||||
#define GPS_L76K
|
||||
#define GPS_RESET_MODE LOW
|
||||
#define PIN_GPS_RESET (32 + 6)
|
||||
#define PIN_GPS_RESET_ACTIVE GPS_RESET_MODE
|
||||
#define PIN_GPS_EN (0 + 7)
|
||||
#define PIN_GPS_EN_ACTIVE LOW
|
||||
#define GPS_EN_ACTIVE PIN_GPS_EN_ACTIVE
|
||||
#define PIN_GPS_STANDBY (32 + 2)
|
||||
#define PIN_GPS_PPS (32 + 4)
|
||||
#define GPS_BAUD_RATE 9600
|
||||
|
||||
// Upstream names are from the GPS perspective. MeshCore's PIN_GPS_TX is the
|
||||
// CPU RX pin because EnvironmentSensorManager passes it as Serial1 RX.
|
||||
#define GPS_TX_PIN (32 + 7)
|
||||
#define GPS_RX_PIN (32 + 5)
|
||||
#define PIN_GPS_TX GPS_RX_PIN
|
||||
#define PIN_GPS_RX GPS_TX_PIN
|
||||
|
||||
#define PIN_SERIAL1_RX PIN_GPS_TX
|
||||
#define PIN_SERIAL1_TX PIN_GPS_RX
|
||||
#define PIN_SERIAL2_RX (-1)
|
||||
#define PIN_SERIAL2_TX (-1)
|
||||
|
||||
#define HAS_EXTERNAL_WATCHDOG
|
||||
#define EXTERNAL_WATCHDOG_DONE_PIN (0 + 9)
|
||||
#define EXTERNAL_WATCHDOG_WAKE_PIN (0 + 10)
|
||||
#define EXTERNAL_WATCHDOG_FEED_INTERVAL_MS (8 * 60 * 1000)
|
||||
|
||||
#define SERIAL_PRINT_PORT 0
|
||||
|
||||
#define PIN_BAT_CTL (0 + 21)
|
||||
#define ADC_CTRL PIN_BAT_CTL
|
||||
#define ADC_CTRL_ENABLED HIGH
|
||||
#define BATTERY_PIN (0 + 4)
|
||||
#define PIN_VBAT_READ BATTERY_PIN
|
||||
#define ADC_RESOLUTION 14
|
||||
#define BATTERY_SENSE_RESOLUTION_BITS 12
|
||||
#define BATTERY_SENSE_RESOLUTION 4096.0
|
||||
#define AREF_VOLTAGE 3.0
|
||||
#define VBAT_AR_INTERNAL AR_INTERNAL_3_0
|
||||
#define ADC_MULTIPLIER (4.916F)
|
||||
#define MV_LSB (3000.0F / 4096.0F)
|
||||
|
||||
#define NRF52_POWER_MANAGEMENT
|
||||
#define PWRMGT_VOLTAGE_BOOTLOCK 3100
|
||||
#define PWRMGT_LPCOMP_AIN 2
|
||||
#define PWRMGT_LPCOMP_REFSEL 1
|
||||
@@ -47,7 +47,7 @@ build_src_filter = ${esp32_base.build_src_filter}
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
|
||||
bodmer/TFT_eSPI @ ^2.4.31
|
||||
|
||||
[env:Heltec_Wireless_Tracker_companion_radio_usb]
|
||||
extends = Heltec_tracker_base
|
||||
|
||||
@@ -35,33 +35,12 @@ void HeltecTrackerV2Board::begin() {
|
||||
loRaFEMControl.setRxModeEnable();
|
||||
}
|
||||
|
||||
void HeltecTrackerV2Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
void HeltecTrackerV2Board::powerOff() {
|
||||
// Turn off PA
|
||||
digitalWrite(P_LORA_PA_POWER, LOW);
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
loRaFEMControl.setRxModeEnableWhenMCUSleep();//It also needs to be enabled in receive mode
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
void HeltecTrackerV2Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
ESP32Board::powerOff();
|
||||
}
|
||||
|
||||
uint16_t HeltecTrackerV2Board::getBattMilliVolts() {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
#include "LoRaFEMControl.h"
|
||||
|
||||
class HeltecTrackerV2Board : public ESP32Board {
|
||||
@@ -17,7 +16,6 @@ public:
|
||||
void begin();
|
||||
void onBeforeTransmit(void) override;
|
||||
void onAfterTransmit(void) override;
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override ;
|
||||
|
||||
@@ -55,7 +55,7 @@ build_src_filter = ${esp32_base.build_src_filter}
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
${sensor_base.lib_deps}
|
||||
adafruit/Adafruit ST7735 and ST7789 Library @ ^1.11.0
|
||||
bodmer/TFT_eSPI @ ^2.4.31
|
||||
|
||||
[env:heltec_tracker_v2_repeater]
|
||||
extends = Heltec_tracker_v2
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#define PIN_VBAT_READ 37
|
||||
#define PIN_LED_BUILTIN 25
|
||||
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
class HeltecV2Board : public ESP32Board {
|
||||
public:
|
||||
void begin() {
|
||||
@@ -26,29 +24,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_0, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_0);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_0), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_0) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
analogReadResolution(10);
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
#define PIN_ADC_CTRL_ACTIVE LOW
|
||||
#define PIN_ADC_CTRL_INACTIVE HIGH
|
||||
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
class HeltecV3Board : public ESP32Board {
|
||||
private:
|
||||
bool adc_active_state;
|
||||
@@ -52,33 +50,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
analogReadResolution(10);
|
||||
digitalWrite(PIN_ADC_CTRL, adc_active_state);
|
||||
|
||||
@@ -32,33 +32,12 @@ void HeltecV4Board::begin() {
|
||||
loRaFEMControl.setRxModeEnable();
|
||||
}
|
||||
|
||||
void HeltecV4Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
void HeltecV4Board::powerOff() {
|
||||
// Turn off PA
|
||||
digitalWrite(P_LORA_PA_POWER, LOW);
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_PA_POWER);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
loRaFEMControl.setRxModeEnableWhenMCUSleep();//It also needs to be enabled in receive mode
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
void HeltecV4Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
ESP32Board::powerOff();
|
||||
}
|
||||
|
||||
uint16_t HeltecV4Board::getBattMilliVolts() {
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
#include "LoRaFEMControl.h"
|
||||
|
||||
#ifndef ADC_MULTIPLIER
|
||||
@@ -23,7 +22,6 @@ public:
|
||||
void begin();
|
||||
void onBeforeTransmit(void) override;
|
||||
void onAfterTransmit(void) override;
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
bool setLoRaFemLnaEnabled(bool enable) override;
|
||||
bool canControlLoRaFemLna() const override;
|
||||
|
||||
@@ -37,8 +37,4 @@ public:
|
||||
digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
|
||||
}
|
||||
#endif
|
||||
|
||||
void powerOff() override {
|
||||
sd_power_system_off();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -21,8 +21,8 @@ build_flags =
|
||||
-D RADIO_CLASS=CustomSX1276
|
||||
-D WRAPPER_CLASS=CustomSX1276Wrapper
|
||||
-D SX127X_CURRENT_LIMIT=120
|
||||
-D SX176X_RXEN=21
|
||||
-D SX176X_TXEN=10
|
||||
-D SX127X_RXEN=21
|
||||
-D SX127X_TXEN=10
|
||||
-D LORA_TX_POWER=20
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/lilygo_t3s3_sx1276>
|
||||
|
||||
@@ -48,12 +48,10 @@ public:
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
// power off system
|
||||
NRF52Board::powerOff();
|
||||
|
||||
// turn off 3.3v
|
||||
digitalWrite(RT9080_EN, LOW);
|
||||
|
||||
// power off system
|
||||
sd_power_system_off();
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <Wire.h>
|
||||
#include <Arduino.h>
|
||||
#include "helpers/ESP32Board.h"
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
#define PIN_VBAT_READ 4
|
||||
#define BATTERY_SAMPLES 8
|
||||
@@ -23,29 +22,6 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
uint16_t getBattMilliVolts() {
|
||||
#if defined(PIN_VBAT_READ) && defined(ADC_MULTIPLIER)
|
||||
analogReadResolution(12);
|
||||
|
||||
@@ -24,6 +24,7 @@ public:
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
NRF52Board::powerOff();
|
||||
#ifdef LED_RED
|
||||
digitalWrite(LED_RED, HIGH);
|
||||
#endif
|
||||
@@ -39,6 +40,5 @@ public:
|
||||
#ifdef PIN_PWR_EN
|
||||
digitalWrite(PIN_PWR_EN, LOW);
|
||||
#endif
|
||||
sd_power_system_off();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -91,7 +91,7 @@ void TechoCardBoard::powerOff() {
|
||||
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
|
||||
turnOffLeds();
|
||||
digitalWrite(PIN_PWR_EN, LOW);
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#ifdef LILYGO_TECHO
|
||||
|
||||
void TechoBoard::begin() {
|
||||
NRF52Board::begin();
|
||||
NRF52BoardDCDC::begin();
|
||||
|
||||
// Configure battery measurement control BEFORE Wire.begin()
|
||||
// to ensure P0.02 is not claimed by another peripheral
|
||||
|
||||
@@ -22,6 +22,8 @@ public:
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
NRF52Board::powerOff();
|
||||
|
||||
digitalWrite(PIN_VBAT_MEAS_EN, LOW);
|
||||
#ifdef LED_RED
|
||||
digitalWrite(LED_RED, LOW);
|
||||
@@ -38,6 +40,5 @@ public:
|
||||
#ifdef PIN_PWR_EN
|
||||
digitalWrite(PIN_PWR_EN, LOW);
|
||||
#endif
|
||||
sd_power_system_off();
|
||||
}
|
||||
};
|
||||
@@ -15,6 +15,7 @@ build_flags = ${nrf52_base.build_flags}
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
-D SX126X_USE_REGULATOR_LDO=1
|
||||
-D P_LORA_TX_LED=LED_GREEN
|
||||
-D DISABLE_DIAGNOSTIC_OUTPUT
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
|
||||
@@ -32,8 +32,4 @@ public:
|
||||
const char* getManufacturerName() const override {
|
||||
return "Heltec MeshPocket";
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
sd_power_system_off();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
[Mesh_pocket]
|
||||
extends = nrf52_base
|
||||
board = heltec_mesh_pocket
|
||||
platform_packages = framework-arduinoadafruitnrf52
|
||||
board_build.ldscript = boards/nrf52840_s140_v6.ld
|
||||
build_flags = ${nrf52_base.build_flags}
|
||||
-I src/helpers/nrf52
|
||||
@@ -32,7 +31,6 @@ lib_deps =
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
zinggjm/GxEPD2 @ 1.6.2
|
||||
bakercp/CRC32 @ ^2.0.0
|
||||
|
||||
debug_tool = jlink
|
||||
upload_protocol = nrfutil
|
||||
|
||||
@@ -40,7 +38,6 @@ upload_protocol = nrfutil
|
||||
extends = Mesh_pocket
|
||||
build_src_filter = ${Mesh_pocket.build_src_filter}
|
||||
+<../examples/simple_repeater>
|
||||
|
||||
build_flags =
|
||||
${Mesh_pocket.build_flags}
|
||||
-D ADVERT_NAME='"Heltec_Mesh_Pocket Repeater"'
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
nrf_gpio_cfg_sense_input(g_ADigitalPinMap[PIN_USER_BTN], NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
|
||||
#endif
|
||||
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
#ifdef BUTTON_PIN
|
||||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
|
||||
#endif
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
|
||||
#if defined(P_LORA_TX_LED)
|
||||
|
||||
@@ -52,6 +52,6 @@ public:
|
||||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(PIN_USER_BTN), NRF_GPIO_PIN_NOPULL,
|
||||
NRF_GPIO_PIN_SENSE_LOW);
|
||||
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -34,7 +34,7 @@ lib_deps =
|
||||
adafruit/Adafruit SSD1306 @ ^2.5.13
|
||||
adafruit/Adafruit NeoPixel @ ^1.12.3
|
||||
|
||||
[env:nibble_screen_connect_repeater]
|
||||
[env:nibble_screen_connect_repeater_]
|
||||
extends = nibble_screen_connect_base
|
||||
build_flags =
|
||||
${nibble_screen_connect_base.build_flags}
|
||||
@@ -51,7 +51,7 @@ lib_deps =
|
||||
${nibble_screen_connect_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:nibble_screen_connect_repeater_bridge_espnow]
|
||||
[env:nibble_screen_connect_repeater_bridge_espnow_]
|
||||
extends = nibble_screen_connect_base
|
||||
build_flags =
|
||||
${nibble_screen_connect_base.build_flags}
|
||||
@@ -70,7 +70,7 @@ lib_deps =
|
||||
${nibble_screen_connect_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:nibble_screen_connect_terminal_chat]
|
||||
[env:nibble_screen_connect_terminal_chat_]
|
||||
extends = nibble_screen_connect_base
|
||||
build_flags =
|
||||
${nibble_screen_connect_base.build_flags}
|
||||
@@ -82,7 +82,7 @@ lib_deps =
|
||||
${nibble_screen_connect_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:nibble_screen_connect_room_server]
|
||||
[env:nibble_screen_connect_room_server_]
|
||||
extends = nibble_screen_connect_base
|
||||
build_flags =
|
||||
${nibble_screen_connect_base.build_flags}
|
||||
@@ -99,7 +99,7 @@ lib_deps =
|
||||
${nibble_screen_connect_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:nibble_screen_connect_companion_radio_usb]
|
||||
[env:nibble_screen_connect_companion_radio_usb_]
|
||||
extends = nibble_screen_connect_base
|
||||
build_flags =
|
||||
${nibble_screen_connect_base.build_flags}
|
||||
@@ -116,7 +116,7 @@ lib_deps =
|
||||
${nibble_screen_connect_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:nibble_screen_connect_companion_radio_ble]
|
||||
[env:nibble_screen_connect_companion_radio_ble_]
|
||||
extends = nibble_screen_connect_base
|
||||
build_flags =
|
||||
${nibble_screen_connect_base.build_flags}
|
||||
@@ -137,7 +137,7 @@ lib_deps =
|
||||
${nibble_screen_connect_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:nibble_screen_connect_companion_radio_wifi]
|
||||
[env:nibble_screen_connect_companion_radio_wifi_]
|
||||
extends = nibble_screen_connect_base
|
||||
build_flags =
|
||||
${nibble_screen_connect_base.build_flags}
|
||||
@@ -160,7 +160,7 @@ lib_deps =
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
|
||||
[env:nibble_screen_connect_kiss_modem]
|
||||
[env:nibble_screen_connect_kiss_modem_]
|
||||
extends = nibble_screen_connect_base
|
||||
build_src_filter = ${nibble_screen_connect_base.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
[nibble_zero_connect_base]
|
||||
extends = esp32_base
|
||||
board = esp32-s3-zero
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
-I variants/nibble_zero_connect
|
||||
-D NIBBLE_ZERO_CONNECT
|
||||
-D P_LORA_DIO_1=4
|
||||
-D P_LORA_NSS=10
|
||||
-D P_LORA_RESET=6
|
||||
-D P_LORA_BUSY=5
|
||||
-D P_LORA_SCLK=12
|
||||
-D P_LORA_MISO=13
|
||||
-D P_LORA_MOSI=11
|
||||
-D PIN_USER_BTN=1
|
||||
-D PIN_BOARD_SDA=8
|
||||
-D PIN_BOARD_SCL=7
|
||||
-D PIN_STATUS_LED=39
|
||||
-D P_LORA_TX_LED=39
|
||||
-D DISPLAY_ROTATION=0
|
||||
-D SX126X_DIO2_AS_RF_SWITCH=true
|
||||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
|
||||
-D SX126X_CURRENT_LIMIT=140
|
||||
-D RADIO_CLASS=CustomSX1262
|
||||
-D WRAPPER_CLASS=CustomSX1262Wrapper
|
||||
-D LORA_TX_POWER=22
|
||||
-D SX126X_RX_BOOSTED_GAIN=1
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<../variants/nibble_zero_connect>
|
||||
lib_deps =
|
||||
${esp32_base.lib_deps}
|
||||
adafruit/Adafruit SSD1306 @ ^2.5.13
|
||||
|
||||
[env:nibble_zero_connect_repeater_]
|
||||
extends = nibble_zero_connect_base
|
||||
build_flags =
|
||||
${nibble_zero_connect_base.build_flags}
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D ADVERT_NAME='"Nibble Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=50
|
||||
build_src_filter = ${nibble_zero_connect_base.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps =
|
||||
${nibble_zero_connect_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:nibble_zero_connect_repeater_bridge_espnow_]
|
||||
extends = nibble_zero_connect_base
|
||||
build_flags =
|
||||
${nibble_zero_connect_base.build_flags}
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D ADVERT_NAME='"ESPNow Bridge"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=50
|
||||
-D WITH_ESPNOW_BRIDGE=1
|
||||
build_src_filter = ${nibble_zero_connect_base.build_src_filter}
|
||||
+<helpers/bridges/ESPNowBridge.cpp>
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/simple_repeater>
|
||||
lib_deps =
|
||||
${nibble_zero_connect_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:nibble_zero_connect_terminal_chat_]
|
||||
extends = nibble_zero_connect_base
|
||||
build_flags =
|
||||
${nibble_zero_connect_base.build_flags}
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=1
|
||||
build_src_filter = ${nibble_zero_connect_base.build_src_filter}
|
||||
+<../examples/simple_secure_chat/main.cpp>
|
||||
lib_deps =
|
||||
${nibble_zero_connect_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:nibble_zero_connect_room_server_]
|
||||
extends = nibble_zero_connect_base
|
||||
build_flags =
|
||||
${nibble_zero_connect_base.build_flags}
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D ADVERT_NAME='"Nibble Room"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
build_src_filter = ${nibble_zero_connect_base.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<../examples/simple_room_server>
|
||||
lib_deps =
|
||||
${nibble_zero_connect_base.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:nibble_zero_connect_companion_radio_usb_]
|
||||
extends = nibble_zero_connect_base
|
||||
build_flags =
|
||||
${nibble_zero_connect_base.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
build_src_filter = ${nibble_zero_connect_base.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${nibble_zero_connect_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:nibble_zero_connect_companion_radio_ble_]
|
||||
extends = nibble_zero_connect_base
|
||||
build_flags =
|
||||
${nibble_zero_connect_base.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D BLE_DEBUG_LOGGING=1
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${nibble_zero_connect_base.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${nibble_zero_connect_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:nibble_zero_connect_companion_radio_wifi_]
|
||||
extends = nibble_zero_connect_base
|
||||
build_flags =
|
||||
${nibble_zero_connect_base.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D DISPLAY_CLASS=SSD1306Display
|
||||
-D MAX_CONTACTS=300
|
||||
-D MAX_GROUP_CHANNELS=8
|
||||
-D WIFI_DEBUG_LOGGING=1
|
||||
-D WIFI_SSID='"myssid"'
|
||||
-D WIFI_PWD='"mypwd"'
|
||||
build_src_filter = ${nibble_zero_connect_base.build_src_filter}
|
||||
+<helpers/ui/SSD1306Display.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${nibble_zero_connect_base.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
|
||||
ESP32Board board;
|
||||
|
||||
static SPIClass spi;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
fallback_clock.begin();
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
return radio.std_init(&spi);
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/SSD1306Display.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#endif
|
||||
|
||||
extern ESP32Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern SensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
|
||||
|
||||
@@ -72,8 +72,4 @@ public:
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
sd_power_system_off();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
||||
#define BATTERY_SAMPLES 8
|
||||
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
class RAK3112Board : public ESP32Board {
|
||||
private:
|
||||
bool adc_active_state;
|
||||
@@ -51,33 +49,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
analogReadResolution(12);
|
||||
|
||||
|
||||
@@ -69,6 +69,6 @@ public:
|
||||
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
|
||||
#endif
|
||||
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
#ifdef NRF52_POWER_MANAGEMENT
|
||||
initiateShutdown(SHUTDOWN_REASON_USER);
|
||||
#else
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
class StationG2Board : public ESP32Board {
|
||||
public:
|
||||
@@ -21,29 +20,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
// Make sure the DIO1 and NSS GPIOs are hold on required levels during deep sleep
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup( (1L << P_LORA_DIO_1) | (1L << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH); // wake up on: recv LoRa packet OR wake btn
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#include "StationG3Board.h"
|
||||
|
||||
void StationG3Board::powerOff() {
|
||||
#ifdef P_PA1_EN
|
||||
setPAModeHigh(false);
|
||||
rtc_gpio_hold_en((gpio_num_t)P_PA1_EN);
|
||||
#endif
|
||||
|
||||
#ifdef P_PRIMARY_LNA_EN
|
||||
setPrimaryLNAControl(true);
|
||||
rtc_gpio_hold_en((gpio_num_t)P_PRIMARY_LNA_EN);
|
||||
#endif
|
||||
|
||||
ESP32Board::powerOff();
|
||||
}
|
||||
@@ -73,36 +73,7 @@ public:
|
||||
setPrimaryLNAControl(true);
|
||||
}
|
||||
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
rtc_gpio_set_direction((gpio_num_t)P_LORA_DIO_1, RTC_GPIO_MODE_INPUT_ONLY);
|
||||
rtc_gpio_pulldown_en((gpio_num_t)P_LORA_DIO_1);
|
||||
|
||||
rtc_gpio_hold_en((gpio_num_t)P_LORA_NSS);
|
||||
|
||||
#ifdef P_PA1_EN
|
||||
setPAModeHigh(false);
|
||||
rtc_gpio_hold_en((gpio_num_t)P_PA1_EN);
|
||||
#endif
|
||||
|
||||
#ifdef P_PRIMARY_LNA_EN
|
||||
setPrimaryLNAControl(true);
|
||||
rtc_gpio_hold_en((gpio_num_t)P_PRIMARY_LNA_EN);
|
||||
#endif
|
||||
|
||||
if (pin_wake_btn < 0) {
|
||||
esp_sleep_enable_ext1_wakeup((1ULL << P_LORA_DIO_1), ESP_EXT1_WAKEUP_ANY_HIGH);
|
||||
} else {
|
||||
esp_sleep_enable_ext1_wakeup((1ULL << P_LORA_DIO_1) | (1ULL << pin_wake_btn), ESP_EXT1_WAKEUP_ANY_HIGH);
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
void powerOff() override;
|
||||
|
||||
uint16_t getBattMilliVolts() override {
|
||||
return 0;
|
||||
|
||||
@@ -88,6 +88,6 @@ public:
|
||||
nrf_gpio_cfg_sense_input(BUTTON_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_HIGH);
|
||||
#endif
|
||||
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <helpers/XiaoC3Board.h>
|
||||
#include <../variants/xiao_c3/XiaoC3Board.h>
|
||||
#include <helpers/radiolib/CustomSX1262Wrapper.h>
|
||||
#include <helpers/radiolib/CustomSX1268Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
|
||||
@@ -40,7 +40,6 @@ public:
|
||||
#endif
|
||||
|
||||
// power off board
|
||||
sd_power_system_off();
|
||||
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -58,6 +58,7 @@ build_flags =
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${ThinkNode_M1.build_src_filter}
|
||||
|
||||
@@ -1,40 +1,30 @@
|
||||
#include "ThinknodeM2Board.h"
|
||||
|
||||
|
||||
|
||||
void ThinknodeM2Board::begin() {
|
||||
pinMode(PIN_VEXT_EN, OUTPUT);
|
||||
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE); // force power cycle
|
||||
delay(20); // allow power rail to discharge
|
||||
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE); // turn backlight back on
|
||||
delay(120); // give display time to bias on cold boot
|
||||
ESP32Board::begin();
|
||||
pinMode(PIN_STATUS_LED, OUTPUT); // init power led
|
||||
}
|
||||
|
||||
void ThinknodeM2Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
void ThinknodeM2Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t ThinknodeM2Board::getBattMilliVolts() {
|
||||
analogReadResolution(12);
|
||||
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
|
||||
|
||||
uint32_t mv = 0;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
mv += analogReadMilliVolts(PIN_VBAT_READ);
|
||||
delayMicroseconds(200);
|
||||
}
|
||||
mv /= 8;
|
||||
|
||||
analogReadResolution(10);
|
||||
return static_cast<uint16_t>(mv * ADC_MULTIPLIER );
|
||||
pinMode(PIN_VEXT_EN, OUTPUT);
|
||||
digitalWrite(PIN_VEXT_EN, !PIN_VEXT_EN_ACTIVE); // force power cycle
|
||||
delay(20); // allow power rail to discharge
|
||||
digitalWrite(PIN_VEXT_EN, PIN_VEXT_EN_ACTIVE); // turn backlight back on
|
||||
delay(120); // give display time to bias on cold boot
|
||||
ESP32Board::begin();
|
||||
pinMode(PIN_STATUS_LED, OUTPUT); // init power led
|
||||
}
|
||||
|
||||
const char* ThinknodeM2Board::getManufacturerName() const {
|
||||
return "Elecrow ThinkNode M2";
|
||||
uint16_t ThinknodeM2Board::getBattMilliVolts() {
|
||||
analogReadResolution(12);
|
||||
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
|
||||
|
||||
uint32_t mv = 0;
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
mv += analogReadMilliVolts(PIN_VBAT_READ);
|
||||
delayMicroseconds(200);
|
||||
}
|
||||
mv /= 8;
|
||||
|
||||
analogReadResolution(10);
|
||||
return static_cast<uint16_t>(mv * ADC_MULTIPLIER);
|
||||
}
|
||||
|
||||
const char *ThinknodeM2Board::getManufacturerName() const {
|
||||
return "Elecrow ThinkNode M2";
|
||||
}
|
||||
|
||||
@@ -3,15 +3,11 @@
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
|
||||
class ThinknodeM2Board : public ESP32Board {
|
||||
|
||||
public:
|
||||
|
||||
void begin();
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override ;
|
||||
|
||||
|
||||
@@ -49,6 +49,6 @@ public:
|
||||
#endif
|
||||
|
||||
// power off board
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -19,14 +19,6 @@ void ThinknodeM5Board::begin() {
|
||||
ESP32Board::begin();
|
||||
}
|
||||
|
||||
void ThinknodeM5Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
void ThinknodeM5Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint16_t ThinknodeM5Board::getBattMilliVolts() {
|
||||
analogReadResolution(12);
|
||||
analogSetPinAttenuation(PIN_VBAT_READ, ADC_11db);
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <driver/rtc_io.h>
|
||||
#include <PCA9557.h>
|
||||
|
||||
extern PCA9557 expander;
|
||||
@@ -13,8 +12,6 @@ class ThinknodeM5Board : public ESP32Board {
|
||||
public:
|
||||
|
||||
void begin();
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
uint16_t getBattMilliVolts() override;
|
||||
const char* getManufacturerName() const override ;
|
||||
|
||||
|
||||
@@ -44,6 +44,6 @@ public:
|
||||
#endif
|
||||
|
||||
// power off board
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,8 +48,8 @@ build_flags =
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=50
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
-D MESH_DEBUG=1
|
||||
-D GPS_NMEA_DEBUG=1
|
||||
; -D MESH_DEBUG=1
|
||||
; -D GPS_NMEA_DEBUG=1
|
||||
build_src_filter = ${ThinkNode_M6.build_src_filter}
|
||||
+<../examples/simple_repeater/*.cpp>
|
||||
lib_deps =
|
||||
@@ -63,6 +63,7 @@ build_flags =
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
build_src_filter = ${ThinkNode_M6.build_src_filter}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#include "ThinkNodeM7Board.h"
|
||||
|
||||
void ThinkNodeM7Board::begin() {
|
||||
ESP32Board::begin();
|
||||
}
|
||||
|
||||
void ThinkNodeM7Board::enterDeepSleep(uint32_t secs, int pin_wake_btn) {
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
void ThinkNodeM7Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
const char* ThinkNodeM7Board::getManufacturerName() const {
|
||||
return "Elecrow ThinkNode M7";
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <helpers/RefCountedDigitalPin.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include "variant.h"
|
||||
#include "NullDisplayDriver.h"
|
||||
#include "MomentaryButton.h"
|
||||
|
||||
class ThinkNodeM7Board : public ESP32Board {
|
||||
|
||||
public:
|
||||
void begin();
|
||||
void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1);
|
||||
void powerOff() override;
|
||||
const char* getManufacturerName() const override;
|
||||
void onBeforeTransmit() override {
|
||||
digitalWrite(P_LORA_TX_LED, LOW);
|
||||
}
|
||||
void onAfterTransmit() override {
|
||||
digitalWrite(P_LORA_TX_LED, HIGH);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define USB_VID 0x303a
|
||||
#define USB_PID 0x1001
|
||||
|
||||
// The default Wire will be mapped to PMU and RTC
|
||||
static const uint8_t SDA = 17;
|
||||
static const uint8_t SCL = 18;
|
||||
|
||||
// Default SPI is the LR1110 radio bus
|
||||
static const uint8_t SS = 12;
|
||||
static const uint8_t MOSI = 10;
|
||||
static const uint8_t MISO = 9;
|
||||
static const uint8_t SCK = 11;
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
@@ -0,0 +1,134 @@
|
||||
[ThinkNode_M7]
|
||||
extends = esp32_base
|
||||
board = thinknode_m7
|
||||
build_flags = ${esp32_base.build_flags}
|
||||
-I src/helpers/esp32
|
||||
-I variants/thinknode_m7
|
||||
-I src/helpers/sensors
|
||||
-I src/helpers/ui
|
||||
-D THINKNODE_M7
|
||||
-D PIN_USER_BTN_ANA=4
|
||||
-D PIN_STATUS_LED=3 ; green
|
||||
-D LED_STATE_ON=LOW
|
||||
-D RADIO_CLASS=CustomLR1110
|
||||
-D WRAPPER_CLASS=CustomLR1110Wrapper
|
||||
-D USE_LR1110
|
||||
-D LORA_TX_POWER=22
|
||||
-D RF_SWITCH_TABLE
|
||||
-D RX_BOOSTED_GAIN=true
|
||||
-D P_LORA_BUSY=13
|
||||
-D P_LORA_SCLK=11
|
||||
-D P_LORA_NSS=12
|
||||
-D P_LORA_DIO_1=38
|
||||
-D P_LORA_MISO=9
|
||||
-D P_LORA_MOSI=10
|
||||
-D P_LORA_RESET=39
|
||||
-D P_LORA_TX_LED=46 ; blue
|
||||
-D LR11X0_DIO_AS_RF_SWITCH=true
|
||||
-D LR11X0_DIO3_TCXO_VOLTAGE=1.8
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<helpers/*.cpp>
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../variants/thinknode_m7>
|
||||
lib_deps = ${esp32_base.lib_deps}
|
||||
stevemarple/MicroNMEA @ ^2.0.6
|
||||
|
||||
[env:ThinkNode_M7_repeater]
|
||||
extends = ThinkNode_M7
|
||||
build_src_filter = ${ThinkNode_M7.build_src_filter}
|
||||
+<../examples/simple_repeater/*.cpp>
|
||||
build_flags =
|
||||
${ThinkNode_M7.build_flags}
|
||||
-D ADVERT_NAME='"ThinkNode M7 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=8
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps =
|
||||
${ThinkNode_M7.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:ThinkNode_M7_room_server]
|
||||
extends = ThinkNode_M7
|
||||
build_src_filter = ${ThinkNode_M7.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
build_flags =
|
||||
${ThinkNode_M7.build_flags}
|
||||
-D ADVERT_NAME='"ThinkNode M7 Room Server"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps =
|
||||
${ThinkNode_M7.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:ThinkNode_M7_companion_radio_ble]
|
||||
extends = ThinkNode_M7
|
||||
build_flags =
|
||||
${ThinkNode_M7.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
build_src_filter = ${ThinkNode_M7.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M7.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:ThinkNode_M7_companion_radio_usb]
|
||||
extends = ThinkNode_M7
|
||||
build_flags =
|
||||
${ThinkNode_M7.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${ThinkNode_M7.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M7.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:ThinkNode_M7_companion_radio_wifi]
|
||||
extends = ThinkNode_M7
|
||||
build_flags =
|
||||
${ThinkNode_M7.build_flags}
|
||||
-I examples/companion_radio/ui-orig
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D DISPLAY_CLASS=NullDisplayDriver
|
||||
-D WIFI_DEBUG_LOGGING=1
|
||||
-D WIFI_SSID='"myssid"'
|
||||
-D WIFI_PWD='"mypwd"'
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
-D MESH_PACKET_LOGGING=1
|
||||
build_src_filter = ${ThinkNode_M7.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-orig/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M7.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
|
||||
[env:ThinkNode_M7_kiss_modem]
|
||||
extends = ThinkNode_M7
|
||||
build_src_filter = ${ThinkNode_M7.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
@@ -0,0 +1,84 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
|
||||
ThinkNodeM7Board board;
|
||||
|
||||
static SPIClass spi;
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
#ifdef ENV_INCLUDE_GPS
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||
#else
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifdef RF_SWITCH_TABLE
|
||||
static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = {
|
||||
RADIOLIB_LR11X0_DIO5,
|
||||
RADIOLIB_LR11X0_DIO6,
|
||||
RADIOLIB_NC,
|
||||
RADIOLIB_NC,
|
||||
RADIOLIB_NC
|
||||
};
|
||||
|
||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
// mode DIO5 DIO6
|
||||
{LR11x0::MODE_STBY, {LOW, LOW}}, {LR11x0::MODE_RX, {HIGH, LOW}},
|
||||
{LR11x0::MODE_TX, {HIGH, HIGH}}, {LR11x0::MODE_TX_HP, {LOW, HIGH}},
|
||||
{LR11x0::MODE_TX_HF, {LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW}},
|
||||
{LR11x0::MODE_WIFI, {LOW, LOW}}, END_OF_MODE_TABLE,
|
||||
END_OF_MODE_TABLE,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
|
||||
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
|
||||
#else
|
||||
float tcxo = 1.6f;
|
||||
#endif
|
||||
|
||||
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI, P_LORA_NSS);
|
||||
|
||||
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
|
||||
if (status != RADIOLIB_ERR_NONE) {
|
||||
Serial.print("ERROR: radio init failed: ");
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
radio.setCRC(2);
|
||||
radio.explicitHeader();
|
||||
|
||||
#ifdef RF_SWITCH_TABLE
|
||||
radio.setRfSwitchTable(rfswitch_dios, rfswitch_table);
|
||||
#endif
|
||||
#ifdef RX_BOOSTED_GAIN
|
||||
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <ThinkNodeM7Board.h>
|
||||
#include <helpers/radiolib/CustomLR1110Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include "NullDisplayDriver.h"
|
||||
#endif
|
||||
|
||||
extern ThinkNodeM7Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern NullDisplayDriver display;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
#include "variant.h"
|
||||
#include "Arduino.h"
|
||||
|
||||
void initVariant()
|
||||
{
|
||||
pinMode(P_LORA_TX_LED, OUTPUT);
|
||||
digitalWrite(P_LORA_TX_LED, HIGH);
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#include "ThinkNodeM9Board.h"
|
||||
|
||||
void ThinkNodeM9Board::begin() {
|
||||
|
||||
// power on screen
|
||||
pinMode(VEXT_ENABLE, OUTPUT);
|
||||
digitalWrite(VEXT_ENABLE, VEXT_ON_VALUE);
|
||||
|
||||
ESP32Board::begin();
|
||||
|
||||
}
|
||||
|
||||
void ThinkNodeM9Board::powerOff() {
|
||||
enterDeepSleep(0);
|
||||
}
|
||||
|
||||
uint32_t ThinkNodeM9Board::getIRQGpio() {
|
||||
return LORA_DIO0;
|
||||
}
|
||||
|
||||
const char* ThinkNodeM9Board::getManufacturerName() const {
|
||||
return "Elecrow ThinkNode M9";
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <helpers/ESP32Board.h>
|
||||
|
||||
class ThinkNodeM9Board : public ESP32Board {
|
||||
|
||||
public:
|
||||
void begin();
|
||||
void powerOff() override;
|
||||
const char* getManufacturerName() const override;
|
||||
uint32_t getIRQGpio() override;
|
||||
};
|
||||
Executable
+64
@@ -0,0 +1,64 @@
|
||||
// Need this file for ESP32-S3
|
||||
// No need to modify this file, changes to pins imported from variant.h
|
||||
// Most is similar to https://github.com/espressif/arduino-esp32/blob/master/variants/esp32s3/pins_arduino.h
|
||||
|
||||
#ifndef Pins_Arduino_h
|
||||
#define Pins_Arduino_h
|
||||
|
||||
#include <stdint.h>
|
||||
#include <variant.h>
|
||||
|
||||
#define USB_VID 0x303a
|
||||
#define USB_PID 0x1001
|
||||
|
||||
// Serial
|
||||
static const uint8_t TX = 43;
|
||||
static const uint8_t RX = 44;
|
||||
|
||||
// Default SPI will be mapped to Radio
|
||||
static const uint8_t SS = LORA_CS;
|
||||
static const uint8_t SCK = SPI_SCK;
|
||||
static const uint8_t MOSI = SPI_MOSI;
|
||||
static const uint8_t MISO = SPI_MISO;
|
||||
|
||||
// The default Wire will be mapped to PMU and RTC
|
||||
static const uint8_t SCL = I2C_SCL;
|
||||
static const uint8_t SDA = I2C_SDA;
|
||||
|
||||
static const uint8_t A0 = 1;
|
||||
static const uint8_t A1 = 2;
|
||||
static const uint8_t A2 = 3;
|
||||
static const uint8_t A3 = 4;
|
||||
static const uint8_t A4 = 5;
|
||||
static const uint8_t A5 = 6;
|
||||
static const uint8_t A6 = 7;
|
||||
static const uint8_t A7 = 8;
|
||||
static const uint8_t A8 = 9;
|
||||
static const uint8_t A9 = 10;
|
||||
static const uint8_t A10 = 11;
|
||||
static const uint8_t A11 = 12;
|
||||
static const uint8_t A12 = 13;
|
||||
static const uint8_t A13 = 14;
|
||||
static const uint8_t A14 = 15;
|
||||
static const uint8_t A15 = 16;
|
||||
static const uint8_t A16 = 17;
|
||||
static const uint8_t A17 = 18;
|
||||
static const uint8_t A18 = 19;
|
||||
static const uint8_t A19 = 20;
|
||||
|
||||
static const uint8_t T1 = 1;
|
||||
static const uint8_t T2 = 2;
|
||||
static const uint8_t T3 = 3;
|
||||
static const uint8_t T4 = 4;
|
||||
static const uint8_t T5 = 5;
|
||||
static const uint8_t T6 = 6;
|
||||
static const uint8_t T7 = 7;
|
||||
static const uint8_t T8 = 8;
|
||||
static const uint8_t T9 = 9;
|
||||
static const uint8_t T10 = 10;
|
||||
static const uint8_t T11 = 11;
|
||||
static const uint8_t T12 = 12;
|
||||
static const uint8_t T13 = 13;
|
||||
static const uint8_t T14 = 14;
|
||||
|
||||
#endif /* Pins_Arduino_h */
|
||||
Executable
+160
@@ -0,0 +1,160 @@
|
||||
[ThinkNode_M9]
|
||||
extends = esp32_base
|
||||
board = thinknode_m9
|
||||
board_check = true
|
||||
board_build.partitions = default_16MB.csv
|
||||
upload_protocol = esptool
|
||||
build_flags =
|
||||
${esp32_base.build_flags}
|
||||
${sensor_base.build_flags}
|
||||
-I variants/thinknode_m9
|
||||
-I src/helpers/esp32
|
||||
-I src/helpers/sensors
|
||||
-D THINKNODE_M9
|
||||
-D PIN_BUZZER=9
|
||||
-D PIN_BOARD_SCL=6
|
||||
-D PIN_BOARD_SDA=7
|
||||
-D P_LORA_NSS=39
|
||||
-D P_LORA_RESET=45
|
||||
-D P_LORA_BUSY=41
|
||||
-D P_LORA_SCLK=40
|
||||
-D P_LORA_MISO=38
|
||||
-D P_LORA_MOSI=47
|
||||
-D P_LORA_DIO_1=42
|
||||
-D USE_LR1110
|
||||
-D RF_SWITCH_TABLE
|
||||
-D RADIO_CLASS=CustomLR1110
|
||||
-D WRAPPER_CLASS=CustomLR1110Wrapper
|
||||
-D LR11X0_DIO_AS_RF_SWITCH=true
|
||||
-D LR11X0_DIO3_TCXO_VOLTAGE=3.3
|
||||
-D LORA_TX_POWER=22
|
||||
-D DISPLAY_CLASS=ST7789Display
|
||||
-D DISPLAY_FLIP_VERTICALLY=1
|
||||
-D DISPLAY_SCALE_X=2.5f ; 320 / 128
|
||||
-D DISPLAY_SCALE_Y=3.75f ; 240 / 64
|
||||
-D ST7789
|
||||
-D PIN_TFT_VDD_CTL=-1
|
||||
-D PIN_TFT_LEDA_CTL=17
|
||||
-D PIN_TFT_RST=14
|
||||
-D PIN_GPS_RX=3
|
||||
-D PIN_GPS_TX=2
|
||||
-D PIN_GPS_EN=11
|
||||
-D PIN_GPS_EN_ACTIVE=LOW
|
||||
-D PIN_GPS_RESET=5
|
||||
-D PIN_GPS_RESET_ACTIVE=HIGH
|
||||
-D GPS_BAUD_RATE=115200
|
||||
-D ENV_INCLUDE_GPS=1
|
||||
-D PIN_VBAT_READ=13
|
||||
build_src_filter = ${esp32_base.build_src_filter}
|
||||
+<helpers/sensors/EnvironmentSensorManager.cpp>
|
||||
+<helpers/ui/ST7789Display.cpp>
|
||||
+<helpers/ui/OLEDDisplay.cpp>
|
||||
+<helpers/ui/OLEDDisplayFonts.cpp>
|
||||
+<helpers/*.cpp>
|
||||
+<../variants/thinknode_m9>
|
||||
lib_deps = ${esp32_base.lib_deps}
|
||||
${sensor_base.lib_deps}
|
||||
adafruit/Adafruit GFX Library @ ^1.12.1
|
||||
|
||||
[env:ThinkNode_M9_repeater_]
|
||||
extends = ThinkNode_M9
|
||||
build_flags =
|
||||
${ThinkNode_M9.build_flags}
|
||||
-D ADVERT_NAME='"ThinkNode M9 Repeater"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D MAX_NEIGHBOURS=50
|
||||
;-D MESH_PACKET_LOGGING=1
|
||||
;-D MESH_DEBUG=1
|
||||
build_src_filter = ${ThinkNode_M9.build_src_filter}
|
||||
+<../examples/simple_repeater/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M9.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:ThinkNode_M9_room_server_]
|
||||
extends = ThinkNode_M9
|
||||
build_src_filter = ${ThinkNode_M9.build_src_filter}
|
||||
+<../examples/simple_room_server>
|
||||
build_flags =
|
||||
${ThinkNode_M9.build_flags}
|
||||
-D ADVERT_NAME='"ThinkNode M9 Room Server"'
|
||||
-D ADVERT_LAT=0.0
|
||||
-D ADVERT_LON=0.0
|
||||
-D ADMIN_PASSWORD='"password"'
|
||||
-D ROOM_PASSWORD='"hello"'
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
; -D MESH_DEBUG=1
|
||||
lib_deps =
|
||||
${ThinkNode_M9.lib_deps}
|
||||
${esp32_ota.lib_deps}
|
||||
|
||||
[env:ThinkNode_M9_companion_radio_ble_]
|
||||
extends = ThinkNode_M9
|
||||
build_flags =
|
||||
${ThinkNode_M9.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D BLE_PIN_CODE=123456
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D BLE_DEBUG_LOGGING=1
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
build_src_filter = ${ThinkNode_M9.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M9.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
||||
[env:ThinkNode_M9_companion_radio_usb_]
|
||||
extends = ThinkNode_M9
|
||||
build_flags =
|
||||
${ThinkNode_M9.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
build_src_filter = ${ThinkNode_M9.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M9.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
||||
[env:ThinkNode_M9_companion_radio_wifi_]
|
||||
extends = ThinkNode_M9
|
||||
build_flags =
|
||||
${ThinkNode_M9.build_flags}
|
||||
-I examples/companion_radio/ui-new
|
||||
-D MAX_CONTACTS=350
|
||||
-D MAX_GROUP_CHANNELS=40
|
||||
-D WIFI_DEBUG_LOGGING=1
|
||||
-D WIFI_SSID='"myssid"'
|
||||
-D WIFI_PWD='"mypwd"'
|
||||
-D OFFLINE_QUEUE_SIZE=256
|
||||
; -D MESH_PACKET_LOGGING=1
|
||||
build_src_filter = ${ThinkNode_M9.build_src_filter}
|
||||
+<helpers/esp32/*.cpp>
|
||||
+<helpers/ui/buzzer.cpp>
|
||||
+<helpers/ui/MomentaryButton.cpp>
|
||||
+<../examples/companion_radio/*.cpp>
|
||||
+<../examples/companion_radio/ui-new/*.cpp>
|
||||
lib_deps =
|
||||
${ThinkNode_M9.lib_deps}
|
||||
densaugeo/base64 @ ~1.4.0
|
||||
end2endzone/NonBlockingRTTTL@^1.3.0
|
||||
|
||||
[env:ThinkNode_M9_kiss_modem]
|
||||
extends = ThinkNode_M9
|
||||
build_src_filter = ${ThinkNode_M9.build_src_filter}
|
||||
+<../examples/kiss_modem/>
|
||||
@@ -0,0 +1,78 @@
|
||||
#include <Arduino.h>
|
||||
#include "target.h"
|
||||
|
||||
ThinkNodeM9Board board;
|
||||
|
||||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
|
||||
WRAPPER_CLASS radio_driver(radio, board);
|
||||
|
||||
ESP32RTCClock fallback_clock;
|
||||
AutoDiscoverRTCClock rtc_clock(fallback_clock);
|
||||
|
||||
#ifdef ENV_INCLUDE_GPS
|
||||
#include <helpers/sensors/MicroNMEALocationProvider.h>
|
||||
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
|
||||
#else
|
||||
EnvironmentSensorManager sensors = EnvironmentSensorManager();
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
DISPLAY_CLASS display;
|
||||
#endif
|
||||
|
||||
#ifdef RF_SWITCH_TABLE
|
||||
static const uint32_t rfswitch_dios[Module::RFSWITCH_MAX_PINS] = {
|
||||
RADIOLIB_LR11X0_DIO5,
|
||||
RADIOLIB_LR11X0_DIO6,
|
||||
RADIOLIB_NC,
|
||||
RADIOLIB_NC,
|
||||
RADIOLIB_NC
|
||||
};
|
||||
|
||||
static const Module::RfSwitchMode_t rfswitch_table[] = {
|
||||
// mode DIO5 DIO6
|
||||
{LR11x0::MODE_STBY, {LOW, LOW}}, {LR11x0::MODE_RX, {HIGH, LOW}},
|
||||
{LR11x0::MODE_TX, {HIGH, HIGH}}, {LR11x0::MODE_TX_HP, {LOW, HIGH}},
|
||||
{LR11x0::MODE_TX_HF, {LOW, LOW}}, {LR11x0::MODE_GNSS, {LOW, LOW}},
|
||||
{LR11x0::MODE_WIFI, {LOW, LOW}}, END_OF_MODE_TABLE,
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef LORA_CR
|
||||
#define LORA_CR 5
|
||||
#endif
|
||||
|
||||
bool radio_init() {
|
||||
rtc_clock.begin(Wire);
|
||||
|
||||
#ifdef LR11X0_DIO3_TCXO_VOLTAGE
|
||||
float tcxo = LR11X0_DIO3_TCXO_VOLTAGE;
|
||||
#else
|
||||
float tcxo = 1.6f;
|
||||
#endif
|
||||
|
||||
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_LR11X0_LORA_SYNC_WORD_PRIVATE, LORA_TX_POWER, 16, tcxo);
|
||||
if (status != RADIOLIB_ERR_NONE) {
|
||||
Serial.print("ERROR: radio init failed: ");
|
||||
Serial.println(status);
|
||||
return false; // fail
|
||||
}
|
||||
|
||||
radio.setCRC(2);
|
||||
radio.explicitHeader();
|
||||
|
||||
#ifdef RF_SWITCH_TABLE
|
||||
radio.setRfSwitchTable(rfswitch_dios, rfswitch_table);
|
||||
#endif
|
||||
#ifdef RX_BOOSTED_GAIN
|
||||
radio.setRxBoostedGainMode(RX_BOOSTED_GAIN);
|
||||
#endif
|
||||
|
||||
return true; // success
|
||||
}
|
||||
|
||||
mesh::LocalIdentity radio_new_identity() {
|
||||
RadioNoiseListener rng(radio);
|
||||
return mesh::LocalIdentity(&rng); // create new random identity
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include <RadioLib.h>
|
||||
#include <helpers/radiolib/RadioLibWrappers.h>
|
||||
#include <ThinkNodeM9Board.h>
|
||||
#include <helpers/radiolib/CustomLR1110Wrapper.h>
|
||||
#include <helpers/AutoDiscoverRTCClock.h>
|
||||
#include <helpers/SensorManager.h>
|
||||
#include <helpers/sensors/EnvironmentSensorManager.h>
|
||||
#include <helpers/sensors/LocationProvider.h>
|
||||
#ifdef DISPLAY_CLASS
|
||||
#include <helpers/ui/ST7789Display.h>
|
||||
#include <helpers/ui/MomentaryButton.h>
|
||||
#endif
|
||||
|
||||
extern ThinkNodeM9Board board;
|
||||
extern WRAPPER_CLASS radio_driver;
|
||||
extern AutoDiscoverRTCClock rtc_clock;
|
||||
extern EnvironmentSensorManager sensors;
|
||||
|
||||
#ifdef DISPLAY_CLASS
|
||||
extern DISPLAY_CLASS display;
|
||||
extern MomentaryButton user_btn;
|
||||
#endif
|
||||
|
||||
bool radio_init();
|
||||
mesh::LocalIdentity radio_new_identity();
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
#include "variant.h"
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
void initVariant() {
|
||||
|
||||
}
|
||||
Executable
+114
@@ -0,0 +1,114 @@
|
||||
/*Power*/
|
||||
#define VEXT_ENABLE 18
|
||||
#define VEXT_ON_VALUE LOW
|
||||
#define PIN_GPS_EN 11
|
||||
#define GPS_EN_ACTIVE LOW
|
||||
|
||||
/*Wire Interface*/
|
||||
#define WIRE_INTERFACES_COUNT 2
|
||||
// I2C keybuttons
|
||||
#define I2C_SCL1 21
|
||||
#define I2C_SDA1 20
|
||||
#define KB_INT 12
|
||||
// I2C peripheral`
|
||||
#define I2C_SCL 6
|
||||
#define I2C_SDA 7
|
||||
|
||||
/*LED*/
|
||||
#define PIN_LED 13
|
||||
#define KB_LED 46
|
||||
|
||||
/*BUZZER*/
|
||||
#define PIN_BUZZER 9
|
||||
|
||||
/*CHARGE_CHECK*/
|
||||
#define DONE 8
|
||||
#define EXT_PWR_DETECT 1
|
||||
#define EXT_CHRG_DETECT 1
|
||||
#define EXT_CHRG_DETECT_VALUE LOW
|
||||
/*GPS*/
|
||||
#define GPS_L76K
|
||||
#define GPS_BAUDRATE 9600
|
||||
#define PIN_GPS_RESET 5
|
||||
#define PIN_GPS_PPS 4
|
||||
#define PIN_GPS_STANDBY 10 // An output to wake GPS, low means allow sleep, high means force wake
|
||||
#define GPS_TX_PIN 3
|
||||
#define GPS_RX_PIN 2
|
||||
#define GPS_THREAD_INTERVAL 50
|
||||
|
||||
/*SPI*/
|
||||
#define SPI_MOSI 47
|
||||
#define SPI_SCK 40
|
||||
#define SPI_MISO 38
|
||||
|
||||
/*SD Card*/
|
||||
#define SDCARD_CS 48
|
||||
#define SD_SPI_FREQUENCY 80000000U
|
||||
|
||||
/*Screen*/
|
||||
// #define USE_ST7789 1
|
||||
#define ST7789_CS 16
|
||||
#define ST7789_RS 15
|
||||
#define ST7789_TE 19
|
||||
#define ST7789_SDA SPI_MOSI // MOSI
|
||||
#define ST7789_SCK SPI_SCK
|
||||
#define ST7789_RESET 14
|
||||
#define ST7789_MISO SPI_MISO
|
||||
#define ST7789_BUSY -1
|
||||
#define ST7789_BL 17
|
||||
#define ST7789_SPI_HOST SPI2_HOST
|
||||
#define SPI_FREQUENCY 80000000
|
||||
#define SPI_READ_FREQUENCY 16000000
|
||||
|
||||
#define USE_TFTDISPLAY 1
|
||||
#define TFT_CS ST7789_CS
|
||||
#define TFT_BL ST7789_BL
|
||||
#define TFT_HEIGHT 320
|
||||
#define TFT_WIDTH 240
|
||||
#define TFT_OFFSET_X 0
|
||||
#define TFT_OFFSET_Y 0
|
||||
#define TFT_OFFSET_ROTATION 0
|
||||
#define TFT_PWM_FREQ 44000
|
||||
#define TFT_PWM_CHANNEL 7
|
||||
#define TFT_INVERT_LIGHT true
|
||||
#define TFT_BACKLIGHT_ON LOW
|
||||
#define SCREEN_ROTATE
|
||||
#define SCREEN_TRANSITION_FRAMERATE 5
|
||||
#define BRIGHTNESS_DEFAULT 128
|
||||
|
||||
#define LGFX_PANEL ST7789
|
||||
#define DISPLAY_SIZE 320x240
|
||||
#define LGFX_ROTATION 0
|
||||
#define LGFX_CFG_HOST SPI2_HOST
|
||||
#define LGFX_PIN_SCK ST7789_SCK
|
||||
#define LGFX_PIN_MOSI ST7789_SDA
|
||||
#define LGFX_PIN_DC ST7789_RS
|
||||
#define LGFX_PIN_CS ST7789_CS
|
||||
#define LGFX_PIN_BL ST7789_BL
|
||||
#define LGFX_SCREEN_WIDTH TFT_WIDTH
|
||||
#define LGFX_SCREEN_HEIGHT TFT_HEIGHT
|
||||
#define LGFX_INVERT_LIGHT true
|
||||
#define LGFX_PWM_FREQ 44000
|
||||
#define LGFX_PWM_CHANNEL 7
|
||||
|
||||
/*Lora radio*/
|
||||
#define LORA_SCK SPI_SCK
|
||||
#define LORA_MISO SPI_MISO
|
||||
#define LORA_MOSI SPI_MOSI
|
||||
#define LORA_CS 39
|
||||
#define LORA_RESET 45
|
||||
#define LORA_DIO0 41
|
||||
|
||||
#define USE_LR1110
|
||||
#define LR1110_IRQ_PIN 42
|
||||
#define LR1110_NRESET_PIN LORA_RESET
|
||||
#define LR1110_BUSY_PIN LORA_DIO0
|
||||
#define LR1110_SPI_NSS_PIN LORA_CS
|
||||
#define LR1110_SPI_SCK_PIN LORA_SCK
|
||||
#define LR1110_SPI_MOSI_PIN LORA_MOSI
|
||||
#define LR1110_SPI_MISO_PIN LORA_MISO
|
||||
#define LR11X0_DIO3_TCXO_VOLTAGE 3.3
|
||||
#define LR11X0_DIO_AS_RF_SWITCH
|
||||
|
||||
/*RTC*/
|
||||
#define PCF8563_RTC 0x51
|
||||
@@ -35,6 +35,6 @@ public:
|
||||
}
|
||||
|
||||
void powerOff() override {
|
||||
sd_power_system_off();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <helpers/ESP32Board.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
#include <driver/rtc_io.h>
|
||||
#include <driver/uart.h>
|
||||
|
||||
class XiaoC3Board : public ESP32Board {
|
||||
@@ -40,37 +39,6 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
void enterDeepSleep(uint32_t secs, int8_t wake_pin = -1) {
|
||||
gpio_set_direction(gpio_num_t(P_LORA_DIO_1), GPIO_MODE_INPUT);
|
||||
if (wake_pin >= 0) {
|
||||
gpio_set_direction((gpio_num_t)wake_pin, GPIO_MODE_INPUT);
|
||||
}
|
||||
|
||||
//hold disable, isolate and power domain config functions may be unnecessary
|
||||
//gpio_deep_sleep_hold_dis();
|
||||
//esp_sleep_config_gpio_isolate();
|
||||
gpio_deep_sleep_hold_en();
|
||||
|
||||
#if defined(LORA_TX_BOOST_PIN)
|
||||
gpio_hold_en((gpio_num_t) LORA_TX_BOOST_PIN);
|
||||
gpio_deep_sleep_hold_en();
|
||||
#endif
|
||||
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
|
||||
|
||||
if (wake_pin >= 0) {
|
||||
esp_deep_sleep_enable_gpio_wakeup((1 << P_LORA_DIO_1) | (1 << wake_pin), ESP_GPIO_WAKEUP_GPIO_HIGH);
|
||||
} else {
|
||||
esp_deep_sleep_enable_gpio_wakeup(1 << P_LORA_DIO_1, ESP_GPIO_WAKEUP_GPIO_HIGH);
|
||||
}
|
||||
|
||||
if (secs > 0) {
|
||||
esp_sleep_enable_timer_wakeup(secs * 1000000);
|
||||
}
|
||||
|
||||
// Finally set ESP32 into sleep
|
||||
esp_deep_sleep_start(); // CPU halts here and never returns!
|
||||
}
|
||||
|
||||
#if defined(LORA_TX_BOOST_PIN) || defined(P_LORA_TX_LED)
|
||||
void onBeforeTransmit() override {
|
||||
#if defined(P_LORA_TX_LED)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
[Xiao_C6]
|
||||
extends = esp32c6_base
|
||||
board = esp32-c6-devkitm-1
|
||||
board_build.flash_mode = dio
|
||||
board_build.partitions = min_spiffs.csv ; get around 4mb flash limit
|
||||
build_flags =
|
||||
${esp32c6_base.build_flags}
|
||||
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
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();
|
||||
NRF52Board::powerOff();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user