Rihards Balass / 4DGL-mbed-32PTU
Revision:
12:29f5ad896382
Parent:
11:3ebd2263f3e9
Child:
13:1a0800957412
--- a/demo.cpp	Tue Sep 13 11:37:04 2016 +0000
+++ b/demo.cpp	Wed Sep 14 13:27:37 2016 +0000
@@ -3,19 +3,45 @@
 #include "Picaso_4DGL-32PTU.h"
 
 #define SHORT_WAIT 500
-#define LONG_WAIT 2000
+#define LONG_WAIT 1000
 
 //**************************************************************************
+// Demo program that goes through media based functions
+//**************************************************************************
+void PICASO_4DGL :: mediaDemo() {
+    
+    cls();
+    screenMode(landscape); // set orientation to landscape
+    puts("\n\rThis is the Media functions demo");
+    wait_ms(LONG_WAIT);
+    cls();
+    
+    wait_ms(SHORT_WAIT);
+    if (media_Init()) puts("\n\r uSD card Initialization: OK");
+    else puts("\n\r uSD card Initialization: FAIL");
+    //if (media_SetAdd(513)) puts("\n\r Byte address set: OK");
+    //else puts("\n\r Byte address set: FAIL");
+    if (media_SetSector(1)) puts("\n\r Sector address set: OK");
+    else puts("\n\r Sector address set: FAIL");
+    puts("\n\r Now read the sector that was set");
+    wait_ms(LONG_WAIT);
+    if (media_ReadSector()) puts("\n\r Read Sector: OK");
+    else puts("\n\r Read Sector: FAIL");
+    
+    
+}
+//**************************************************************************
 // Demo program that goes through graphics based functions
 //**************************************************************************
 void PICASO_4DGL :: graphicsDemo() {
 
-    //cls();
+
+    cls();
     screenMode(landscape); // set orientation to landscape
     puts("This is the Graphics functions demo");
     wait_ms(LONG_WAIT);
     cls();
-/*
+    
     puts("\nLets change background color:");
     bgColor(Purple);
     cls();
@@ -34,18 +60,16 @@
     wait_ms(SHORT_WAIT);
     bgColor(Black);
     cls();
-    wait_ms(SHORT_WAIT);
-*/
-/*
+    wait_ms(LONG_WAIT);
+    
     puts("\nLets change contrast");
     wait_ms(LONG_WAIT);
     contrast(DISABLE);
-    wait_ms(SHORT_WAIT);
+    wait_ms(LONG_WAIT);
     contrast(ENABLE);
-    wait_ms(SHORT_WAIT);
+    wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("\nLets change outline color ");
     wait_ms(LONG_WAIT);
     drawFilledCircle(50, 50, 20, Red);
@@ -55,8 +79,7 @@
     drawFilledCircle(100, 50, 20, Red);
     wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("\nLets change all the ");
     textFgColor(Purple);
     puts("PURPLE");
@@ -67,8 +90,7 @@
     changeColor(Purple, Yellow);
     wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("Lets draw some shapes:");
     wait_ms(SHORT_WAIT);
     drawCircle(100, 100, 20, Aqua);
@@ -100,11 +122,12 @@
     drawElipse(200, 130, 20, 10, Olive);
     wait_ms(SHORT_WAIT);
     drawFilledElipse(200, 100, 30, 20, Navy);
+    wait_ms(SHORT_WAIT);
     linePatern(10);
     drawLine(200, 200, 100, 300, White);
     wait_ms(LONG_WAIT);
     cls();
-*/
+    
 /*
     // somehow after this function display stops (but the calculation is right)
     puts("Lets calculate distance from point 0,0 on angle 40, 60 pixels away:");
@@ -114,144 +137,137 @@
     wait_ms(SHORT_WAIT);
     cls();
 */
-/*
+
     puts("Lets draw some pixels:");
     wait_ms(LONG_WAIT);
-    putPixel(15, 15, White);
-    wait_ms(SHORT_WAIT);
-    putPixel(20, 20, Red);
-    wait_ms(SHORT_WAIT);
-    putPixel(25, 25, Green);
-    wait_ms(SHORT_WAIT);
-    putPixel(30, 30, Blue);
-    wait_ms(SHORT_WAIT);
-    putPixel(35, 35, Aqua);
+    cls();
+    for (int i = 0; i <= 10; i++) {
+        for (int j = 0; j <= 10; j++) {
+            putPixel(i, j, Red);
+        }
+    }
     wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("Lets move origin point:");
     wait_ms(LONG_WAIT);
     moveOrigin(100, 100);
     puts("This is the new origin!");
     wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("Now draw line from here:");
     wait_ms(SHORT_WAIT);
     lineTo(100, 100);
-    wait_ms(SHORT_WAIT);
+    wait_ms(LONG_WAIT);
     puts("To here!");
     wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("Change clipping window, to test it, we use changeColor function, that works only in clipping area:");
     wait_ms(LONG_WAIT);
+    wait_ms(LONG_WAIT);
     setClipWindow(0, 0, 200, 20);
     changeColor(Green, Red);
     puts("\n\n\rDone!!!!");
     wait_ms(LONG_WAIT);
     puts("\n\n\rNow extend to here!");
-    wait_ms(SHORT_WAIT);
+    wait_ms(LONG_WAIT);
     extendClipRegion();
     changeColor(Green, Red);
     puts("\n\n\rHow does it look?");
     wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("\nLets place a button:");
     wait_ms(LONG_WAIT);
     cls();
-    drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+    drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     puts("\n\n\n\nDid it work?");
     wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("\nNow lets change bevel width");
     wait_ms(LONG_WAIT);
     if (bevelWidth(0)) {
         puts("\nNo bevel");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
-    wait_ms(SHORT_WAIT);
+    wait_ms(LONG_WAIT);
     cls();
     if (bevelWidth(1)) {
         puts("\nbevel 1");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
-    wait_ms(SHORT_WAIT);
+    wait_ms(LONG_WAIT);
     cls();
     if (bevelWidth(10)) {
         puts("\nbevel 10");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
-    wait_ms(SHORT_WAIT);
+    wait_ms(LONG_WAIT);
     cls();
     if (bevelWidth(16)) {
         puts("\nbevel 16");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
-    wait_ms(SHORT_WAIT);
+    wait_ms(LONG_WAIT);
     cls();
     if (bevelWidth(2)) {
         puts("\nbevel 2");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
+    wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("\nNow lets change bevel shadow level");
     wait_ms(LONG_WAIT);
     if (bevelShadow(0)) {
         puts("\nNo shadow");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
     wait_ms(SHORT_WAIT);
     if (bevelShadow(1)) {
         puts("\nShadow 1");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
     wait_ms(SHORT_WAIT);
     if (bevelShadow(2)) {
         puts("\nShadow 2");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
     wait_ms(SHORT_WAIT);
     if (bevelShadow(3)) {
         puts("\nShadow 3");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
     wait_ms(SHORT_WAIT);
     if (bevelShadow(4)) {
         puts("\nShadow 4");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
     wait_ms(SHORT_WAIT);
     if (bevelShadow(5)) {
         puts("\nShadow 5");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
     wait_ms(SHORT_WAIT);
     if (bevelShadow(1)) {
         puts("\nShadow 1");
-        drawButton(DEPRESSED, 100, 200, Aqua, Violet, 2, 2, 2, "Press Me");
+        drawButton(DEPRESSED, 100, 100, Aqua, Violet, 2, 2, 2, "Press Me");
     }
+    wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("\nLets place a panel:");
     wait_ms(LONG_WAIT);
     cls();
-    drawPanel(DEPRESSED, 0, 0, 2, 2, Cream);
+    drawPanel(RECESSED, 0, 0, 200, 20, Cream);
+    wait_ms(SHORT_WAIT);
     puts("\nDid it work?");
     wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("\nLets place a slider:");
     wait_ms(LONG_WAIT);
     cls();
@@ -259,17 +275,17 @@
     puts("\nDid it work?");
     wait_ms(LONG_WAIT);
     cls();
-*/
-/*
+    
     puts("\nThis particular function is going to copy a specified portion of the creen and paste it somewhere else!");
     wait_ms(LONG_WAIT);
     wait_ms(LONG_WAIT);
+    wait_ms(LONG_WAIT);
     //cls();
     screenCopyPaste(0, 0, 50, 100, 200, 50);
     puts("\nDid it work?");
     wait_ms(LONG_WAIT);
     cls();
-*/
+    
     puts("\nLets get Xmax:");
     wait_ms(LONG_WAIT);
     short Xmax = getGraphics(currentXMax);
@@ -278,7 +294,7 @@
     short Ymax = getGraphics(currentYMax);
     wait_ms(LONG_WAIT);
     pc.printf("\nCurrent orientation xMax = %i, yMax = %i\n\r", Xmax, Ymax);
-    
+    cls();
 } 
 
 //**************************************************************************
