Basic swim GUI for LPC4088

Fork of DMBasicGUI by Embedded Artists

Revision:
11:265884fa7fdd
Parent:
10:651861441108
Child:
12:53601973f7eb
--- a/SlideShow/SlideShow.cpp	Mon Jan 26 10:06:58 2015 +0100
+++ b/SlideShow/SlideShow.cpp	Tue Feb 17 10:34:13 2015 +0100
@@ -189,7 +189,7 @@
           ss->rend->setFramebuffer(ss->rendHnd, ss->ImageBackBuffer);
 
           // Sleep and do over again
-          wait_ms(LeftRight_DelayMs);
+          Thread::wait(LeftRight_DelayMs);
         }
 
         // Show final image
@@ -197,24 +197,26 @@
       }
       break;
 
-      case DownUp:  // TODO: Note that this transition is only implemented for fullscreen mode
+      case DownUp:
       {
+        int imgNumPixels = NewImage->width * NewImage->height;
+
         // Create a buffer with the two images after each other, NewImage below
         if (CurrentImage == NULL) {
-          memset(ss->ImageBackBuffer, 0, ss->screenBytes);
+          memset(ss->ImageBackBuffer, 0, imgNumPixels*2);
         } else {
-          memcpy(ss->ImageBackBuffer, CurrentImage->pixels, ss->screenBytes);
+          memcpy(ss->ImageBackBuffer, CurrentImage->pixels, imgNumPixels*2);
         }
-        memcpy(ss->ImageBackBuffer+ss->screenPixels, NewImage->pixels, ss->screenBytes);
+        memcpy(ss->ImageBackBuffer + imgNumPixels, NewImage->pixels, imgNumPixels*2);
 
         // We will be using a back buffer
-        for (int i = DownUp_LineSkip/2; i < (ss->screenHeight-1); i+=DownUp_LineSkip)
+        for (int i = DownUp_LineSkip/2; i < (NewImage->height - 1); i+=DownUp_LineSkip)
         {
           // Show image by advancing what is shown one line at a time
-          ss->rend->setFramebuffer(ss->rendHnd, ss->ImageBackBuffer + i*ss->screenWidth);
+          ss->rend->setFramebuffer(ss->rendHnd, ss->ImageBackBuffer + i * NewImage->width);
 
           // Sleep and do over again
-          wait_ms(DownUp_DelayMs);
+          Thread::wait(DownUp_DelayMs);
         }
 
         // show final image
@@ -222,24 +224,26 @@
       }
       break;
 
-      case TopDown:  // TODO: Note that this transition is only implemented for fullscreen mode
+      case TopDown:
       {
+        int imgNumPixels = NewImage->width * NewImage->height;
+
         // Create a buffer with the two images after each other, NewImage above
         if (CurrentImage == NULL) {
-          memset(ss->ImageBackBuffer+ss->screenPixels, 0, ss->screenBytes);
+          memset(ss->ImageBackBuffer + imgNumPixels, 0, imgNumPixels*2);
         } else {
-          memcpy(ss->ImageBackBuffer+ss->screenPixels, CurrentImage->pixels, ss->screenBytes);
+          memcpy(ss->ImageBackBuffer + imgNumPixels, CurrentImage->pixels, imgNumPixels*2);
         }
-        memcpy(ss->ImageBackBuffer, NewImage->pixels, ss->screenBytes);
+        memcpy(ss->ImageBackBuffer, NewImage->pixels, imgNumPixels*2);
 
         // We will be using a back buffer
-        for (int i = ss->screenHeight - TopDown_LineSkip/2; i > 0; i-=TopDown_LineSkip)
+        for (int i = NewImage->height - TopDown_LineSkip/2; i > 0; i-=TopDown_LineSkip)
         {
           // Show image by advancing what is shown one line at a time
-          ss->rend->setFramebuffer(ss->rendHnd, ss->ImageBackBuffer + i*ss->screenWidth);
+          ss->rend->setFramebuffer(ss->rendHnd, ss->ImageBackBuffer + i*NewImage->width);
 
           // Sleep and do over again
-          wait_ms(TopDown_DelayMs);
+          Thread::wait(TopDown_DelayMs);
         }
 
         // show final image
@@ -280,11 +284,11 @@
           ss->rend->setFramebuffer(ss->rendHnd, ss->ImageBackBuffer);
 
           // Sleep and do over again
-          wait_ms(Blinds_DelayMs);
+          Thread::wait(Blinds_DelayMs);
         }
         memcpy(ss->ImageBackBuffer+i-blockNumPixels, bkgBlock, blockNumBytes);
         ss->rend->setFramebuffer(ss->rendHnd, ss->ImageBackBuffer);
-        wait_ms(Blinds_DelayMs);
+        Thread::wait(Blinds_DelayMs);
 
         for (i = 0; i < ss->screenPixels; i += blockNumPixels)
         {
@@ -300,7 +304,7 @@
           ss->rend->setFramebuffer(ss->rendHnd, ss->ImageBackBuffer);
 
           // Sleep and do over again
-          wait_ms(Blinds_DelayMs);
+          Thread::wait(Blinds_DelayMs);
         }
 
         // show final image
@@ -362,7 +366,7 @@
           ss->rend->setFramebuffer(ss->rendHnd, ss->ImageBackBuffer);
 
           // Sleep and do over again
-          wait_ms(Fade_DelayMs);
+          Thread::wait(Fade_DelayMs);
         }
 
         // show final image
@@ -758,7 +762,7 @@
 {
     int timeToWait = (lastTime + millis) - msTicks;
     if (timeToWait > 0) {
-        wait_ms(timeToWait);
+        Thread::wait(timeToWait);
     }
 }