target.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <Arduino.h>
  2. #include "target.h"
  3. #include <helpers/ArduinoHelpers.h>
  4. GAT56230SMeshKitBoard board;
  5. #ifndef PIN_USER_BTN
  6. #define PIN_USER_BTN (-1)
  7. #endif
  8. #ifdef DISPLAY_CLASS
  9. DISPLAY_CLASS display;
  10. MomentaryButton user_btn(PIN_USER_BTN, 1000, true, false, false);
  11. MomentaryButton joystick_left(JOYSTICK_LEFT, 1000, true, false, false);
  12. MomentaryButton joystick_right(JOYSTICK_RIGHT, 1000, true, false, false);
  13. MomentaryButton back_btn(PIN_BACK_BTN, 1000, true, false, true);
  14. #endif
  15. RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
  16. WRAPPER_CLASS radio_driver(radio, board);
  17. VolatileRTCClock fallback_clock;
  18. AutoDiscoverRTCClock rtc_clock(fallback_clock);
  19. #if ENV_INCLUDE_GPS
  20. #include <helpers/sensors/MicroNMEALocationProvider.h>
  21. MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
  22. EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
  23. #else
  24. EnvironmentSensorManager sensors;
  25. #endif
  26. bool radio_init() {
  27. rtc_clock.begin(Wire);
  28. return radio.std_init(&SPI);
  29. }
  30. mesh::LocalIdentity radio_new_identity() {
  31. RadioNoiseListener rng(radio);
  32. return mesh::LocalIdentity(&rng); // create new random identity
  33. }