CARPENTIER ANTOINE / Mbed 2 deprecated panneau

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers LEDMatrix.h Source File

LEDMatrix.h

00001 /**
00002  * LED Matrix library for http://www.seeedstudio.com/depot/ultrathin-16x32-red-led-matrix-panel-p-1582.html
00003  * The LED Matrix panel has 32x16 pixels. Several panel can be combined together as a large screen.
00004  * 
00005  * Coordinate & Connection (mbed -> panel 0 -> panel 1 -> ...)
00006  *   (0, 0)                                     (0, 0)
00007  *     +--------+--------+--------+               +--------+--------+
00008  *     |   5    |    3   |    1   |               |    1   |    0   |
00009  *     |        |        |        |               |        |        |<----- mbed
00010  *     +--------+--------+--------+               +--------+--------+
00011  *     |   4    |    2   |    0   |                              (64, 16)
00012  *     |        |        |        |<----- mbed
00013  *     +--------+--------+--------+
00014  *                             (96, 32)
00015  *  Copyright (c) 2013 Seeed Technology Inc.
00016  *  @auther     Yihui Xiong
00017  *  @date       Nov 7, 2013
00018  *  @license    Apache
00019  */
00020 
00021 
00022 #ifndef __LED_MATRIX_H__
00023 #define __LED_MATRIX_H__
00024 
00025 #include "mbed.h"
00026 #include "fonts.h"
00027 
00028 class LEDMatrix {
00029 public:
00030     LEDMatrix(PinName pinA, PinName pinB, PinName pinC, PinName pinD, PinName pinOE,
00031               PinName pinR1, PinName pinR2, PinName pinB1, PinName pinB2, PinName pinG1, PinName pinG2,
00032                PinName pinSTB, PinName pinCLK);
00033     
00034     /**
00035      * set the display's display buffer and number, the buffer's size must be not less than 512 * number / 8 bytes
00036      * @param displaybuf    display buffer
00037      * @param number        panels' number
00038      */
00039     void begin(uint8_t *displaybuf, uint16_t width, uint16_t height);
00040 
00041     /**
00042      * draw a point
00043      * @param x     x
00044      * @param y     y
00045      * @param pixel 0: led off, >0: led on
00046      */
00047     void drawPoint(uint16_t x, uint16_t y, uint8_t pixel);
00048 
00049     /**
00050      * draw a rect
00051      * @param (x1, y1)   top-left position
00052      * @param (x2, y2)   bottom-right position, not included in the rect
00053      * @param pixel      0: rect off, >0: rect on
00054      */
00055     void drawRect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t pixel);
00056 
00057     int drawChar(uint16_t x, uint16_t y, char c, uint8_t pixel, Font *font);
00058    
00059     void drawCharString (uint16_t x, uint16_t y, char *c, uint8_t pixel, Font *font);
00060     
00061     void drawCharBig(uint16_t x, uint16_t y, char c, uint8_t pixel);
00062 
00063     /**
00064      * draw a image
00065      * @param (x1, y1)   top-left position
00066      * @param (x2, y2)   bottom-right position, not included in the rect
00067      * @param pixels     contents, 1 bit to 1 led
00068      */
00069     void drawImage(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t *image);
00070 
00071     /**
00072      * Set screen buffer to zero
00073      */
00074     void clear();
00075 
00076     /**
00077      * turn off 1/16 leds and turn on another 1/16 leds
00078      */
00079     void scan();
00080 
00081     void reverse();
00082 
00083     uint8_t isReversed();
00084 
00085     void on();
00086 
00087     void off();
00088 
00089     void swap();
00090     
00091     int synchro();
00092     
00093 private:
00094     DigitalOut a, b, c, d, oe, r1, r2, b1, b2, g1, g2, stb, clk;
00095     uint8_t *displaybuf, *memoBuf, *drawBuf;
00096     uint16_t width;
00097     uint16_t height;
00098     uint8_t  mask;
00099     uint8_t  state;
00100     int bufferIndex;
00101     volatile int flagSwap;
00102 };
00103 
00104 #endif