TBeam1WBoard.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #pragma once
  2. #include <Arduino.h>
  3. #include <helpers/ESP32Board.h>
  4. #include "variant.h"
  5. // LilyGo T-Beam 1W with SX1262 + external PA (XY16P35 module)
  6. //
  7. // Power architecture (LDO is separate chip on T-Beam board, not inside XY16P35):
  8. //
  9. // VCC (+4.0~+8.0V) ──┬──────────────────► XY16P35 VCC pin 5 (PA direct)
  10. // (USB or Battery) │
  11. // │ ┌───────────┐
  12. // └──►│ LDO Chip │──► +3.3V ──► XY16P35 (SX1262 + LNA)
  13. // │ EN=GPIO40 │
  14. // └───────────┘
  15. // LDO_EN (GPIO 40): H @ +1.2V~VIN, active high, not floating
  16. //
  17. // Control signals:
  18. // - LDO_EN (GPIO 40): HIGH enables LDO → powers SX1262 + LNA
  19. // - TCXO_EN (DIO3): HIGH enables TCXO (set to 1.8V per Meshtastic)
  20. // - CTL (GPIO 21): HIGH=RX (LNA on), LOW=TX (LNA off)
  21. // - DIO2: AUTO via SX126X_DIO2_AS_RF_SWITCH (TX path)
  22. //
  23. // Power notes:
  24. // - PA needs VCC 4.0-8.0V for full 32dBm output
  25. // - USB-C (3.9-6V) marginal; 7.4V battery recommended
  26. // - Battery must support 2A+ discharge for high-power TX
  27. class TBeam1WBoard : public ESP32Board {
  28. public:
  29. enum class FanMode : uint8_t {
  30. Auto = 0,
  31. On,
  32. Off
  33. };
  34. private:
  35. bool radio_powered = false;
  36. bool fan_enabled = true;
  37. uint32_t fan_force_on_until = 0;
  38. uint32_t next_fan_control_check_at = 0;
  39. uint32_t fan_post_tx_hold_ms = 30000;
  40. FanMode fan_mode = FanMode::Auto;
  41. float last_board_temperature_c = NAN;
  42. float readBoardTemperatureC() const;
  43. public:
  44. void begin();
  45. void onBeforeTransmit() override;
  46. void onAfterTransmit() override;
  47. uint16_t getBattMilliVolts() override;
  48. uint16_t getBatteryMinMilliVolts() const override;
  49. uint16_t getBatteryMaxMilliVolts() const override;
  50. const char* getManufacturerName() const override;
  51. void powerOff() override;
  52. // Fan control methods
  53. void setFanEnabled(bool enabled);
  54. bool isFanEnabled() const;
  55. void setFanMode(FanMode mode);
  56. FanMode getFanMode() const;
  57. const char* getFanModeName() const;
  58. float getLastBoardTemperatureC() const;
  59. bool setFanPostTxHoldMs(uint32_t hold_ms);
  60. uint32_t getFanPostTxHoldMs() const;
  61. void updateFanControl(bool force = false);
  62. };