Adafruit Library
Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Adafruit_seesaw Class Reference

Class that stores state and functions for interacting with seesaw helper IC. More...

#include <Adafruit_seesaw.h>

Inheritance diagram for Adafruit_seesaw:
Adafruit_Crickit Adafruit_miniTFTWing Adafruit_NeoTrellis Adafruit_TFTShield18

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...
 
void SWReset ()
 perform a software reset. This resets all seesaw registers to their default values. This is called automatically from Adafruit_seesaw.begin()
 
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 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...
 
void 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 ()
 Read the current position of the encoder. More...
 
int32_t getEncoderDelta ()
 Read the change in encoder position since it was last read. More...
 
void enableEncoderInterrupt ()
 Enable the interrupt to fire when the encoder changes position.
 
void disableEncoderInterrupt ()
 Disable the interrupt from firing when the encoder changes position.
 
void setEncoderPosition (int32_t pos)
 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

void 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=125)
 read 1 byte from the specified seesaw register. More...
 
void read (uint8_t regHigh, uint8_t regLow, uint8_t *buf, uint8_t num, uint16_t delay=125)
 Read a specified number of bytes into a buffer from the seesaw. More...
 
void 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...
 
void writeEmpty (uint8_t regHigh, uint8_t regLow)
 Write only the module base address register and the function address register. More...
 
void _i2c_init ()
 Initialize I2C. On arduino this just calls i2c->begin()
 

Protected Attributes

uint8_t _i2caddr
 
TwoWire * _i2cbus
 
int8_t _flow
 
sercom_inten _sercom_inten
 sercom interrupt enable register instance
 

Detailed Description

Class that stores state and functions for interacting with seesaw helper IC.

Constructor & Destructor Documentation

◆ Adafruit_seesaw()

Adafruit_seesaw::Adafruit_seesaw ( TwoWire *  i2c_bus = NULL)

Create a seesaw object on a given I2C bus.

Parameters
i2c_busthe I2C bus connected to the seesaw, defaults to "Wire"

Member Function Documentation

◆ begin()

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

Parameters
addrthe I2C address of the seesaw
flowthe flow control pin to use
resetpass true to reset the seesaw on startup. Defaults to true.
Returns
true if we could connect to the seesaw, false otherwise

◆ getOptions()

uint32_t Adafruit_seesaw::getOptions ( )

Returns the available options compiled into the seesaw firmware.

Returns
the available options compiled into the seesaw firmware. If the option is included, the corresponding bit is set. For example, if the ADC module is compiled in then (ss.getOptions() & (1UL << SEESAW_ADC_BASE)) > 0

◆ getVersion()

uint32_t Adafruit_seesaw::getVersion ( )

Returns the version of the seesaw.

Returns
The version code. Bits [31:16] will be a date code, [15:0] will be the product id.

◆ pinMode()

void Adafruit_seesaw::pinMode ( uint8_t  pin,
uint8_t  mode 
)

Set the mode of a GPIO pin.

Parameters
pinthe pin number. On the SAMD09 breakout, this corresponds to the number on the silkscreen.
modethe mode to set the pin. One of INPUT, OUTPUT, or INPUT_PULLUP.

◆ pinModeBulk() [1/2]

void Adafruit_seesaw::pinModeBulk ( uint32_t  pins,
uint8_t  mode 
)

set the mode of multiple GPIO pins at once.

Parameters
pinsa 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.
modethe mode to set the pins to. One of INPUT, OUTPUT, or INPUT_PULLUP.

◆ pinModeBulk() [2/2]

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.

Parameters
pinsaa 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.
pinsba bitmask of the pins to write on port B.
modethe mode to set the pins to. One of INPUT, OUTPUT, or INPUT_PULLUP.

◆ analogWrite()

void Adafruit_seesaw::analogWrite ( uint8_t  pin,
uint16_t  value,
uint8_t  width = 8 
)
virtual

write a PWM value to a PWM-enabled pin

Parameters
pinthe 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.
valuethe value to write to the pin
widththe width of the value to write. Defaults to 8. If 16 is passed a 16 bit value will be written.

Reimplemented in Adafruit_Crickit.

◆ digitalWrite()

void Adafruit_seesaw::digitalWrite ( uint8_t  pin,
uint8_t  value 
)

Set the output of a GPIO pin.

Parameters
pinthe pin number. On the SAMD09 breakout, this corresponds to the number on the silkscreen.
valuethe value to write to the GPIO pin. This should be HIGH or LOW.

◆ digitalWriteBulk() [1/2]

void Adafruit_seesaw::digitalWriteBulk ( uint32_t  pins,
uint8_t  value 
)

write a value to multiple GPIO pins at once.

