Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 2:3935d2ed40cd
- Parent:
- 0:f76850de7b57
- Child:
- 3:9376bf1f1bbd
diff -r 4a62ae180af0 -r 3935d2ed40cd main.cpp
--- a/main.cpp Tue Aug 19 07:16:17 2014 +0000
+++ b/main.cpp Wed Aug 20 05:24:38 2014 +0000
@@ -1,11 +1,28 @@
#include "mbed.h"
#include "sbDriver.h"
+#include "movie.h"
/*MUST TRY THIS!!!!
Inheritance is one of the great features of object oriented languages like C++. The stream methods are not included in serial to allow you to use them in other classes as well. They are for example also included in the TextLCD class and in my enhanced TextLCD class. All you need to do to make use of the powerful printf features is implement a putc() method in your own new class.
from https://mbed.org/questions/1029/pcprintf-a-method/
*/
+//6 leds example. Format it suitably for easy reading
+unsigned short int aMovie[] = {
+ /* LED1 LED2 LED3 LED4 LED5 LED6 */
+ 1023,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, /*Frame 0*/
+ 0,0,0, 1023,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, /*Frame 1*/
+ 0,0,0, 0,0,0, 1023,0,0, 0,0,0, 0,0,0, 0,0,0, /*Frame 2*/
+ 0,0,0, 0,0,0, 0,0,0, 1023,0,0, 0,0,0, 0,0,0, /*Frame 3*/
+ 0,0,0, 0,0,0, 0,0,0, 0,0,0, 1023,0,0, 0,0,0, /*Frame 4*/
+ 0,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0, 1023,0,0, /*Frame 5*/
+ 0,0,0, 0,0,0, 0,0,0, 0,0,0, 1023,0,0, 0,0,0, /*Frame 6*/
+ 0,0,0, 0,0,0, 0,0,0, 1023,0,0, 0,0,0, 0,0,0, /*Frame 7*/
+ 0,0,0, 0,0,0, 1023,0,0, 0,0,0, 0,0,0, 0,0,0, /*Frame 8*/
+ 0,0,0, 1023,0,0, 0,0,0, 0,0,0, 0,0,0, 0,0,0 /*Frame 9*/
+ /*A simple 'cylon' scanner 'movie'*/
+};
+
Serial PC(PTA2, PTA1);//So I can use Bluetooth/Serial as output to terminal and input
@@ -31,20 +48,17 @@
//sbDisplay.setLed(0,0X550000);
//sbDisplay.setLed(4,0XFF,0X00,0X55);
//in this case, 6 of these statements wold be required to build one frame
-//BUILD A FRAME
-/*sbDisplay.setLed(0,0XFF0000);//Red
+
+
+//HOW TO BUILD A FRAME IF YOU ARE NOT USING THE MOVIE CLASS
+sbDisplay.setLed(0,0XFF0000);//Red
sbDisplay.setLed(1,0X00FF00);//Green
sbDisplay.setLed(2,0X0000FF);//Blue
sbDisplay.setLed(3,0XFFFF00);//Yellow
sbDisplay.setLed(4,0X00FFFF); //Cyan?
-sbDisplay.setLed(5,0XFF00FF); // Purple*/
+sbDisplay.setLed(5,0XFF00FF); // Purple
-sbDisplay.setLed(0,0XFFFFFF);//White
-sbDisplay.setLed(1,0XFFFFFF);//
-sbDisplay.setLed(2,0XFFFFFF);//
-sbDisplay.setLed(3,0XFFFFFF);//
-sbDisplay.setLed(4,0XFFFFFF); //
-sbDisplay.setLed(5,0XFFFFFF); //
+//HOW TO ADJUST THE CURRENT CONTROLLERS USED FOR DOT CORRECTION
sbDisplay.setCurrentCorr(0,0,0);//suggested default value cor current control regs. Values g&b=100, r=120
sbDisplay.displayFrame();//force an update
wait(2);
@@ -56,38 +70,30 @@
PC.printf("Hallo (size=%d)\r\n", sizeof(unsigned long int));
-//Setup the framerate and update the display
-//I chose standard 24fps
-t.attach_us(&sbDisplay,&shiftBriteDisplay::displayFrame,41666);//call updateFrame 24 times per second (every 41666uS)
-//t.attach(&sbDisplay,&shiftBriteDisplay::displayFrame,0.5);//Only every 0.5s for testing
+
+
+ sbDisplay.setLed(0,0X0F0000);//Red
+ sbDisplay.setLed(1,0X000F00);//Green
+ sbDisplay.setLed(2,0X00000F);//Blue
+ sbDisplay.setLed(3,0X0F0F00);//Yellow
+ sbDisplay.setLed(4,0X000F0F); //Cyan?
+ sbDisplay.setLed(5,0X0F000F); // Purple
+ sbDisplay.displayFrame(); //get it on the LEDS
+ wait(0.5);
+ sbDisplay.setCurrentCorr(0,0,0);//Dim
+
+ sbDisplay.displayFrame(); //get it on the LEDS
+//Alternative to calling displayFrame() yourself, setup the framerate and update the display
+//t.attach_us(&sbDisplay,&shiftBriteDisplay::displayFrame,41666);//call updateFrame 24 times per second (every 41666uS)
+//t.attach(&sbDisplay,&shiftBriteDisplay::displayFrame,0.5);// or only every 0.5s for testing
+
+
+//USING THE MOVIE CLASS
+//Note, it uses the previously declared sbDisplay object.
+ movie myMovie(aMovie,sbDisplay,sizeof(aMovie));
+ myMovie.setRepeat(1);
+ t.attach(&myMovie,&movie::play,0.05);//Beware, if you go too fast here the MBED will crash
-
- while(1){
-/*TEST THE CURRENT ADJUSMENT FUNCTIONALITY
- sbDisplay.setCurrentCorr(0,0,0);
- wait(0.5);
- sbDisplay.setCurrentCorr(30,30,30);
- wait(0.5);
- sbDisplay.setCurrentCorr(60,60,60);
- wait(0.5);
- sbDisplay.setCurrentCorr(90,90,30);
- wait(0.5);
- sbDisplay.setCurrentCorr(120,120,30);
- wait(0.5);
-*/
- sbDisplay.setLed(0,0XFF0000);//Red
- sbDisplay.setLed(1,0X00FF00);//Green
- sbDisplay.setLed(2,0X0000FF);//Blue
- sbDisplay.setLed(3,0XFFFF00);//Yellow
- sbDisplay.setLed(4,0X00FFFF); //Cyan?
- sbDisplay.setLed(5,0XFF00FF); // Purple
- wait(0.5);
- sbDisplay.setLed(5,0XFF0000);//Red
- sbDisplay.setLed(4,0X00FF00);//Green
- sbDisplay.setLed(3,0X0000FF);//Blue
- sbDisplay.setLed(2,0XFFFF00);//Yellow
- sbDisplay.setLed(1,0X00FFFF); //Cyan?
- sbDisplay.setLed(0,0XFF00FF); // Purple
- wait(0.5);
+ while(1){
}
}