Smartcar Shield
Public Member Functions | List of all members
ArduinoRuntime Class Reference

#include <ArduinoRuntime.hpp>

Inheritance diagram for ArduinoRuntime:
Inheritance graph
Collaboration diagram for ArduinoRuntime:
Collaboration graph

Public Member Functions

void setPinDirection (uint8_t pin, uint8_t direction) override
 Set pin direction, equivalent of pinMode in Arduino. More...
 
void setPinState (uint8_t pin, uint8_t state) override
 Set pin state, equivalent of digitalWrite in Arduino. More...
 
int getPinState (uint8_t pin) override
 Get the pin state, equivalent of digitalRead in Arduino. More...
 
int getAnalogPinState (uint8_t pin) override
 Get pin's analog (ADC) reading, equivalent of analogRead in Arduino. More...
 
void setPWM (uint8_t pin, int dutyCycle) override
 Set PWM state, equivalent of analogWrite in Arduino. More...
 
void i2cInit () override
 Initialize I2C bus as master, equivalent of Wire.begin in Arduino. More...
 
void i2cBeginTransmission (uint8_t address) override
 Initiate a transmission to the specified I2C slave device, equivalent of Wire.beginTransmission in Arduino. More...
 
size_t i2cWrite (uint8_t value) override
 Send the specified byte via i2c, equivalent of Wire.write in Arduino. More...
 
uint8_t i2cEndTransmission () override
 Ends a transmission to an I2C device equivalent of Wire.endTransmission in Arduino. More...
 
uint8_t i2cRequestFrom (uint8_t address, uint8_t numberOfBytes) override
 Request a number of bytes from the specified I2C slave, equivalent of Wire.requestFrom in Arduino. More...
 
int i2cAvailable () override
 Gets the number of bytes available to be retrieved, equivalent of Wire.availableO in Arduino. More...
 
int i2cRead () override
 Reads a byte from I2C bus, equivalent of Wire.read in Arduino. More...
 
int8_t pinToInterrupt (uint8_t pin) override
 Gets the interrupt number of the specified pin, equivalent of digitalPinToInterrupt in Arduino. More...
 
unsigned long currentTimeMillis () override
 Gets the amount of milliseconds since the microcontroller started running, equivalent of millis in Arduino. More...
 
unsigned long currentTimeMicros () override
 Gets the amount of microseconds since the microcontroller started running, equivalent of micros in Arduino. More...
 
void delayMillis (unsigned long milliseconds) override
 Block the execution for the specified number of milliseconds, equivalent of delay in Arduino. More...
 
void delayMicros (unsigned int microseconds) override
 Block the execution for the specified number of microseconds, equivalent of delayMicroseconds in Arduino. More...
 
unsigned long getPulseDuration (uint8_t pin, uint8_t state, unsigned long timeout) override
 Gets the incomming pulse length in microseconds starting from the nearest state, equivalent to pulseIn in Arduino. More...
 
void setInterrupt (uint8_t pin, InterruptCallback callback, int mode) override
 Enables an external hardware interrupt and provides a callback, equivalent to attachInterrupt in Arduino. More...
 
uint8_t getLowState () const override
 Get the runtime-specific value representing a logical LOW voltage state. More...
 
uint8_t getHighState () const override
 Get the runtime-specific value representing a logical HIGH voltage state. More...
 
uint8_t getOutputState () const override
 Get the runtime-specific value representing an OUTPUT pin state. More...
 
uint8_t getInputState () const override
 Get the runtime-specific value representing an INPUT pin state. More...
 
int getRisingEdgeMode () const override
 Get the rising edge constant for setting an interrupt. More...
 
- Public Member Functions inherited from Runtime
virtual ~Runtime ()=default
 

Detailed Description

The class to programatically represent the Arduino runtime environment or alternatively calls to the AVR and Arduino libraries.

Definition at line 11 of file ArduinoRuntime.hpp.

Member Function Documentation

◆ currentTimeMicros()

unsigned long STORED_IN_RAM ArduinoRuntime::currentTimeMicros ( )
overridevirtual

Gets the amount of microseconds since the microcontroller started running, equivalent of micros in Arduino.

Returns
Microseconds since beginning of operation

