Chinnawat Chinnapun / my8x8RGB

Files at this revision

API Documentation at this revision

Comitter:
bankzamak
Date:
Sat Oct 22 07:08:42 2016 +0000
Commit message:
RMUMPU9250 FIBO naja

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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/my8x8RGB.cpp	Sat Oct 22 07:08:42 2016 +0000
@@ -0,0 +1,170 @@
+#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=0,GreenWB=10,BlueWB=10; // percent | R,G,B calibrate change it if some color brighter than other
+uint8_t display[8][8][4]= {0};
+uint8_t ii,jj,kk;
+/*******************************************/
+void color_choose(int oasis[8][8][4])
+{
+    for(ii=0; ii<=7; ii++) {
+        for(jj=0; jj<=7; jj++) {
+            for(kk=0; kk<=7; kk++) {
+                display[ii][jj][kk]=oasis[ii][jj][kk];
+            }
+        }
+    }
+}
+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 Showscreen()
+{
+
+    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;
+        }
+    }
+    Showscreen();
+}
+
+
+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;
+}
+
+*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/my8x8RGB.h	Sat Oct 22 07:08:42 2016 +0000
@@ -0,0 +1,14 @@
+
+#ifndef my8x8RGB_H
+#define my8x8RGB_H
+
+
+void INITRGB(char in[3]); //whitebalance define
+void color_choose(int oasis[8][8][4]);
+void Showscreen(); //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
+