1
+ /* !
2
+ * @file controller.h
3
+ *
4
+ * Controller for the AnalogIO API
5
+ *
6
+ * Adafruit invests time and resources providing this open source code,
7
+ * please support Adafruit and open-source hardware by purchasing
8
+ * products from Adafruit!
9
+ *
10
+ * Copyright (c) Brent Rubell 2024 for Adafruit Industries.
11
+ *
12
+ * BSD license, all text here must be included in any redistribution.
13
+ *
14
+ */
15
+ #ifndef WS_ANALOGIO_CONTROLLER_H
16
+ #define WS_ANALOGIO_CONTROLLER_H
17
+ #include " Wippersnapper_V2.h"
18
+ #include " hardware.h"
19
+ #include " model.h"
20
+
21
+ class Wippersnapper_V2 ; // /< Forward declaration
22
+ class AnalogIOModel ; // /< Forward declaration
23
+ class AnalogIOHardware ; // /< Forward declaration
24
+
25
+ /* *
26
+ * @struct analogioPin
27
+ * @brief Structure repesenting an analogio pin on the device.
28
+ */
29
+ struct analogioPin {
30
+ uint8_t name; // /< The pin's name.
31
+ float period; // /< The pin's period, in milliseconds.
32
+ float prv_period; // /< The pin's previous period, in milliseconds.
33
+ wippersnapper_sensor_SensorType read_mode; // /< Type of analog read to perform
34
+ }
35
+
36
+ /* *************************************************************************/
37
+ /* !
38
+ @brief Routes messages using the analogio.proto API to the
39
+ appropriate hardware and model classes, controls and tracks
40
+ the state of the hardware's digital I/O pins.
41
+ */
42
+ /* *************************************************************************/
43
+ class AnalogIOController {
44
+ public:
45
+ AnalogIOController ();
46
+ ~AnalogIOController ();
47
+ bool Handle_AnalogIOAdd (pb_istream_t *stream);
48
+
49
+ void SetRefVoltage (float voltage);
50
+ float GetRefVoltage (void );
51
+ private:
52
+ AnalogIOModel *_analogio_model; // /< AnalogIO model
53
+ AnalogIOHardware *_analogio_hardware; // /< AnalogIO hardware
54
+ std::vector<analogioPin> _analogio_pins; // /< Vector of analogio pins
55
+ uint8_t _total_analogio_pins; // /< Total number of analogio pins
56
+ float _ref_voltage; // /< The device's reference voltage
57
+ };
58
+ extern Wippersnapper_V2 WsV2; // /< Wippersnapper V2 instance
59
+ #endif // WS_ANALOGIO_CONTROLLER_H
0 commit comments