RGB 8*8 By Oey

Dependents:   B17_ClockGame

Files at this revision

API Documentation at this revision

Comitter:
mmoodevil
Date:
Mon Dec 07 11:24:40 2015 +0000
Commit message:
SSSSS

Changed in this revision

my8x8RGB.cpp Show annotated file Show diff for this revision Revisions of this file
my8x8RGB.h Show annotated file Show diff for this revision Revisions of this file
my8x8RGB.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r c01d67879eb2 my8x8RGB.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/my8x8RGB.cpp	Mon Dec 07 11:24:40 2015 +0000
@@ -0,0 +1,160 @@
+#include "mbed.h"
+#include "my8x8RGB.h"
+/**************Define*************************/
+DigitalOut RGB_RST(A2);
+DigitalOut RGB_LAT(A1);
+DigitalOut RGB_SB(A0);
+
+/*DigitalIn nn0(D7);
+DigitalIn nn1(D2);
+DigitalIn nn2(D6);*/
+SPI RGB_SPI(PB_15,PB_14,PB_13);
+BusOut RGB_CP(D8,D9,D10,D11,D12,D13,D3,D4);
+uint8_t RGBi= 0,RGBj= 0,RGBk= 0;
+uint8_t RedWB=55,GreenWB=0,BlueWB=60; // percent | R,G,B calibrate change it if some color brighter than other
+uint8_t display[8][8][3]= {0};
+/*******************************************/
+
+void INITRGB(char in[3])
+{
+    int wd;
+    RGB_RST =0;
+    RGB_RST =1;
+    RGB_SPI.frequency(20000000);
+    RGB_SPI.format(8,1);
+    RGB_LAT = 0;
+    RGB_SB  =0;
+    int l=0;
+
+    for (int i = 0; i<8; i++) { // Whitebalance......**important
+        for (int j = 0; j<3; j++) {
+            for (int k = 0; k<6; k++) {
+                wd+=((in[j]<<k)&0b00100000)?1:0;
+          //      wd<<1;
+                l++;
+                if(l>=7) {
+                    RGB_SPI.write(255);
+                    l=0;
+                }
+            }
+            //RGB_SPI.write(255);
+        }
+    }
+
+    RGB_LAT = 1;
+    RGB_LAT = 0;
+
+    RGB_SPI.format(8,0);
+}
+
+void displayRGB()
+{
+
+    RGB_SB  =1;
+    for( RGBi=0; RGBi<8; RGBi++) {
+        for( RGBk=0; RGBk<8; RGBk++) {
+            for( RGBj=0; RGBj<3; RGBj++) {
+                RGB_SPI.write(display[RGBi][RGBk][RGBj]);
+            }
+
+        }
+        RGB_CP = 0;
+        wait_us(15);
+        RGB_LAT = 1;
+        RGB_LAT = 0;
+
+        RGB_CP = (0x01<<RGBi);
+
+    }
+}
+
+void screen_color(uint8_t R,uint8_t G,uint8_t B)
+{
+
+    for(uint8_t Colum=0; Colum<8; Colum++) {
+        for(uint8_t Row=0; Row<8; Row++) {
+            display[Colum][Row][2]=R*RedWB/100;
+            display[Colum][Row][1]=G;
+            display[Colum][Row][0]=B*BlueWB/100;
+        }
+    }
+
+}
+void screen_off()
+{
+
+    for(uint8_t Colum=0; Colum<8; Colum++) {
+        for(uint8_t Row=0; Row<8; Row++) {
+            display[Colum][Row][2]=0;
+            display[Colum][Row][1]=0;
+            display[Colum][Row][0]=0;
+        }
+    }
+    displayRGB();
+}
+
+
+void RGB_led(uint8_t Colum,uint8_t Row,char color,uint8_t brightness)
+{
+    uint8_t c;
+    switch (color) {
+        case 'R':
+            c=2;
+            break;
+        case 'G':
+            c=1;
+            break;
+        case 'B':
+            c=0;
+            break;
+    }
+    display[Colum][Row][c]=brightness;
+}
+
+
+void rgb_point(uint8_t Colum,uint8_t Row,uint8_t R,uint8_t G,uint8_t B)
+{
+    display[Colum][Row][2]=R*RedWB/100;
+    display[Colum][Row][1]=G;
+    display[Colum][Row][0]=B*BlueWB/100;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff -r 000000000000 -r c01d67879eb2 my8x8RGB.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/my8x8RGB.h	Mon Dec 07 11:24:40 2015 +0000
@@ -0,0 +1,14 @@
+
+#ifndef my8x8RGB_H
+#define my8x8RGB_H
+
+
+void INITRGB(char in[3]); //whitebalance define
+
+void displayRGB(); //display
+
+void screen_color(uint8_t R,uint8_t G,uint8_t B); // all dot on screen
+void screen_off();//all led brightness=0
+void RGB_led(uint8_t Colum,uint8_t Row,char  color,uint8_t brightness); ////on LED each point | color = 'R','G','B' | **brightness 0-255 => rgb_point(1,1,'R ',255);
+void rgb_point(uint8_t Colum,uint8_t Row,uint8_t R,uint8_t G,uint8_t B); // 16m_colorful *yellow,purple,pink. etc.
+#endif // my8x8RGB_H
\ No newline at end of file
diff -r 000000000000 -r c01d67879eb2 my8x8RGB.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/my8x8RGB.lib	Mon Dec 07 11:24:40 2015 +0000
@@ -0,0 +1,1 @@
+my8x8RGB#ebde2c5bf97a