Parameters
pinsa 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.
valuepass HIGH to set the output on the passed pins to HIGH, low to set the output on the passed pins to LOW.

◆ digitalWriteBulk() [2/2]

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

Parameters
pinsaa 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.
pinsba bitmask of the pins to write on port B.
valuepass HIGH to set the output on the passed pins to HIGH, low to set the output on the passed pins to LOW.

◆ digitalRead()

bool Adafruit_seesaw::digitalRead ( uint8_t  pin)

Read the current status of a GPIO pin.

Parameters
pinthe pin number. On the SAMD09 breakout, this corresponds to the number on the silkscreen.
Returns
the status of the pin. HIGH or LOW (1 or 0).

◆ digitalReadBulk()

uint32_t Adafruit_seesaw::digitalReadBulk ( uint32_t  pins)

read the status of multiple pins on port A.

Parameters
pinsa 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.
Returns
the status of the passed pins. If 0b0110 was passed and pin 2 is high and pin 3 is low, 0b0010 (decimal number 2) will be returned.

◆ digitalReadBulkB()

uint32_t Adafruit_seesaw::digitalReadBulkB ( uint32_t  pins)

read the status of multiple pins on port B.

Parameters
pinsa bitmask of the pins to write.
Returns
the status of the passed pins. If 0b0110 was passed and pin 2 is high and pin 3 is low, 0b0010 (decimal number 2) will be returned.

◆ setGPIOInterrupts()

void Adafruit_seesaw::setGPIOInterrupts ( uint32_t  pins,
bool  enabled 
)

Enable or disable GPIO interrupts on the passed pins.

Parameters
pinsa 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.
enabledpass true to enable the interrupts on the passed pins, false to disable the interrupts on the passed pins.

◆ analogRead()

uint16_t Adafruit_seesaw::analogRead ( uint8_t  pin)
virtual

read the analog value on an ADC-enabled pin.

Parameters
pinthe 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.
Returns
the analog value. This is an integer between 0 and 1023

Reimplemented in Adafruit_Crickit.

◆ touchRead()

uint16_t Adafruit_seesaw::touchRead ( uint8_t  pin)

read the analog value on an capacitive touch-enabled pin.

Parameters
pinthe number of the pin to read.
Returns
the analog value. This is an integer between 0 and 1023

◆ setPWMFreq()

void Adafruit_seesaw::setPWMFreq ( uint8_t  pin,
uint16_t  freq 
)
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.

Parameters
pinthe 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.
freqthe frequency to set.

Reimplemented in Adafruit_Crickit.

◆ enableSercomDataRdyInterrupt()

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.

Parameters
sercomthe sercom to enable the interrupt on.

◆ disableSercomDataRdyInterrupt()

void Adafruit_seesaw::disableSercomDataRdyInterrupt ( uint8_t  sercom = 0)

Disable the data ready interrupt on the passed sercom.

Parameters
sercomthe sercom to disable the interrupt on.

◆ readSercomData()

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.

Parameters
sercomthe sercom to read data from.
Returns
One byte of data

◆ EEPROMWrite8()

void Adafruit_seesaw::EEPROMWrite8 ( uint8_t  addr,
uint8_t  val 
)

Write a 1 byte to an EEPROM address.

Parameters
addrthe address to write to. On the default seesaw firmware on the SAMD09 breakout this is between 0 and 63.
valto write between 0 and 255

◆ EEPROMWrite()

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

Parameters
addrthe starting address to write the first byte. This will be automatically incremented with each byte written.
bufthe buffer of bytes to be written.
sizethe number of bytes to write. Writing past the end of available EEPROM may result in undefined behavior.

◆ EEPROMRead8()

uint8_t Adafruit_seesaw::EEPROMRead8 ( uint8_t  addr)

Read 1 byte from the specified EEPROM address.

Parameters
addrthe address to read from. One the default seesaw firmware on the SAMD09 breakout this is between 0 and 63.
Returns
the value between 0 and 255 that was read from the passed address.

◆ setI2CAddr()

void Adafruit_seesaw::setI2CAddr ( uint8_t  addr)

Set the seesaw I2C address. This will automatically call Adafruit_seesaw.begin() with the new address.

Parameters
addrthe new address for the seesaw. This must be a valid 7 bit I2C address.

◆ getI2CAddr()

uint8_t Adafruit_seesaw::getI2CAddr ( )

Read the I2C address of the seesaw.

Returns
the 7 bit I2C address of the seesaw... which you probably already know because you just read data from it.

◆ UARTSetBaud()

void Adafruit_seesaw::UARTSetBaud ( uint32_t  baud)

Set the baud rate on SERCOM0.

