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