LAST PUBLISH MATRIX PROJECT

Dependencies:   mbed

Committer:
antoine_carpentier
Date:
Tue Jun 22 11:55:19 2021 +0000
Revision:
1:7a7366246b30
Parent:
0:c78ec5cab98d
last commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
iut_cachan01 0:c78ec5cab98d 1 /**
iut_cachan01 0:c78ec5cab98d 2 * LED Matrix library for http://www.seeedstudio.com/depot/ultrathin-16x32-red-led-matrix-panel-p-1582.html
iut_cachan01 0:c78ec5cab98d 3 * The LED Matrix panel has 32x16 pixels. Several panel can be combined together as a large screen.
iut_cachan01 0:c78ec5cab98d 4 *
iut_cachan01 0:c78ec5cab98d 5 * Coordinate & Connection (mbed -> panel 0 -> panel 1 -> ...)
iut_cachan01 0:c78ec5cab98d 6 * (0, 0) (0, 0)
iut_cachan01 0:c78ec5cab98d 7 * +--------+--------+--------+ +--------+--------+
iut_cachan01 0:c78ec5cab98d 8 * | 5 | 3 | 1 | | 1 | 0 |
iut_cachan01 0:c78ec5cab98d 9 * | | | | | | |<----- mbed
iut_cachan01 0:c78ec5cab98d 10 * +--------+--------+--------+ +--------+--------+
iut_cachan01 0:c78ec5cab98d 11 * | 4 | 2 | 0 | (64, 16)
iut_cachan01 0:c78ec5cab98d 12 * | | | |<----- mbed
iut_cachan01 0:c78ec5cab98d 13 * +--------+--------+--------+
iut_cachan01 0:c78ec5cab98d 14 * (96, 32)
iut_cachan01 0:c78ec5cab98d 15 * Copyright (c) 2013 Seeed Technology Inc.
iut_cachan01 0:c78ec5cab98d 16 * @auther Yihui Xiong
iut_cachan01 0:c78ec5cab98d 17 * @date Nov 7, 2013
iut_cachan01 0:c78ec5cab98d 18 * @license Apache
iut_cachan01 0:c78ec5cab98d 19 */
iut_cachan01 0:c78ec5cab98d 20
iut_cachan01 0:c78ec5cab98d 21
iut_cachan01 0:c78ec5cab98d 22 #ifndef __LED_MATRIX_H__
iut_cachan01 0:c78ec5cab98d 23 #define __LED_MATRIX_H__
iut_cachan01 0:c78ec5cab98d 24
iut_cachan01 0:c78ec5cab98d 25 #include "mbed.h"
iut_cachan01 0:c78ec5cab98d 26 #include "fonts.h"
iut_cachan01 0:c78ec5cab98d 27
iut_cachan01 0:c78ec5cab98d 28 class LEDMatrix {
iut_cachan01 0:c78ec5cab98d 29 public:
iut_cachan01 0:c78ec5cab98d 30 LEDMatrix(PinName pinA, PinName pinB, PinName pinC, PinName pinD, PinName pinOE,
iut_cachan01 0:c78ec5cab98d 31 PinName pinR1, PinName pinR2, PinName pinB1, PinName pinB2, PinName pinG1, PinName pinG2,
iut_cachan01 0:c78ec5cab98d 32 PinName pinSTB, PinName pinCLK);
iut_cachan01 0:c78ec5cab98d 33
iut_cachan01 0:c78ec5cab98d 34 /**
iut_cachan01 0:c78ec5cab98d 35 * set the display's display buffer and number, the buffer's size must be not less than 512 * number / 8 bytes
iut_cachan01 0:c78ec5cab98d 36 * @param displaybuf display buffer
iut_cachan01 0:c78ec5cab98d 37 * @param number panels' number
iut_cachan01 0:c78ec5cab98d 38 */
iut_cachan01 0:c78ec5cab98d 39 void begin(uint8_t *displaybuf, uint16_t width, uint16_t height);
iut_cachan01 0:c78ec5cab98d 40
iut_cachan01 0:c78ec5cab98d 41 /**
iut_cachan01 0:c78ec5cab98d 42 * draw a point
iut_cachan01 0:c78ec5cab98d 43 * @param x x
iut_cachan01 0:c78ec5cab98d 44 * @param y y
iut_cachan01 0:c78ec5cab98d 45 * @param pixel 0: led off, >0: led on
iut_cachan01 0:c78ec5cab98d 46 */
iut_cachan01 0:c78ec5cab98d 47 void drawPoint(uint16_t x, uint16_t y, uint8_t pixel);
iut_cachan01 0:c78ec5cab98d 48
iut_cachan01 0:c78ec5cab98d 49 /**
iut_cachan01 0:c78ec5cab98d 50 * draw a rect
iut_cachan01 0:c78ec5cab98d 51 * @param (x1, y1) top-left position
iut_cachan01 0:c78ec5cab98d 52 * @param (x2, y2) bottom-right position, not included in the rect
iut_cachan01 0:c78ec5cab98d 53 * @param pixel 0: rect off, >0: rect on
iut_cachan01 0:c78ec5cab98d 54 */
iut_cachan01 0:c78ec5cab98d 55 void drawRect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t pixel);
iut_cachan01 0:c78ec5cab98d 56
iut_cachan01 0:c78ec5cab98d 57 int drawChar(uint16_t x, uint16_t y, char c, uint8_t pixel, Font *font);
iut_cachan01 0:c78ec5cab98d 58
iut_cachan01 0:c78ec5cab98d 59 void drawCharString (uint16_t x, uint16_t y, char *c, uint8_t pixel, Font *font);
iut_cachan01 0:c78ec5cab98d 60
iut_cachan01 0:c78ec5cab98d 61 void drawCharBig(uint16_t x, uint16_t y, char c, uint8_t pixel);
iut_cachan01 0:c78ec5cab98d 62
iut_cachan01 0:c78ec5cab98d 63 /**
iut_cachan01 0:c78ec5cab98d 64 * draw a image
iut_cachan01 0:c78ec5cab98d 65 * @param (x1, y1) top-left position
iut_cachan01 0:c78ec5cab98d 66 * @param (x2, y2) bottom-right position, not included in the rect
iut_cachan01 0:c78ec5cab98d 67 * @param pixels contents, 1 bit to 1 led
iut_cachan01 0:c78ec5cab98d 68 */
iut_cachan01 0:c78ec5cab98d 69 void drawImage(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint8_t *image);
iut_cachan01 0:c78ec5cab98d 70
iut_cachan01 0:c78ec5cab98d 71 /**
iut_cachan01 0:c78ec5cab98d 72 * Set screen buffer to zero
iut_cachan01 0:c78ec5cab98d 73 */
iut_cachan01 0:c78ec5cab98d 74 void clear();
iut_cachan01 0:c78ec5cab98d 75
iut_cachan01 0:c78ec5cab98d 76 /**
iut_cachan01 0:c78ec5cab98d 77 * turn off 1/16 leds and turn on another 1/16 leds
iut_cachan01 0:c78ec5cab98d 78 */
iut_cachan01 0:c78ec5cab98d 79 void scan();
iut_cachan01 0:c78ec5cab98d 80
iut_cachan01 0:c78ec5cab98d 81 void reverse();
iut_cachan01 0:c78ec5cab98d 82
iut_cachan01 0:c78ec5cab98d 83 uint8_t isReversed();
iut_cachan01 0:c78ec5cab98d 84
iut_cachan01 0:c78ec5cab98d 85 void on();
iut_cachan01 0:c78ec5cab98d 86
iut_cachan01 0:c78ec5cab98d 87 void off();
iut_cachan01 0:c78ec5cab98d 88
iut_cachan01 0:c78ec5cab98d 89 void swap();
iut_cachan01 0:c78ec5cab98d 90
iut_cachan01 0:c78ec5cab98d 91 int synchro();
iut_cachan01 0:c78ec5cab98d 92
iut_cachan01 0:c78ec5cab98d 93 private:
antoine_carpentier 1:7a7366246b30 94 DigitalOut a, b, c, d, oe, r1, r2, b1, b2, g1, g2, stb, clk;
iut_cachan01 0:c78ec5cab98d 95 uint8_t *displaybuf, *memoBuf, *drawBuf;
iut_cachan01 0:c78ec5cab98d 96 uint16_t width;
iut_cachan01 0:c78ec5cab98d 97 uint16_t height;
iut_cachan01 0:c78ec5cab98d 98 uint8_t mask;
iut_cachan01 0:c78ec5cab98d 99 uint8_t state;
iut_cachan01 0:c78ec5cab98d 100 int bufferIndex;
iut_cachan01 0:c78ec5cab98d 101 volatile int flagSwap;
iut_cachan01 0:c78ec5cab98d 102 };
iut_cachan01 0:c78ec5cab98d 103
iut_cachan01 0:c78ec5cab98d 104 #endif