|
| 1 | +#pragma once |
| 2 | + |
| 3 | +#include "BoardBase.h" |
| 4 | +#include "GpsBoard.h" |
| 5 | +#include "LoraBoard.h" |
| 6 | +#include "SdBoard.h" |
| 7 | +#include "MotionBoard.h" |
| 8 | +#include "display/DisplayInterface.h" |
| 9 | + |
| 10 | +// Minimal M5Stack Tab5 board integration. |
| 11 | +// This is a skeleton that allows the firmware to build and run basic UI |
| 12 | +// on ESP32-P4, with hardware-specific details to be filled in incrementally. |
| 13 | + |
| 14 | +class SensorBHI260AP; |
| 15 | +class GPS; |
| 16 | + |
| 17 | +class M5Tab5Board : public BoardBase, |
| 18 | + public LoraBoard, |
| 19 | + public GpsBoard, |
| 20 | + public MotionBoard, |
| 21 | + public SdBoard, |
| 22 | + public LilyGo_Display |
| 23 | +{ |
| 24 | + public: |
| 25 | + static M5Tab5Board* getInstance(); |
| 26 | + |
| 27 | + // BoardBase |
| 28 | + uint32_t begin(uint32_t disable_hw_init = 0) override; |
| 29 | + void wakeUp() override {} |
| 30 | + void handlePowerButton() override {} |
| 31 | + void softwareShutdown() override {} |
| 32 | + |
| 33 | + void setBrightness(uint8_t level) override; |
| 34 | + uint8_t getBrightness() override { return brightness_; } |
| 35 | + |
| 36 | + bool hasKeyboard() override { return false; } |
| 37 | + void keyboardSetBrightness(uint8_t /*level*/) override {} |
| 38 | + uint8_t keyboardGetBrightness() override { return 0; } |
| 39 | + |
| 40 | + bool isRTCReady() const override { return rtc_ready_; } |
| 41 | + bool isCharging() override { return false; } |
| 42 | + int getBatteryLevel() override { return -1; } |
| 43 | + |
| 44 | + bool isSDReady() const override { return sd_ready_; } |
| 45 | + bool isCardReady() override { return false; } |
| 46 | + bool isGPSReady() const override { return gps_ready_; } |
| 47 | + |
| 48 | + void vibrator() override {} |
| 49 | + void stopVibrator() override {} |
| 50 | + |
| 51 | + // Display / input (LilyGo_Display interface used by LV_Helper_v9) |
| 52 | + void setRotation(uint8_t rotation) override; |
| 53 | + uint8_t getRotation() override { return rotation_; } |
| 54 | + void pushColors(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t* color) override; |
| 55 | + uint16_t width() override; |
| 56 | + uint16_t height() override; |
| 57 | + bool useDMA() override { return false; } |
| 58 | + bool hasTouch() override { return true; } |
| 59 | + uint8_t getPoint(int16_t* x, int16_t* y, uint8_t get_point) override; |
| 60 | + bool hasEncoder() override { return false; } |
| 61 | + RotaryMsg_t getRotary() override; |
| 62 | + int getKeyChar(char* c) override; |
| 63 | + void feedback(void* args = NULL) override { (void)args; } |
| 64 | + |
| 65 | + // LoraBoard (stubs for now; real radio wiring to be added later) |
| 66 | + bool isRadioOnline() const override { return false; } |
| 67 | + int transmitRadio(const uint8_t* data, size_t len) override; |
| 68 | + int startRadioReceive() override; |
| 69 | + uint32_t getRadioIrqFlags() override; |
| 70 | + int getRadioPacketLength(bool update) override; |
| 71 | + int readRadioData(uint8_t* buf, size_t len) override; |
| 72 | + void clearRadioIrqFlags(uint32_t flags) override; |
| 73 | + float getRadioRSSI() override; |
| 74 | + float getRadioSNR() override; |
| 75 | + void configureLoraRadio(float freq_mhz, float bw_khz, uint8_t sf, uint8_t cr_denom, |
| 76 | + int8_t tx_power, uint16_t preamble_len, uint8_t sync_word, |
| 77 | + uint8_t crc_len) override; |
| 78 | + |
| 79 | + // GpsBoard (stubs; to be connected to Tab5 GNSS module) |
| 80 | + bool initGPS() override; |
| 81 | + void setGPSOnline(bool online) override { gps_ready_ = online; } |
| 82 | + GPS& getGPS() override; |
| 83 | + bool isGPSReady() const override { return gps_ready_; } |
| 84 | + void powerControl(PowerCtrlChannel_t ch, bool enable) override; |
| 85 | + bool syncTimeFromGPS(uint32_t gps_task_interval_ms = 0) override; |
| 86 | + |
| 87 | + // MotionBoard (Tab5 has IMU; stub until wired) |
| 88 | + SensorBHI260AP& getMotionSensor() override; |
| 89 | + bool isSensorReady() const override { return false; } |
| 90 | + |
| 91 | + // SdBoard |
| 92 | + bool installSD() override; |
| 93 | + void uninstallSD() override; |
| 94 | + bool isCardReady() override; |
| 95 | + |
| 96 | + private: |
| 97 | + M5Tab5Board(); |
| 98 | + |
| 99 | + private: |
| 100 | + uint8_t brightness_ = DEVICE_MAX_BRIGHTNESS_LEVEL; |
| 101 | + uint8_t rotation_ = 0; |
| 102 | + bool display_ready_ = false; |
| 103 | + bool touch_ready_ = false; |
| 104 | + bool rtc_ready_ = false; |
| 105 | + bool sd_ready_ = false; |
| 106 | + bool gps_ready_ = false; |
| 107 | +}; |
| 108 | + |
0 commit comments