- 
                Notifications
    
You must be signed in to change notification settings  - Fork 8
 
Hardware Abstraction
We are using wrapper classes to provide a flexible, configurable functionality for
- SPI (SPIWrapper with the default object SPI)
 - I2C (I2CWrapper with the default object Wire)
 - GPIO (GPIOWrapper with the default object GPIO)
 
In addition we provide the following initialization classes / objects to set up some consistent szenarios accross these objects:
- HardwareSetupRPI with the default object RPI
 - HardwareSetupRemote with the default object Remote
 
If you compile with -DUSE_PI then RPI.begin() is called automatically which will set the SPI, I2C and GPIO to use Linux API provided by the Raspberry PI.
If you compile with -DUSE_REMOTE then Remote.begin() is called automatically which will set the SPI, I2C and GPIO to use communication via UDP.
If you omit any of the above, we just use a dummy implementation where you can call all available methods on the objects but w/o any impact.
This setup provides you with a lot of flexibility, since you can call this functionality in the sketch as well: e.g. calling Remote.begin() in the sketch switches the SPI, I2C and GPIO to using Serial communication via UDP even when compiled with -USE_RPI. In addition you can configure SPI, I2C or GPIO individually:
RPI.begin(false); // initialize RPI w/o updating GPIO, SPI and I2C
Remote.begin(false); // initialize Remote  w/o updating GPIO, SPI and I2C
GPIO.setGPIO(RPI.getGPIO()); // use Raspberry PI API for GPIO
SPI.setSPI(Remote.getSPI()); // Exchange SPI via UDP
I2C.setI2C(nullptr); // Dummy I2C where functions calls don't have any impact
The remote API uses UDP by default, but you can use any Stream class provided by Arduino.
E.g. the following
Remote.begin(Serial); // initialize Remote for GPIO, SPI and I2Cwill using Serial to communicate state changes.