Quick demo for LED 8x8 Matrix with FRDM-K82F

/media/uploads/suntopbd/img_20180523_081229.jpg

Revision:
2:4e21ea1275a1
Parent:
1:1088a4658fc2
Child:
3:6cdeb3b19afb
--- a/main.cpp	Wed May 23 17:48:41 2018 +0000
+++ b/main.cpp	Sun Jun 03 01:14:51 2018 +0000
@@ -3,235 +3,34 @@
 PINOUT
 https://os.mbed.com/platforms/FRDM-K82F/#board-pinout
 should work with any other board with 16 I/O available
-    
-    C1 C2 C3 C4 C5 C6 C7 C8
-R1   x  x  x  x  x  x  x  x
-R2   x  x  x  x  x  x  x  x
-R3   x  x  x  x  x  x  x  x
-R4   x  x  x  x  x  x  x  x
-R5   x  x  x  x  x  x  x  x
-R6   x  x  x  x  x  x  x  x
-R7   x  x  x  x  x  x  x  x
-R8   x  x  x  x  x  x  x  x
-
 */
-#include "mbed.h"
-
-// Row Pins //
-DigitalOut R1(PTC9);
-DigitalOut R2(PTC8);
-DigitalOut R3(PTC10);
-DigitalOut R4(PTC11);
-DigitalOut R5(PTA14);
-DigitalOut R6(PTC7);
-DigitalOut R7(PTA16);
-DigitalOut R8(PTA15);
 
-// Col Pins //
-DigitalOut C1(PTD0);
-DigitalOut C2(PTC12);
-DigitalOut C3(PTB17);
-DigitalOut C4(PTB16);
-DigitalOut C5(PTA5);
-DigitalOut C6(PTA13);
-DigitalOut C7(PTA12);
-DigitalOut C8(PTA17);
-
-// func declearation //
-
-void disp_off(void);
-void disp_line(int,int,int,int,int,int,int,int,int);
-void disp_page(int*);
-
- 
-int *dotpointer;
-
-// 0 will glow LED and 1 will keep off //
-// Use it to make Icon, Character, Symble //
-int canvas[64] = { 
-
-  1,1,1,0,0,1,1,1,
-  1,1,0,0,0,0,1,1,
-  1,0,0,0,0,0,0,1,
-  0,0,0,0,0,0,0,0,
-  1,1,0,0,0,0,1,1,
-  1,1,0,0,0,0,1,1,
-  1,1,0,0,0,0,1,1,
-  1,1,0,0,0,0,1,1,
-
-};  
-int m[64] = { 
+#include "mbed.h"
+#include "Char_Fonts.h"
 
-  1,1,1,1,1,1,1,1,
-  0,0,1,1,1,0,0,1,
-  0,1,0,1,0,1,0,1,
-  0,1,1,0,1,1,0,1,
-  0,1,1,1,1,1,0,1,
-  0,1,1,1,1,1,0,1,
-  0,1,1,1,1,1,0,1,
-  0,1,1,1,1,1,0,1,
- 
-}; 
-
-int b[64] = { 
-  1,1,1,1,1,1,1,1,
-  0,0,0,0,0,1,1,1,
-  0,1,1,1,1,0,1,1,
-  0,1,1,1,1,0,1,1,
-  0,0,0,0,0,1,1,1,
-  0,1,1,1,1,0,1,1,
-  0,1,1,1,1,0,1,1,
-  0,0,0,0,0,1,1,1,
-  
-}; 
-
-int e[64] = { 
-  1,1,1,1,1,1,1,1,
-  0,0,0,0,0,0,1,1,
-  0,1,1,1,1,1,1,1,
-  0,1,1,1,1,1,1,1,
-  0,0,0,0,0,1,1,1,
-  0,1,1,1,1,1,1,1,
-  0,1,1,1,1,1,1,1,
-  0,0,0,0,0,0,1,1,
-  
-}; 
+int main() 
 