Implements Runtime.

Definition at line 88 of file ArduinoRuntime.cpp.

◆ currentTimeMillis()

unsigned long ArduinoRuntime::currentTimeMillis ( )
overridevirtual

Gets the amount of milliseconds since the microcontroller started running, equivalent of millis in Arduino.

Returns
Milliseconds since beginning of operation

Implements Runtime.

Definition at line 83 of file ArduinoRuntime.cpp.

◆ delayMicros()

void ArduinoRuntime::delayMicros ( unsigned int  microseconds)
overridevirtual

Block the execution for the specified number of microseconds, equivalent of delayMicroseconds in Arduino.

Parameters
microsecondsHow much time to block execution in microseconds

Implements Runtime.

Definition at line 98 of file ArduinoRuntime.cpp.

◆ delayMillis()

void ArduinoRuntime::delayMillis ( unsigned long  milliseconds)
overridevirtual

Block the execution for the specified number of milliseconds, equivalent of delay in Arduino.

Parameters
millisecondsHow much time to block execution in milliseconds

Implements Runtime.

Definition at line 93 of file ArduinoRuntime.cpp.

◆ getAnalogPinState()

int ArduinoRuntime::getAnalogPinState ( uint8_t  pin)
overridevirtual

Get pin's analog (ADC) reading, equivalent of analogRead in Arduino.

Parameters
pinPin to get ADC reading
Returns
ADC reading

Implements Runtime.

Definition at line 30 of file ArduinoRuntime.cpp.

◆ getHighState()

uint8_t ArduinoRuntime::getHighState ( ) const
overridevirtual

Get the runtime-specific value representing a logical HIGH voltage state.

Returns
uint8_t The HIGH value

Implements Runtime.

Definition at line 118 of file ArduinoRuntime.cpp.

◆ getInputState()

uint8_t ArduinoRuntime::getInputState ( ) const
overridevirtual

Get the runtime-specific value representing an INPUT pin state.

Returns
uint8_t The INPUT state

Implements Runtime.

Definition at line 128 of file ArduinoRuntime.cpp.

◆ getLowState()

uint8_t ArduinoRuntime::getLowState ( ) const
overridevirtual

Get the runtime-specific value representing a logical LOW voltage state.

Returns
uint8_t The LOW value

Implements Runtime.

Definition at line 113 of file ArduinoRuntime.cpp.

◆ getOutputState()

uint8_t ArduinoRuntime::getOutputState ( ) const
overridevirtual

Get the runtime-specific value representing an OUTPUT pin state.

Returns
uint8_t The OUTPUT state

Implements Runtime.

Definition at line 123 of file ArduinoRuntime.cpp.

◆ getPinState()

int STORED_IN_RAM ArduinoRuntime::getPinState ( uint8_t  pin)
overridevirtual

Get the pin state, equivalent of digitalRead in Arduino.

Parameters
pinPin to get state
Returns
Pin's state (i.e. HIGH or LOW)

Implements Runtime.

Definition at line 25 of file ArduinoRuntime.cpp.

◆ getPulseDuration()

unsigned long ArduinoRuntime::getPulseDuration ( uint8_t  pin,
uint8_t  state,
unsigned long  timeout 
)
overridevirtual

Gets the incomming pulse length in microseconds starting from the nearest state, equivalent to pulseIn in Arduino.

Parameters
pinThe pin to expect the pulse
stateThe state (HIGH or LOW) of the incoming pulse
timeoutHow long to wait for a complete pulse in microseconds
Returns
0 if no pulse arrived otherwise the pulse length in in microseconds

Implements Runtime.

Definition at line 103 of file ArduinoRuntime.cpp.

◆ getRisingEdgeMode()

int ArduinoRuntime::getRisingEdgeMode ( ) const
overridevirtual

Get the rising edge constant for setting an interrupt.

Returns
int The rising edge mode

Implements Runtime.

Definition at line 133 of file ArduinoRuntime.cpp.

◆ i2cAvailable()

int ArduinoRuntime::i2cAvailable ( )
overridevirtual

Gets the number of bytes available to be retrieved, equivalent of Wire.availableO in Arduino.

Returns
The number of bytes available for reading

Implements Runtime.

