2#ifndef DSY_NEO_TRELLIS_H
3#define DSY_NEO_TRELLIS_H
7#define NEO_TRELLIS_ADDR 0x2E
9#define NEO_TRELLIS_NEOPIX_PIN 3
11#define NEO_TRELLIS_NUM_ROWS 4
12#define NEO_TRELLIS_NUM_COLS 4
13#define NEO_TRELLIS_NUM_KEYS (NEO_TRELLIS_NUM_ROWS * NEO_TRELLIS_NUM_COLS)
15#define NEO_TRELLIS_MAX_CALLBACKS 32
17#define NEO_TRELLIS_KEY(x) (((x) / 4) * 8 + ((x) % 4))
18#define NEO_TRELLIS_SEESAW_KEY(x) (((x) / 8) * 4 + ((x) % 8))
20#define NEO_TRELLIS_X(k) ((k) % 4)
21#define NEO_TRELLIS_Y(k) ((k) / 4)
23#define NEO_TRELLIS_XY(x, y) ((y)*NEO_TRELLIS_NUM_ROWS + (x))
145template <
typename Transport>
359 if(_callbacks[
e[
i].bit.NUM] !=
NULL)
361 _callbacks[
e[
i].bit.NUM](
evt);
391 rising_[
idx] =
false;
407 falling_[
idx] =
false;
439 ks.bit.STATE = enable;
440 ks.bit.ACTIVE = (1 <<
edge);
442 transport_.Write(
cmd, 4);
Result Init(const Config &config)
Result ReceiveBlocking(uint16_t address, uint8_t *data, uint16_t size, uint32_t timeout)
Result TransmitBlocking(uint16_t address, uint8_t *data, uint16_t size, uint32_t timeout)
Definition leddriver.h:33
void Init(I2CHandle i2c, const uint8_t(&addresses)[numDrivers], DmaBuffer dma_buffer_a, DmaBuffer dma_buffer_b, Pin oe_pin=Pin(PORTX, 0))
Definition leddriver.h:65
Result Init(Config config)
Definition neopixel.h:266
@ ERR
Definition neopixel.h:215
Device support for the Adafruit Neotrellis device.
Definition neotrellis.h:147
KeypadEdge
Definition neotrellis.h:230
@ HIGH
Definition neotrellis.h:231
@ FALLING
Definition neotrellis.h:233
@ LOW
Definition neotrellis.h:232
@ RISING
Definition neotrellis.h:234
bool GetRising(uint8_t idx)
Definition neotrellis.h:386
void(* TrellisCallback)(keyEvent evt)
Definition neotrellis.h:251
void UnregisterCallback(uint8_t x, uint8_t y)
Definition neotrellis.h:469
NeoPixelI2C pixels
Definition neotrellis.h:478
~NeoTrellis()
Definition neotrellis.h:150
Result Init(Config config)
Definition neotrellis.h:256
ModuleBaseAddress
Definition neotrellis.h:156
@ SEESAW_INTERRUPT_BASE
Definition neotrellis.h:164
@ SEESAW_TOUCH_BASE
Definition neotrellis.h:168
@ SEESAW_GPIO_BASE
Definition neotrellis.h:158
@ SEESAW_SPECTRUM_BASE
Definition neotrellis.h:171
@ SEESAW_ADC_BASE
Definition neotrellis.h:162
@ SEESAW_DAP_BASE
Definition neotrellis.h:165
@ SEESAW_ENCODER_BASE
Definition neotrellis.h:170
@ SEESAW_TIMER_BASE
Definition neotrellis.h:161
@ SEESAW_STATUS_BASE
Definition neotrellis.h:157
@ SEESAW_DAC_BASE
Definition neotrellis.h:163
@ SEESAW_SERCOM0_BASE
Definition neotrellis.h:159
@ SEESAW_NEOPIXEL_BASE
Definition neotrellis.h:167
@ SEESAW_KEYPAD_BASE
Definition neotrellis.h:169
@ SEESAW_EEPROM_BASE
Definition neotrellis.h:166
void Write8(uint8_t reg_high, uint8_t reg_low, uint8_t value)
Definition neotrellis.h:280
void ReadLen(uint8_t reg_high, uint8_t reg_low, uint8_t *buff, uint8_t len, int delay)
Definition neotrellis.h:294
void ActivateKey(uint8_t x, uint8_t y, uint8_t edge, bool enable)
Definition neotrellis.h:322
uint8_t Read8(uint8_t reg_high, uint8_t reg_low, int delay)
Definition neotrellis.h:289
void SetKeypadEvent(uint8_t key, uint8_t edge, bool enable)
Definition neotrellis.h:436
void EnableKeypadInterrupt()
Definition neotrellis.h:446
Result
Definition neotrellis.h:246
@ ERR
Definition neotrellis.h:248
@ OK
Definition neotrellis.h:247
NeoTrellis()
Definition neotrellis.h:149
void RegisterCallback(uint8_t x, uint8_t y, TrellisCallback(*cb)(keyEvent))
Definition neotrellis.h:456
void Process(bool polling=true)
Definition neotrellis.h:336
KeypadFuncAddRegs
Definition neotrellis.h:177
@ SEESAW_KEYPAD_EVENT
Definition neotrellis.h:179
@ SEESAW_KEYPAD_FIFO
Definition neotrellis.h:183
@ SEESAW_KEYPAD_INTENSET
Definition neotrellis.h:180
@ SEESAW_KEYPAD_INTENCLR
Definition neotrellis.h:181
@ SEESAW_KEYPAD_STATUS
Definition neotrellis.h:178
@ SEESAW_KEYPAD_COUNT
Definition neotrellis.h:182
bool GetFalling(uint8_t idx)
Definition neotrellis.h:402
void ReadKeypad(keyEventRaw *buf, uint8_t count)
Definition neotrellis.h:414
void SWReset()
Definition neotrellis.h:312
uint8_t GetKeypadCount()
Definition neotrellis.h:426
Result GetTransportError()
Definition neotrellis.h:306
StatusFuncAddRegs
Definition neotrellis.h:188
@ SEESAW_STATUS_SWRST
Definition neotrellis.h:193
@ SEESAW_STATUS_TEMP
Definition neotrellis.h:192
@ SEESAW_STATUS_VERSION
Definition neotrellis.h:190
@ SEESAW_STATUS_HW_ID
Definition neotrellis.h:189
@ SEESAW_STATUS_OPTIONS
Definition neotrellis.h:191
bool GetState(uint8_t idx)
Definition neotrellis.h:372
Definition neotrellis.h:33
NeoTrellisI2CTransport()
Definition neotrellis.h:35
bool GetError()
Definition neotrellis.h:126
void Write8(uint8_t reg_high, uint8_t reg_low, uint8_t value)
Definition neotrellis.h:104
void Write(uint8_t *data, uint16_t size)
Definition neotrellis.h:74
~NeoTrellisI2CTransport()
Definition neotrellis.h:36
void Init(Config config)
Definition neotrellis.h:59
void Read(uint8_t *data, uint16_t size)
Definition neotrellis.h:80
uint8_t Read8(uint8_t reg_high, uint8_t reg_low, int delay)
Definition neotrellis.h:119
void ReadLen(uint8_t reg_high, uint8_t reg_low, uint8_t *buff, uint16_t size, int delay)
Definition neotrellis.h:86
static void DelayUs(uint32_t delay_us)
static void Delay(uint32_t delay_ms)
Hardware defines and helpers for daisy field platform.
Definition index.h:2
@ PORTB
Definition daisy_core.h:178
#define NEO_TRELLIS_SEESAW_KEY(x)
Definition neotrellis.h:18
#define NEO_TRELLIS_NUM_KEYS
Definition neotrellis.h:13
#define NEO_TRELLIS_X(k)
Definition neotrellis.h:20
#define NEO_TRELLIS_ADDR
Definition neotrellis.h:7
#define NEO_TRELLIS_KEY(x)
Definition neotrellis.h:17
#define NEO_TRELLIS_Y(k)
Definition neotrellis.h:21
#define NEO_TRELLIS_XY(x, y)
Definition neotrellis.h:23
#define NEO_TRELLIS_NUM_ROWS
Definition neotrellis.h:11
#define NEO_TRELLIS_NUM_COLS
Definition neotrellis.h:12
struct daisy::I2CHandle::Config::@15 pin_config
Mode mode
Definition i2c.h:65
Speed speed
Definition i2c.h:64
Peripheral periph
Definition i2c.h:57
Peripheral
Definition i2c.h:40
Definition neotrellis.h:238
NeoPixelI2C::Config pixels_conf
Definition neotrellis.h:240
Config()
Definition neotrellis.h:242
Transport::Config transport_config
Definition neotrellis.h:239
Definition neotrellis.h:210
uint16_t NUM
the event number
Definition neotrellis.h:212
uint8_t EDGE
the edge that was triggered
Definition neotrellis.h:211
Definition neotrellis.h:39
I2CHandle::Config::Peripheral periph
Definition neotrellis.h:40
I2CHandle::Config::Speed speed
Definition neotrellis.h:41
Config()
Definition neotrellis.h:47
Pin sda
Definition neotrellis.h:43
uint8_t address
Definition neotrellis.h:45
Pin scl
Definition neotrellis.h:42
representation of hardware port/pin combination
Definition daisy_core.h:193
Definition neotrellis.h:208
uint16_t reg
register format
Definition neotrellis.h:214
struct daisy::NeoTrellis::keyEvent::Bit bit
bitfield format
Definition neotrellis.h:197
uint8_t reg
register format
Definition neotrellis.h:203
uint8_t EDGE
the edge that was triggered
Definition neotrellis.h:200
uint8_t NUM
the event number
Definition neotrellis.h:201
struct daisy::NeoTrellis::keyEventRaw::@7 bit
bitfield format
Definition neotrellis.h:219
uint8_t STATE
the current state of the key
Definition neotrellis.h:222
struct daisy::NeoTrellis::keyState::@8 bit
bitfield format
uint8_t ACTIVE
the registered events for that key
Definition neotrellis.h:223
uint8_t reg
register format
Definition neotrellis.h:225