CANTram Framework 1.0.1
Dieses Framework ermöglicht die Nutzung der CANTram Hardware, einer Mikrocontroller basierten mdoularen Steuerung.
Loading...
Searching...
No Matches
Interface.h
1#ifndef INTERFACE_BASE_H
2#define INTERFACE_BASE_H
3#include <Arduino.h>
4#include "Debug.h"
5
6
7class Interface {
8 public:
9 enum Resolution {
10 RES_8BIT = 8,
11 RES_10BIT = 10,
12 RES_12BIT = 12,
13 RES_16BIT = 16
14 };
15
16
17 enum Type {
18 DIGITAL_INPUT,
19 DIGITAL_OUTPUT,
20 ANALOG_INPUT,
21 ANALOG_OUTPUT,
22 RELAIS,
23 BUS
24 };
25 // Overload setQ for bool and float_t to auto-cast to Value
26 virtual void setQ(uint16_t q) { Q = q; } // Accepts float_t, sets analog
27 virtual uint16_t getQ() const { return Q; }
28 virtual Type getType() const = 0; //Type of the interface
29
30 void rename(const String& newName) {
31 String oldName = name;
32 name = newName;
33 INFO_PRINTLN("[Interface] Interface renamed " + oldName + " to " + name);
34 }
35 template <typename T>
36 T as() {return static_cast<T>(this);}
37
38 void validate() { _valid = true; }
39 void validate(bool state) { _valid = state; }
40 void invalidate() { _invalid = true; }
41 bool isValid() { return _valid && !_invalid; }
42 bool isInvalid() { return _invalid; }
43
44 String getName() const { return name; }
45 protected:
46 String name;
47 Interface() = default;
48 uint16_t Q = 0;
49 bool _valid = false;
50 bool _invalid = false;
51
52
53 // Protected members here
54};
55
56#endif
Logging and debug macro definitions for CANTramCore.
#define INFO_PRINTLN(x)
Print an info-level message with newline.
Definition Debug.h:137