Definition at line 68 of file ArduinoRuntime.cpp.

◆ i2cBeginTransmission()

void ArduinoRuntime::i2cBeginTransmission ( uint8_t  address)
overridevirtual

Initiate a transmission to the specified I2C slave device, equivalent of Wire.beginTransmission in Arduino.

Parameters
addressI2C address to begin a transmission to

Implements Runtime.

Definition at line 48 of file ArduinoRuntime.cpp.

◆ i2cEndTransmission()

uint8_t ArduinoRuntime::i2cEndTransmission ( )
overridevirtual

Ends a transmission to an I2C device equivalent of Wire.endTransmission in Arduino.

Returns
Transmission status

Implements Runtime.

Definition at line 58 of file ArduinoRuntime.cpp.

◆ i2cInit()

void ArduinoRuntime::i2cInit ( )
overridevirtual

Initialize I2C bus as master, equivalent of Wire.begin in Arduino.

Implements Runtime.

Definition at line 43 of file ArduinoRuntime.cpp.

◆ i2cRead()

int ArduinoRuntime::i2cRead ( )
overridevirtual

Reads a byte from I2C bus, equivalent of Wire.read in Arduino.

Returns
Byte read from I2C

Implements Runtime.

Definition at line 73 of file ArduinoRuntime.cpp.

◆ i2cRequestFrom()

uint8_t ArduinoRuntime::i2cRequestFrom ( uint8_t  address,
uint8_t  numberOfBytes 
)
overridevirtual

Request a number of bytes from the specified I2C slave, equivalent of Wire.requestFrom in Arduino.

Parameters
addressI2C slave device address
numberOfBytesNumber of bytes to request
Returns
Number of bytes returned from the slave

Implements Runtime.

Definition at line 63 of file ArduinoRuntime.cpp.

◆ i2cWrite()

size_t ArduinoRuntime::i2cWrite ( uint8_t  value)
overridevirtual

Send the specified byte via i2c, equivalent of Wire.write in Arduino.

Parameters
valueByte to send
Returns
Number of bytes sent

Implements Runtime.

Definition at line 53 of file ArduinoRuntime.cpp.

◆ pinToInterrupt()

int8_t ArduinoRuntime::pinToInterrupt ( uint8_t  pin)
overridevirtual

Gets the interrupt number of the specified pin, equivalent of digitalPinToInterrupt in Arduino.

Parameters
pinPin to get interrupt number
Returns
Interrupt number

Implements Runtime.

Definition at line 78 of file ArduinoRuntime.cpp.

◆ setInterrupt()

void ArduinoRuntime::setInterrupt ( uint8_t  pin,
InterruptCallback  callback,
int  mode 
)
overridevirtual

Enables an external hardware interrupt and provides a callback, equivalent to attachInterrupt in Arduino.

Parameters
pinThe interrupt pin to attach the interrupt
callbackThe callback to be executed
modeThe state of the pin to run the callback

Implements Runtime.

Definition at line 108 of file ArduinoRuntime.cpp.

◆ setPinDirection()

void ArduinoRuntime::setPinDirection ( uint8_t  pin,
uint8_t  direction 
)
overridevirtual

Set pin direction, equivalent of pinMode in Arduino.

Parameters
pinThe pin to set direction
directionThe pin's direction (e.g. INPUT, OUTPUT etc)

Implements Runtime.

Definition at line 15 of file ArduinoRuntime.cpp.

◆ setPinState()

void STORED_IN_RAM ArduinoRuntime::setPinState ( uint8_t  pin,
uint8_t  state 
)
overridevirtual

Set pin state, equivalent of digitalWrite in Arduino.

Parameters
pinThe pin to set state
stateThe pin's state (i.e. HIGH or LOW)

Implements Runtime.

Definition at line 20 of file ArduinoRuntime.cpp.

◆ setPWM()

void ArduinoRuntime::setPWM ( uint8_t  pin,
int  dutyCycle 
)
overridevirtual

Set PWM state, equivalent of analogWrite in Arduino.

Parameters
pinPin to set PWM
dutyCycleDuty cycle of PWM

Implements Runtime.

Definition at line 35 of file ArduinoRuntime.cpp.

Here is the call graph for this function:

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