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