@@ -290,10 +306,11 @@
     puts("This is the main functions demo");
     wait_ms(LONG_WAIT);
     cls();
-
+/*
     puts("\nBaudrates:");
     wait_ms(LONG_WAIT);
     cls();
+    
     baudrate(4800);
     puts("\n4800");
     wait_ms(SHORT_WAIT);
@@ -322,39 +339,11 @@
     puts("\n57600");
     wait_ms(SHORT_WAIT);
     cls();
-    baudrate(115200);
-    puts("\n115200");
-    wait_ms(SHORT_WAIT);
-    cls();
-    baudrate(128000);
-    puts("\n128000");
-    wait_ms(SHORT_WAIT);
-    cls();
-    baudrate(256000);
-    puts("\n256000");
-    wait_ms(SHORT_WAIT);
-    cls();
-    baudrate(300000);
-    puts("\n300000");
+    baudrate(9600);
+    puts("\n9600");
     wait_ms(SHORT_WAIT);
     cls();
-    baudrate(375000);
-    puts("\n375000");
-    wait_ms(SHORT_WAIT);
-    cls();
-    baudrate(500000);
-    puts("\n500000");
-    wait_ms(SHORT_WAIT);
-    cls();
-    baudrate(600000);
-    puts("\n600000");
-    wait_ms(SHORT_WAIT);
-    cls();
-    baudrate(115200);
-    puts("\nSet back to 115200");
-    wait_ms(LONG_WAIT);
-    cls();
-
+*/
     puts("\nOrientation:");
     wait_ms(LONG_WAIT);
     cls();
@@ -569,6 +558,7 @@
     textFgColor(Green); // set Color back
     cls();
     
+    screenMode(landscape);
     puts("Lets try moving cursor...");
     wait_ms(LONG_WAIT);
     cls();
@@ -576,7 +566,7 @@
     wait_ms(SHORT_WAIT);
     if (moveCursor(10, 10) == 1) puts("+");
     wait_ms(SHORT_WAIT);
-    screenMode(4);
+    screenMode(portraitRew);
     if (moveCursor(50, 50) == 1) puts("+");
     wait_ms(SHORT_WAIT);
     if (moveCursor(19, 29) == 1) puts("+");