Adafruit-RGB_matrix_Panel(32*16)
RGBmatrixPanel.h@3:aa3762e0dfee, 2014-05-24 (annotated)
- Committer:
- lelect
- Date:
- Sat May 24 17:33:23 2014 +0000
- Revision:
- 3:aa3762e0dfee
- Parent:
- 2:6136465ffd3a
- Child:
- 4:0ff6053c4bb2
Using the matrix buffer is unknown;
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 | 0:06d9443a018f | 42 | uint8_t *matrixbuff[2]; |
lelect | 0:06d9443a018f | 43 | uint8_t nRows; |
lelect | 0:06d9443a018f | 44 | volatile uint8_t backindex; |
lelect | 0:06d9443a018f | 45 | volatile 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 | 3:aa3762e0dfee | 50 | DigitalOut _sclk, _latch, _oe, _d; |
lelect | 3:aa3762e0dfee | 51 | BusOut _dataBus,_rowBus; |
lelect | 3:aa3762e0dfee | 52 | Ticker _refresh; |
lelect | 0:06d9443a018f | 53 | // Counters/pointers for interrupt handler: |
lelect | 0:06d9443a018f | 54 | volatile uint8_t row, plane; |
lelect | 0:06d9443a018f | 55 | volatile uint8_t *buffptr; |
lelect | 0:06d9443a018f | 56 | }; |