Modmata  v0
An arduino communications server using Modbus
Functions | Variables
Functions.cpp File Reference

Define standard callback functions to control Arduino I/O. More...

#include "Functions.h"
Include dependency graph for Functions.cpp:

Go to the source code of this file.

Functions

struct registers pinMode (uint8_t argc, uint8_t *argv)
 Change the settings of the Arduino I/O pins. More...
 
struct registers digitalWrite (uint8_t argc, uint8_t *argv)
 Write a digital (HIGH/LOW) value to the Arduino I/O pins. More...
 
struct registers digitalRead (uint8_t argc, uint8_t *argv)
 Read a digital value (HIGH/LOW) from the Arduino I/O pins. More...
 
struct registers analogWrite (uint8_t argc, uint8_t *argv)
 Write an analog value (0-255) to the Arduino I/O pins. More...
 
struct registers analogRead (uint8_t argc, uint8_t *argv)
 Read an analog value (0-1023) from the Arduino I/O pins. More...
 
struct registers servoAttach (uint8_t argc, uint8_t *argv)
 Attach a connected servo to a control interface. More...
 
struct registers servoDetach (uint8_t argc, uint8_t *argv)
 Detach a servo from the the control interface. More...
 
struct registers servoWrite (uint8_t argc, uint8_t *argv)
 Write a value to the connected servo. More...
 
struct registers servoRead (uint8_t argc, uint8_t *argv)
 Read a value from the connected servo. More...
 
struct registers wireBegin (uint8_t argc, uint8_t *argv)
 Begin an I2C connection between the Arduino and a peripheral. More...
 
struct registers wireEnd (uint8_t argc, uint8_t *argv)
 End an I2C connection between the Arduino and a peripheral. More...
 
struct registers wireSetClock (uint8_t argc, uint8_t *argv)
 Change the clock speed settings of the I2C connection. More...
 
struct registers wireWrite (uint8_t argc, uint8_t *argv)
 Write data to the connected I2C peripheral. More...
 
struct registers wireRead (uint8_t argc, uint8_t *argv)
 Read data from the connected I2C peripheral. More...
 
struct registers spiBegin (uint8_t argc, uint8_t *argv)
 Begin a SPI connection between the Arduino and a peripheral. More...
 
struct registers spiSettings (uint8_t argc, uint8_t *argv)
 Change the settings of the SPI connection. More...
 
struct registers spiTransferBuf (uint8_t argc, uint8_t *argv)
 Exchange data over the SPI connection (Read + Write) More...
 
struct registers spiEnd (uint8_t argc, uint8_t *argv)
 End a SPI connection between the Arduino and a peripheral. More...
 

Variables

int servo_count = 0
 Current number of attached servos.
 
Servo servos [14]
 Array to control attached servos.
 
struct spi_settings settings
 Singleton to represent the current SPI connection settings.
 
const registers VOID_STRUCT {0, nullptr}
 Helper struct that is returned directly when a callback function has no return values, and that is copy-constructed from when a clean struct is needed to populate with values.
 

Detailed Description

Define standard callback functions to control Arduino I/O.

Author
Sam Hutcherson, Chase Wallendorff, Iris Astrid
Date
2023-04-06

Definition in file Functions.cpp.

Function Documentation

◆ analogRead()

struct registers analogRead ( uint8_t  argc,
uint8_t *  argv 
)

