Shows how to use the display. Draws circles that bounce around on the display.

Dependencies:   DmTftLibrary mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BubbleDemo.h Source File

BubbleDemo.h

00001 
00002 #ifndef BUBBLEDEMO_H
00003 #define BUBBLEDEMO_H
00004 
00005 #include "DmTftBase.h"
00006 
00007 class BubbleDemo {
00008 public:
00009 
00010     enum Constants {
00011         NumBalls = 4 // 17
00012     };
00013 
00014     /** Set the address of the frame buffer to use.
00015      *
00016      *  It is the content of the frame buffer that is shown on the
00017      *  display. All the drawing on the frame buffer can be done
00018      *  'offline' and whenever it should be shown this function
00019      *  can be called with the address of the offline frame buffer.
00020      *
00021      *  @param pFrameBuf  Pointer to the frame buffer, which must be
00022      *                    3 times as big as the frame size (for tripple
00023      *                    buffering).
00024      *         dispWidth  The width of the display (in pixels).
00025      *         dispHeight The height of the display (in pixels).
00026      *         loops      Number of loops in the demo code.
00027      *         delayMs    Delay in milliseconds between schreen updates.
00028      *
00029      *  @returns
00030      *       none
00031      */
00032     BubbleDemo(DmTftBase* display, uint16_t dispWidth, uint16_t dispHeight);
00033     
00034     void run(uint32_t loops, uint32_t delayMs);
00035 
00036 private:
00037     int32_t windowX;
00038     int32_t windowY;
00039     
00040     DmTftBase* tft;
00041     
00042     uint8_t i;
00043     uint8_t j;
00044     
00045     float x[NumBalls];
00046     float y[NumBalls];
00047     uint8_t r[NumBalls];
00048     
00049     float oldX[NumBalls];
00050     float oldY[NumBalls];
00051     
00052     float velX[NumBalls];
00053     float velY[NumBalls];
00054     
00055     uint8_t red[NumBalls];
00056     uint8_t green[NumBalls];
00057     uint8_t blue[NumBalls];
00058     
00059     
00060     void initialize();
00061     void collision();
00062     void borders();
00063     void draw();
00064 };
00065 
00066 #endif /* BUBBLEDEMO_H */
00067 
00068