Merge branch 'meshtastic:develop' into develop

This commit is contained in:
吴文峰
2026-07-31 10:32:02 +08:00
committed by GitHub
co-authored by GitHub
200 changed files with 4800 additions and 311 deletions
@@ -0,0 +1,41 @@
; First prototype eink/nrf52840/sx1262 device
[env:thinknode_m8]
custom_meshtastic_support_level = 1
custom_meshtastic_images = thinknode_m8.svg
custom_meshtastic_tags = Elecrow
custom_meshtastic_hw_model = 130
custom_meshtastic_hw_model_slug = THINKNODE_M8
custom_meshtastic_architecture = nrf52840
custom_meshtastic_display_name = Elecrow ThinkNode M8
custom_meshtastic_actively_supported = true
extends = nrf52840_base
board = ThinkNode-M8
board_check = true
debug_tool = jlink
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
build_flags =
${nrf52840_base.build_flags}
-I variants/nrf52840/ELECROW-ThinkNode-M8
-D ELECROW_ThinkNode_M8
-D EINK_DISPLAY_MODEL=GxEPD2_154_D67
-D EINK_WIDTH=200
-D EINK_HEIGHT=200
-D USE_EINK_DYNAMICDISPLAY ; Enable Dynamic EInk
-D EINK_LIMIT_FASTREFRESH=20 ; How many consecutive fast-refreshes are permitted //20
-D EINK_LIMIT_RATE_BACKGROUND_SEC=10 ; Minimum interval between BACKGROUND updates //30
-D EINK_LIMIT_RATE_RESPONSIVE_SEC=1 ; Minimum interval between RESPONSIVE updates
-D EINK_BACKGROUND_USES_FAST ; (Optional) Use FAST refresh for both BACKGROUND and RESPONSIVE, until a limit is reached.
build_src_filter =
${nrf52_base.build_src_filter}
+<../variants/nrf52840/ELECROW-ThinkNode-M8>
lib_deps =
${nrf52840_base.lib_deps}
# renovate: datasource=git-refs depName=meshtastic-GxEPD2 packageName=https://github.com/meshtastic/GxEPD2 gitBranch=master
https://github.com/meshtastic/GxEPD2/archive/c7eb4c3c167cf396ef4f541cc5d4c6aa42f3c46b.zip
# renovate: datasource=custom.pio depName=nRF52_PWM packageName=khoih-prog/library/nRF52_PWM
khoih-prog/nRF52_PWM@1.0.1
# renovate: datasource=custom.pio depName=SensorLib packageName=lewisxhe/library/SensorLib
lewisxhe/SensorLib@0.3.4
@@ -0,0 +1,75 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "variant.h"
#include "main.h"
#include "nrf.h"
#include "wiring_constants.h"
#include "wiring_digital.h"
#include <Wire.h>
const uint32_t g_ADigitalPinMap[] = {
// P0 - pins 0 and 1 are hardwired for xtal and should never be enabled
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,
// P1
32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47};
void initVariant()
{
pinMode(I2C_EN, OUTPUT);
digitalWrite(I2C_EN, HIGH);
pinMode(VCC_ELNK_EN, OUTPUT);
digitalWrite(VCC_ELNK_EN, HIGH);
pinMode(PIN_GPS_EN, OUTPUT);
digitalWrite(PIN_GPS_EN, HIGH);
pinMode(ADC_EN, OUTPUT);
digitalWrite(ADC_EN, HIGH);
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
}
void variant_shutdown()
{
auto dispdev = screen->getDisplayDevice();
dispdev->resetDisplay();
screen->forceDisplay();
delay(500);
digitalWrite(I2C_EN, LOW);
digitalWrite(VCC_ELNK_EN, LOW);
digitalWrite(PIN_GPS_EN, LOW);
digitalWrite(ADC_EN, LOW);
for (int pin = 0; pin < 48; pin++) {
if (pin == I2C_EN || pin == VCC_ELNK_EN || pin == PIN_GPS_EN || pin == ADC_EN || pin == PIN_BUTTON1 ||
pin == SX1262_SPI_NSS_PIN || pin == SX1262_SPI_SCK_PIN || pin == SX1262_SPI_MOSI_PIN || pin == SX1262_SPI_MISO_PIN ||
pin == SX1262_IRQ_PIN || pin == SX1262_NRESET_PIN || pin == SX126X_BUSY) {
continue;
}
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
if (pin >= 32) {
NRF_P1->DIRCLR = (1 << (pin - 32));
} else {
NRF_GPIO->DIRCLR = (1 << pin);
}
}
nrf_gpio_cfg_input(PIN_BUTTON1, NRF_GPIO_PIN_PULLUP); // Configure the pin to be woken up as an input
nrf_gpio_pin_sense_t sense1 = NRF_GPIO_PIN_SENSE_LOW;
nrf_gpio_cfg_sense_set(PIN_BUTTON1, sense1);
}
@@ -0,0 +1,182 @@
/*
Copyright (c) 2014-2015 Arduino LLC. All right reserved.
Copyright (c) 2016 Sandeep Mistry All right reserved.
Copyright (c) 2018, Adafruit Industries (adafruit.com)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _VARIANT_ELECROW_EINK_V1_0_
#define _VARIANT_ELECROW_EINK_V1_0_
/** Master clock frequency */
#define VARIANT_MCK (64000000ul)
#define USE_LFXO // Board uses 32khz crystal for LF
/*----------------------------------------------------------------------------
* Headers
*----------------------------------------------------------------------------*/
#include "WVariant.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
// Number of pins defined in PinDescription array
#define PINS_COUNT (48)
#define NUM_DIGITAL_PINS (48)
#define NUM_ANALOG_INPUTS (1)
#define NUM_ANALOG_OUTPUTS (0)
#define PIN_NFC1 (9)
#define PIN_NFC2 (10)
#define CANNED_MESSAGE_MODULE_ENABLE 1
/*Power*/
#define I2C_EN (0 + 13)
#define VCC_ELNK_EN (32 + 10)
#define PIN_GPS_EN (0 + 16) // active high
#define ADC_EN (32 + 8)
/*Buttons*/
#define HAS_BUTTON 1
#define PIN_BUTTON_E (0 + 12)
#define PIN_BUTTON_EC04_A (0 + 8)
#define PIN_BUTTON_EC04_B (32 + 9)
#define PIN_BUTTON_EC04 (0 + 6)
#define PIN_BUTTON1 PIN_BUTTON_E
// Press and turn the encoder to dim the frontlight
#define INPUTDRIVER_PRESS_AND_TURN_CW INPUT_BROKER_MSG_BRIGHTNESS_UP
#define INPUTDRIVER_PRESS_AND_TURN_CCW INPUT_BROKER_MSG_BRIGHTNESS_DOWN
/*LED*/
#define PIN_LED1 -1
#define LED_STATE_ON HIGH // State when LED is lit
#define LED_BLUE PIN_LED1
/*BUZZER*/
#define PIN_BUZZER (32 + 1)
/*USB_CHECK*/
// Reference only: sits on a divider from VBUS, too near the input threshold to read
// digitally. USB presence comes from USBREGSTATUS instead.
#define USB_VBUS (32 + 3)
/*CHARGE_CHECK*/
// Reference only: link resistors and pull-ups unpopulated on V0.3, so these never reach the MCU.
#define CHRG (32 + 5)
#define DONE (32 + 6)
/*Wire Interfaces*/
// Found by the I2C scan: PCF8563 RTC at 0x51, SC7A20 accelerometer at 0x19.
#define WIRE_INTERFACES_COUNT 1
#define PIN_WIRE_SDA (0 + 26)
#define PIN_WIRE_SCL (0 + 27)
/*GPS*/
// ATGM336H-5NR32. Probes as GNSS_MODEL_MTK; both branches speak CASIC $PCAS.
#define HAS_GPS 1
#define GPS_BAUDRATE 9600
#define PIN_GPS_RESET (0 + 17)
#define PIN_GPS_STANDBY (0 + 15) // An output to wake GPS, low means allow sleep, high means force wake
#define PIN_GPS_PPS (0 + 14) // 1PPS output, configured as an input by GPS.cpp
#define PIN_SERIAL1_RX (32 + 2)
#define PIN_SERIAL1_TX (32 + 4)
#define GPS_TX_PIN PIN_SERIAL1_TX
#define GPS_RX_PIN PIN_SERIAL1_RX
#define GPS_THREAD_INTERVAL 50
/*FLASH*/
#define PIN_QSPI_CS (32 + 15)
#define PIN_QSPI_SCK (32 + 14)
#define PIN_QSPI_IO0 (32 + 12) // MOSI if using two bit interface
#define PIN_QSPI_IO1 (32 + 13) // MISO if using two bit interface
#define PIN_QSPI_IO2 (0 + 7) // WP if using two bit interface (i.e. not used)
#define PIN_QSPI_IO3 (0 + 5) // HOLD if using two bit interface (i.e. not used)
#define EXTERNAL_FLASH_DEVICES MX25R1635F
#define EXTERNAL_FLASH_USE_QSPI
/*SPI*/
#define SPI_INTERFACES_COUNT 2
#define PIN_SPI_NSS (0 + 21)
#define PIN_SPI_SCK (0 + 19)
#define PIN_SPI_MOSI (0 + 20)
#define PIN_SPI_MISO (0 + 22)
#define PIN_SPI1_NSS (0 + 30)
#define PIN_SPI1_SCK (0 + 31)
#define PIN_SPI1_MOSI (0 + 29)
#define PIN_SPI1_MISO -1
/*EINK*/
#define MESHTASTIC_USE_EINK_UI 1
#define USE_EINK 1
#define PIN_EINK_CS PIN_SPI1_NSS
#define PIN_EINK_SCLK PIN_SPI1_SCK
#define PIN_EINK_MOSI PIN_SPI1_MOSI
#define PIN_EINK_BUSY (0 + 3)
#define PIN_EINK_DC (0 + 28)
#define PIN_EINK_RES (0 + 2)
// Panel supply is VCC_ELNK_EN; P1.11 is the dimmable frontlight. No PIN_EINK_EN on this board.
#define PIN_PWM_BACKLIGHT (32 + 11)
#define PWM_BACKLIGHT_DEFAULT 128
#define PWM_BACKLIGHT_MIN 8
#define PWM_BACKLIGHT_MAX 248
#define PWM_BACKLIGHT_STEP 20
/*Lora radio*/
#define USE_SX1262
// PE4259 /CTRL pad, held high for single-pin mode; the SX1262 selects the path from DIO2.
#define SX126X_ANT_SW (0 + 23)
#define SX126X_RESET (0 + 24) // RST
#define SX126X_DIO1 (0 + 25) // IRQ
#define SX126X_DIO2 (32 + 0) // BUSY
#define SX126X_SCK PIN_SPI_SCK
#define SX126X_MISO PIN_SPI_MISO
#define SX126X_MOSI PIN_SPI_MOSI
#define SX126X_CS PIN_SPI_NSS
#define SX1262_IRQ_PIN SX126X_DIO1
#define SX1262_NRESET_PIN SX126X_RESET
#define SX126X_BUSY SX126X_DIO2
#define SX1262_SPI_NSS_PIN SX126X_CS
#define SX1262_SPI_SCK_PIN SX126X_SCK
#define SX1262_SPI_MOSI_PIN SX126X_MOSI
#define SX1262_SPI_MISO_PIN SX126X_MISO
#define SX126X_DIO2_AS_RF_SWITCH
#define SX126X_DIO3_TCXO_VOLTAGE 3.3
/*Serial*/
#define SERIAL_PRINT_PORT 0 // USB CDC is the StreamAPI transport; no secondary UART
/*RTC*/
#define PCF8563_RTC 0x51
/*Battert*/
#define BATTERY_PIN (0 + 4)
#define ADC_V (0 + 4)
#define BATTERY_SENSE_RESOLUTION_BITS 12
#define BATTERY_SENSE_RESOLUTION 4096.0
#define BATTERY_SENSE_SAMPLES 100
#undef AREF_VOLTAGE
#define AREF_VOLTAGE 2.4
#define VBAT_AR_INTERNAL AR_INTERNAL_2_4
#define ADC_MULTIPLIER (1.75)
#ifdef __cplusplus
}
#endif
#endif
@@ -15,6 +15,7 @@ board = promicro-nrf52840
build_flags = ${nrf52840_base.build_flags}
-I variants/nrf52840/diy/nrf52_promicro_diy_tcxo
-D NRF52_PROMICRO_DIY
-D EXCLUDE_EMOJI ; this variant builds 4 radio driver families and is the largest nrf52 image; emote bitmaps don't fit under the 0xEA000 warm-store cap
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/diy/nrf52_promicro_diy_tcxo>
debug_tool = jlink
@@ -38,3 +39,17 @@ lib_deps =
extra_scripts =
${nrf52840_base.extra_scripts}
variants/nrf52840/diy/nrf52_promicro_diy_tcxo/custom_build_tasks.py ; Add to PIO's Project Tasks pane: preset builds for common displays
; NRF52 ProMicro w/ EasyProMicro pinout
[env:nrf52_promicro_diy-easypromicro]
board_level = extra
extends = nrf52840_base
board = promicro-nrf52840
build_flags =
${nrf52840_base.build_flags}
-I variants/nrf52840/diy/nrf52_promicro_diy_tcxo
-D NRF52_PROMICRO_DIY
-D EASYPROMICRO ; For EasyProMicro pinout (instead of ProMicro pinout)
build_src_filter = ${nrf52_base.build_src_filter} +<../variants/nrf52840/diy/nrf52_promicro_diy_tcxo>
debug_tool = jlink
@@ -44,6 +44,32 @@ NRF52 PRO MICRO PIN ASSIGNMENT
| P1.07 | Free pin   |   |         |             | |
*/
/*
Alternative pin assignement for Easy E22 Promicro build
https://github.com/brad112358/easy_E22
| Pin   | Function   |   | Pin     | Function     |
| ----- | ----------- | --- | -------- | ------------ |
| Gnd   |             |   | vbat     |             |
| P0.06 | BUTTON_PIN |   | vbat     |             |
| P0.08 | PIN_BUZZER |   | Gnd     |             |
| Gnd   |             |   | reset   |             |
| Gnd   |             |   | ext_vcc | *see 0.13   |
| P0.17 | Serial2 TX |   | P0.31   | BATTERY_PIN |
| P0.20 | Rotary B   |   | P0.29   | DIO1         |
| P0.22 | Rotary A   |   | P0.02   | BUSY |
| P0.24 | Rotary press|   | P1.15   | NRST         |
| P1.00 | TXEN |   | P1.13   | MISO         |
| P0.11 | RXEN        |   | P1.11   | MOSI        |
| P1.04 | SDA         |   | P0.10   | SCK     |
| P1.06 | SCL   |   | P0.09   | CS       |
|       |             |   |         |             |
|       | Mid board   |   |         | Internal     |
| P1.01 | Serial2 RX |   | 0.15     | LED         |
| P1.02 | TX to GPS   |   | 0.13     | 3V3_EN       |
| P1.07 | RX from GPS |   |         |             |
*/
// Number of pins defined in PinDescription array
#define PINS_COUNT (48)
#define NUM_DIGITAL_PINS (48)
@@ -76,8 +102,13 @@ NRF52 PRO MICRO PIN ASSIGNMENT
// WIRE IC AND IIC PINS
#define WIRE_INTERFACES_COUNT 1
#ifndef EASYPROMICRO
#define PIN_WIRE_SDA (32 + 4) // P1.04
#define PIN_WIRE_SCL (0 + 11) // P0.11
#else // Easy E22 Promicro arrangement
#define PIN_WIRE_SDA (32 + 4) // P1.04
#define PIN_WIRE_SCL (32 + 6) // P1.06
#endif
// LED
#define PIN_LED1 (0 + 15) // P0.15
@@ -86,13 +117,23 @@ NRF52 PRO MICRO PIN ASSIGNMENT
#define LED_STATE_ON 1 // State when LED is lit
// Button
#ifndef EASYPROMICRO
#define BUTTON_PIN (32 + 0) // P1.00
#else // Easy E22 Promicro arrangement
#define BUTTON_PIN (0 + 6) // P0.06
#endif
// GPS
#ifndef EASYPROMICRO
#define GPS_TX_PIN (0 + 20) // P0.20 - This is data from the MCU
#define GPS_RX_PIN (0 + 22) // P0.22 - This is data from the GNSS
#define PIN_GPS_EN (0 + 24) // P0.24
#else // Easy E22 Promicro arrangement
#define GPS_TX_PIN (32 + 2) // P1.02 - This is data from the MCU
#define GPS_RX_PIN (32 + 7) // P1.07 - This is data from the GNSS
#define PIN_GPS_EN (0 + 13) // P0.13 - Use power control for GPS enable
#endif
#define GPS_UBLOX
// define GPS_DEBUG
@@ -100,12 +141,20 @@ NRF52 PRO MICRO PIN ASSIGNMENT
#define PIN_SERIAL1_TX GPS_TX_PIN
#define PIN_SERIAL1_RX GPS_RX_PIN
#define PIN_SERIAL2_RX (0 + 6) // P0.06
#define PIN_SERIAL2_TX (0 + 8) // P0.08
#ifndef EASYPROMICRO
#define PIN_SERIAL2_RX (0 + 6) // P0.06
#define PIN_SERIAL2_TX (0 + 8) // P0.08
#else // Easy E22 Promicro arrangement
#define PIN_SERIAL2_RX (32 + 1) // P1.01
#define PIN_SERIAL2_TX (0 + 17) // P0.17
// Buzzer - PWM
#define PIN_BUZZER (0 + 8) // p0.08
#endif
// Serial interfaces
#define SPI_INTERFACES_COUNT 1
#ifndef EASYPROMICRO
#define PIN_SPI_MISO (0 + 2) // P0.02
#define PIN_SPI_MOSI (32 + 15) // P1.15
#define PIN_SPI_SCK (32 + 11) // P1.11
@@ -166,7 +215,35 @@ NRF52 PRO MICRO PIN ASSIGNMENT
#define LR2021_IRQ_DIO_NUM 9 // DIO9 → P0.10
#endif
// #define SX126X_MAX_POWER 8 set this if using a high-power board!
#else // Easy E22 Promicro arrangement
#define USE_SSD1306
// #define USE_SH1106
#define USE_SX1262
#define PIN_SPI_MISO (32 + 13) // P1.13
#define PIN_SPI_MOSI (32 + 11) // P1.11
#define PIN_SPI_SCK (0 + 10) // P0.10
#define LORA_MISO PIN_SPI_MISO
#define LORA_MOSI PIN_SPI_MOSI
#define LORA_SCK PIN_SPI_SCK
#define LORA_CS (0 + 9) // P0.09 NSS
#define LORA_DIO0 (0 + 2) // P0.02 BUSY
#define LORA_DIO1 (0 + 29) // P0.29 IRQ
#define LORA_RESET (32 + 15) // P1.15 NRST
#define SX126X_CS LORA_CS
#define SX126X_DIO1 LORA_DIO1
#define SX126X_BUSY LORA_DIO0
#define SX126X_RESET LORA_RESET
#define SX126X_RXEN (0 + 11) // P0.11
#define SX126X_TXEN (32 + 0) // P1.00
#define SX126X_MAX_POWER 8 // Default to prevent damage to E22_900M33S; Comment out for others
#undef TX_GAIN_LORA
#define TX_GAIN_LORA 22 // 8 for E22 900M30S, 25 for 900M33S, 22 for 3.7V battery powered 900M33S, 0 for 900M22S
#endif
// #define SX126X_MAX_POWER 8 // set this if using a high-power board!
/*
On the SX1262, DIO3 sets the voltage for an external TCXO, if one is present. If one is not present, use TCXO_OPTIONAL to try both
@@ -11,7 +11,6 @@ custom_meshtastic_tags = Heltec
extends = nrf52840_base
board = heltec_mesh_node_t096
board_level = pr
debug_tool = jlink
build_flags = ${nrf52840_base.build_flags}
@@ -11,7 +11,6 @@ custom_meshtastic_tags = Heltec
extends = nrf52840_base
board = heltec_mesh_node_t1
board_level = pr
debug_tool = jlink
build_flags = ${nrf52840_base.build_flags}
@@ -2,7 +2,6 @@
[heltec_mesh_solar_base]
extends = nrf52840_base
board = heltec_mesh_solar
board_level = pr
debug_tool = jlink
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
@@ -11,7 +11,6 @@ custom_meshtastic_tags = Heltec
extends = nrf52840_base
board = heltec_mesh_tower_v2
board_level = pr
debug_tool = jlink
# add -DCFG_SYSVIEW if you want to use the Segger systemview tool for OS profiling.
@@ -6,7 +6,6 @@ custom_meshtastic_tags = RAK
extends = nrf52840_base
board = wiscore_rak4631
board_level = pr
board_check = true
custom_meshtastic_hw_model = 105
custom_meshtastic_hw_model_slug = WISMESH_TAG
@@ -11,7 +11,6 @@ custom_meshtastic_tags = Seeed
extends = nrf52840_base
board = xiao_ble_sense
board_level = pr
build_flags = ${nrf52840_base.build_flags}
-I variants/nrf52840/seeed_xiao_nrf52840_kit
-I src/platform/nrf52/softdevice
-2
View File
@@ -12,7 +12,6 @@ custom_meshtastic_has_ink_hud = true
extends = nrf52840_base
board = t-echo
board_level = pr
board_check = true
debug_tool = jlink
@@ -39,7 +38,6 @@ lib_deps =
[env:t-echo-inkhud]
extends = nrf52840_base, inkhud
board = t-echo
board_level = pr
board_check = true
debug_tool = jlink
build_flags =
@@ -10,7 +10,6 @@ custom_meshtastic_requires_dfu = true
extends = nrf52840_base
board = t-impulse-plus
board_level = pr
build_flags = ${nrf52840_base.build_flags}
-I variants/nrf52840/t-impulse-plus