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

145 lines
2.6 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
#ifndef DISPLAY_ADDR
#define DISPLAY_ADDR 0x3C
#endif
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),
2026-01-14 15:07:43 +08:00
QMC6310U_ONLINE = _BV(10),
QMC6310N_ONLINE = _BV(11),
QMI8658_ONLINE = _BV(12),
PCF8563_ONLINE = _BV(13),
2026-04-08 14:47:17 +08:00
OSC32768_ONLINE = _BV(14),
QMC6309_ONLINE = _BV(15),
2024-12-18 16:01:35 +08:00
};
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
#ifdef DISPLAY_MODEL
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()
2025-11-17 09:24:17 +08:00
#define disablePeripherals()
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
2026-01-27 16:28:07 +08:00
extern U8G2 *disp;
#define U8G2_HOR_ALIGN_CENTER(t) ((disp->getDisplayWidth() - (disp->getUTF8Width(t))) / 2)
#define U8G2_HOR_ALIGN_RIGHT(t) ( disp->getDisplayWidth() - disp->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-11-17 09:24:17 +08:00
#ifdef NTC_PIN
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-11-17 09:24:17 +08:00
#else
#define setupBLE()
2025-10-13 09:54:39 +08:00
#endif
2024-12-18 16:01:35 +08:00
extern uint32_t deviceOnline;