Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.5 KiB

  1. // -----------------------------------------------------------------------------
  2. // Median Filter
  3. // -----------------------------------------------------------------------------
  4. #pragma once
  5. typedef enum magnitude_t {
  6. MAGNITUDE_NONE = 0,
  7. MAGNITUDE_TEMPERATURE,
  8. MAGNITUDE_HUMIDITY,
  9. MAGNITUDE_PRESSURE,
  10. MAGNITUDE_ACTIVE_POWER,
  11. MAGNITUDE_APPARENT_POWER,
  12. MAGNITUDE_REACTIVE_POWER,
  13. MAGNITUDE_VOLTAGE_POWER,
  14. MAGNITUDE_CURRENT_POWER,
  15. MAGNITUDE_ENERGY_POWER,
  16. MAGNITUDE_POWER_FACTOR,
  17. MAGNITUDE_ANALOG,
  18. MAGNITUDE_EVENTS,
  19. MAGNITUDE_MAX,
  20. } magnitude_t;
  21. class BaseSensor {
  22. public:
  23. BaseSensor() {
  24. }
  25. ~BaseSensor() {
  26. }
  27. // Pre-read hook (usually to populate registers with up-to-date data)
  28. virtual void pre();
  29. // Post-read hook (usually to reset things)
  30. virtual void post();
  31. // Return sensor status (true for ready)
  32. virtual bool status();
  33. // Return sensor last internal error
  34. virtual int error();
  35. // Number of available slots
  36. virtual unsigned char count();
  37. // Descriptive name of the sensor
  38. virtual String name();
  39. // Descriptive name of the slot # index
  40. virtual String slot(unsigned char index);
  41. // Type for slot # index
  42. virtual magnitude_t type(unsigned char index);
  43. // Current value for slot # index
  44. virtual double value(unsigned char index);
  45. private:
  46. };