Parameters
baudthe baud rate to set. This is an integer value. Baud rates up to 115200 are supported.

◆ setKeypadEvent()

void Adafruit_seesaw::setKeypadEvent ( uint8_t  key,
uint8_t  edge,
bool  enable = true 
)

activate or deactivate a key and edge on the keypad module

Parameters
keythe key number to activate
edgethe edge to trigger on
enablepassing true will enable the passed event, passing false will disable it.

◆ getKeypadCount()

uint8_t Adafruit_seesaw::getKeypadCount ( )

Get the number of events currently in the fifo.

Returns
the number of events in the fifo

◆ readKeypad()

void Adafruit_seesaw::readKeypad ( keyEventRaw buf,
uint8_t  count 
)

Read all keyEvents into the passed buffer.

Parameters
bufpointer to where the keyEvents should be stored
countthe number of events to read

◆ getTemp()

float Adafruit_seesaw::getTemp ( )

Read the temperature of the seesaw board in degrees Celsius. NOTE: not all seesaw firmwares have the temperature sensor enabled.

Returns
Temperature in degrees Celsius as a floating point value.

◆ getEncoderPosition()

int32_t Adafruit_seesaw::getEncoderPosition ( )

Read the current position of the encoder.

Returns
The encoder position as a 32 bit signed integer.

◆ getEncoderDelta()

int32_t Adafruit_seesaw::getEncoderDelta ( )

Read the change in encoder position since it was last read.

Returns
The encoder change as a 32 bit signed integer.

◆ setEncoderPosition()

void Adafruit_seesaw::setEncoderPosition ( int32_t  pos)

Set the current position of the encoder.

Parameters
posthe position to set the encoder to.

◆ write() [1/3]

size_t Adafruit_seesaw::write ( uint8_t  character)
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.

Parameters
characterthe character to write.
Returns
The number of bytes written (1)

◆ write() [2/3]

size_t Adafruit_seesaw::write ( const char *  str)
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.

Parameters
strthe string to write
Returns
number of bytes written (not including trailing 0)

◆ write8()

void Adafruit_seesaw::write8 ( byte  regHigh,
byte  regLow,
byte  value 
)
protected

Write 1 byte to the specified seesaw register.

Parameters
regHighthe module address register (ex. SEESAW_NEOPIXEL_BASE)
regLowthe function address register (ex. SEESAW_NEOPIXEL_PIN)
valuethe value between 0 and 255 to write

◆ read8()

uint8_t Adafruit_seesaw::read8 ( byte  regHigh,
byte  regLow,
uint16_t  delay = 125 
)
protected

read 1 byte from the specified seesaw register.

Parameters
regHighthe module address register (ex. SEESAW_STATUS_BASE)
regLowthe function address register (ex. SEESAW_STATUS_VERSION)
delaya 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.
Returns
the value between 0 and 255 read from the passed register

◆ read()

void Adafruit_seesaw::read ( uint8_t  regHigh,
uint8_t  regLow,
uint8_t *  buf,
uint8_t  num,
uint16_t  delay = 125 
)
protected

Read a specified number of bytes into a buffer from the seesaw.

Parameters
regHighthe module address register (ex. SEESAW_STATUS_BASE)
regLowthe function address register (ex. SEESAW_STATUS_VERSION)
bufthe buffer to read the bytes into
numthe number of bytes to read.
delayan optional delay in between setting the read register and reading out the data. This is required for some seesaw functions (ex. reading ADC data)

◆ write() [3/3]

void Adafruit_seesaw::write ( uint8_t  regHigh,
uint8_t  regLow,
uint8_t *  buf,
uint8_t  num 
)
protected

Write a specified number of bytes to the seesaw from the passed buffer.

Parameters
regHighthe module address register (ex. SEESAW_GPIO_BASE)
regLowthe function address register (ex. SEESAW_GPIO_BULK_SET)
bufthe buffer the the bytes from
numthe number of bytes to write.

◆ writeEmpty()

void Adafruit_seesaw::writeEmpty ( uint8_t  regHigh,
uint8_t  regLow 
)
protected

Write only the module base address register and the function address register.

Parameters
regHighthe module address register (ex. SEESAW_STATUS_BASE)
regLowthe function address register (ex. SEESAW_STATUS_SWRST)

Member Data Documentation

◆ _i2caddr

uint8_t Adafruit_seesaw::_i2caddr
protected

The I2C address used to communicate with the seesaw

◆ _i2cbus

TwoWire* Adafruit_seesaw::_i2cbus
protected

The I2C Bus used to communicate with the seesaw

◆ _flow

int8_t Adafruit_seesaw::_flow
protected

The flow control pin to use


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