This library is meant to provide different options to use Arduino or other compatible controllers and integrate use of different devices (rotary encoders, buttons, switches).
There are following levels of abstractions:
- Raw API
- Support library hardware API facade
- Pins
- Components
- Devices
Direct usage of Arduino API functions like pinMode()
, digitalRead()
etc.
This is a facade to isolate Arduino API calls.
It provides the possibility of mocking these interfaces for the purpose of components unit testing.
classDiagram
class HwApi {
<<interface>>
+ digitalRead(...)
+ digitalWrite(...)
+ pinMode(...)
}
Abstraction level that represents pins and work with them.
classDiagram
direction BT
class PinApi {
<<interface>>
+ begin() = 0
+ loop() = 0
}
class DigitalInputPin {
+ begin()
+ loop()
}
class DigitalOutputPin {
+ begin()
+ loop()
}
class AnalogInputPin {
+ begin()
+ loop()
}
class AnalogOutputPin {
+ begin()
+ loop()
}
DigitalInputPin --|> PinApi : implements
DigitalOutputPin --|> PinApi : implements
AnalogInputPin --|> PinApi : implements
AnalogOutputPin --|> PinApi : implements
Component is a composition of pins that has clear real life functional representation:
- encoder
- switch
- button
- etc.
classDiagram
direction BT
class Component {
<<interface>>
+ begin() = 0
+ loop() = 0
}
class DigitalInputPin {
+ begin()
+ loop()
}
class Button {
+ begin()
+ loop()
}
class RotaryEncoder {
+ ctor(dt, clk, sw)
+ begin()
+ loop()
}
DigitalInputPin "1" --* "1" Button
DigitalInputPin "3" --* "1" RotaryEncoder
class DigitalOutputPin {
+ begin()
+ loop()
}
class Led {
+ begin()
+ loop()
}
DigitalOutputPin "1" --* "1" Led
RotaryEncoder --|> Component : implements
Led --|> Component : implements
Button --|> Component : implements
Device is a composition of components providing a specific functionality to user (e.g. volume control, gamepad, mouse, etc.).
classDiagram
direction BT
class Device {
<<interface>>
+ begin() = 0
+ loop() = 0
}
class VolumeControl {
+ begin()
+ loop()
}
VolumeControl --|> Device : implements
RotaryEncoder "1" --* "1" VolumeControl