QPIDfirmware  v0.1
Object oriented firmware for autonomous motor drivers with encoder based PID controller and flexible interface
QPID_Endstop_PinSharedAnalog Class Reference

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>

Inheritance diagram for QPID_Endstop_PinSharedAnalog:

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...
 
- Public Member Functions inherited from QPID_Object
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...
 
- Protected Member Functions inherited from QPID_Object
 QPID_Object ()
 Constructor. Begins Serial with 115200 baud for logging and error reporting, if not done previously.
 

Detailed Description

Implements an endstop connected to an analog pin with a resistor network, thus sharing the pin with other switches.

Todo:
check private, protected etc. for all dervide classes

Member Function Documentation

◆ isOn()

bool QPID_Endstop_PinSharedAnalog::isOn ( )
virtual

returns true if switch is currently activated

Todo:

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.

◆ init()

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.

Parameters
switchPinanalog input pin
lowerLimit,upperLimitIf the analogRead() value is between these two limits, isOn() will be true.

◆ processMessage()

bool QPID_Endstop_PinSharedAnalog::processMessage ( uint8_t *  m)
overrideprotectedvirtual

Interprets messages specific for this class.

Parameters
mPointer to message
Returns
true if correct command was found and executed

Reimplemented from QPID_Endstop.


The documentation for this class was generated from the following files: