Junichi Katsu
/
wallbotLED_base
うおーるぼっとLEDのワークショップ用
wallbotLED/Adafruit_LEDBackpack/Adafruit_LEDBackpack.h@0:9fcc79b3f00e, 2017-02-03 (annotated)
- Committer:
- jksoft
- Date:
- Fri Feb 03 06:26:54 2017 +0000
- Revision:
- 0:9fcc79b3f00e
??
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jksoft | 0:9fcc79b3f00e | 1 | /*************************************************** |
jksoft | 0:9fcc79b3f00e | 2 | This is a library for our I2C LED Backpacks |
jksoft | 0:9fcc79b3f00e | 3 | |
jksoft | 0:9fcc79b3f00e | 4 | Designed specifically to work with the Adafruit LED Matrix backpacks |
jksoft | 0:9fcc79b3f00e | 5 | ----> http://www.adafruit.com/products/ |
jksoft | 0:9fcc79b3f00e | 6 | ----> http://www.adafruit.com/products/ |
jksoft | 0:9fcc79b3f00e | 7 | |
jksoft | 0:9fcc79b3f00e | 8 | These displays use I2C to communicate, 2 pins are required to |
jksoft | 0:9fcc79b3f00e | 9 | interface. There are multiple selectable I2C addresses. For backpacks |
jksoft | 0:9fcc79b3f00e | 10 | with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks |
jksoft | 0:9fcc79b3f00e | 11 | with 3 Address Select pins: 0x70 thru 0x77 |
jksoft | 0:9fcc79b3f00e | 12 | |
jksoft | 0:9fcc79b3f00e | 13 | Adafruit invests time and resources providing this open source code, |
jksoft | 0:9fcc79b3f00e | 14 | please support Adafruit and open-source hardware by purchasing |
jksoft | 0:9fcc79b3f00e | 15 | products from Adafruit! |
jksoft | 0:9fcc79b3f00e | 16 | |
jksoft | 0:9fcc79b3f00e | 17 | Written by Limor Fried/Ladyada for Adafruit Industries. |
jksoft | 0:9fcc79b3f00e | 18 | BSD license, all text above must be included in any redistribution |
jksoft | 0:9fcc79b3f00e | 19 | ****************************************************/ |
jksoft | 0:9fcc79b3f00e | 20 | |
jksoft | 0:9fcc79b3f00e | 21 | /* |
jksoft | 0:9fcc79b3f00e | 22 | * Modified by Luiz Hespanha (http://www.d3.do) 8/16/2013 for use in LPC1768 |
jksoft | 0:9fcc79b3f00e | 23 | */ |
jksoft | 0:9fcc79b3f00e | 24 | |
jksoft | 0:9fcc79b3f00e | 25 | #include "mbed.h" |
jksoft | 0:9fcc79b3f00e | 26 | #include "Adafruit_GFX.h" |
jksoft | 0:9fcc79b3f00e | 27 | |
jksoft | 0:9fcc79b3f00e | 28 | #define LED_ON 1 |
jksoft | 0:9fcc79b3f00e | 29 | #define LED_OFF 0 |
jksoft | 0:9fcc79b3f00e | 30 | |
jksoft | 0:9fcc79b3f00e | 31 | #define LED_RED 1 |
jksoft | 0:9fcc79b3f00e | 32 | #define LED_YELLOW 2 |
jksoft | 0:9fcc79b3f00e | 33 | #define LED_GREEN 3 |
jksoft | 0:9fcc79b3f00e | 34 | |
jksoft | 0:9fcc79b3f00e | 35 | |
jksoft | 0:9fcc79b3f00e | 36 | |
jksoft | 0:9fcc79b3f00e | 37 | #define HT16K33_BLINK_CMD 0x80 |
jksoft | 0:9fcc79b3f00e | 38 | #define HT16K33_BLINK_DISPLAYON 0x01 |
jksoft | 0:9fcc79b3f00e | 39 | #define HT16K33_BLINK_OFF 0 |
jksoft | 0:9fcc79b3f00e | 40 | #define HT16K33_BLINK_2HZ 1 |
jksoft | 0:9fcc79b3f00e | 41 | #define HT16K33_BLINK_1HZ 2 |
jksoft | 0:9fcc79b3f00e | 42 | #define HT16K33_BLINK_HALFHZ 3 |
jksoft | 0:9fcc79b3f00e | 43 | |
jksoft | 0:9fcc79b3f00e | 44 | #define HT16K33_CMD_BRIGHTNESS 0x0E |
jksoft | 0:9fcc79b3f00e | 45 | |
jksoft | 0:9fcc79b3f00e | 46 | // this is the raw HT16K33 controller |
jksoft | 0:9fcc79b3f00e | 47 | class Adafruit_LEDBackpack { |
jksoft | 0:9fcc79b3f00e | 48 | public: |
jksoft | 0:9fcc79b3f00e | 49 | Adafruit_LEDBackpack(I2C *i2c); |
jksoft | 0:9fcc79b3f00e | 50 | void begin(uint8_t _addr); |
jksoft | 0:9fcc79b3f00e | 51 | void setBrightness(uint8_t b); |
jksoft | 0:9fcc79b3f00e | 52 | void blinkRate(uint8_t b); |
jksoft | 0:9fcc79b3f00e | 53 | void writeDisplay(void); |
jksoft | 0:9fcc79b3f00e | 54 | void clear(void); |
jksoft | 0:9fcc79b3f00e | 55 | |
jksoft | 0:9fcc79b3f00e | 56 | uint16_t displaybuffer[16]; |
jksoft | 0:9fcc79b3f00e | 57 | |
jksoft | 0:9fcc79b3f00e | 58 | void init(uint8_t a); |
jksoft | 0:9fcc79b3f00e | 59 | |
jksoft | 0:9fcc79b3f00e | 60 | protected: |
jksoft | 0:9fcc79b3f00e | 61 | I2C *_i2c; |
jksoft | 0:9fcc79b3f00e | 62 | |
jksoft | 0:9fcc79b3f00e | 63 | private: |
jksoft | 0:9fcc79b3f00e | 64 | uint8_t i2c_addr; |
jksoft | 0:9fcc79b3f00e | 65 | }; |
jksoft | 0:9fcc79b3f00e | 66 | |
jksoft | 0:9fcc79b3f00e | 67 | class Adafruit_8x8matrix : public Adafruit_LEDBackpack, public Adafruit_GFX { |
jksoft | 0:9fcc79b3f00e | 68 | public: |
jksoft | 0:9fcc79b3f00e | 69 | Adafruit_8x8matrix(I2C *i2c); |
jksoft | 0:9fcc79b3f00e | 70 | |
jksoft | 0:9fcc79b3f00e | 71 | virtual void drawPixel(int16_t x, int16_t y, uint16_t color); |
jksoft | 0:9fcc79b3f00e | 72 | |
jksoft | 0:9fcc79b3f00e | 73 | private: |
jksoft | 0:9fcc79b3f00e | 74 | }; |