-  int d[64] = { 
-  1,1,1,1,1,1,1,1,
-  0,0,0,0,1,1,1,1,
-  0,1,1,1,0,1,1,1,
-  0,1,1,1,1,0,1,1,
-  0,1,1,1,1,0,1,1,
-  0,1,1,1,1,0,1,1,
-  0,1,1,1,0,1,1,1,
-  0,0,0,0,1,1,1,1,
-  
-}; 
-
-int space[64] = { 
-  1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,
-  1,1,1,1,1,1,1,1,
-  
-}; 
-
- 
-  
-void update_disp_m();
-void update_disp_b();
-void update_disp_e();
-void update_disp_d();
-void update_disp_space();
-
-Timer timer;
-
-int main() {
-// SETUP //
+{
  disp_off();
- timer.start();   
-// END OF SETUP //
+ speed_down(0.5);
+ gap_up(0.2);
     
-
-// LOOP //
     while (1) 
     {
+          // Prints M B E D on Dot Matrix  //
           
-      while (timer.read() < 0.6) {update_disp_m();}timer.reset();
-      while (timer.read() < 0.6) {update_disp_b();}timer.reset();
-      while (timer.read() < 0.6) {update_disp_e();}timer.reset();
-      while (timer.read() < 0.6) {update_disp_d();}timer.reset();
-      while (timer.read() < 0.8) {update_disp_space();}timer.reset();
-      
+     A();space();
+     Q();U();I();C();K();space();
+     B();R();O();W();N();space();
+     F();O();X();space();
+     J();U();M();P();E();D();space();
+     O();V();E();R();space();
+     T();H();E();space();
+     L();A();Z();Y();space();
+     D();O();G();S();
+     space(); // show a blank display
+             
     }
-// END OF LOOP //
-}
 
 //..........................................//
-
-
-// MBED OS Tasks //
-void update_disp_m()
-{
-    dotpointer = &m[0];
-    disp_page(dotpointer);
-    disp_off();
-    
 }
-
-void update_disp_b()
-{
-    dotpointer = &b[0];
-    disp_page(dotpointer);
-    disp_off();
-    
-}
-void update_disp_e()
-{
-    dotpointer = &e[0];
-    disp_page(dotpointer);
-    disp_off();
-    
-}
-void update_disp_d()
-{
-    dotpointer = &d[0];
-    disp_page(dotpointer);
-    disp_off();
-    
-}
-void update_disp_space()
-{
-    dotpointer = &space[0];
-    disp_page(dotpointer);
-    disp_off();
-    
-}
-
-// End of Tasks //
-
-
-// Functions Body //
-void disp_off(void)
-{
-// for CC type    
-C1 = 1; C2 = 1; C3 = 1; C4 = 1; C5 = 1; C6 = 1; C7 = 1; C8 = 1;    
-// for CA 
-//C1 = 0; C2 = 0; C3 = 0; C4 = 0; C5 = 0; C6 = 0; C7 = 0; C8 = 0;    
-}
-
-void disp_line(int r,int c1,int c2,int c3,int c4,int c5,int c6,int c7,int c8)
-{
-    disp_off();
-    if(r==1) {R1=1;R2=0;R3=0;R4=0;R5=0;R6=0;R7=0;R8=0;}
-    if(r==2) {R1=0;R2=1;R3=0;R4=0;R5=0;R6=0;R7=0;R8=0;}
-    if(r==3) {R1=0;R2=0;R3=1;R4=0;R5=0;R6=0;R7=0;R8=0;}
-    if(r==4) {R1=0;R2=0;R3=0;R4=1;R5=0;R6=0;R7=0;R8=0;}
-    if(r==5) {R1=0;R2=0;R3=0;R4=0;R5=1;R6=0;R7=0;R8=0;}
-    if(r==6) {R1=0;R2=0;R3=0;R4=0;R5=0;R6=1;R7=0;R8=0;}
-    if(r==7) {R1=0;R2=0;R3=0;R4=0;R5=0;R6=0;R7=1;R8=0;}
-    if(r==8) {R1=0;R2=0;R3=0;R4=0;R5=0;R6=0;R7=0;R8=1;}
-    C1=c1;C2=c2;C3=c3;C4=c4; C5=c5;C6=c6;C7=c7;C8=c8;
-}
-
-
-
-void disp_page(int *dot)
-{
-  disp_line(1,*(dot+0) ,*(dot+1) ,*(dot+2) ,*(dot+3) ,*(dot+4) ,*(dot+5) ,*(dot+6) ,*(dot+7) );
-  disp_line(2,*(dot+8) ,*(dot+9) ,*(dot+10),*(dot+11),*(dot+12),*(dot+13),*(dot+14),*(dot+15));
-  disp_line(3,*(dot+16),*(dot+17),*(dot+18),*(dot+19),*(dot+20),*(dot+21),*(dot+22),*(dot+23));
-  disp_line(4,*(dot+24),*(dot+25),*(dot+26),*(dot+27),*(dot+28),*(dot+29),*(dot+30),*(dot+31));
-  disp_line(5,*(dot+32),*(dot+33),*(dot+34),*(dot+35),*(dot+36),*(dot+37),*(dot+38),*(dot+39));
-  disp_line(6,*(dot+40),*(dot+41),*(dot+42),*(dot+43),*(dot+44),*(dot+45),*(dot+46),*(dot+47));
-  disp_line(7,*(dot+48),*(dot+49),*(dot+50),*(dot+51),*(dot+52),*(dot+53),*(dot+54),*(dot+55));
-  disp_line(8,*(dot+56),*(dot+57),*(dot+58),*(dot+59),*(dot+60),*(dot+61),*(dot+62),*(dot+63));
-
-}
-
-// End of Functions //