EmbeddedArtists AB
/
app_lcdboard_demo_mandelbrot
Example for the LPC4088 QSB Base Board
MandelbDemo.h@0:7ce952ea2c4c, 2014-01-08 (annotated)
- Committer:
- embeddedartists
- Date:
- Wed Jan 08 10:17:43 2014 +0000
- Revision:
- 0:7ce952ea2c4c
First version
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:7ce952ea2c4c | 1 | |
embeddedartists | 0:7ce952ea2c4c | 2 | #ifndef MANDELBDEMO_H |
embeddedartists | 0:7ce952ea2c4c | 3 | #define MANDELBDEMO_H |
embeddedartists | 0:7ce952ea2c4c | 4 | |
embeddedartists | 0:7ce952ea2c4c | 5 | #include "Graphics.h" |
embeddedartists | 0:7ce952ea2c4c | 6 | #include "GFXFb.h" |
embeddedartists | 0:7ce952ea2c4c | 7 | |
embeddedartists | 0:7ce952ea2c4c | 8 | class MandelbDemo : public Graphics { |
embeddedartists | 0:7ce952ea2c4c | 9 | public: |
embeddedartists | 0:7ce952ea2c4c | 10 | |
embeddedartists | 0:7ce952ea2c4c | 11 | typedef struct |
embeddedartists | 0:7ce952ea2c4c | 12 | { |
embeddedartists | 0:7ce952ea2c4c | 13 | uint8_t xx; |
embeddedartists | 0:7ce952ea2c4c | 14 | uint8_t yy; |
embeddedartists | 0:7ce952ea2c4c | 15 | uint8_t rr; |
embeddedartists | 0:7ce952ea2c4c | 16 | uint8_t skip; |
embeddedartists | 0:7ce952ea2c4c | 17 | } Coord_t; |
embeddedartists | 0:7ce952ea2c4c | 18 | |
embeddedartists | 0:7ce952ea2c4c | 19 | /** Set the address of the frame buffer to use. |
embeddedartists | 0:7ce952ea2c4c | 20 | * |
embeddedartists | 0:7ce952ea2c4c | 21 | * It is the content of the frame buffer that is shown on the |
embeddedartists | 0:7ce952ea2c4c | 22 | * display. All the drawing on the frame buffer can be done |
embeddedartists | 0:7ce952ea2c4c | 23 | * 'offline' and whenever it should be shown this function |
embeddedartists | 0:7ce952ea2c4c | 24 | * can be called with the address of the offline frame buffer. |
embeddedartists | 0:7ce952ea2c4c | 25 | * |
embeddedartists | 0:7ce952ea2c4c | 26 | * @param pFrameBuf Pointer to the frame buffer, which must be |
embeddedartists | 0:7ce952ea2c4c | 27 | * 3 times as big as the frame size (for tripple |
embeddedartists | 0:7ce952ea2c4c | 28 | * buffering). |
embeddedartists | 0:7ce952ea2c4c | 29 | * dispWidth The width of the display (in pixels). |
embeddedartists | 0:7ce952ea2c4c | 30 | * dispHeight The height of the display (in pixels). |
embeddedartists | 0:7ce952ea2c4c | 31 | * loops Number of loops in the demo code. |
embeddedartists | 0:7ce952ea2c4c | 32 | * delayMs Delay in milliseconds between schreen updates. |
embeddedartists | 0:7ce952ea2c4c | 33 | * |
embeddedartists | 0:7ce952ea2c4c | 34 | * @returns |
embeddedartists | 0:7ce952ea2c4c | 35 | * none |
embeddedartists | 0:7ce952ea2c4c | 36 | */ |
embeddedartists | 0:7ce952ea2c4c | 37 | MandelbDemo(uint8_t *pFrameBuf, uint16_t dispWidth, uint16_t dispHeight); |
embeddedartists | 0:7ce952ea2c4c | 38 | |
embeddedartists | 0:7ce952ea2c4c | 39 | void run(uint32_t loops, uint32_t delayMs); |
embeddedartists | 0:7ce952ea2c4c | 40 | |
embeddedartists | 0:7ce952ea2c4c | 41 | protected: |
embeddedartists | 0:7ce952ea2c4c | 42 | virtual void plot4points( int32_t cx, int32_t cy, int32_t x, int32_t y, int16_t color, int32_t doMandel ); |
embeddedartists | 0:7ce952ea2c4c | 43 | |
embeddedartists | 0:7ce952ea2c4c | 44 | private: |
embeddedartists | 0:7ce952ea2c4c | 45 | |
embeddedartists | 0:7ce952ea2c4c | 46 | enum Constants { |
embeddedartists | 0:7ce952ea2c4c | 47 | UPDATE_ZONE_COLOR = 0x39e7, //DARK_GRAY |
embeddedartists | 0:7ce952ea2c4c | 48 | |
embeddedartists | 0:7ce952ea2c4c | 49 | // Width and Height of Mandelbrot (which will be a square) |
embeddedartists | 0:7ce952ea2c4c | 50 | MANDEL_WIDTH = 250, |
embeddedartists | 0:7ce952ea2c4c | 51 | MANDEL_HEIGHT = MANDEL_WIDTH, |
embeddedartists | 0:7ce952ea2c4c | 52 | |
embeddedartists | 0:7ce952ea2c4c | 53 | // Number of iterations before the Mandelbrot function stops |
embeddedartists | 0:7ce952ea2c4c | 54 | MAXITERATIONS = 256 |
embeddedartists | 0:7ce952ea2c4c | 55 | }; |
embeddedartists | 0:7ce952ea2c4c | 56 | |
embeddedartists | 0:7ce952ea2c4c | 57 | int32_t windowX; |
embeddedartists | 0:7ce952ea2c4c | 58 | int32_t windowY; |
embeddedartists | 0:7ce952ea2c4c | 59 | uint16_t *pFrmBuf; |
embeddedartists | 0:7ce952ea2c4c | 60 | uint16_t *pFrmBuf1; |
embeddedartists | 0:7ce952ea2c4c | 61 | uint16_t *pFrmBuf2; |
embeddedartists | 0:7ce952ea2c4c | 62 | uint16_t *pFrmBuf3; |
embeddedartists | 0:7ce952ea2c4c | 63 | |
embeddedartists | 0:7ce952ea2c4c | 64 | //Graphics graphics; |
embeddedartists | 0:7ce952ea2c4c | 65 | |
embeddedartists | 0:7ce952ea2c4c | 66 | // Color mapping array |
embeddedartists | 0:7ce952ea2c4c | 67 | uint16_t cols[MAXITERATIONS + 1]; |
embeddedartists | 0:7ce952ea2c4c | 68 | |
embeddedartists | 0:7ce952ea2c4c | 69 | // Color of pixel to be plotted |
embeddedartists | 0:7ce952ea2c4c | 70 | uint32_t color; |
embeddedartists | 0:7ce952ea2c4c | 71 | |
embeddedartists | 0:7ce952ea2c4c | 72 | // real and imaginary part of the pixel p |
embeddedartists | 0:7ce952ea2c4c | 73 | float pixel_real; |
embeddedartists | 0:7ce952ea2c4c | 74 | float pixel_imag; |
embeddedartists | 0:7ce952ea2c4c | 75 | |
embeddedartists | 0:7ce952ea2c4c | 76 | //real and imaginary parts of new and old z |
embeddedartists | 0:7ce952ea2c4c | 77 | float newReal; |
embeddedartists | 0:7ce952ea2c4c | 78 | float newImag; |
embeddedartists | 0:7ce952ea2c4c | 79 | float oldReal; |
embeddedartists | 0:7ce952ea2c4c | 80 | float oldImag; |
embeddedartists | 0:7ce952ea2c4c | 81 | |
embeddedartists | 0:7ce952ea2c4c | 82 | // Zoom and position within image |
embeddedartists | 0:7ce952ea2c4c | 83 | float zoom; |
embeddedartists | 0:7ce952ea2c4c | 84 | float moveX; |
embeddedartists | 0:7ce952ea2c4c | 85 | float moveY; |
embeddedartists | 0:7ce952ea2c4c | 86 | |
embeddedartists | 0:7ce952ea2c4c | 87 | // For loop counters |
embeddedartists | 0:7ce952ea2c4c | 88 | // int x; |
embeddedartists | 0:7ce952ea2c4c | 89 | // int y; |
embeddedartists | 0:7ce952ea2c4c | 90 | |
embeddedartists | 0:7ce952ea2c4c | 91 | uint32_t iterate( int32_t x, int32_t y ); |
embeddedartists | 0:7ce952ea2c4c | 92 | |
embeddedartists | 0:7ce952ea2c4c | 93 | unsigned short qsqrt(unsigned long a) const; |
embeddedartists | 0:7ce952ea2c4c | 94 | }; |
embeddedartists | 0:7ce952ea2c4c | 95 | |
embeddedartists | 0:7ce952ea2c4c | 96 | #endif /* MANDELBDEMO_H */ |
embeddedartists | 0:7ce952ea2c4c | 97 |