Adafruit Library
|
Class that stores state and functions for interacting with seesaw helper IC. More...
#include <Adafruit_seesaw.h>
Classes | |
union | sercom_inten |
Public Member Functions | |
Adafruit_seesaw (TwoWire *Wi=NULL) | |
Create a seesaw object on a given I2C bus. More... | |
bool | begin (uint8_t addr=SEESAW_ADDRESS, int8_t flow=-1, bool reset=true) |
Start the seesaw. More... | |
uint32_t | getOptions () |
Returns the available options compiled into the seesaw firmware. More... | |
uint32_t | getVersion () |
Returns the version of the seesaw. More... | |
bool | getProdDatecode (uint16_t *pid, uint8_t *year, uint8_t *mon, uint8_t *day) |
Returns the version of the seesaw. More... | |
bool | SWReset () |
perform a software reset. This resets all seesaw registers to their default values. This is called automatically from Adafruit_seesaw.begin() More... | |
void | pinMode (uint8_t pin, uint8_t mode) |
Set the mode of a GPIO pin. More... | |
void | pinModeBulk (uint32_t pins, uint8_t mode) |
set the mode of multiple GPIO pins at once. More... | |
void | pinModeBulk (uint32_t pinsa, uint32_t pinsb, uint8_t mode) |
set the mode of multiple GPIO pins at once. This supports both ports A and B. More... | |
virtual void | analogWrite (uint8_t pin, uint16_t value, uint8_t width=8) |
write a PWM value to a PWM-enabled pin More... | |
void | digitalWrite (uint8_t pin, uint8_t value) |
Set the output of a GPIO pin. More... | |
void | digitalWriteBulk (uint32_t port_values) |
write the entire GPIO port at once. More... | |
void | digitalWriteBulk (uint32_t pins, uint8_t value) |
write a value to multiple GPIO pins at once. More... | |
void | digitalWriteBulk (uint32_t pinsa, uint32_t pinsb, uint8_t value) |
write a value to multiple GPIO pins at once. This supports both ports A and B More... | |
bool | digitalRead (uint8_t pin) |
Read the current status of a GPIO pin. More... | |
uint32_t | digitalReadBulk (uint32_t pins) |
read the status of multiple pins on port A. More... | |
uint32_t | digitalReadBulkB (uint32_t pins) |
read the status of multiple pins on port B. More... | |
void | setGPIOInterrupts (uint32_t pins, bool enabled) |
Enable or disable GPIO interrupts on the passed pins. More... | |
virtual uint16_t | analogRead (uint8_t pin) |
read the analog value on an ADC-enabled pin. More... | |
uint16_t | touchRead (uint8_t pin) |
read the analog value on an capacitive touch-enabled pin. More... | |
virtual void | setPWMFreq (uint8_t pin, uint16_t freq) |
set the PWM frequency of a PWM-enabled pin. Note that on SAMD09, SAMD11 boards the frequency will be mapped to closest match fixed frequencies. Also note that PWM pins 4 and 5 share a timer, and PWM pins 6 and 7 share a timer. Changing the frequency for one pin will change the frequency for the other pin that is on the timer. More... | |
void | enableSercomDataRdyInterrupt (uint8_t sercom=0) |
Enable the data ready interrupt on the passed sercom. Note that both the interrupt module and the passed sercom must be compiled into the seesaw firmware for this to function. If both of these things are true, the interrupt pin on the seesaw will fire when there is data to be read from the passed sercom. On the default seesaw firmeare on the SAMD09 breakout, no sercoms are enabled. More... | |
void | disableSercomDataRdyInterrupt (uint8_t sercom=0) |
Disable the data ready interrupt on the passed sercom. More... | |
char | readSercomData (uint8_t sercom=0) |
Reads a character from the passed sercom if one is available. Note that on the default seesaw firmware on the SAMD09 breakout no sercoms are enabled. More... | |
void | EEPROMWrite8 (uint8_t addr, uint8_t val) |
Write a 1 byte to an EEPROM address. More... | |
void | EEPROMWrite (uint8_t addr, uint8_t *buf, uint8_t size) |
write a string of bytes to EEPROM starting at the passed address More... | |
uint8_t | EEPROMRead8 (uint8_t addr) |
Read 1 byte from the specified EEPROM address. More... | |
void | setI2CAddr (uint8_t addr) |
Set the seesaw I2C address. This will automatically call Adafruit_seesaw.begin() with the new address. More... | |
uint8_t | getI2CAddr () |
Read the I2C address of the seesaw. More... | |
void | UARTSetBaud (uint32_t baud) |
Set the baud rate on SERCOM0. More... | |
void | setKeypadEvent (uint8_t key, uint8_t edge, bool enable=true) |
activate or deactivate a key and edge on the keypad module More... | |
void | enableKeypadInterrupt () |
enable the keypad interrupt that fires when events are in the fifo. | |
void | disableKeypadInterrupt () |
disable the keypad interrupt that fires when events are in the fifo. | |
uint8_t | getKeypadCount () |
Get the number of events currently in the fifo. More... | |
bool | readKeypad (keyEventRaw *buf, uint8_t count) |
Read all keyEvents into the passed buffer. More... | |
float | getTemp () |
Read the temperature of the seesaw board in degrees Celsius. NOTE: not all seesaw firmwares have the temperature sensor enabled. More... | |
int32_t | getEncoderPosition (uint8_t encoder=0) |
Read the current position of the encoder. More... | |
int32_t | getEncoderDelta (uint8_t encoder=0) |
Read the change in encoder position since it was last read. More... | |
bool | enableEncoderInterrupt (uint8_t encoder=0) |
Enable the interrupt to fire when the encoder changes position. More... | |
bool | disableEncoderInterrupt (uint8_t encoder=0) |
Disable the interrupt from firing when the encoder changes position. More... | |
void | setEncoderPosition (int32_t pos, uint8_t encoder=0) |
Set the current position of the encoder. More... | |
virtual size_t | write (uint8_t) |
The print wrapper for the seesaw class. Calling this allows you to use ss.print() or ss.println() and write to the UART on SERCOM0 of the seesaw. Note that this functionality is only available when the UART (sercom) module is compiled into the seesaw firmware. On the default seesaw firmware on the SAMD09 breakout this functionality is not available. More... | |
virtual size_t | write (const char *str) |
The print wrapper for the seesaw class allowing the user to print a string. Calling this allows you to use ss.print() or ss.println() and write to the UART on SERCOM0 of the seesaw. Note that this functionality is only available when the UART (sercom) module is compiled into the seesaw firmware. On the default seesaw firmware on the SAMD09 breakout this functionality is not available. More... | |
Protected Member Functions | |
uint8_t | getI2CaddrEEPROMloc () |
Return the EEPROM address used to store I2C address. More... | |
bool | write8 (byte regHigh, byte regLow, byte value) |
Write 1 byte to the specified seesaw register. More... | |
uint8_t | read8 (byte regHigh, byte regLow, uint16_t delay=250) |
read 1 byte from the specified seesaw register. More... | |
bool | read (uint8_t regHigh, uint8_t regLow, uint8_t *buf, uint8_t num, uint16_t delay=250) |
Read a specified number of bytes into a buffer from the seesaw. More... | |
bool | write (uint8_t regHigh, uint8_t regLow, uint8_t *buf, uint8_t num) |
Write a specified number of bytes to the seesaw from the passed buffer. More... | |
Protected Attributes | |
TwoWire * | _i2cbus |
Adafruit_I2CDevice * | _i2c_dev = NULL |
The BusIO device for I2C control. | |
int8_t | _flow |
uint8_t | _hardwaretype = 0 |
sercom_inten | _sercom_inten |
sercom interrupt enable register instance | |
Class that stores state and functions for interacting with seesaw helper IC.
Adafruit_seesaw::Adafruit_seesaw | ( | TwoWire * | i2c_bus = NULL | ) |
Create a seesaw object on a given I2C bus.
i2c_bus | the I2C bus connected to the seesaw, defaults to "Wire" |
bool Adafruit_seesaw::begin | ( | uint8_t | addr = SEESAW_ADDRESS , |
int8_t | flow = -1 , |
||
bool | reset = true |
||
) |
Start the seesaw.
This should be called when your sketch is connecting to the seesaw
addr | the I2C address of the seesaw |
flow | the flow control pin to use |
reset | pass true to reset the seesaw on startup. Defaults to true. |
uint32_t Adafruit_seesaw::getOptions | ( | ) |
Returns the available options compiled into the seesaw firmware.
uint32_t Adafruit_seesaw::getVersion | ( | ) |
Returns the version of the seesaw.
bool Adafruit_seesaw::getProdDatecode | ( | uint16_t * | pid, |
uint8_t * | year, | ||
uint8_t * | mon, | ||
uint8_t * | day | ||
) |
Returns the version of the seesaw.
pid | Pointer to uint16_t for product code result. |
year | Pointer to uint8_t for date code year result. |
mon | Pointer to uint8_t for date code month result. |
day | Pointer to uint8_t for date code day result. |
bool Adafruit_seesaw::SWReset | ( | ) |
perform a software reset. This resets all seesaw registers to their default values. This is called automatically from Adafruit_seesaw.begin()
void Adafruit_seesaw::pinMode | ( | uint8_t | pin, |
uint8_t | mode | ||
) |
Set the mode of a GPIO pin.
pin | the pin number. On the SAMD09 breakout, this corresponds to the number on the silkscreen. |
mode | the mode to set the pin. One of INPUT, OUTPUT, or INPUT_PULLUP. |
void Adafruit_seesaw::pinModeBulk | ( | uint32_t | pins, |
uint8_t | mode | ||
) |
set the mode of multiple GPIO pins at once.
pins | a bitmask of the pins to write. On the SAMD09 breakout, this corresponds to the number on the silkscreen. For example, passing 0b0110 will set the mode of pins 2 and 3. |
mode | the mode to set the pins to. One of INPUT, OUTPUT, or INPUT_PULLUP. |
void Adafruit_seesaw::pinModeBulk | ( | uint32_t | pinsa, |
uint32_t | pinsb, | ||
uint8_t | mode | ||
) |
set the mode of multiple GPIO pins at once. This supports both ports A and B.
pinsa | a bitmask of the pins to write on port A. On the SAMD09 breakout, this corresponds to the number on the silkscreen. For example, passing 0b0110 will set the mode of pins 2 and 3. |
pinsb | a bitmask of the pins to write on port B. |
mode | the mode to set the pins to. One of INPUT, OUTPUT, or INPUT_PULLUP. |
|
virtual |
write a PWM value to a PWM-enabled pin
pin | the number of the pin to write. On the SAMD09 breakout, this corresponds to the number on the silkscreen. on the default seesaw firmware on the SAMD09 breakout, pins 5, 6, and 7 are PWM enabled. |
value | the value to write to the pin |
width | the width of the value to write. Defaults to 8. If 16 is passed a 16 bit value will be written. |
Reimplemented in Adafruit_Crickit.
void Adafruit_seesaw::digitalWrite | ( | uint8_t | pin, |
uint8_t | value | ||
) |
Set the output of a GPIO pin.
pin | the pin number. On the SAMD09 breakout, this corresponds to the number on the silkscreen. |
value | the value to write to the GPIO pin. This should be HIGH or LOW. |
void Adafruit_seesaw::digitalWriteBulk | ( | uint32_t | port_values | ) |
write the entire GPIO port at once.
port_values | The up-to-32 values to write to the pins, doesn't set direction used for bulk writing quickly all valid pins |
void Adafruit_seesaw::digitalWriteBulk | ( | uint32_t | pins, |
uint8_t | value | ||
) |
write a value to multiple GPIO pins at once.
pins | a bitmask of the pins to write. On the SAMD09 breakout, this corresponds to the number on the silkscreen. For example, passing 0b0110 will write the passed value to pins 2 and 3. |
value | pass HIGH to set the output on the passed pins to HIGH, low to set the output on the passed pins to LOW. |
void Adafruit_seesaw::digitalWriteBulk | ( | uint32_t | pinsa, |
uint32_t | pinsb, | ||
uint8_t | value | ||
) |
write a value to multiple GPIO pins at once. This supports both ports A and B
pinsa | a bitmask of the pins to write on port A. On the SAMD09 breakout, this corresponds to the number on the silkscreen. For example, passing 0b0110 will write the passed value to pins 2 and 3. |
pinsb | a bitmask of the pins to write on port B. |
value | pass HIGH to set the output on the passed pins to HIGH, low to set the output on the passed pins to LOW. |
bool Adafruit_seesaw::digitalRead | ( | uint8_t | pin | ) |
Read the current status of a GPIO pin.
pin | the pin number. On the SAMD09 breakout, this corresponds to the number on the silkscreen. |
uint32_t Adafruit_seesaw::digitalReadBulk | ( | uint32_t | pins | ) |
read the status of multiple pins on port A.
pins | a bitmask of the pins to write. On the SAMD09 breakout, this corresponds to the number on the silkscreen. For example, passing 0b0110 will return the values of pins 2 and 3. |
uint32_t Adafruit_seesaw::digitalReadBulkB | ( | uint32_t | pins | ) |
read the status of multiple pins on port B.
pins | a bitmask of the pins to write. |
void Adafruit_seesaw::setGPIOInterrupts | ( | uint32_t | pins, |
bool | enabled | ||
) |
Enable or disable GPIO interrupts on the passed pins.
pins | a bitmask of the pins to write. On the SAMD09 breakout, this corresponds to the number on the silkscreen. For example, passing 0b0110 will enable or disable interrups on pins 2 and 3. |
enabled | pass true to enable the interrupts on the passed pins, false to disable the interrupts on the passed pins. |
|
virtual |
read the analog value on an ADC-enabled pin.
pin | the number of the pin to read. On the SAMD09 breakout, this corresponds to the number on the silkscreen. On the default seesaw firmware on the SAMD09 breakout, pins 2, 3, and 4 are ADC-enabled. |
Reimplemented in Adafruit_Crickit.
uint16_t Adafruit_seesaw::touchRead | ( | uint8_t | pin | ) |
read the analog value on an capacitive touch-enabled pin.
pin | the number of the pin to read. |
|
virtual |
set the PWM frequency of a PWM-enabled pin. Note that on SAMD09, SAMD11 boards the frequency will be mapped to closest match fixed frequencies. Also note that PWM pins 4 and 5 share a timer, and PWM pins 6 and 7 share a timer. Changing the frequency for one pin will change the frequency for the other pin that is on the timer.
pin | the number of the pin to change frequency of. On the SAMD09 breakout, this corresponds to the number on the silkscreen. on the default seesaw firmware on the SAMD09 breakout, pins 5, 6, and 7 are PWM enabled. |
freq | the frequency to set. |
Reimplemented in Adafruit_Crickit.
void Adafruit_seesaw::enableSercomDataRdyInterrupt | ( | uint8_t | sercom = 0 | ) |
Enable the data ready interrupt on the passed sercom. Note that both the interrupt module and the passed sercom must be compiled into the seesaw firmware for this to function. If both of these things are true, the interrupt pin on the seesaw will fire when there is data to be read from the passed sercom. On the default seesaw firmeare on the SAMD09 breakout, no sercoms are enabled.
sercom | the sercom to enable the interrupt on. |
void Adafruit_seesaw::disableSercomDataRdyInterrupt | ( | uint8_t | sercom = 0 | ) |
Disable the data ready interrupt on the passed sercom.
sercom | the sercom to disable the interrupt on. |
char Adafruit_seesaw::readSercomData | ( | uint8_t | sercom = 0 | ) |
Reads a character from the passed sercom if one is available. Note that on the default seesaw firmware on the SAMD09 breakout no sercoms are enabled.
sercom | the sercom to read data from. |
void Adafruit_seesaw::EEPROMWrite8 | ( | uint8_t | addr, |
uint8_t | val | ||
) |
Write a 1 byte to an EEPROM address.
addr | the address to write to. On the default seesaw firmware on the SAMD09 breakout this is between 0 and 63. |
val | to write between 0 and 255 |
void Adafruit_seesaw::EEPROMWrite | ( | uint8_t | addr, |
uint8_t * | buf, | ||
uint8_t | size | ||
) |
write a string of bytes to EEPROM starting at the passed address
addr | the starting address to write the first byte. This will be automatically incremented with each byte written. |
buf | the buffer of bytes to be written. |
size | the number of bytes to write. Writing past the end of available EEPROM may result in undefined behavior. |
uint8_t Adafruit_seesaw::EEPROMRead8 | ( | uint8_t | addr | ) |
Read 1 byte from the specified EEPROM address.
addr | the address to read from. One the default seesaw firmware on the SAMD09 breakout this is between 0 and 63. |
void Adafruit_seesaw::setI2CAddr | ( | uint8_t | addr | ) |
Set the seesaw I2C address. This will automatically call Adafruit_seesaw.begin() with the new address.
addr | the new address for the seesaw. This must be a valid 7 bit I2C address. |
uint8_t Adafruit_seesaw::getI2CAddr | ( | ) |
Read the I2C address of the seesaw.
void Adafruit_seesaw::UARTSetBaud | ( | uint32_t | baud | ) |
Set the baud rate on SERCOM0.
baud | the baud rate to set. This is an integer value. Baud rates up to 115200 are supported. |
void Adafruit_seesaw::setKeypadEvent | ( | uint8_t | key, |
uint8_t | edge, | ||
bool | enable = true |
||
) |
activate or deactivate a key and edge on the keypad module
key | the key number to activate |
edge | the edge to trigger on |
enable | passing true will enable the passed event, passing false will disable it. |
uint8_t Adafruit_seesaw::getKeypadCount | ( | ) |
Get the number of events currently in the fifo.
bool Adafruit_seesaw::readKeypad | ( | keyEventRaw * | buf, |
uint8_t | count | ||
) |
Read all keyEvents into the passed buffer.
buf | pointer to where the keyEvents should be stored |
count | the number of events to read |
float Adafruit_seesaw::getTemp | ( | ) |
Read the temperature of the seesaw board in degrees Celsius. NOTE: not all seesaw firmwares have the temperature sensor enabled.
int32_t Adafruit_seesaw::getEncoderPosition | ( | uint8_t | encoder = 0 | ) |
Read the current position of the encoder.
encoder | Which encoder to use, defaults to 0 |
int32_t Adafruit_seesaw::getEncoderDelta | ( | uint8_t | encoder = 0 | ) |
Read the change in encoder position since it was last read.
encoder | Which encoder to use, defaults to 0 |
bool Adafruit_seesaw::enableEncoderInterrupt | ( | uint8_t | encoder = 0 | ) |
Enable the interrupt to fire when the encoder changes position.
encoder | Which encoder to use, defaults to 0 |
bool Adafruit_seesaw::disableEncoderInterrupt | ( | uint8_t | encoder = 0 | ) |
Disable the interrupt from firing when the encoder changes position.
encoder | Which encoder to use, defaults to 0 |
void Adafruit_seesaw::setEncoderPosition | ( | int32_t | pos, |
uint8_t | encoder = 0 |
||
) |
Set the current position of the encoder.
encoder | Which encoder to use, defaults to 0 |
pos | the position to set the encoder to. |
|
virtual |
The print wrapper for the seesaw class. Calling this allows you to use ss.print() or ss.println() and write to the UART on SERCOM0 of the seesaw. Note that this functionality is only available when the UART (sercom) module is compiled into the seesaw firmware. On the default seesaw firmware on the SAMD09 breakout this functionality is not available.
character | the character to write. |
|
virtual |
The print wrapper for the seesaw class allowing the user to print a string. Calling this allows you to use ss.print() or ss.println() and write to the UART on SERCOM0 of the seesaw. Note that this functionality is only available when the UART (sercom) module is compiled into the seesaw firmware. On the default seesaw firmware on the SAMD09 breakout this functionality is not available.
str | the string to write |
|
protected |
Return the EEPROM address used to store I2C address.
|
protected |
Write 1 byte to the specified seesaw register.
regHigh | the module address register (ex. SEESAW_NEOPIXEL_BASE) |
regLow | the function address register (ex. SEESAW_NEOPIXEL_PIN) |
value | the value between 0 and 255 to write |
|
protected |
read 1 byte from the specified seesaw register.
regHigh | the module address register (ex. SEESAW_STATUS_BASE) |
regLow | the function address register (ex. SEESAW_STATUS_VERSION) |
delay | a number of microseconds to delay before reading out the data. Different delay values may be necessary to ensure the seesaw chip has time to process the requested data. Defaults to 125. |
|
protected |
Read a specified number of bytes into a buffer from the seesaw.
regHigh | the module address register (ex. SEESAW_STATUS_BASE) |
regLow | the function address register (ex. SEESAW_STATUS_VERSION) |
buf | the buffer to read the bytes into |
num | the number of bytes to read. |
delay | an optional delay in between setting the read register and reading out the data. This is required for some seesaw functions (ex. reading ADC data) |
|
protected |
Write a specified number of bytes to the seesaw from the passed buffer.
regHigh | the module address register (ex. SEESAW_GPIO_BASE) |
regLow | the function address register (ex. SEESAW_GPIO_BULK_SET) |
buf | the buffer the the bytes from |
num | the number of bytes to write. |
|
protected |
The I2C Bus used to communicate with the seesaw
|
protected |
The flow control pin to use
|
protected |
what hardware type is attached!