Mbed driver for adafruit trellis.

Dependents:   Adafruit_Trellis_Hello_World

Adafruit_Trellis.h

Committer:
wliu88
Date:
2016-03-13
Revision:
0:bbc12ba2cb6c
Child:
1:3a43c8b959d8

File content as of revision 0:bbc12ba2cb6c:

// Set _BV if not already set
#ifndef _BV
#define _BV(bit) (1 << (bit))
#endif

#include "mbed.h"

#define LED_ON  1
#define LED_OFF 0

#define HT16K33_BLINK_OFF    0
#define HT16K33_BLINK_2HZ    1
#define HT16K33_BLINK_1HZ    2
#define HT16K33_BLINK_HALFHZ 3


// this is the raw HT16K33 controller
class Adafruit_Trellis {
 public:
  Adafruit_Trellis(void);
  void begin(I2C *_wire, uint8_t _addr);
  void setBrightness(uint8_t b);
  void blinkRate(uint8_t b);
  void writeDisplay(void);
  void clear(void);
  
  bool isLED(uint8_t x);
  void setLED(uint8_t x);
  void clrLED(uint8_t x);
  
  bool isKeyPressed(uint8_t k);
  bool wasKeyPressed(uint8_t k);
  bool readSwitches(void);
  bool justPressed(uint8_t k);
  bool justReleased(uint8_t k);

  uint16_t displaybuffer[8];

  void init(uint8_t a);
    
 private:
  uint8_t keys[6], lastkeys[6];

  uint8_t i2c_addr;
  char cmd[20];
  I2C *wire;
};