Read an analog value (0-1023) from the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (1)
argvThe arguments to use within the function (pin #)
Returns
struct containing the value of pin (10-bit unsigned int contained within a uint16_t)

Definition at line 29 of file Functions.cpp.

◆ analogWrite()

struct registers analogWrite ( uint8_t  argc,
uint8_t *  argv 
)

Write an analog value (0-255) to the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (3)
argvThe arguments to use within the function (pin #, 16-bit value split into 2 8-bit values)
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ digitalRead()

struct registers digitalRead ( uint8_t  argc,
uint8_t *  argv 
)

Read a digital value (HIGH/LOW) from the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (1)
argvThe arguments to use within the function (pin #)
Returns
struct containing the value of pin (1 uint8_t)

Definition at line 29 of file Functions.cpp.

◆ digitalWrite()

struct registers digitalWrite ( uint8_t  argc,
uint8_t *  argv 
)

Write a digital (HIGH/LOW) value to the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (2)
argvThe arguments to use within the function (pin #, value)
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ pinMode()

struct registers pinMode ( uint8_t  argc,
uint8_t *  argv 
)

Change the settings of the Arduino I/O pins.

Parameters
argcThe number of arguments contained within the 'argv' array (2)
argvThe arguments to use within the function (pin #, mode)
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ servoAttach()

struct registers servoAttach ( uint8_t  argc,
uint8_t *  argv 
)

Attach a connected servo to a control interface.

Parameters
argcThe number of arguments contained within the 'argv' array (1)
argvThe arguments to use within the function (pin #)
Returns
struct containing the ServoIndex (uint8_t), I have no idea what it actually means though (undocumented on Arduino???)

Definition at line 29 of file Functions.cpp.

◆ servoDetach()

struct registers servoDetach ( uint8_t  argc,
uint8_t *  argv 
)

Detach a servo from the the control interface.

Parameters
argcThe number of arguments contained within the 'argv' array (1)
argvThe arguments to use within the function (pin #)
Returns
struct containing the boolean value of the operation's success (uint8_t)

Definition at line 29 of file Functions.cpp.

◆ servoRead()

struct registers servoRead ( uint8_t  argc,
uint8_t *  argv 
)

Read a value from the connected servo.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
struct containing the last value written to the servo (uint8_t)

Definition at line 29 of file Functions.cpp.

◆ servoWrite()

struct registers servoWrite ( uint8_t  argc,
uint8_t *  argv 
)

Write a value to the connected servo.

Parameters
argcThe number of arguments contained within the 'argv' array (2)
argvThe arguments to use within the function (pin #, value)
Returns
struct containing the boolean value of the operation's success (uint8_t)

Definition at line 29 of file Functions.cpp.

◆ spiBegin()

struct registers spiBegin ( uint8_t  argc,
uint8_t *  argv 
)

Begin a SPI connection between the Arduino and a peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ spiEnd()

struct registers spiEnd ( uint8_t  argc,
uint8_t *  argv 
)

End a SPI connection between the Arduino and a peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array (0)
argvThe arguments to use within the function (None)
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ spiSettings()

struct registers spiSettings ( uint8_t  argc,
uint8_t *  argv 
)

Change the settings of the SPI connection.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ spiTransferBuf()

struct registers spiTransferBuf ( uint8_t  argc,
uint8_t *  argv 
)

Exchange data over the SPI connection (Read + Write)

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
struct containing the response to the command written (argc - 1 * uint8_t)

Definition at line 29 of file Functions.cpp.

◆ wireBegin()

struct registers wireBegin ( uint8_t  argc,
uint8_t *  argv 
)

Begin an I2C connection between the Arduino and a peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ wireEnd()

struct registers wireEnd ( uint8_t  argc,
uint8_t *  argv 
)

End an I2C connection between the Arduino and a peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ wireRead()

struct registers wireRead ( uint8_t  argc,
uint8_t *  argv 
)

Read data from the connected I2C peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
struct containing the bytes read (num_bytes * uint8_t)

Definition at line 29 of file Functions.cpp.

◆ wireSetClock()

struct registers wireSetClock ( uint8_t  argc,
uint8_t *  argv 
)

Change the clock speed settings of the I2C connection.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.

◆ wireWrite()

struct registers wireWrite ( uint8_t  argc,
uint8_t *  argv 
)

Write data to the connected I2C peripheral.

Parameters
argcThe number of arguments contained within the 'argv' array
argvThe arguments to use within the function
Returns
void (empty struct)

Definition at line 29 of file Functions.cpp.