SAE Teensy ECU
IIT SAE Microcontroller programming
Loading...
Searching...
No Matches
SerialVar.h
Go to the documentation of this file.
1
12#ifndef __ECU_SERIALVAR_H__
13#define __ECU_SERIALVAR_H__
14
15#include "Log.h"
16#include "SerialVars.def"
17#include "WProgram.h"
18
22namespace SerialVar {
23
30uint8_t *getVariable(size_t ID);
31
36
47template <typename T>
48class SerialVar {
49private:
50 uint8_t *buffer;
51
52public:
58 SerialVar(int ID) {
59 buffer = getVariable(ID);
60 }
61
67 operator T() const { return *((T *)(buffer)); }
68
76 *((T *)(buffer)) = val;
77 return *this;
78 }
79};
80
93
94} // namespace SerialVar
95#endif // __ECU_SERIALVAR_H__
Special logging functionality.
Serial Variable definitions.
Template of a Serial Variable.
Definition SerialVar.h:48
SerialVar & operator=(T val)
Set this variable's buffer given the primitive data type T.
Definition SerialVar.h:75
SerialVar(int ID)
Construct a new Serial Var given the predefined ID defined in SerialVars.def.
Definition SerialVar.h:58
SerialVar is used for variables that can be modified over usb serial while still being used during ru...
Definition SerialVar.h:22
SerialVar< float > SerialFloat
Convienece type for SerialVar floats.
Definition SerialVar.h:84
void receiveSerialVar()
Receive a variable over serial.
SerialVar< unsigned int > SerialUInt
Convienece type for SerialVar uints.
Definition SerialVar.h:92
uint8_t * getVariable(size_t ID)
Get the Serial Variable for a given ID.
SerialVar< int > SerialInt
Convienece type for SerialVar ints.
Definition SerialVar.h:88