CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
AnalogInput.h
1#ifndef ANALOG_INPUT_H
2#define ANALOG_INPUT_H
3
4#include "Interface.h"
5#include "Debug.h"
6
7class AnalogInput : public Interface {
8 public:
9
10 Interface::Type getType() const override {
11 return ANALOG_INPUT;
12 }
13 AnalogInput(Interface::Resolution res = Interface::RES_12BIT) : resolution(res) {
14 Q = 0;
15 }
16 Interface::Resolution getResolution() const {
17 return resolution;
18 }
19 void setQ(uint16_t q) override {
20 if(q > ((1 << resolution) - 1)) {
21 WARNING_PRINTLN("[AnalogInput] WARNING: Attempted to set value " + String(q) + " which exceeds the maximum for resolution " + String(resolution) + " bits. Clamping to max value.");
22 Q = (1 << resolution) - 1; // Clamp to max value
23 } else {
24 Q = q;
25 DEBUG_PRINTLN("[AnalogInput] " + name + " set to " + String(Q));
26 }
27 }
28 private:
29 Interface::Resolution resolution = Interface::RES_12BIT;
30
31
32};
33
34#endif
Logging and debug macro definitions for CANTramCore.
#define WARNING_PRINTLN(x)
Print a warning-level message with newline.
Definition Debug.h:185
#define DEBUG_PRINTLN(x)
Print a debug message with newline.
Definition Debug.h:63