|
9 | 9 | #pragma once |
10 | 10 | #include "ErrorHandler/ErrorHandler.hpp" |
11 | 11 | #include "HALAL/HALAL.hpp" |
12 | | -template<class Type> |
| 12 | +template <class Type> |
13 | 13 | class PWMSensor { |
14 | | -protected: |
15 | | - uint8_t id; |
16 | | - Type *frequency; |
17 | | - Type *duty_cycle; |
18 | | - |
| 14 | + protected: |
| 15 | + uint8_t id; |
| 16 | + Type *frequency; |
| 17 | + Type *duty_cycle; |
19 | 18 |
|
20 | | -public: |
21 | | - PWMSensor() = default; |
22 | | - PWMSensor(Pin &pin, Type &frequency, Type &duty_cycle); |
23 | | - PWMSensor(Pin &pin, Type *frequency, Type *duty_cycle); |
24 | | - void read(); |
25 | | - uint8_t get_id(); |
| 19 | + public: |
| 20 | + PWMSensor() = default; |
| 21 | + PWMSensor(Pin &pin, Type &frequency, Type &duty_cycle); |
| 22 | + PWMSensor(Pin &pin, Type *frequency, Type *duty_cycle); |
| 23 | + void read(); |
| 24 | + uint8_t get_id(); |
26 | 25 | }; |
27 | 26 |
|
28 | | -template<class Type> |
29 | | -PWMSensor<Type>::PWMSensor(Pin &pin, Type &frequency, Type &duty_cycle) : |
30 | | - duty_cycle(&duty_cycle), frequency(&frequency) { |
31 | | - id = InputCapture::inscribe(pin); |
32 | | - Sensor::inputcapture_id_list.push_back(id); |
| 27 | +template <class Type> |
| 28 | +PWMSensor<Type>::PWMSensor(Pin &pin, Type &frequency, Type &duty_cycle) |
| 29 | + : frequency(&frequency), duty_cycle(&duty_cycle) { |
| 30 | + id = InputCapture::inscribe(pin); |
| 31 | + Sensor::inputcapture_id_list.push_back(id); |
33 | 32 | } |
34 | 33 |
|
35 | | -template<class Type> |
36 | | -PWMSensor<Type>::PWMSensor(Pin &pin, Type *frequency, Type *duty_cycle) : |
37 | | - duty_cycle(duty_cycle), frequency(frequency) { |
38 | | - id = InputCapture::inscribe(pin); |
39 | | - Sensor::inputcapture_id_list.push_back(id); |
| 34 | +template <class Type> |
| 35 | +PWMSensor<Type>::PWMSensor(Pin &pin, Type *frequency, Type *duty_cycle) |
| 36 | + : frequency(frequency), duty_cycle(duty_cycle) { |
| 37 | + id = InputCapture::inscribe(pin); |
| 38 | + Sensor::inputcapture_id_list.push_back(id); |
40 | 39 | } |
41 | 40 |
|
42 | | -template<class Type> |
| 41 | +template <class Type> |
43 | 42 | void PWMSensor<Type>::read() { |
44 | | - *duty_cycle = InputCapture::read_duty_cycle(id); |
45 | | - *frequency = InputCapture::read_frequency(id); |
| 43 | + *duty_cycle = InputCapture::read_duty_cycle(id); |
| 44 | + *frequency = InputCapture::read_frequency(id); |
46 | 45 | } |
47 | | -template<class Type> |
| 46 | +template <class Type> |
48 | 47 | uint8_t PWMSensor<Type>::get_id() { |
49 | | - return id; |
| 48 | + return id; |
50 | 49 | } |
51 | | - |
0 commit comments