Update boards.cpp
This commit is contained in:
parent
eb2cdef022
commit
53169538bd
98 changed files with 2450 additions and 2205 deletions
|
|
@ -33,8 +33,11 @@ HardwareSerial SerialGPS(GPS_RX_PIN, GPS_TX_PIN);
|
|||
#include "driver/gpio.h"
|
||||
#endif //ARDUINO_ARCH_ESP32
|
||||
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
DISPLAY_MODEL *u8g2 = NULL;
|
||||
#endif
|
||||
|
||||
|
||||
static DevInfo_t devInfo;
|
||||
|
||||
#ifdef HAS_GPS
|
||||
|
|
@ -45,6 +48,7 @@ String gps_model = "None";
|
|||
|
||||
uint32_t deviceOnline = 0x00;
|
||||
|
||||
static void enable_slow_clock();
|
||||
|
||||
#ifdef HAS_PMU
|
||||
XPowersLibInterface *PMU = NULL;
|
||||
|
|
@ -54,14 +58,8 @@ static void setPmuFlag()
|
|||
{
|
||||
pmuInterrupt = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void enable_slow_clock();
|
||||
|
||||
|
||||
bool beginPower()
|
||||
{
|
||||
#ifdef HAS_PMU
|
||||
if (!PMU) {
|
||||
PMU = new XPowersAXP2101(PMU_WIRE_PORT);
|
||||
if (!PMU->init()) {
|
||||
|
|
@ -340,14 +338,12 @@ bool beginPower()
|
|||
default:
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
void disablePeripherals()
|
||||
{
|
||||
|
||||
#ifdef HAS_PMU
|
||||
if (!PMU)return;
|
||||
|
||||
PMU->setChargingLedMode(XPOWERS_CHG_LED_OFF);
|
||||
|
|
@ -403,12 +399,10 @@ void disablePeripherals()
|
|||
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void loopPMU(void (*pressed_cb)(void))
|
||||
{
|
||||
#ifdef HAS_PMU
|
||||
if (!PMU) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -453,9 +447,10 @@ void loopPMU(void (*pressed_cb)(void))
|
|||
}
|
||||
// Clear PMU Interrupt Status Register
|
||||
PMU->clearIrqStatus();
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_ADDR
|
||||
bool beginDisplay()
|
||||
{
|
||||
Wire.beginTransmission(DISPLAY_ADDR);
|
||||
|
|
@ -481,6 +476,7 @@ bool beginDisplay()
|
|||
Serial.printf("Warning: Failed to find Display at 0x%0X address\n", DISPLAY_ADDR);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
bool writeFile(const char *path, const char *buffer)
|
||||
|
|
@ -538,9 +534,9 @@ bool testSDWriteAndRead()
|
|||
}
|
||||
#endif /*HAS_SDCARD*/
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
bool beginSDCard()
|
||||
{
|
||||
#ifdef HAS_SDCARD
|
||||
#if defined(HAS_SDCARD) && defined(SD_SHARE_SPI_BUS)
|
||||
bool rlst = SD.begin(SDCARD_CS);
|
||||
#else
|
||||
|
|
@ -557,9 +553,9 @@ bool beginSDCard()
|
|||
} else {
|
||||
Serial.println("Warning: Failed to init Sd Card");
|
||||
}
|
||||
#endif /*HAS_SDCARD*/
|
||||
return false;
|
||||
}
|
||||
#endif /*HAS_SDCARD*/
|
||||
|
||||
void beginWiFi()
|
||||
{
|
||||
|
|
@ -814,9 +810,11 @@ void setupBoards(bool disable_u8g2 )
|
|||
|
||||
beginSDCard();
|
||||
|
||||
#ifdef DISPLAY_ADDR
|
||||
if (!disable_u8g2) {
|
||||
beginDisplay();
|
||||
}
|
||||
#endif
|
||||
|
||||
// scanWiFi();
|
||||
|
||||
|
|
@ -872,8 +870,10 @@ void printResult(bool radio_online)
|
|||
Serial.print("PSRAM : ");
|
||||
Serial.println((psramFound()) ? "+" : "-");
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
Serial.print("Display : ");
|
||||
Serial.println(( u8g2) ? "+" : "-");
|
||||
#endif
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
Serial.print("Sd Card : ");
|
||||
|
|
@ -890,6 +890,7 @@ void printResult(bool radio_online)
|
|||
Serial.println(( find_gps ) ? "+" : "-");
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
if (u8g2) {
|
||||
|
||||
u8g2->clearBuffer();
|
||||
|
|
@ -915,6 +916,7 @@ void printResult(bool radio_online)
|
|||
delay(2000);
|
||||
}
|
||||
#endif
|
||||
#endif /*DISPLAY_MODEL*/
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -925,9 +927,9 @@ static uint32_t lastDebounceTime = 0;
|
|||
#endif
|
||||
|
||||
|
||||
#ifdef BOARD_LED
|
||||
void flashLed()
|
||||
{
|
||||
#ifdef BOARD_LED
|
||||
if ((millis() - lastDebounceTime) > debounceDelay) {
|
||||
ledState = !ledState;
|
||||
if (ledState) {
|
||||
|
|
@ -937,8 +939,8 @@ void flashLed()
|
|||
}
|
||||
lastDebounceTime = millis();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void scanDevices(TwoWire *w)
|
||||
|
|
@ -1201,13 +1203,13 @@ float getTempForNTC()
|
|||
return temperature;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_BLE
|
||||
|
||||
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
|
||||
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
|
||||
|
||||
void setupBLE()
|
||||
{
|
||||
#ifdef ENABLE_BLE
|
||||
|
||||
uint8_t mac[6];
|
||||
char macStr[18] = { 0 };
|
||||
|
|
@ -1239,8 +1241,8 @@ void setupBLE()
|
|||
pAdvertising->setMinPreferred(0x12);
|
||||
BLEDevice::startAdvertising();
|
||||
Serial.println("Characteristic defined! Now you can read it in your phone!");
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#define CALIBRATE_ONE(cali_clk) calibrate_one(cali_clk, #cali_clk)
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
#include <SD.h>
|
||||
#endif
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
#include <FS.h>
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
|
@ -24,30 +24,18 @@
|
|||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
#include <U8g2lib.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAS_PMU
|
||||
#include <XPowersLib.h>
|
||||
#endif
|
||||
|
||||
#include <esp_mac.h>
|
||||
|
||||
#ifndef DISPLAY_MODEL
|
||||
#define DISPLAY_MODEL U8G2_SSD1306_128X64_NONAME_F_HW_I2C
|
||||
#endif
|
||||
|
||||
#ifndef OLED_WIRE_PORT
|
||||
#define OLED_WIRE_PORT Wire
|
||||
#endif
|
||||
|
||||
#ifndef PMU_WIRE_PORT
|
||||
#define PMU_WIRE_PORT Wire
|
||||
#endif
|
||||
|
||||
#ifndef DISPLAY_ADDR
|
||||
#define DISPLAY_ADDR 0x3C
|
||||
#endif
|
||||
|
||||
#ifndef LORA_FREQ_CONFIG
|
||||
#define LORA_FREQ_CONFIG 915.0
|
||||
#endif
|
||||
// #define ENABLE_BLE //Enable ble function
|
||||
|
||||
enum {
|
||||
POWERMANAGE_ONLINE = _BV(0),
|
||||
|
|
@ -67,7 +55,6 @@ enum {
|
|||
};
|
||||
|
||||
|
||||
#define ENABLE_BLE //Enable ble function
|
||||
|
||||
typedef struct {
|
||||
String chipModel;
|
||||
|
|
@ -81,17 +68,24 @@ typedef struct {
|
|||
|
||||
void setupBoards(bool disable_u8g2 = false);
|
||||
|
||||
#ifdef HAS_SDCARD
|
||||
bool beginSDCard();
|
||||
#else
|
||||
#define beginSDCard()
|
||||
#endif
|
||||
|
||||
#ifdef DISPLAY_ADDR
|
||||
bool beginDisplay();
|
||||
#endif
|
||||
|
||||
void disablePeripherals();
|
||||
|
||||
bool beginPower();
|
||||
|
||||
void printResult(bool radio_online);
|
||||
|
||||
#ifdef BOARD_LED
|
||||
void flashLed();
|
||||
#else
|
||||
#define flashLed()
|
||||
#endif
|
||||
|
||||
void scanDevices(TwoWire *w);
|
||||
|
||||
|
|
@ -99,18 +93,23 @@ bool beginGPS();
|
|||
|
||||
bool recoveryGPS();
|
||||
|
||||
void loopPMU(void (*pressed_cb)(void));
|
||||
|
||||
void scanWiFi();
|
||||
|
||||
#ifdef HAS_PMU
|
||||
extern XPowersLibInterface *PMU;
|
||||
extern bool pmuInterrupt;
|
||||
void loopPMU(void (*pressed_cb)(void));
|
||||
bool beginPower();
|
||||
void disablePeripherals();
|
||||
#else
|
||||
#define beginPower()
|
||||
#endif
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
|
||||
#ifdef DISPLAY_MODEL
|
||||
extern DISPLAY_MODEL *u8g2;
|
||||
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
|
||||
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP32)
|
||||
|
|
@ -124,8 +123,12 @@ extern SPIClass SDCardSPI;
|
|||
extern HardwareSerial SerialGPS;
|
||||
#endif
|
||||
|
||||
#ifdef HAS_NTC
|
||||
float getTempForNTC();
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_BLE
|
||||
void setupBLE();
|
||||
#endif
|
||||
|
||||
extern uint32_t deviceOnline;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue