Adafruit-RGB_matrix_Panel(32*32)
Dependencies: Adafruit-GFX
RGBmatrixPanel.h@6:b594794a132e, 2014-05-25 (annotated)
- Committer:
- lelect
- Date:
- Sun May 25 11:40:55 2014 +0000
- Revision:
- 6:b594794a132e
- Parent:
- 5:1f8409ee8850
- Child:
- 8:6d98c8cd8045
test feature
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lelect | 0:06d9443a018f | 1 | #include "mbed.h" |
lelect | 0:06d9443a018f | 2 | #include "Adafruit_GFX.h" |
lelect | 0:06d9443a018f | 3 | |
lelect | 2:6136465ffd3a | 4 | #ifndef _BV |
lelect | 2:6136465ffd3a | 5 | #define _BV(bit) (1<<(bit)) |
lelect | 2:6136465ffd3a | 6 | #endif |
lelect | 2:6136465ffd3a | 7 | |
lelect | 2:6136465ffd3a | 8 | |
lelect | 2:6136465ffd3a | 9 | #ifdef DEBUG |
lelect | 3:aa3762e0dfee | 10 | #define log_debug(format,...) std::printf(format,##__VA_ARGS__) |
lelect | 2:6136465ffd3a | 11 | #else |
lelect | 2:6136465ffd3a | 12 | #define log_debug(...) |
lelect | 2:6136465ffd3a | 13 | #endif |
lelect | 2:6136465ffd3a | 14 | |
lelect | 2:6136465ffd3a | 15 | |
lelect | 0:06d9443a018f | 16 | class RGBmatrixPanel : public Adafruit_GFX |
lelect | 0:06d9443a018f | 17 | { |
lelect | 0:06d9443a018f | 18 | |
lelect | 0:06d9443a018f | 19 | public: |
lelect | 0:06d9443a018f | 20 | // Constructor for 16x32 panel: |
lelect | 3:aa3762e0dfee | 21 | RGBmatrixPanel(PinName r1,PinName r2,PinName g1,PinName g2,PinName b1,PinName b2,PinName a,PinName b,PinName c,PinName sclk,PinName latch, PinName oe,bool dbuf); |
lelect | 0:06d9443a018f | 22 | |
lelect | 0:06d9443a018f | 23 | // Constructor for 32x32 panel (adds 'd' pin): |
lelect | 3:aa3762e0dfee | 24 | RGBmatrixPanel(PinName r1,PinName r2,PinName g1,PinName g2,PinName b1,PinName b2,PinName a,PinName b,PinName c,PinName d,PinName sclk, PinName latch,PinName oe,bool dbuf); |
lelect | 0:06d9443a018f | 25 | |
lelect | 0:06d9443a018f | 26 | void begin(void); |
lelect | 0:06d9443a018f | 27 | virtual void drawPixel(int16_t x, int16_t y, uint16_t c); |
lelect | 0:06d9443a018f | 28 | virtual void fillScreen(uint16_t c); |
lelect | 0:06d9443a018f | 29 | void updateDisplay(void); |
lelect | 0:06d9443a018f | 30 | void swapBuffers(bool); |
lelect | 0:06d9443a018f | 31 | void dumpMatrix(void); |
lelect | 0:06d9443a018f | 32 | |
lelect | 0:06d9443a018f | 33 | uint8_t *backBuffer(void); |
lelect | 0:06d9443a018f | 34 | |
lelect | 0:06d9443a018f | 35 | uint16_t Color333(uint8_t r, uint8_t g, uint8_t b); |
lelect | 0:06d9443a018f | 36 | uint16_t Color444(uint8_t r, uint8_t g, uint8_t b); |
lelect | 0:06d9443a018f | 37 | uint16_t Color888(uint8_t r, uint8_t g, uint8_t b); |
lelect | 0:06d9443a018f | 38 | uint16_t Color888(uint8_t r, uint8_t g, uint8_t b, bool gflag); |
lelect | 0:06d9443a018f | 39 | uint16_t ColorHSV(long hue, uint8_t sat, uint8_t val, bool gflag); |
lelect | 0:06d9443a018f | 40 | |
lelect | 0:06d9443a018f | 41 | private: |
lelect | 4:0ff6053c4bb2 | 42 | uint8_t *matrixbuff[2]; |
lelect | 4:0ff6053c4bb2 | 43 | uint8_t nRows; |
lelect | 4:0ff6053c4bb2 | 44 | uint8_t backindex; |
lelect | 4:0ff6053c4bb2 | 45 | bool swapflag; |
lelect | 0:06d9443a018f | 46 | |
lelect | 0:06d9443a018f | 47 | // Init/alloc code common to both constructors: |
lelect | 2:6136465ffd3a | 48 | void init(uint8_t rows, bool dbuf); |
lelect | 0:06d9443a018f | 49 | |
lelect | 5:1f8409ee8850 | 50 | BusOut _dataBus; |
lelect | 6:b594794a132e | 51 | |
lelect | 5:1f8409ee8850 | 52 | BusOut _rowBus; |
lelect | 5:1f8409ee8850 | 53 | DigitalOut _d,_sclk, _latch, _oe; |
lelect | 3:aa3762e0dfee | 54 | Ticker _refresh; |
lelect | 0:06d9443a018f | 55 | // Counters/pointers for interrupt handler: |
lelect | 5:1f8409ee8850 | 56 | volatile uint8_t row, plane; |
lelect | 5:1f8409ee8850 | 57 | volatile uint8_t *buffptr; |
lelect | 0:06d9443a018f | 58 | }; |