libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::NeoTrellis< Transport > Class Template Reference

Device support for the Adafruit Neotrellis device. More...

Detailed Description

template<typename Transport>
class daisy::NeoTrellis< Transport >

Device support for the Adafruit Neotrellis device.

Author
beserge
Date
December 2021

#include <neotrellis.h>

Classes

struct  Config
 
union  keyEvent
 
union  keyEventRaw
 
union  keyState
 

Public Types

enum  ModuleBaseAddress {
  SEESAW_STATUS_BASE = 0x00 , SEESAW_GPIO_BASE = 0x01 , SEESAW_SERCOM0_BASE = 0x02 , SEESAW_TIMER_BASE = 0x08 ,
  SEESAW_ADC_BASE = 0x09 , SEESAW_DAC_BASE = 0x0A , SEESAW_INTERRUPT_BASE = 0x0B , SEESAW_DAP_BASE = 0x0C ,
  SEESAW_EEPROM_BASE = 0x0D , SEESAW_NEOPIXEL_BASE = 0x0E , SEESAW_TOUCH_BASE = 0x0F , SEESAW_KEYPAD_BASE = 0x10 ,
  SEESAW_ENCODER_BASE = 0x11 , SEESAW_SPECTRUM_BASE = 0x12
}
 
enum  KeypadFuncAddRegs {
  SEESAW_KEYPAD_STATUS = 0x00 , SEESAW_KEYPAD_EVENT = 0x01 , SEESAW_KEYPAD_INTENSET = 0x02 , SEESAW_KEYPAD_INTENCLR = 0x03 ,
  SEESAW_KEYPAD_COUNT = 0x04 , SEESAW_KEYPAD_FIFO = 0x10
}
 
enum  StatusFuncAddRegs {
  SEESAW_STATUS_HW_ID = 0x01 , SEESAW_STATUS_VERSION = 0x02 , SEESAW_STATUS_OPTIONS = 0x03 , SEESAW_STATUS_TEMP = 0x04 ,
  SEESAW_STATUS_SWRST = 0x7F
}
 
enum  KeypadEdge { HIGH = 0 , LOW , FALLING , RISING }
 
enum  Result { OK = 0 , ERR }
 
typedef void(* TrellisCallback) (keyEvent evt)
 

Public Member Functions

 NeoTrellis ()
 
 ~NeoTrellis ()
 
Result Init (Config config)
 
void Write8 (uint8_t reg_high, uint8_t reg_low, uint8_t value)
 
uint8_t Read8 (uint8_t reg_high, uint8_t reg_low, int delay)
 
void ReadLen (uint8_t reg_high, uint8_t reg_low, uint8_t *buff, uint8_t len, int delay)
 
Result GetTransportError ()
 
void SWReset ()
 
void ActivateKey (uint8_t x, uint8_t y, uint8_t edge, bool enable)
 
void Process (bool polling=true)
 
bool GetState (uint8_t idx)
 
bool GetRising (uint8_t idx)
 
bool GetFalling (uint8_t idx)
 
void ReadKeypad (keyEventRaw *buf, uint8_t count)
 
uint8_t GetKeypadCount ()
 
void SetKeypadEvent (uint8_t key, uint8_t edge, bool enable)
 
void EnableKeypadInterrupt ()
 
void RegisterCallback (uint8_t x, uint8_t y, TrellisCallback(*cb)(keyEvent))
 
void UnregisterCallback (uint8_t x, uint8_t y)
 

Public Attributes

NeoPixelI2C pixels
 

Member Typedef Documentation

◆ TrellisCallback

template<typename Transport >
typedef void(* daisy::NeoTrellis< Transport >::TrellisCallback) (keyEvent evt)

Member Enumeration Documentation

◆ KeypadEdge

keypad module edge definitions

Enumerator
HIGH 
LOW 
FALLING 
RISING 

◆ KeypadFuncAddRegs

keypad module function address registers

Enumerator
SEESAW_KEYPAD_STATUS 
SEESAW_KEYPAD_EVENT 
SEESAW_KEYPAD_INTENSET 
SEESAW_KEYPAD_INTENCLR 
SEESAW_KEYPAD_COUNT 
SEESAW_KEYPAD_FIFO 

◆ ModuleBaseAddress

Module Base Addreses The module base addresses for different seesaw modules.

Enumerator
SEESAW_STATUS_BASE 
SEESAW_GPIO_BASE 
SEESAW_SERCOM0_BASE 
SEESAW_TIMER_BASE 
SEESAW_ADC_BASE 
SEESAW_DAC_BASE 
SEESAW_INTERRUPT_BASE 
SEESAW_DAP_BASE 
SEESAW_EEPROM_BASE 
SEESAW_NEOPIXEL_BASE 
SEESAW_TOUCH_BASE 
SEESAW_KEYPAD_BASE 
SEESAW_ENCODER_BASE 
SEESAW_SPECTRUM_BASE 

◆ Result

Enumerator
OK 
ERR 

◆ StatusFuncAddRegs

status module function address registers

