Graphical demo for the LPC4088 Experiment Base Board with one of the Display Expansion Kits. This demo shows a number of bubbles bouncing around.

Dependencies:   EALib mbed

Committer:
embeddedartists
Date:
Fri Oct 03 13:09:11 2014 +0000
Revision:
0:4839ec6c350d
First version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:4839ec6c350d 1
embeddedartists 0:4839ec6c350d 2 #ifndef BUBBLEDEMO_H
embeddedartists 0:4839ec6c350d 3 #define BUBBLEDEMO_H
embeddedartists 0:4839ec6c350d 4
embeddedartists 0:4839ec6c350d 5 #include "Graphics.h"
embeddedartists 0:4839ec6c350d 6 #include "EaLcdBoardGPIO.h"
embeddedartists 0:4839ec6c350d 7
embeddedartists 0:4839ec6c350d 8 class BubbleDemo {
embeddedartists 0:4839ec6c350d 9 public:
embeddedartists 0:4839ec6c350d 10
embeddedartists 0:4839ec6c350d 11 enum Constants {
embeddedartists 0:4839ec6c350d 12 NumBalls = 17
embeddedartists 0:4839ec6c350d 13 };
embeddedartists 0:4839ec6c350d 14
embeddedartists 0:4839ec6c350d 15 /** Set the address of the frame buffer to use.
embeddedartists 0:4839ec6c350d 16 *
embeddedartists 0:4839ec6c350d 17 * It is the content of the frame buffer that is shown on the
embeddedartists 0:4839ec6c350d 18 * display. All the drawing on the frame buffer can be done
embeddedartists 0:4839ec6c350d 19 * 'offline' and whenever it should be shown this function
embeddedartists 0:4839ec6c350d 20 * can be called with the address of the offline frame buffer.
embeddedartists 0:4839ec6c350d 21 *
embeddedartists 0:4839ec6c350d 22 * @param pFrameBuf Pointer to the frame buffer, which must be
embeddedartists 0:4839ec6c350d 23 * 3 times as big as the frame size (for tripple
embeddedartists 0:4839ec6c350d 24 * buffering).
embeddedartists 0:4839ec6c350d 25 * dispWidth The width of the display (in pixels).
embeddedartists 0:4839ec6c350d 26 * dispHeight The height of the display (in pixels).
embeddedartists 0:4839ec6c350d 27 * loops Number of loops in the demo code.
embeddedartists 0:4839ec6c350d 28 * delayMs Delay in milliseconds between schreen updates.
embeddedartists 0:4839ec6c350d 29 *
embeddedartists 0:4839ec6c350d 30 * @returns
embeddedartists 0:4839ec6c350d 31 * none
embeddedartists 0:4839ec6c350d 32 */
embeddedartists 0:4839ec6c350d 33 BubbleDemo(uint8_t *pFrameBuf, uint16_t dispWidth, uint16_t dispHeight);
embeddedartists 0:4839ec6c350d 34
embeddedartists 0:4839ec6c350d 35 void run(EaLcdBoardGPIO& lcdBoard, uint32_t loops, uint32_t delayMs);
embeddedartists 0:4839ec6c350d 36
embeddedartists 0:4839ec6c350d 37 private:
embeddedartists 0:4839ec6c350d 38 int32_t windowX;
embeddedartists 0:4839ec6c350d 39 int32_t windowY;
embeddedartists 0:4839ec6c350d 40 uint16_t *pFrmBuf;
embeddedartists 0:4839ec6c350d 41 uint16_t *pFrmBuf1;
embeddedartists 0:4839ec6c350d 42 uint16_t *pFrmBuf2;
embeddedartists 0:4839ec6c350d 43 uint16_t *pFrmBuf3;
embeddedartists 0:4839ec6c350d 44
embeddedartists 0:4839ec6c350d 45 Graphics graphics;
embeddedartists 0:4839ec6c350d 46
embeddedartists 0:4839ec6c350d 47 uint8_t i;
embeddedartists 0:4839ec6c350d 48 uint8_t j;
embeddedartists 0:4839ec6c350d 49
embeddedartists 0:4839ec6c350d 50 float x[NumBalls];
embeddedartists 0:4839ec6c350d 51 float y[NumBalls];
embeddedartists 0:4839ec6c350d 52 uint8_t r[NumBalls];
embeddedartists 0:4839ec6c350d 53
embeddedartists 0:4839ec6c350d 54 float oldX[NumBalls];
embeddedartists 0:4839ec6c350d 55 float oldY[NumBalls];
embeddedartists 0:4839ec6c350d 56
embeddedartists 0:4839ec6c350d 57 float velX[NumBalls];
embeddedartists 0:4839ec6c350d 58 float velY[NumBalls];
embeddedartists 0:4839ec6c350d 59
embeddedartists 0:4839ec6c350d 60 uint8_t red[NumBalls];
embeddedartists 0:4839ec6c350d 61 uint8_t green[NumBalls];
embeddedartists 0:4839ec6c350d 62 uint8_t blue[NumBalls];
embeddedartists 0:4839ec6c350d 63
embeddedartists 0:4839ec6c350d 64
embeddedartists 0:4839ec6c350d 65 void initialize();
embeddedartists 0:4839ec6c350d 66 void collision();
embeddedartists 0:4839ec6c350d 67 void borders();
embeddedartists 0:4839ec6c350d 68 void draw();
embeddedartists 0:4839ec6c350d 69 };
embeddedartists 0:4839ec6c350d 70
embeddedartists 0:4839ec6c350d 71 #endif /* BUBBLEDEMO_H */
embeddedartists 0:4839ec6c350d 72