EIC / RGB_matrix_Panel

Dependencies:   Adafruit-GFX

Embed: (wiki syntax)

« Back to documentation index

RGBmatrixPanel Class Reference

RGBmatrixPanel Class Reference

RGBmatrixPanel is class for full color LED matrix. More...

#include <RGBmatrixPanel.h>

Public Member Functions

void begin (void)
 Attach a updateDisplay() to be called by the Ticker(every 100us)
virtual void drawPixel (int16_t x, int16_t y, uint16_t c)
 drawPixel
virtual void fillScreen (uint16_t c)
 fillScreen
void updateDisplay (void)
void swapBuffers (bool copy)
void dumpMatrix (void)
 dump to default USB Serial
Declaration is required to use.
uint16_t Color333 (uint8_t r, uint8_t g, uint8_t b)
 up convert to 16bit color from 9bit color.
uint16_t Color444 (uint8_t r, uint8_t g, uint8_t b)
 up convert to 16bit color from 12bit color.
uint16_t Color888 (uint8_t r, uint8_t g, uint8_t b)
 down convert to 16bit color from 24bit color.
uint16_t Color888 (uint8_t r, uint8_t g, uint8_t b, bool gflag)
 down convert to 16bit color from 24bit color using the gamma value table.
uint16_t ColorHSV (long hue, uint8_t sat, uint8_t val, bool gflag)
 convert to 16bit color from (unsigned integer)HSV color using the gamma value table.
uint16_t ColorHSV (float hue, float sat, float val, bool gflag)
 convert to 16bit color from (float)HSV color using the gamma value table.

Detailed Description

RGBmatrixPanel is class for full color LED matrix.

#include "mbed.h"
#include "RGBmatrixPanel.h" // Hardware-specific library

PinName ub1=p6;
PinName ug1=p7;
PinName ur1=p8;
PinName lb2=p9;
PinName lg2=p10;
PinName lr2=p11;
RGBmatrixPanel matrix(ur1,ug1,ub1,lr2,lg2,lb2,p12,p13,p14,p15,p16,p17,false);
//RGBmatrixPanel(r1, g1, b1, r2, g2, b2, a, b, c, sclk, latch, oe, enable double_buffer);

int main()
{
    matrix.begin();
    while(1) {
        // fill the screen with 'black'
        matrix.fillScreen(matrix.Color333(0, 0, 0));
        // draw a pixel in solid white
        matrix.drawPixel(0, 0, matrix.Color333(7, 7, 7));
        wait_ms(500);

        // fix the screen with green
        matrix.fillRect(0, 0, 32, 16, matrix.Color333(0, 7, 0));
        wait_ms(500);

        // draw a box in yellow
        matrix.drawRect(0, 0, 32, 16, matrix.Color333(7, 7, 0));
        wait_ms(500);

        // draw an 'X' in red
        matrix.drawLine(0, 0, 31, 15, matrix.Color333(7, 0, 0));
        matrix.drawLine(31, 0, 0, 15, matrix.Color333(7, 0, 0));
        wait_ms(500);

        // draw a blue circle
        matrix.drawCircle(7, 7, 7, matrix.Color333(0, 0, 7));
        wait_ms(500);

        // fill a violet circle
        matrix.fillCircle(23, 7, 7, matrix.Color333(7, 0, 7));
        wait_ms(500);

        // fill the screen with 'black'
        matrix.fillScreen(matrix.Color333(0, 0, 0));

        // draw some text!
        matrix.setCursor(1, 0);   // start at top left, with one pixel of spacing
        matrix.setTextSize(1);    // size 1 == 8 pixels high

        // printff each letter with a rainbow color
        matrix.setTextColor(matrix.Color333(7,0,0));
        matrix.putc('1');
        matrix.setTextColor(matrix.Color333(7,4,0));
        matrix.putc('6');
        matrix.setTextColor(matrix.Color333(7,7,0));
        matrix.putc('x');
        matrix.setTextColor(matrix.Color333(4,7,0));
        matrix.putc('3');
        matrix.setTextColor(matrix.Color333(0,7,0));
        matrix.putc('2');

        matrix.setCursor(1, 9);   // next line
        matrix.setTextColor(matrix.Color333(0,7,7));
        matrix.putc('*');
        matrix.setTextColor(matrix.Color333(0,4,7));
        matrix.putc('R');
        matrix.setTextColor(matrix.Color333(0,0,7));
        matrix.putc('G');
        matrix.setTextColor(matrix.Color333(4,0,7));
        matrix.putc('B');
        matrix.setTextColor(matrix.Color333(7,0,4));
        matrix.putc('*');
        wait_ms(500);
    }
}

Definition at line 96 of file RGBmatrixPanel.h.


Member Function Documentation

void begin ( void   )

Attach a updateDisplay() to be called by the Ticker(every 100us)

Definition at line 62 of file RGBmatrixPanel.cpp.

uint16_t Color333 ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

up convert to 16bit color from 9bit color.

Returns:
16bit(uint16_t) color value

Definition at line 86 of file RGBmatrixPanel.cpp.

uint16_t Color444 ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

up convert to 16bit color from 12bit color.

Parameters:
r0~7
g0~7
b0~7
Returns:
16bit(uint16_t) color value

Definition at line 95 of file RGBmatrixPanel.cpp.

uint16_t Color888 ( uint8_t  r,
uint8_t  g,
uint8_t  b,
bool  gflag 
)

down convert to 16bit color from 24bit color using the gamma value table.

Returns:
16bit(uint16_t) color value

Definition at line 111 of file RGBmatrixPanel.cpp.

uint16_t Color888 ( uint8_t  r,
uint8_t  g,
uint8_t  b 
)

down convert to 16bit color from 24bit color.

Returns:
16bit(uint16_t) color value

Definition at line 105 of file RGBmatrixPanel.cpp.

uint16_t ColorHSV ( float  hue,
float  sat,
float  val,
bool  gflag 
)

convert to 16bit color from (float)HSV color using the gamma value table.

Parameters:
hueNormalized value from 0.0 to 1.0
satNormalized value from 0.0 to 1.0
valNormalized value from 0.0 to 1.0
Returns:
16bit(uint16_t) color value

Definition at line 192 of file RGBmatrixPanel.cpp.

uint16_t ColorHSV ( long  hue,
uint8_t  sat,
uint8_t  val,
bool  gflag 
)

convert to 16bit color from (unsigned integer)HSV color using the gamma value table.

Parameters:
hue0~1536(decimal value)
sat0~255(decimal value) Does not make sense that it is not a multiple of 32.
val0~255(decimal value) Does not make sense that it is not a multiple of 32.
Returns:
16bit(uint16_t) color value

Definition at line 124 of file RGBmatrixPanel.cpp.

void drawPixel ( int16_t  x,
int16_t  y,
uint16_t  c 
) [virtual]

drawPixel

Definition at line 234 of file RGBmatrixPanel.cpp.

void dumpMatrix ( void   )

dump to default USB Serial
Declaration is required to use.

(define DEBUG)

Definition at line 341 of file RGBmatrixPanel.cpp.

void fillScreen ( uint16_t  c ) [virtual]

fillScreen

Parameters:
cfill screen 16bit color 0x0000 ~ 0xFFFF

Definition at line 298 of file RGBmatrixPanel.cpp.

void swapBuffers ( bool  copy )
Parameters:
copyswap buffer (if you use double-buffer)

Definition at line 323 of file RGBmatrixPanel.cpp.

void updateDisplay ( void   )
Parameters:
cupdateDisplay
This method is called by the interrupt start at begin().

Definition at line 356 of file RGBmatrixPanel.cpp.