![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Working Menu with selectable fields yet to add comparison with healthy temperature ranges
Dependencies: TMP102_02
Bitmap/Bitmap.h@1:e11018cf2c14, 2022-02-01 (annotated)
- Committer:
- ejh23
- Date:
- Tue Feb 01 15:31:24 2022 +0000
- Revision:
- 1:e11018cf2c14
added menu with time out function - after X seconds screen is off and device sleeps
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ejh23 | 1:e11018cf2c14 | 1 | #ifndef BITMAP_H |
ejh23 | 1:e11018cf2c14 | 2 | #define BITMAP_H |
ejh23 | 1:e11018cf2c14 | 3 | |
ejh23 | 1:e11018cf2c14 | 4 | #include <vector> |
ejh23 | 1:e11018cf2c14 | 5 | |
ejh23 | 1:e11018cf2c14 | 6 | // Forward declarations |
ejh23 | 1:e11018cf2c14 | 7 | class N5110; |
ejh23 | 1:e11018cf2c14 | 8 | |
ejh23 | 1:e11018cf2c14 | 9 | /** |
ejh23 | 1:e11018cf2c14 | 10 | * @brief A black & white bitmap that can be rendered on an N5110 screen |
ejh23 | 1:e11018cf2c14 | 11 | * |
ejh23 | 1:e11018cf2c14 | 12 | * |
ejh23 | 1:e11018cf2c14 | 13 | * @code |
ejh23 | 1:e11018cf2c14 | 14 | // First declare the pixel map data using '1' for black, |
ejh23 | 1:e11018cf2c14 | 15 | // or '0' for white pixels |
ejh23 | 1:e11018cf2c14 | 16 | static int sprite_data[] = { |
ejh23 | 1:e11018cf2c14 | 17 | 0,0,1,0,0, |
ejh23 | 1:e11018cf2c14 | 18 | 0,1,1,1,0, |
ejh23 | 1:e11018cf2c14 | 19 | 0,0,1,0,0, |
ejh23 | 1:e11018cf2c14 | 20 | 0,1,1,1,0, |
ejh23 | 1:e11018cf2c14 | 21 | 1,1,1,1,1, |
ejh23 | 1:e11018cf2c14 | 22 | 1,1,1,1,1, |
ejh23 | 1:e11018cf2c14 | 23 | 1,1,0,1,1, |
ejh23 | 1:e11018cf2c14 | 24 | 1,1,0,1,1 |
ejh23 | 1:e11018cf2c14 | 25 | }; |
ejh23 | 1:e11018cf2c14 | 26 | |
ejh23 | 1:e11018cf2c14 | 27 | // Instantiate the Bitmap object using the data above |
ejh23 | 1:e11018cf2c14 | 28 | Bitmap sprite(sprite_data, 8, 5); // Specify rows and columns in sprite |
ejh23 | 1:e11018cf2c14 | 29 | |
ejh23 | 1:e11018cf2c14 | 30 | // We can render the bitmap wherever we want on the screen |
ejh23 | 1:e11018cf2c14 | 31 | sprite.render(lcd, 20, 6); // x and y locations for rendering |
ejh23 | 1:e11018cf2c14 | 32 | sprite.render(lcd, 30, 10); |
ejh23 | 1:e11018cf2c14 | 33 | |
ejh23 | 1:e11018cf2c14 | 34 | // We can also print its values to the terminal |
ejh23 | 1:e11018cf2c14 | 35 | sprite.print(); |
ejh23 | 1:e11018cf2c14 | 36 | * @endcode |
ejh23 | 1:e11018cf2c14 | 37 | */ |
ejh23 | 1:e11018cf2c14 | 38 | class Bitmap |
ejh23 | 1:e11018cf2c14 | 39 | { |
ejh23 | 1:e11018cf2c14 | 40 | private: |
ejh23 | 1:e11018cf2c14 | 41 | /** |
ejh23 | 1:e11018cf2c14 | 42 | * @brief The contents of the drawing, with pixels stored in row-major order |
ejh23 | 1:e11018cf2c14 | 43 | * @details '1' represents a black pixel; '0' represents white |
ejh23 | 1:e11018cf2c14 | 44 | */ |
ejh23 | 1:e11018cf2c14 | 45 | std::vector<int> _contents; |
ejh23 | 1:e11018cf2c14 | 46 | |
ejh23 | 1:e11018cf2c14 | 47 | unsigned int _height; ///< The height of the drawing in pixels |
ejh23 | 1:e11018cf2c14 | 48 | unsigned int _width; ///< The width of the drawing in pixels |
ejh23 | 1:e11018cf2c14 | 49 | |
ejh23 | 1:e11018cf2c14 | 50 | public: |
ejh23 | 1:e11018cf2c14 | 51 | Bitmap(int const *contents, |
ejh23 | 1:e11018cf2c14 | 52 | unsigned int const height, |
ejh23 | 1:e11018cf2c14 | 53 | unsigned int const width); |
ejh23 | 1:e11018cf2c14 | 54 | |
ejh23 | 1:e11018cf2c14 | 55 | int get_pixel(unsigned int const row, |
ejh23 | 1:e11018cf2c14 | 56 | unsigned int const column) const; |
ejh23 | 1:e11018cf2c14 | 57 | |
ejh23 | 1:e11018cf2c14 | 58 | void print() const; |
ejh23 | 1:e11018cf2c14 | 59 | |
ejh23 | 1:e11018cf2c14 | 60 | void render(N5110 &lcd, |
ejh23 | 1:e11018cf2c14 | 61 | unsigned int const x0, |
ejh23 | 1:e11018cf2c14 | 62 | unsigned int const y0) const; |
ejh23 | 1:e11018cf2c14 | 63 | }; |
ejh23 | 1:e11018cf2c14 | 64 | |
ejh23 | 1:e11018cf2c14 | 65 | #endif // BITMAP_H |