Update Pins
This commit is contained in:
parent
1e9f24841e
commit
8ed49ad55b
99 changed files with 7608 additions and 2687 deletions
|
|
@ -4,7 +4,7 @@
|
|||
* @license MIT
|
||||
* @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd
|
||||
* @date 2024-04-24
|
||||
* @last-update 2024-08-07
|
||||
* @last-update 2025-04-09
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
@ -17,7 +17,7 @@
|
|||
#include <BLEServer.h>
|
||||
#endif
|
||||
|
||||
#if defined(HAS_SDCARD)
|
||||
#if defined(HAS_SDCARD) && !defined(SD_SHARE_SPI_BUS)
|
||||
SPIClass SDCardSPI(HSPI);
|
||||
#endif
|
||||
|
||||
|
|
@ -472,21 +472,82 @@ bool beginDisplay()
|
|||
return false;
|
||||
}
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
bool writeFile(const char *path, const char *buffer)
|
||||
{
|
||||
bool rlst = false;
|
||||
File file = SD.open(path, FILE_WRITE);
|
||||
if (!file) {
|
||||
Serial.println("Failed to open file for writing");
|
||||
return false;
|
||||
}
|
||||
if (file.print(buffer)) {
|
||||
Serial.println("File written");
|
||||
rlst = true;
|
||||
} else {
|
||||
Serial.println("Write failed");
|
||||
rlst = false;
|
||||
}
|
||||
file.close();
|
||||
return rlst;
|
||||
}
|
||||
|
||||
|
||||
bool readFile(const char *path, uint8_t *buffer, size_t size)
|
||||
{
|
||||
File file = SD.open(path, FILE_READ);
|
||||
if (!file) {
|
||||
Serial.println("Failed to open file for reading");
|
||||
return false;
|
||||
}
|
||||
file.read(buffer, size);
|
||||
file.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool testSDWriteAndRead()
|
||||
{
|
||||
const char *path = "/test_sd.txt";
|
||||
const char *message = "This is a string for reading and writing SD card.";
|
||||
uint8_t buffer[128] = {0};
|
||||
|
||||
if (!writeFile(path, message)) {
|
||||
Serial.println("SD Text write failed");
|
||||
return false;
|
||||
}
|
||||
delay(100);
|
||||
|
||||
readFile(path, buffer, 128);
|
||||
|
||||
if (memcmp(buffer, message, strlen(message)) != 0) {
|
||||
Serial.println("SD verification failed");
|
||||
return false;
|
||||
}
|
||||
Serial.println("SD verification successful");
|
||||
return true;
|
||||
}
|
||||
#endif /*HAS_SDCARD*/
|
||||
|
||||
bool beginSDCard()
|
||||
{
|
||||
#ifdef SDCARD_CS
|
||||
if (SD.begin(SDCARD_CS, SDCardSPI)) {
|
||||
#ifdef HAS_SDCARD
|
||||
#if defined(HAS_SDCARD) && defined(SD_SHARE_SPI_BUS)
|
||||
bool rlst = SD.begin(SDCARD_CS);
|
||||
#else
|
||||
bool rlst = SD.begin(SDCARD_CS, SDCardSPI);
|
||||
#endif
|
||||
|
||||
if (rlst) {
|
||||
uint32_t cardSize = SD.cardSize() / (1024 * 1024);
|
||||
Serial.print("Sd Card init succeeded, The current available capacity is ");
|
||||
Serial.print(cardSize / 1024.0);
|
||||
Serial.println(" GB");
|
||||
deviceOnline |= SDCARD_ONLINE;
|
||||
return true;
|
||||
return testSDWriteAndRead();
|
||||
} else {
|
||||
Serial.println("Warning: Failed to init Sd Card");
|
||||
}
|
||||
#endif
|
||||
#endif /*HAS_SDCARD*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -630,9 +691,18 @@ void setupBoards(bool disable_u8g2 )
|
|||
SPI.begin();
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
|
||||
#if defined(HAS_SDCARD)
|
||||
#if defined(SD_SHARE_SPI_BUS)
|
||||
// Share spi bus with lora , set lora cs,rst to high
|
||||
pinMode(RADIO_CS_PIN, OUTPUT);
|
||||
pinMode(RADIO_RST_PIN, OUTPUT);
|
||||
digitalWrite(RADIO_CS_PIN, HIGH);
|
||||
digitalWrite(RADIO_RST_PIN, HIGH);
|
||||
#else
|
||||
SDCardSPI.begin(SDCARD_SCLK, SDCARD_MISO, SDCARD_MOSI);
|
||||
#endif
|
||||
#endif /*SD_SHARE_SPI_BUS*/
|
||||
#endif /*HAS_SDCARD*/
|
||||
|
||||
#ifdef I2C_SDA
|
||||
Wire.begin(I2C_SDA, I2C_SCL);
|
||||
|
|
@ -688,6 +758,11 @@ void setupBoards(bool disable_u8g2 )
|
|||
digitalWrite(GPS_RST_PIN, HIGH);
|
||||
#endif
|
||||
|
||||
#ifdef GPS_WAKEUP_PIN
|
||||
pinMode(GPS_WAKEUP_PIN, OUTPUT);
|
||||
digitalWrite(GPS_WAKEUP_PIN, HIGH);
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(ARDUINO_ARCH_STM32)
|
||||
SerialGPS.println("@GSR"); delay(300);
|
||||
|
|
@ -718,6 +793,10 @@ void setupBoards(bool disable_u8g2 )
|
|||
digitalWrite(RADIO_CTRL, LOW);
|
||||
#endif
|
||||
|
||||
#ifdef RADIO_DIO2_PIN
|
||||
pinMode(RADIO_DIO2_PIN, INPUT);
|
||||
#endif
|
||||
|
||||
beginPower();
|
||||
|
||||
beginSDCard();
|
||||
|
|
@ -736,7 +815,7 @@ void setupBoards(bool disable_u8g2 )
|
|||
|
||||
#ifdef HAS_GPS
|
||||
|
||||
#if defined(T_BEAM_S3_SUPREME) || defined(T_BEAM_2W)
|
||||
#if defined(T_BEAM_S3_SUPREME) || defined(T_BEAM_2W) || defined(T_BEAM_S3_BPF)
|
||||
// T-Beam v1.2 skips L76K
|
||||
find_gps = beginGPS();
|
||||
#endif
|
||||
|
|
@ -1081,7 +1160,7 @@ bool recoveryGPS()
|
|||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
|
||||
//NCP18XH103F03RB: https://item.szlcsc.com/14214.html
|
||||
#define NTC_PIN 14 // NTC connection pins
|
||||
// #define NTC_PIN 14 // NTC connection pins
|
||||
#define SERIES_RESISTOR 10000 // Series resistance value (10kΩ)
|
||||
#define B_COEFFICIENT 3950 // B value, set according to the NTC specification
|
||||
#define ROOM_TEMP 298.15 // 25°C absolute temperature (K)
|
||||
|
|
@ -1099,9 +1178,9 @@ float getTempForNTC()
|
|||
// Calculate temperature using the Steinhart-Hart equation
|
||||
temperature = (1.0 / (log(resistance / ROOM_TEMP_RESISTANCE) / B_COEFFICIENT + 1.0 / ROOM_TEMP)) - 273.15;
|
||||
|
||||
Serial.print("Temperature: ");
|
||||
Serial.print(temperature);
|
||||
Serial.println(" °C");
|
||||
// Serial.print("Temperature: ");
|
||||
// Serial.print(temperature);
|
||||
// Serial.println(" °C");
|
||||
|
||||
check_temperature = millis() + 1000;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,6 +145,11 @@
|
|||
#define HAS_DISPLAY
|
||||
#define BOARD_VARIANT_NAME "T3 V1.3"
|
||||
|
||||
#define BAT_ADC_PULLUP_RES (100000.0)
|
||||
#define BAT_ADC_PULLDOWN_RES (100000.0)
|
||||
#define BAT_MAX_VOLTAGE (4.2)
|
||||
#define BAT_VOL_COMPENSATION (0.0)
|
||||
|
||||
#elif defined(T3_V1_6_SX1276) || defined(T3_V1_6_SX1278)
|
||||
|
||||
|
||||
|
|
@ -189,6 +194,10 @@
|
|||
|
||||
#define BOARD_VARIANT_NAME "T3 V1.6"
|
||||
|
||||
#define BAT_ADC_PULLUP_RES (100000.0)
|
||||
#define BAT_ADC_PULLDOWN_RES (100000.0)
|
||||
#define BAT_MAX_VOLTAGE (4.2)
|
||||
#define BAT_VOL_COMPENSATION (0.0)
|
||||
|
||||
#elif defined(T3_V1_6_SX1276_TCXO)
|
||||
|
||||
|
|
@ -230,7 +239,10 @@
|
|||
|
||||
#define BOARD_VARIANT_NAME "T3 V1.6 TCXO"
|
||||
|
||||
|
||||
#define BAT_ADC_PULLUP_RES (100000.0)
|
||||
#define BAT_ADC_PULLDOWN_RES (100000.0)
|
||||
#define BAT_MAX_VOLTAGE (4.2)
|
||||
#define BAT_VOL_COMPENSATION (0.0)
|
||||
|
||||
#elif defined(T3_V3_0)
|
||||
|
||||
|
|
@ -276,8 +288,6 @@
|
|||
#define BOARD_LED 25
|
||||
#define LED_ON HIGH
|
||||
|
||||
#define ADC_PIN 35
|
||||
|
||||
#define HAS_SDCARD
|
||||
#define HAS_DISPLAY
|
||||
|
||||
|
|
@ -286,6 +296,10 @@
|
|||
#define BUTTON_PIN 0
|
||||
#define ADC_PIN 35
|
||||
|
||||
#define BAT_ADC_PULLUP_RES (100000.0)
|
||||
#define BAT_ADC_PULLDOWN_RES (100000.0)
|
||||
#define BAT_MAX_VOLTAGE (4.2)
|
||||
#define BAT_VOL_COMPENSATION (0.0)
|
||||
|
||||
#elif defined(T3_S3_V1_2_SX1262) || defined(ARDUINO_LILYGO_T3S3_SX1262) || \
|
||||
defined(T3_S3_V1_2_SX1276) || defined(ARDUINO_LILYGO_T3S3_SX1276) || \
|
||||
|
|
@ -345,6 +359,11 @@
|
|||
|
||||
#define RADIO_RST_PIN 8
|
||||
|
||||
#define BAT_ADC_PULLUP_RES (100000.0)
|
||||
#define BAT_ADC_PULLDOWN_RES (100000.0)
|
||||
#define BAT_MAX_VOLTAGE (4.2)
|
||||
#define BAT_VOL_COMPENSATION (0.0)
|
||||
|
||||
#if defined(USING_SX1262)
|
||||
|
||||
#define RADIO_DIO1_PIN 33
|
||||
|
|
@ -545,33 +564,33 @@
|
|||
#define USING_SX1278
|
||||
#endif
|
||||
|
||||
#define I2C_SDA 8
|
||||
#define I2C_SCL 9
|
||||
#define I2C_SDA (8)
|
||||
#define I2C_SCL (9)
|
||||
|
||||
#define PMU_IRQ 4
|
||||
#define PMU_IRQ (4)
|
||||
|
||||
#define GPS_RX_PIN 5
|
||||
#define GPS_TX_PIN 6
|
||||
#define GPS_PPS_PIN 7
|
||||
#define GPS_RX_PIN (5)
|
||||
#define GPS_TX_PIN (6)
|
||||
#define GPS_PPS_PIN (7)
|
||||
|
||||
#define BUTTON_PIN 0
|
||||
#define BUTTON_PIN (0)
|
||||
#define BUTTON2_PIN (3) /*BUTTON 2 = GPIO3*/
|
||||
#define BUTTON_PIN_MASK GPIO_SEL_0 /*BUTTON 1 = GPIO0*/
|
||||
#define BUTTON_COUNT (2)
|
||||
#define BUTTON_ARRAY {BUTTON_PIN, 3 /*BUTTON 2 = GPIO3*/}
|
||||
#define BUTTON_ARRAY {BUTTON_PIN, BUTTON2_PIN /*BUTTON 2 = GPIO3*/}
|
||||
|
||||
#define RADIO_SCLK_PIN (41)
|
||||
#define RADIO_MISO_PIN (42)
|
||||
#define RADIO_MOSI_PIN (2)
|
||||
#define RADIO_SCLK_PIN (12)//(41)
|
||||
#define RADIO_MISO_PIN (13)//(42)
|
||||
#define RADIO_MOSI_PIN (11)//(2)
|
||||
#define RADIO_CS_PIN (1)
|
||||
#define RADIO_RST_PIN (18)
|
||||
|
||||
#define RADIO_DIO0_PIN (14)
|
||||
#define RADIO_DIO1_PIN (21)
|
||||
#define RADIO_DIO2_PIN (15)
|
||||
|
||||
#define RADIO_TCXO_ENABLE (17)
|
||||
// #define RADIO_TCXO_ENABLE (17)
|
||||
#define RADIO_LDO_EN (16)
|
||||
#define RADIO_BUSY_PIN (RADIO_DIO1_PIN)
|
||||
#define RADIO_CTRL (39)
|
||||
|
||||
#define SPI_MOSI (11)
|
||||
#define SPI_SCK (12)
|
||||
|
|
@ -590,13 +609,11 @@
|
|||
#define HAS_GPS
|
||||
#define HAS_DISPLAY
|
||||
#define HAS_PMU
|
||||
|
||||
#define __HAS_SPI1__
|
||||
#define HAS_SENSOR
|
||||
#define SD_SHARE_SPI_BUS
|
||||
|
||||
#define PMU_WIRE_PORT Wire
|
||||
#define DISPLAY_MODEL U8G2_SH1106_128X64_NONAME_F_HW_I2C
|
||||
#define DISPLAY_MODEL_SSD_LIB SSD1306Wire
|
||||
#define DISPLAY_MODEL_SSD_LIB SH1106Wire
|
||||
#define BOARD_VARIANT_NAME "T-Beam BPF"
|
||||
|
||||
|
||||
|
|
@ -608,49 +625,53 @@
|
|||
|
||||
#define I2C_SDA (8)
|
||||
#define I2C_SCL (9)
|
||||
|
||||
#define GPS_RX_PIN (5)
|
||||
#define GPS_TX_PIN (6)
|
||||
#define GPS_PPS_PIN (7)
|
||||
#define GPS_EN_PIN (10)
|
||||
|
||||
#define BUTTON_PIN (0) /*BUTTON 1 = GPIO0*/
|
||||
#define BUTTON2_PIN (3) /*BUTTON 2 = GPIO3*/
|
||||
#define BUTTON2_PIN (2) /*BUTTON 2 = GPIO3*/
|
||||
|
||||
#define BUTTON_PIN_MASK GPIO_SEL_0
|
||||
#define BUTTON_CONUT (2)
|
||||
#define BUTTON_ARRAY {BUTTON_PIN,BUTTON2_PIN/*BUTTON 2 = GPIO3*/}
|
||||
|
||||
|
||||
#define RADIO_SCLK_PIN (16)
|
||||
#define RADIO_MISO_PIN (17)
|
||||
#define RADIO_MOSI_PIN (18)
|
||||
#define RADIO_CS_PIN (15)
|
||||
#define RADIO_RST_PIN (3)
|
||||
#define RADIO_LDO_EN (40)
|
||||
#define RADIO_CTRL (21)
|
||||
|
||||
#define RADIO_DIO1_PIN (1)
|
||||
// #define RADIO_DIO3_PIN (2)
|
||||
|
||||
#define RADIO_BUSY_PIN (38)
|
||||
|
||||
#define SPI_MOSI (11)
|
||||
#define SPI_SCK (13)
|
||||
#define SPI_MISO (12)
|
||||
#define SPI_CS (10)
|
||||
|
||||
#define SDCARD_MOSI SPI_MOSI
|
||||
#define SDCARD_MISO SPI_MISO
|
||||
#define SDCARD_SCLK SPI_SCK
|
||||
#define SDCARD_CS SPI_CS
|
||||
#define RADIO_SCLK_PIN (16)
|
||||
#define RADIO_MISO_PIN (17)
|
||||
#define RADIO_MOSI_PIN (18)
|
||||
|
||||
#define RADIO_CS_PIN (15)
|
||||
#define RADIO_RST_PIN (3)
|
||||
#define RADIO_LDO_EN (40)
|
||||
#define RADIO_CTRL (21)
|
||||
#define RADIO_DIO1_PIN (1)
|
||||
#define RADIO_BUSY_PIN (38)
|
||||
|
||||
// #define SDCARD_MOSI SPI_MOSI
|
||||
// #define SDCARD_MISO SPI_MISO
|
||||
// #define SDCARD_SCLK SPI_SCK
|
||||
// #define SDCARD_CS SPI_CS
|
||||
|
||||
#define NTC_PIN (14)
|
||||
#define FAN_CTRL (41)
|
||||
#define ADC_PIN (4)
|
||||
|
||||
#define BAT_ADC_PULLUP_RES (300000.0)
|
||||
#define BAT_ADC_PULLDOWN_RES (150000.0)
|
||||
#define BAT_MAX_VOLTAGE (7.4)
|
||||
#define BAT_VOL_COMPENSATION (0.25)
|
||||
#define GPS_SLEEP_HOLD_ON_LOW
|
||||
|
||||
#define GPS_BAUD_RATE 9600
|
||||
|
||||
#define HAS_SDCARD
|
||||
// #define HAS_SDCARD
|
||||
#define HAS_GPS
|
||||
#define HAS_DISPLAY
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue