#include <DfRobotInputAbstraction.h>
|
| DfRobotInputAbstraction (const DfRobotAnalogRanges &ranges, pinid_t pin=A0) |
|
void | initAbstraction () |
|
| DfRobotInputAbstraction (const DfRobotAnalogRanges *ranges, pinid_t pin, AnalogDevice *device) |
|
uint8_t | readValue (pinid_t pin) override |
|
uint8_t | readPort (pinid_t port) override |
|
bool | runLoop () override |
|
uint8_t | mapAnalogToPin (float reading) |
|
void | pinDirection (pinid_t pin, uint8_t mode) override |
|
void | writeValue (pinid_t pin, uint8_t value) override |
|
void | writePort (pinid_t pin, uint8_t portVal) override |
|
uint8_t | digitalRead (pinid_t p) |
|
void | digitalWrite (pinid_t p, uint8_t v) |
|
uint8_t | digitalReadS (pinid_t p) |
|
void | digitalWriteS (pinid_t p, uint8_t v) |
|
void | writePortS (pinid_t p, uint8_t v) |
|
uint8_t | readPortS (pinid_t p) |
|
void | pinMode (pinid_t pin, uint8_t mode) |
|
bool | sync () |
|
virtual void | attachInterrupt (pinid_t pin, RawIntHandler interruptHandler, uint8_t mode) |
|
DfRobotInputAbstraction provides the means to use many buttons connected to a single Analog input. It is mainly designed to work with the df robot shield. It simulates a digital port of 8 bits where the following mappings are made
- pin0 = right (DF_KEY_RIGHT)
- pin1 = up (DF_KEY_UP)
- pin2 = down (DF_KEY_DOWN)
- pin3 = left (DF_KEY_LEFT)
- pin4 = select (DF_KEY_SELECT)
◆ DfRobotInputAbstraction() [1/2]
DfRobotInputAbstraction::DfRobotInputAbstraction |
( |
const DfRobotAnalogRanges & |
ranges, |
|
|
pinid_t |
pin = A0 |
|
) |
| |
|
inline |
Create a dfRobot device that can handle switches using the dfRobot analog input configuration. Takes a range of values for the joystick and button voltage ranges. There are two standard ranges defined that work well for these shields on avr boards, other arrangements may vary, these are dfRobotAvrRanges and dfRobotV1AvrRanges.
- Parameters
-
ranges | the voltage ranges as per description. |
pin | the analog pin on which the buttons are attached. |
◆ DfRobotInputAbstraction() [2/2]
Create a dfRobot device that can handle switches using the dfRobot analog input configuration. Takes a range of values for the joystick and button voltage ranges. There are two standard ranges defined that work well for these shields on avr boards, other arrangements may vary, these are dfRobotAvrRanges and dfRobotV1AvrRanges. This is for compatibility and advanced cases, prefer the two arg constructor when possible.
- Parameters
-
ranges | the voltage ranges as per description. |
pin | the analog pin on which the buttons are attached. |
device | pointer to an analog device. |
◆ readValue()
uint8_t DfRobotInputAbstraction::readValue |
( |
pinid_t |
pin | ) |
|
|
inlineoverridevirtual |
Reads a value from a pin for this abstraction as per digitalRead
. For serial devices may need a sync first.
- Parameters
-
Reimplemented from BasicIoAbstraction.
◆ readPort()
uint8_t DfRobotInputAbstraction::readPort |
( |
pinid_t |
pin | ) |
|
|
inlineoverridevirtual |
Reads a whole port at once, on Arduino pins this is achieved by providing any pin within that port. On Arduino pins you should take care not to use ports that are providing core functions.
- Parameters
-
pin | the pin determines the hardware port to use. |
- Returns
- the 8 bit value read from the port.
Reimplemented from BasicIoAbstraction.
◆ runLoop()
bool DfRobotInputAbstraction::runLoop |
( |
| ) |
|
|
inlineoverridevirtual |
This method is not needed on Arduino pins, but for most serial implementations it causes the device and abstraction to be synced. Returns true if the write call worked, normally true, false indicates error
Reimplemented from BasicIoAbstraction.
◆ pinDirection()
void DfRobotInputAbstraction::pinDirection |
( |
pinid_t |
pin, |
|
|
uint8_t |
mode |
|
) |
| |
|
inlineoverridevirtual |
sets the pin direction for a pin controlled by this abstraction - as per pinMode
- Parameters
-
pin | the pin to be changed |
mode | the new mode, as per pinMode (or on Mbed you can use PinMode enum values) |
ignored as only input is supported
Reimplemented from BasicIoAbstraction.
◆ writeValue()
void DfRobotInputAbstraction::writeValue |
( |
pinid_t |
pin, |
|
|
uint8_t |
value |
|
) |
| |
|
inlineoverridevirtual |
Writes a value to a pin on this abstraction, as per digitalWrite
. For serial devices, may need a sync first.
- Parameters
-
pin | the pin to be written to |
value | the new value such as HIGH / LOW |
ignored as only input is supported
Reimplemented from BasicIoAbstraction.
◆ writePort()
void DfRobotInputAbstraction::writePort |
( |
pinid_t |
pin, |
|
|
uint8_t |
portVal |
|
) |
| |
|
inlineoverridevirtual |
Writes out a whole port at once, on Arduino pins this is achieved by providing any pin within that port. On Arduino pins you should take care not to use ports that are providing core functions.
- Parameters
-
pin | the pin determines the hardware port to use. |
portVal | the 8 bit value to write to the port. Use with care. |
ignored as only input is supported
Reimplemented from BasicIoAbstraction.
The documentation for this class was generated from the following file: