LilyGo-LoRa-Series/examples/ArduinoLoRa/LoRaReceiver/LoRaBoards.h

134 lines
2.4 KiB
C
Raw Normal View History

2024-05-15 17:58:37 +08:00
/**
* @file boards.h
* @author Lewis He (lewishe@outlook.com)
* @license MIT
* @copyright Copyright (c) 2024 ShenZhen XinYuan Electronic Technology Co., Ltd
* @date 2024-04-25
2024-08-07 17:29:31 +08:00
* @last-update 2024-08-07
2024-05-15 17:58:37 +08:00
*/
#pragma once
#include "utilities.h"
#ifdef HAS_SDCARD
#include <SD.h>
#endif
2025-10-13 09:54:39 +08:00
#if defined(ARDUINO_ARCH_ESP32)
2024-05-15 17:58:37 +08:00
#include <FS.h>
#include <WiFi.h>
#endif
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
2025-10-13 09:54:39 +08:00
#ifdef DISPLAY_MODEL
#include <U8g2lib.h>
2024-05-15 17:58:37 +08:00
#endif
2025-10-13 09:54:39 +08:00
#ifdef HAS_PMU
#include <XPowersLib.h>
2024-05-15 17:58:37 +08:00
#endif
2025-10-13 09:54:39 +08:00
#include <esp_mac.h>
2024-05-15 17:58:37 +08:00
2025-10-13 09:54:39 +08:00
// #define ENABLE_BLE //Enable ble function
2024-05-15 17:58:37 +08:00
2024-12-18 16:01:35 +08:00
enum {
POWERMANAGE_ONLINE = _BV(0),
DISPLAY_ONLINE = _BV(1),
RADIO_ONLINE = _BV(2),
GPS_ONLINE = _BV(3),
PSRAM_ONLINE = _BV(4),
SDCARD_ONLINE = _BV(5),
AXDL345_ONLINE = _BV(6),
BME280_ONLINE = _BV(7),
BMP280_ONLINE = _BV(8),
BME680_ONLINE = _BV(9),
QMC6310_ONLINE = _BV(10),
QMI8658_ONLINE = _BV(11),
PCF8563_ONLINE = _BV(12),
OSC32768_ONLINE = _BV(13),
};
2024-05-15 17:58:37 +08:00
typedef struct {
String chipModel;
float psramSize;
uint8_t chipModelRev;
uint8_t chipFreq;
uint8_t flashSize;
uint8_t flashSpeed;
} DevInfo_t;
2024-08-07 17:29:31 +08:00
void setupBoards(bool disable_u8g2 = false);
2024-05-15 17:58:37 +08:00
2025-10-13 09:54:39 +08:00
#ifdef HAS_SDCARD
2024-05-15 17:58:37 +08:00
bool beginSDCard();
2025-10-13 09:54:39 +08:00
#else
#define beginSDCard()
#endif
2024-05-15 17:58:37 +08:00
2025-10-13 09:54:39 +08:00
#ifdef DISPLAY_ADDR
2024-05-15 17:58:37 +08:00
bool beginDisplay();
2025-10-13 09:54:39 +08:00
#endif
2024-05-15 17:58:37 +08:00
void printResult(bool radio_online);
2025-10-13 09:54:39 +08:00
#ifdef BOARD_LED
2024-05-15 17:58:37 +08:00
void flashLed();
2025-10-13 09:54:39 +08:00
#else
#define flashLed()
#endif
2024-05-15 17:58:37 +08:00
2024-08-07 17:29:31 +08:00
void scanDevices(TwoWire *w);
bool beginGPS();
2024-12-18 16:01:35 +08:00
bool recoveryGPS();
2025-01-13 17:38:35 +08:00
void scanWiFi();
2024-05-16 13:38:53 +08:00
#ifdef HAS_PMU
2024-05-15 17:58:37 +08:00
extern XPowersLibInterface *PMU;
extern bool pmuInterrupt;
2025-10-13 09:54:39 +08:00
void loopPMU(void (*pressed_cb)(void));
bool beginPower();
void disablePeripherals();
#else
#define beginPower()
2024-05-16 13:38:53 +08:00
#endif
2024-05-15 17:58:37 +08:00
2025-10-13 09:54:39 +08:00
#ifdef DISPLAY_MODEL
extern DISPLAY_MODEL *u8g2;
2024-05-15 17:58:37 +08:00
#define U8G2_HOR_ALIGN_CENTER(t) ((u8g2->getDisplayWidth() - (u8g2->getUTF8Width(t))) / 2)
#define U8G2_HOR_ALIGN_RIGHT(t) ( u8g2->getDisplayWidth() - u8g2->getUTF8Width(t))
2025-10-13 09:54:39 +08:00
#endif
2024-05-15 17:58:37 +08:00
#if defined(ARDUINO_ARCH_ESP32)
#if defined(HAS_SDCARD)
extern SPIClass SDCardSPI;
#endif
#define SerialGPS Serial1
#elif defined(ARDUINO_ARCH_STM32)
extern HardwareSerial SerialGPS;
#endif
2024-12-18 16:01:35 +08:00
2025-10-13 09:54:39 +08:00
#ifdef HAS_NTC
2024-12-18 16:01:35 +08:00
float getTempForNTC();
2025-10-13 09:54:39 +08:00
#endif
2024-12-18 16:01:35 +08:00
2025-10-13 09:54:39 +08:00
#ifdef ENABLE_BLE
2024-12-18 16:01:35 +08:00
void setupBLE();
2025-10-13 09:54:39 +08:00
#endif
2024-12-18 16:01:35 +08:00
extern uint32_t deviceOnline;