mirror of https://github.com/meshcore-dev/MeshCore
60 changed files with 1234 additions and 240 deletions
@ -0,0 +1,44 @@ |
|||
{ |
|||
"build": { |
|||
"arduino": { |
|||
"ldscript": "esp32s3_out.ld", |
|||
"partitions": "default_16MB.csv", |
|||
"memory_type": "qio_opi" |
|||
}, |
|||
"core": "esp32", |
|||
"extra_flags": [ |
|||
"-DBOARD_HAS_PSRAM", |
|||
"-DARDUINO_USB_MODE=0", |
|||
"-DARDUINO_USB_CDC_ON_BOOT=1", |
|||
"-DARDUINO_RUNNING_CORE=1", |
|||
"-DARDUINO_EVENT_RUNNING_CORE=1" |
|||
], |
|||
"f_cpu": "240000000L", |
|||
"f_flash": "80000000L", |
|||
"flash_mode": "qio", |
|||
"psram_type": "opi", |
|||
"hwids": [ |
|||
["0x303A", "0x1001"], |
|||
["0x303A", "0x0002"] |
|||
], |
|||
"mcu": "esp32s3", |
|||
"variant": "heltec_vision_master_t190" |
|||
}, |
|||
"connectivity": ["wifi", "bluetooth", "lora"], |
|||
"debug": { |
|||
"openocd_target": "esp32s3.cfg" |
|||
}, |
|||
"frameworks": ["arduino", "espidf"], |
|||
"name": "Heltec Vision Master T190", |
|||
"upload": { |
|||
"flash_size": "16MB", |
|||
"maximum_ram_size": 8388608, |
|||
"maximum_size": 16777216, |
|||
"use_1200bps_touch": true, |
|||
"wait_for_upload_port": true, |
|||
"require_upload_port": true, |
|||
"speed": 921600 |
|||
}, |
|||
"url": "https://heltec.org/project/vision-master-t190/", |
|||
"vendor": "Heltec" |
|||
} |
|||
@ -0,0 +1,64 @@ |
|||
from os.path import realpath |
|||
|
|||
Import("env") # type: ignore |
|||
menv=env # type: ignore |
|||
|
|||
src_filter = [ |
|||
'+<*.cpp>', |
|||
'+<helpers/*.cpp>', |
|||
'+<helpers/sensors>', |
|||
'+<helpers/radiolib/*.cpp>', |
|||
'+<helpers/ui/MomentaryButton.cpp>', |
|||
'+<helpers/ui/buzzer.cpp>', |
|||
] |
|||
|
|||
# add build and include dirs according to CPPDEFINES |
|||
for item in menv.get("CPPDEFINES", []): |
|||
|
|||
# PLATFORM HANDLING |
|||
if item == "STM32_PLATFORM": |
|||
src_filter.append("+<helpers/stm32/*>") |
|||
elif item == "ESP32": |
|||
src_filter.append("+<helpers/esp32/*>") |
|||
elif item == "NRF52_PLATFORM": |
|||
src_filter.append("+<helpers/nrf52/*>") |
|||
elif item == "RP2040_PLATFORM": |
|||
src_filter.append("+<helpers/rp2040/*>") |
|||
|
|||
# DISPLAY HANDLING |
|||
elif isinstance(item, tuple) and item[0] == "DISPLAY_CLASS": |
|||
display_class = item[1] |
|||
src_filter.append(f"+<helpers/ui/{display_class}.cpp>") |
|||
if (display_class == "ST7789Display") : |
|||
src_filter.append(f"+<helpers/ui/OLEDDisplay.cpp>") |
|||
src_filter.append(f"+<helpers/ui/OLEDDisplayFonts.cpp>") |
|||
|
|||
# VARIANTS HANDLING |
|||
elif isinstance(item, tuple) and item[0] == "MC_VARIANT": |
|||
variant_name = item[1] |
|||
src_filter.append(f"+<../variants/{variant_name}>") |
|||
|
|||
# INCLUDE EXAMPLE CODE IN BUILD (to provide your own support files without touching the tree) |
|||
elif isinstance(item, tuple) and item[0] == "BUILD_EXAMPLE": |
|||
example_name = item[1] |
|||
src_filter.append(f"+<../examples/{example_name}/*.cpp>") |
|||
|
|||
# EXCLUDE A SOURCE FILE FROM AN EXAMPLE (must be placed after example name or boom) |
|||
elif isinstance(item, tuple) and item[0] == "EXCLUDE_FROM_EXAMPLE": |
|||
exclude_name = item[1] |
|||
if example_name is None: |
|||
print("***** PLEASE DEFINE EXAMPLE FIRST *****") |
|||
break |
|||
src_filter.append(f"-<../examples/{example_name}/{exclude_name}>") |
|||
|
|||
# DEAL WITH UI VARIANT FOR AN EXAMPLE |
|||
elif isinstance(item, tuple) and item[0] == "MC_UI_FLAVOR": |
|||
ui_flavor = item[1] |
|||
if example_name is None: |
|||
print("***** PLEASE DEFINE EXAMPLE FIRST *****") |
|||
break |
|||
src_filter.append(f"+<../examples/{example_name}/{ui_flavor}/*.cpp>") |
|||
|
|||
menv.Replace(SRC_FILTER=src_filter) |
|||
|
|||
#print (menv.Dump()) |
|||
@ -0,0 +1,16 @@ |
|||
{ |
|||
"name": "MeshCore", |
|||
"version" : "1.8.0", |
|||
"dependencies": { |
|||
"SPI": "*", |
|||
"Wire": "*", |
|||
"jgromes/RadioLib": "^7.1.2", |
|||
"rweather/Crypto": "^0.4.0", |
|||
"adafruit/RTClib": "^2.1.3", |
|||
"melopero/Melopero RV3028": "^1.1.0", |
|||
"electroniccats/CayenneLPP": "1.4.0" |
|||
}, |
|||
"build": { |
|||
"extraScript": "build_as_lib.py" |
|||
} |
|||
} |
|||
@ -53,7 +53,7 @@ build_src_filter = |
|||
|
|||
[esp32_base] |
|||
extends = arduino_base |
|||
platform = platformio/espressif32@^6.11.0 |
|||
platform = platformio/[email protected] |
|||
monitor_filters = esp32_exception_decoder |
|||
extra_scripts = merge-bin.py |
|||
build_flags = ${arduino_base.build_flags} |
|||
@ -68,7 +68,7 @@ lib_deps = |
|||
; esp32c6 uses arduino framework 3.x |
|||
[esp32c6_base] |
|||
extends = esp32_base |
|||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/54.03.21/platform-espressif32.zip |
|||
platform = https://github.com/pioarduino/platform-espressif32/releases/download/53.03.12/platform-espressif32.zip |
|||
|
|||
; ----------------- NRF52 --------------------- |
|||
|
|||
|
|||
@ -0,0 +1,69 @@ |
|||
#include "HeltecT190Board.h" |
|||
|
|||
void HeltecT190Board::begin() { |
|||
ESP32Board::begin(); |
|||
|
|||
pinMode(PIN_ADC_CTRL, OUTPUT); |
|||
digitalWrite(PIN_ADC_CTRL, LOW); // Initially inactive
|
|||
|
|||
periph_power.begin(); |
|||
|
|||
esp_reset_reason_t reason = esp_reset_reason(); |
|||
if (reason == ESP_RST_DEEPSLEEP) { |
|||
long wakeup_source = esp_sleep_get_ext1_wakeup_status(); |
|||
if (wakeup_source & (1 << P_LORA_DIO_1)) { // received a LoRa packet (while in deep sleep)
|
|||
startup_reason = BD_STARTUP_RX_PACKET; |
|||
} |
|||
|
|||
rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS); |
|||
rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1); |
|||
} |
|||
} |
|||
|
|||
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() { |
|||
// TODO: re-enable this when there is a definite wake-up source pin:
|
|||
// enterDeepSleep(0);
|
|||
} |
|||
|
|||
uint16_t HeltecT190Board::getBattMilliVolts() { |
|||
analogReadResolution(10); |
|||
digitalWrite(PIN_ADC_CTRL, HIGH); |
|||
delay(10); |
|||
uint32_t raw = 0; |
|||
for (int i = 0; i < 8; i++) { |
|||
raw += analogRead(PIN_VBAT_READ); |
|||
} |
|||
raw = raw / 8; |
|||
|
|||
digitalWrite(PIN_ADC_CTRL, LOW); |
|||
|
|||
return (5.42 * (3.3 / 1024.0) * raw) * 1000; |
|||
} |
|||
|
|||
const char* HeltecT190Board::getManufacturerName() const { |
|||
return "Heltec T190"; |
|||
} |
|||
|
|||
@ -0,0 +1,30 @@ |
|||
#pragma once |
|||
|
|||
#include <Arduino.h> |
|||
#include <helpers/RefCountedDigitalPin.h> |
|||
#include <helpers/ESP32Board.h> |
|||
#include <driver/rtc_io.h> |
|||
|
|||
// LoRa radio module pins for heltec_vision_master_e290
|
|||
#define P_LORA_DIO_1 14 |
|||
#define P_LORA_NSS 8 |
|||
#define P_LORA_RESET 12 |
|||
#define P_LORA_BUSY 13 |
|||
#define P_LORA_SCLK 9 |
|||
#define P_LORA_MISO 11 |
|||
#define P_LORA_MOSI 10 |
|||
|
|||
class HeltecT190Board : public ESP32Board { |
|||
|
|||
public: |
|||
RefCountedDigitalPin periph_power; |
|||
|
|||
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,61 @@ |
|||
#ifndef Pins_Arduino_h |
|||
#define Pins_Arduino_h |
|||
|
|||
#include <stdint.h> |
|||
|
|||
static const uint8_t LED_BUILTIN = 45; // LED is not populated on earliest board variant
|
|||
#define BUILTIN_LED LED_BUILTIN // Backward compatibility
|
|||
#define LED_BUILTIN LED_BUILTIN |
|||
|
|||
static const uint8_t TX = 43; |
|||
static const uint8_t RX = 44; |
|||
|
|||
static const uint8_t SDA = 2; |
|||
static const uint8_t SCL = 1; |
|||
|
|||
static const uint8_t SS = 8; |
|||
static const uint8_t MOSI = 10; |
|||
static const uint8_t MISO = 11; |
|||
static const uint8_t SCK = 9; |
|||
|
|||
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; |
|||
|
|||
static const uint8_t RST_LoRa = 12; |
|||
static const uint8_t BUSY_LoRa = 13; |
|||
static const uint8_t DIO1 = 14; |
|||
|
|||
#endif /* Pins_Arduino_h */ |
|||
@ -0,0 +1,87 @@ |
|||
[Heltec_Vision_Master_T190_base] |
|||
extends = esp32_base |
|||
board = heltec_vision_master_t190 |
|||
build_flags = |
|||
${esp32_base.build_flags} |
|||
-I variants/heltec_vision_master_t190 |
|||
-I src/helpers/ui |
|||
-D HELTEC_VISION_MASTER_T190 |
|||
-D RADIO_CLASS=CustomSX1262 |
|||
-D WRAPPER_CLASS=CustomSX1262Wrapper |
|||
-D LORA_TX_POWER=22 |
|||
-D PIN_USER_BTN=0 |
|||
-D PIN_VEXT_EN=5 |
|||
-D PIN_VEXT_EN_ACTIVE=HIGH |
|||
-D PIN_VBAT_READ=6 |
|||
-D PIN_ADC_CTRL=46 |
|||
-D SX126X_DIO2_AS_RF_SWITCH=true |
|||
-D SX126X_DIO3_TCXO_VOLTAGE=1.8 |
|||
-D SX126X_CURRENT_LIMIT=140 |
|||
-D SX126X_RX_BOOSTED_GAIN=1 |
|||
-D PIN_BOARD_SDA=2 |
|||
-D PIN_BOARD_SCL=1 |
|||
-D PIN_TFT_SCL=38 |
|||
-D PIN_TFT_SDA=48 |
|||
-D PIN_TFT_RST=40 |
|||
-D PIN_TFT_VDD_CTL=7 |
|||
-D PIN_TFT_LEDA_CTL=17 |
|||
-D PIN_TFT_LEDA_CTL_ACTIVE=HIGH |
|||
-D PIN_TFT_CS=39 |
|||
-D PIN_TFT_DC=47 |
|||
-D ST7789 |
|||
-D DISPLAY_CLASS=ST7789Display |
|||
build_src_filter = ${esp32_base.build_src_filter} |
|||
+<../variants/heltec_vision_master_t190> |
|||
+<helpers/*.cpp> |
|||
+<helpers/ui/ST7789Display.cpp> |
|||
+<helpers/ui/OLEDDisplay.cpp> |
|||
+<helpers/ui/OLEDDisplayFonts.cpp> |
|||
lib_deps = |
|||
${esp32_base.lib_deps} |
|||
adafruit/Adafruit GFX Library @ ^1.12.1 |
|||
|
|||
[env:Heltec_Vision_Master_T190_radio_ble] |
|||
extends = Heltec_Vision_Master_T190_base |
|||
build_flags = |
|||
${Heltec_Vision_Master_T190_base.build_flags} |
|||
-I examples/companion_radio/ui-new |
|||
-D MAX_CONTACTS=300 |
|||
-D MAX_GROUP_CHANNELS=8 |
|||
-D BLE_PIN_CODE=123456 ; dynamic, random PIN |
|||
-D BLE_DEBUG_LOGGING=1 |
|||
-D OFFLINE_QUEUE_SIZE=256 |
|||
build_src_filter = ${Heltec_Vision_Master_T190_base.build_src_filter} |
|||
+<helpers/esp32/*.cpp> |
|||
+<../examples/companion_radio/*.cpp> |
|||
+<../examples/companion_radio/ui-new/*.cpp> |
|||
lib_deps = |
|||
${Heltec_Vision_Master_T190_base.lib_deps} |
|||
densaugeo/base64 @ ~1.4.0 |
|||
|
|||
[env:Heltec_Vision_Master_T190_repeater] |
|||
extends = Heltec_Vision_Master_T190_base |
|||
build_flags = |
|||
${Heltec_Vision_Master_T190_base.build_flags} |
|||
-D ADVERT_NAME='"Heltec T190 Repeater"' |
|||
-D ADVERT_LAT=0.0 |
|||
-D ADVERT_LON=0.0 |
|||
build_src_filter = ${Heltec_Vision_Master_T190_base.build_src_filter} |
|||
+<../examples/simple_repeater> |
|||
lib_deps = |
|||
${Heltec_Vision_Master_T190_base.lib_deps} |
|||
${esp32_ota.lib_deps} |
|||
|
|||
[env:Heltec_Vision_Master_T190_room_server] |
|||
extends = Heltec_Vision_Master_T190_base |
|||
build_flags = |
|||
${Heltec_Vision_Master_T190_base.build_flags} |
|||
-D ADVERT_NAME='"Heltec T190 Room"' |
|||
-D ADVERT_LAT=0.0 |
|||
-D ADVERT_LON=0.0 |
|||
-D ADMIN_PASSWORD='"password"' |
|||
-D ROOM_PASSWORD='"hello"' |
|||
build_src_filter = ${Heltec_Vision_Master_T190_base.build_src_filter} |
|||
+<../examples/simple_room_server> |
|||
lib_deps = |
|||
${Heltec_Vision_Master_T190_base.lib_deps} |
|||
${esp32_ota.lib_deps} |
|||
@ -0,0 +1,54 @@ |
|||
#include "target.h" |
|||
#include <Arduino.h> |
|||
|
|||
HeltecT190Board board; |
|||
|
|||
#if defined(P_LORA_SCLK) |
|||
static SPIClass spi(FSPI); |
|||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi); |
|||
#else |
|||
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY); |
|||
#endif |
|||
|
|||
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 |
|||
|
|||
bool radio_init() { |
|||
fallback_clock.begin(); |
|||
rtc_clock.begin(Wire); |
|||
|
|||
#if defined(P_LORA_SCLK) |
|||
return radio.std_init(&spi); |
|||
#else |
|||
return radio.std_init(); |
|||
#endif |
|||
} |
|||
|
|||
uint32_t radio_get_rng_seed() { |
|||
return radio.random(0x7FFFFFFF); |
|||
} |
|||
|
|||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr) { |
|||
radio.setFrequency(freq); |
|||
radio.setSpreadingFactor(sf); |
|||
radio.setBandwidth(bw); |
|||
radio.setCodingRate(cr); |
|||
} |
|||
|
|||
void radio_set_tx_power(uint8_t dbm) { |
|||
radio.setOutputPower(dbm); |
|||
} |
|||
|
|||
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 <HeltecT190Board.h> |
|||
#include <helpers/radiolib/CustomSX1262Wrapper.h> |
|||
#include <helpers/AutoDiscoverRTCClock.h> |
|||
#include <helpers/SensorManager.h> |
|||
#ifdef DISPLAY_CLASS |
|||
#include <helpers/ui/ST7789Display.h> |
|||
#include <helpers/ui/MomentaryButton.h> |
|||
#endif |
|||
|
|||
extern HeltecT190Board 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(); |
|||
uint32_t radio_get_rng_seed(); |
|||
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr); |
|||
void radio_set_tx_power(uint8_t dbm); |
|||
mesh::LocalIdentity radio_new_identity(); |
|||
Loading…
Reference in new issue