Enumerator
SEESAW_STATUS_HW_ID 
SEESAW_STATUS_VERSION 
SEESAW_STATUS_OPTIONS 
SEESAW_STATUS_TEMP 
SEESAW_STATUS_SWRST 

Constructor & Destructor Documentation

◆ NeoTrellis()

template<typename Transport >
daisy::NeoTrellis< Transport >::NeoTrellis ( )
inline

◆ ~NeoTrellis()

Member Function Documentation

◆ ActivateKey()

template<typename Transport >
void daisy::NeoTrellis< Transport >::ActivateKey ( uint8_t  x,
uint8_t  y,
uint8_t  edge,
bool  enable 
)
inline

activate or deactivate a given key event

Parameters
keythe key number to map the event to
edgethe edge sensitivity of the event
enablepass true to enable the passed event, false to disable it.

◆ EnableKeypadInterrupt()

template<typename Transport >
void daisy::NeoTrellis< Transport >::EnableKeypadInterrupt ( )
inline

Enable the keypad interrupt that fires when events are in the fifo.

◆ GetFalling()

template<typename Transport >
bool daisy::NeoTrellis< Transport >::GetFalling ( uint8_t  idx)
inline

Has this key just been released? (aka falling edge) Updated via the Process() function.

Parameters
idxKey to check
Returns
True if just released, false otherwise

◆ GetKeypadCount()

template<typename Transport >
uint8_t daisy::NeoTrellis< Transport >::GetKeypadCount ( )
inline

Get the number of events currently in the fifo

Returns
the number of events in the fifo

◆ GetRising()

template<typename Transport >
bool daisy::NeoTrellis< Transport >::GetRising ( uint8_t  idx)
inline

Has this key just been pressed? (aka rising edge) Updated via the Process() function.

Parameters
idxKey to check
Returns
True if just pressed, false otherwise

◆ GetState()

template<typename Transport >
bool daisy::NeoTrellis< Transport >::GetState ( uint8_t  idx)
inline

Is this key currently pressed or released? Updated via the Process() function.

Parameters
idxKey to check
Returns
True if pressed, false otherwise

◆ GetTransportError()

template<typename Transport >
Result daisy::NeoTrellis< Transport >::GetTransportError ( )
inline

Get and reset the transport error flag

Returns
Whether the transport has errored since the last check

◆ Init()

template<typename Transport >
Result daisy::NeoTrellis< Transport >::Init ( Config  config)
inline

Initialize the NeoTrellis device

Parameters
configConfiguration settings

◆ Process()

template<typename Transport >
void daisy::NeoTrellis< Transport >::Process ( bool  polling = true)
inline

read all events currently stored in the seesaw fifo and call any callbacks.

Parameters
pollingpass true if the interrupt pin is not being used, false if it is. Defaults to true.

◆ Read8()

template<typename Transport >
uint8_t daisy::NeoTrellis< Transport >::Read8 ( uint8_t  reg_high,
uint8_t  reg_low,
int  delay 
)
inline

Reads an 8 bit value

Parameters
regthe register address to read from
Returns
the data uint8_t read from the device

◆ ReadKeypad()

template<typename Transport >
void daisy::NeoTrellis< Transport >::ReadKeypad ( keyEventRaw buf,
uint8_t  count 
)
inline

◆ ReadLen()

template<typename Transport >
void daisy::NeoTrellis< Transport >::ReadLen ( uint8_t  reg_high,
uint8_t  reg_low,
uint8_t buff,
uint8_t  len,
int  delay 
)
inline

◆ RegisterCallback()

template<typename Transport >
void daisy::NeoTrellis< Transport >::RegisterCallback ( uint8_t  x,
uint8_t  y,
TrellisCallback(*)(keyEvent cb 
)
inline

register a callback for a key addressed by key index.

Parameters
xthe column index of the key. column 0 is on the lefthand side of the matix.
ythe row index of the key. row 0 is at the top of the matrix and the numbers increase downwards.
cbthe function to be called when an event from the specified key is detected.

◆ SetKeypadEvent()

template<typename Transport >
void daisy::NeoTrellis< Transport >::SetKeypadEvent ( uint8_t  key,
uint8_t  edge,
bool  enable 
)
inline

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.

◆ SWReset()

template<typename Transport >
void daisy::NeoTrellis< Transport >::SWReset ( )
inline

Perform a software reset. This resets all seesaw registers to their default values. This is called automatically from Init().

◆ UnregisterCallback()

template<typename Transport >
void daisy::NeoTrellis< Transport >::UnregisterCallback ( uint8_t  x,
uint8_t  y 
)
inline

Unregister a callback for a key addressed by key index.

Parameters
xthe column index of the key. column 0 is on the lefthand side of the matix.
ythe row index of the key. row 0 is at the top of the matrix and the numbers increase downwards.

◆ Write8()

template<typename Transport >
void daisy::NeoTrellis< Transport >::Write8 ( uint8_t  reg_high,
uint8_t  reg_low,
uint8_t  value 
)
inline

Writes an 8 bit value

Parameters
regthe register address to write to
valuethe value to write to the register

Member Data Documentation

◆ pixels


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