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