CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
AnalogOutput.h
1#ifndef ANALOG_OUTPUT_H
2#define ANALOG_OUTPUT_H
3
4#include "Interface.h"
5#include "Debug.h"
6
11class AnalogOutput : public Interface {
12 public:
13
19 AnalogOutput(Interface::Resolution res = Interface::RES_12BIT) : resolution(res) {
20 Q = 0;
21 }
22
28 Interface::Type getType() const override {
29 return ANALOG_OUTPUT;
30 }
31
39 void setQ(uint16_t q) override {
40 if(q > ((1 << resolution) - 1)) {
41 WARNING_PRINTLN("[AnalogOutput] WARNING: Attempted to set value " + String(q) + " which exceeds the maximum for resolution " + String(resolution) + " bits. Clamping to max value.");
42 Q = (1 << resolution) - 1; // Clamp to max value
43 } else {
44 Q = q;
45 }
46 }
47 uint8_t channel;
48 private:
49 bool valid = false;
50 Interface::Resolution resolution=Interface::RES_12BIT;
51
52};
53
54#endif
Logging and debug macro definitions for CANTramCore.
#define WARNING_PRINTLN(x)
Print a warning-level message with newline.
Definition Debug.h:185
AnalogOutput(Interface::Resolution res=Interface::RES_12BIT)
Construct a new AnalogOutput object.
Definition AnalogOutput.h:19
Interface::Type getType() const override
Get the interface type.
Definition AnalogOutput.h:28
void setQ(uint16_t q) override
Set the output value (Q).
Definition AnalogOutput.h:39