Adafruit-RGB_matrix_Panel(32*16)

Dependencies:   Adafruit-GFX

Dependents:   Ardoise_magique

Committer:
lelect
Date:
Sun May 25 12:24:33 2014 +0000
Revision:
9:349baf041171
Parent:
7:3ac98c836aa1
Child:
10:db4941188812
done porting

Who changed what in which revision?

UserRevisionLine numberNew 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 #ifdef DEBUG
lelect 3:aa3762e0dfee 9 #define log_debug(format,...) std::printf(format,##__VA_ARGS__)
lelect 2:6136465ffd3a 10 #else
lelect 2:6136465ffd3a 11 #define log_debug(...)
lelect 2:6136465ffd3a 12 #endif
lelect 2:6136465ffd3a 13
lelect 0:06d9443a018f 14 class RGBmatrixPanel : public Adafruit_GFX
lelect 0:06d9443a018f 15 {
lelect 0:06d9443a018f 16
lelect 0:06d9443a018f 17 public:
lelect 0:06d9443a018f 18 // Constructor for 16x32 panel:
lelect 9:349baf041171 19 RGBmatrixPanel(PinName r1,PinName g1,PinName b1,PinName r2,PinName g2,PinName b2,PinName a,PinName b,PinName c,PinName sclk,PinName latch,PinName oe, bool dbuf);
lelect 9:349baf041171 20 // 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 21
lelect 0:06d9443a018f 22 // Constructor for 32x32 panel (adds 'd' pin):
lelect 9:349baf041171 23 //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 24
lelect 0:06d9443a018f 25 void begin(void);
lelect 0:06d9443a018f 26 virtual void drawPixel(int16_t x, int16_t y, uint16_t c);
lelect 0:06d9443a018f 27 virtual void fillScreen(uint16_t c);
lelect 0:06d9443a018f 28 void updateDisplay(void);
lelect 0:06d9443a018f 29 void swapBuffers(bool);
lelect 0:06d9443a018f 30 void dumpMatrix(void);
lelect 0:06d9443a018f 31
lelect 0:06d9443a018f 32 uint8_t *backBuffer(void);
lelect 0:06d9443a018f 33
lelect 0:06d9443a018f 34 uint16_t Color333(uint8_t r, uint8_t g, uint8_t b);
lelect 0:06d9443a018f 35 uint16_t Color444(uint8_t r, uint8_t g, uint8_t b);
lelect 0:06d9443a018f 36 uint16_t Color888(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, bool gflag);
lelect 0:06d9443a018f 38 uint16_t ColorHSV(long hue, uint8_t sat, uint8_t val, bool gflag);
lelect 0:06d9443a018f 39
lelect 0:06d9443a018f 40 private:
lelect 4:0ff6053c4bb2 41 uint8_t *matrixbuff[2];
lelect 4:0ff6053c4bb2 42 uint8_t nRows;
lelect 4:0ff6053c4bb2 43 uint8_t backindex;
lelect 4:0ff6053c4bb2 44 bool swapflag;
lelect 0:06d9443a018f 45
lelect 0:06d9443a018f 46 // Init/alloc code common to both constructors:
lelect 2:6136465ffd3a 47 void init(uint8_t rows, bool dbuf);
lelect 0:06d9443a018f 48
lelect 5:1f8409ee8850 49 BusOut _dataBus;
lelect 5:1f8409ee8850 50 BusOut _rowBus;
lelect 5:1f8409ee8850 51 DigitalOut _d,_sclk, _latch, _oe;
lelect 3:aa3762e0dfee 52 Ticker _refresh;
lelect 0:06d9443a018f 53 // Counters/pointers for interrupt handler:
lelect 5:1f8409ee8850 54 volatile uint8_t row, plane;
lelect 5:1f8409ee8850 55 volatile uint8_t *buffptr;
lelect 0:06d9443a018f 56 };