Unix-style Fortune teller text display on LCD

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed

Revision:
2:7507d0c0e509
Parent:
1:4d5e6b8edd00
diff -r 4d5e6b8edd00 -r 7507d0c0e509 main.cpp
--- a/main.cpp	Mon Mar 09 02:44:24 2015 +0000
+++ b/main.cpp	Thu Mar 12 17:55:45 2015 +0000
@@ -10,33 +10,24 @@
     char buffer[300]; //buffer to store the quotation
     float rando=0; //variable responsible to receive the random value
     uLCD.cls(); //clear the screen
-    printf("Hello\n"); //check the conection with the computer
-
-    mkdir("/sd/mydir", 0777); //create a folder calle mydir
-    //Create the file with the quotations
-    FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
-    if(fp == NULL) {
-        error("Could not open file for write\n");
-    }
-    fprintf(fp, "It is much harder to find a job than to keep one.\nNo act of kindness, no matter how small, is ever wasted.   -- Aesop\nDistance doesn't make you any smaller, but it does make you part of a larger picture.\nGod instructs the heart, not by ideas, but by pains and contradictions.   -- De Caussade\nYou can always tell the people that are forging the new frontier. They're the ones with arrows sticking out of their backs.\nMan belongs wherever he wants to go.   -- Wernher von Braun\nLife is too important to take seriously   -- Corky Siegel\nShe never liked zippers, she said, until she opened one in bed.\nSales tax applies.\nGod created a few perfect heads.  The rest he covered with hair.\n");
-    fclose(fp);
-     
-    printf("Press the button\n");//lets you know when the file is created
+    
     while (true){
         if (pb == 1){
             //open the file to be read
-            FILE *ft = fopen("/sd/mydir/sdtest.txt", "r+");
+            FILE *ft = fopen("/sd/sdtest.txt", "r+");
             if(ft == NULL) {
                 error("Could not open file for write\n");
             }
-            
             rando = rand()%10+1;//random value
             for(int i=0; i<rando; i++){ //copy to buffer the quotation of the random value
                 fgets(buffer, 300, ft);
             }
+            uLCD.background_color(WHITE);
             uLCD.cls();
+            uLCD.background_color(WHITE);
+            uLCD.textbackground_color(WHITE);
+            uLCD.color(BLACK);
             uLCD.printf("%s\n", buffer); //prints in the scrren the string
-            printf("%s\n", buffer);
             fclose(ft);
             wait(0.2); 
         }