![]() |
QPIDfirmware
v0.1
Object oriented firmware for autonomous motor drivers with encoder based PID controller and flexible interface
|
Implements an endstop connected to an analog pin with a resistor network, thus sharing the pin with other switches. More...
#include <QPID_Endstop_PinSharedAnalog.h>
Public Member Functions | |
bool | isOn () |
returns true if switch is currently activated More... | |
void | init (int8_t analogPin, int lowerLimit, int upperLimit) |
Initialises the endstop with given parameters. Needs be called first before using the object. More... | |
![]() | |
virtual void | update () |
(abstract) Can be overridden by QPID subsystems which need to do their own polling. Will be called by QPID_Unit::update() for subsystems, and by firmware/client for QPID_Unit itself. | |
void | throwError (const char *invokedBy, const char *errorMessage) |
Writes error message and error invoking class to Serial. More... | |
void | log (const char *logEntry) |
Puts timestamped string into the system log (atm: writes it out to Serial). More... | |
Protected Member Functions | |
bool | processMessage (uint8_t *m) override |
Interprets messages specific for this class. More... | |
![]() | |
QPID_Object () | |
Constructor. Begins Serial with 115200 baud for logging and error reporting, if not done previously. | |
Implements an endstop connected to an analog pin with a resistor network, thus sharing the pin with other switches.
|
virtual |
returns true if switch is currently activated
AD converters need short pauses between readings on Arduinos. We could use a timer to recycle very fresh readings.
Also, two endstops sharing the same pin don't know from each other, which complicates the possible problem. Needs testing to see if this actually could lead to errors. A possible solution could be based on semaphores or something like that.
Reimplemented from QPID_Endstop.
void QPID_Endstop_PinSharedAnalog::init | ( | int8_t | analogPin, |
int | lowerLimit, | ||
int | upperLimit | ||
) |
Initialises the endstop with given parameters. Needs be called first before using the object.
switchPin | analog input pin |
lowerLimit,upperLimit | If the analogRead() value is between these two limits, isOn() will be true. |
|
overrideprotectedvirtual |
Interprets messages specific for this class.
m | Pointer to message |
Reimplemented from QPID_Endstop.