target.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #include <Arduino.h>
  2. #include "target.h"
  3. TBeam1WBoard board;
  4. #ifdef DISPLAY_CLASS
  5. DISPLAY_CLASS display;
  6. MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
  7. #endif
  8. static SPIClass spi;
  9. SPIClass* getBoardSharedArchiveSPI() {
  10. return &spi;
  11. }
  12. RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
  13. WRAPPER_CLASS radio_driver(radio, board);
  14. ESP32RTCClock fallback_clock;
  15. AutoDiscoverRTCClock rtc_clock(fallback_clock);
  16. #if ENV_INCLUDE_GPS
  17. #include <helpers/sensors/MicroNMEALocationProvider.h>
  18. MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
  19. EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
  20. #else
  21. EnvironmentSensorManager sensors;
  22. #endif
  23. bool radio_init() {
  24. fallback_clock.begin();
  25. rtc_clock.begin(Wire);
  26. // Initialize SPI for radio
  27. spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
  28. // GPS serial initialized by EnvironmentSensorManager::begin()
  29. bool success = radio.std_init(&spi);
  30. if (success) {
  31. // T-Beam 1W has external PA requiring longer ramp time (>800us recommended)
  32. // RADIOLIB_SX126X_PA_RAMP_800U = 0x05
  33. radio.setTxParams(LORA_TX_POWER, RADIOLIB_SX126X_PA_RAMP_800U);
  34. }
  35. return success;
  36. }
  37. mesh::LocalIdentity radio_new_identity() {
  38. RadioNoiseListener rng(radio);
  39. return mesh::LocalIdentity(&rng);
  40. }