target.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #pragma once
  2. #define RADIOLIB_STATIC_ONLY 1
  3. #include <RadioLib.h>
  4. #include <helpers/radiolib/RadioLibWrappers.h>
  5. #include <helpers/stm32/STM32Board.h>
  6. #include <helpers/radiolib/CustomSTM32WLxWrapper.h>
  7. #include <helpers/ArduinoHelpers.h>
  8. #include <helpers/SensorManager.h>
  9. #ifdef DISPLAY_CLASS
  10. #include "NullDisplayDriver.h"
  11. #endif
  12. #include <BME280I2C.h>
  13. #include <Wire.h>
  14. #ifdef DISPLAY_CLASS
  15. extern NullDisplayDriver display;
  16. #endif
  17. class WIOE5Board : public STM32Board {
  18. public:
  19. void begin() override {
  20. STM32Board::begin();
  21. pinMode(LED_RED, OUTPUT);
  22. digitalWrite(LED_RED, HIGH);
  23. pinMode(USER_BTN, INPUT_PULLUP);
  24. }
  25. const char* getManufacturerName() const override {
  26. return "Seeed Wio E5 mini";
  27. }
  28. uint16_t getBattMilliVolts() override {
  29. analogReadResolution(12);
  30. uint32_t raw = 0;
  31. for (int i=0; i<8;i++) {
  32. raw += analogRead(PIN_A3);
  33. }
  34. return ((double)raw) * 1.73 * 5 * 1000 / 8 / 4096;
  35. }
  36. };
  37. class WIOE5SensorManager : public SensorManager {
  38. BME280I2C bme;
  39. bool has_bme = false;
  40. public:
  41. WIOE5SensorManager() {}
  42. bool begin() override;
  43. bool querySensors(uint8_t requester_permissions, CayenneLPP& telemetry) override;
  44. };
  45. extern WIOE5Board board;
  46. extern WRAPPER_CLASS radio_driver;
  47. extern VolatileRTCClock rtc_clock;
  48. extern WIOE5SensorManager sensors;
  49. bool radio_init();
  50. uint32_t radio_get_rng_seed();
  51. void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
  52. void radio_set_tx_power(int8_t dbm);
  53. mesh::LocalIdentity radio_new_identity();