(DA) Internet of Things and Smart Electronics- ELE3006M2122 / Mbed 2 deprecated Final_Project_V15_DLeaming_25574043

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Bitmap.h Source File

Bitmap.h

00001 /* * Print String
00002 *
00003 * Prints a string of characters to the screen buffer, string is cut off after the 83rd  pixel.
00004 * @param x - the column number (0 to 83)
00005 * @param y - the row number (0-5) - the display is split into 6 banks - each bank can be considered a row
00006 * @author - David Leaming - 25574043
00007 * @ Date - December 2021
00008 *
00009 * Acknowledgements 
00010 * Craig A. Evans, University of Leeds, TMP102 Library ,Feb 2016
00011 * Dr Edmond Nurellari, University of Lincoln, Joystick & N5110 Libraries
00012 *
00013 */ 
00014 
00015 #ifndef BITMAP_H
00016 #define BITMAP_H
00017 
00018 #include <vector>
00019 
00020 // Forward declarations
00021 class N5110;
00022 
00023 /**
00024  * @brief  A black & white bitmap that can be rendered on an N5110 screen
00025  * 
00026  * 
00027  * @code
00028   // First declare the pixel map data using '1' for black,
00029   // or '0' for white pixels
00030   static int sprite_data[] = {
00031     0,0,1,0,0,
00032     0,1,1,1,0,
00033     0,0,1,0,0,
00034     0,1,1,1,0,
00035     1,1,1,1,1,
00036     1,1,1,1,1,
00037     1,1,0,1,1,
00038     1,1,0,1,1
00039   };
00040 
00041   // Instantiate the Bitmap object using the data above
00042   Bitmap sprite(sprite_data, 8, 5); // Specify rows and columns in sprite
00043   
00044   // We can render the bitmap wherever we want on the screen
00045   sprite.render(lcd, 20, 6); // x and y locations for rendering
00046   sprite.render(lcd, 30, 10);
00047   
00048   // We can also print its values to the terminal
00049   sprite.print();
00050  * @endcode
00051  */
00052 class Bitmap
00053 {
00054 private:
00055     /**
00056      * @brief The contents of the drawing, with pixels stored in row-major order
00057      * @details '1' represents a black pixel; '0' represents white
00058      */
00059     std::vector<int> _contents;
00060     
00061     unsigned int _height; ///< The height of the drawing in pixels
00062     unsigned int _width;  ///< The width of the drawing in pixels
00063     
00064 public:
00065     Bitmap(int const          *contents,
00066            unsigned int const  height,
00067            unsigned int const  width);
00068 
00069     int get_pixel (unsigned int const row,
00070                   unsigned int const column) const;
00071 
00072     void print() const;
00073 
00074     void render(N5110 &lcd,
00075                 unsigned int const x0,
00076                 unsigned int const y0) const;
00077 };
00078 
00079 #endif // BITMAP_H