Graphical demo for the LPC4088 Experiment Base Board with one of the Display Expansion Kits. This program displays a number of dots in a 3D-projected wave.

Dependencies:   EALib mbed

Committer:
embeddedartists
Date:
Fri Oct 03 13:37:30 2014 +0000
Revision:
0:d1e4929f6956
First version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
embeddedartists 0:d1e4929f6956 1
embeddedartists 0:d1e4929f6956 2 #ifndef WAVEDEMO_H
embeddedartists 0:d1e4929f6956 3 #define WAVEDEMO_H
embeddedartists 0:d1e4929f6956 4
embeddedartists 0:d1e4929f6956 5 #include "Graphics.h"
embeddedartists 0:d1e4929f6956 6 #include "GFXFb.h"
embeddedartists 0:d1e4929f6956 7
embeddedartists 0:d1e4929f6956 8 #include "EaLcdBoardGPIO.h"
embeddedartists 0:d1e4929f6956 9
embeddedartists 0:d1e4929f6956 10 class WaveDemo {
embeddedartists 0:d1e4929f6956 11 public:
embeddedartists 0:d1e4929f6956 12
embeddedartists 0:d1e4929f6956 13 /** Set the address of the frame buffer to use.
embeddedartists 0:d1e4929f6956 14 *
embeddedartists 0:d1e4929f6956 15 * It is the content of the frame buffer that is shown on the
embeddedartists 0:d1e4929f6956 16 * display. All the drawing on the frame buffer can be done
embeddedartists 0:d1e4929f6956 17 * 'offline' and whenever it should be shown this function
embeddedartists 0:d1e4929f6956 18 * can be called with the address of the offline frame buffer.
embeddedartists 0:d1e4929f6956 19 *
embeddedartists 0:d1e4929f6956 20 * @param pFrameBuf Pointer to the frame buffer, which must be
embeddedartists 0:d1e4929f6956 21 * 3 times as big as the frame size (for tripple
embeddedartists 0:d1e4929f6956 22 * buffering).
embeddedartists 0:d1e4929f6956 23 * dispWidth The width of the display (in pixels).
embeddedartists 0:d1e4929f6956 24 * dispHeight The height of the display (in pixels).
embeddedartists 0:d1e4929f6956 25 * loops Number of loops in the demo code.
embeddedartists 0:d1e4929f6956 26 * delayMs Delay in milliseconds between schreen updates.
embeddedartists 0:d1e4929f6956 27 *
embeddedartists 0:d1e4929f6956 28 * @returns
embeddedartists 0:d1e4929f6956 29 * none
embeddedartists 0:d1e4929f6956 30 */
embeddedartists 0:d1e4929f6956 31 WaveDemo(uint8_t *pFrameBuf, uint16_t dispWidth, uint16_t dispHeight);
embeddedartists 0:d1e4929f6956 32
embeddedartists 0:d1e4929f6956 33 void run(EaLcdBoardGPIO& lcdBoard, uint32_t loops, uint32_t delayMs);
embeddedartists 0:d1e4929f6956 34
embeddedartists 0:d1e4929f6956 35 private:
embeddedartists 0:d1e4929f6956 36
embeddedartists 0:d1e4929f6956 37 enum Constants {
embeddedartists 0:d1e4929f6956 38 N = 1024, // Number of dots
embeddedartists 0:d1e4929f6956 39 SCALE = 8192,
embeddedartists 0:d1e4929f6956 40 INCREMENT = 512, // INCREMENT = SCALE / sqrt(N) * 2
embeddedartists 0:d1e4929f6956 41 SPEED = 5
embeddedartists 0:d1e4929f6956 42 };
embeddedartists 0:d1e4929f6956 43
embeddedartists 0:d1e4929f6956 44 int32_t windowX;
embeddedartists 0:d1e4929f6956 45 int32_t windowY;
embeddedartists 0:d1e4929f6956 46 uint16_t *pFrmBuf;
embeddedartists 0:d1e4929f6956 47 uint16_t *pFrmBuf1;
embeddedartists 0:d1e4929f6956 48 uint16_t *pFrmBuf2;
embeddedartists 0:d1e4929f6956 49 uint16_t *pFrmBuf3;
embeddedartists 0:d1e4929f6956 50
embeddedartists 0:d1e4929f6956 51 Graphics graphics;
embeddedartists 0:d1e4929f6956 52
embeddedartists 0:d1e4929f6956 53 int16_t sine[SCALE];
embeddedartists 0:d1e4929f6956 54 int16_t cosi[SCALE];
embeddedartists 0:d1e4929f6956 55
embeddedartists 0:d1e4929f6956 56 uint16_t fastsqrt(uint32_t n) const;
embeddedartists 0:d1e4929f6956 57 void matrix(int16_t xyz[3][N], uint8_t rgb[3][N]);
embeddedartists 0:d1e4929f6956 58 void rotate(int16_t xyz[3][N], uint8_t rgb[3][N], uint16_t angleX, uint16_t angleY, uint16_t angleZ);
embeddedartists 0:d1e4929f6956 59 void draw(int16_t xyz[3][N], uint8_t rgb[3][N]);
embeddedartists 0:d1e4929f6956 60 };
embeddedartists 0:d1e4929f6956 61
embeddedartists 0:d1e4929f6956 62 #endif /* WAVEDEMO_H */
embeddedartists 0:d1e4929f6956 63