Final tidy of code following installation of new sensor, more comments added prior to submission

Dependencies:   mbed

Committer:
legstar85
Date:
Fri Jan 21 14:26:56 2022 +0000
Revision:
13:5ad65a688f3f
Updated due to issues with using Start Temp variable later in program now resolved. Doxygen completed and folders in place correctly

Who changed what in which revision?

UserRevisionLine numberNew contents of line
legstar85 13:5ad65a688f3f 1 /* * Print String
legstar85 13:5ad65a688f3f 2 *
legstar85 13:5ad65a688f3f 3 * Prints a string of characters to the screen buffer, string is cut off after the 83rd pixel.
legstar85 13:5ad65a688f3f 4 * @param x - the column number (0 to 83)
legstar85 13:5ad65a688f3f 5 * @param y - the row number (0-5) - the display is split into 6 banks - each bank can be considered a row
legstar85 13:5ad65a688f3f 6 * @author - David Leaming - 25574043
legstar85 13:5ad65a688f3f 7 * @ Date - December 2021
legstar85 13:5ad65a688f3f 8 *
legstar85 13:5ad65a688f3f 9 * Acknowledgements
legstar85 13:5ad65a688f3f 10 * Craig A. Evans, University of Leeds, TMP102 Library ,Feb 2016
legstar85 13:5ad65a688f3f 11 * Dr Edmond Nurellari, University of Lincoln, Joystick & N5110 Libraries
legstar85 13:5ad65a688f3f 12 *
legstar85 13:5ad65a688f3f 13 */
legstar85 13:5ad65a688f3f 14
legstar85 13:5ad65a688f3f 15 #ifndef BITMAP_H
legstar85 13:5ad65a688f3f 16 #define BITMAP_H
legstar85 13:5ad65a688f3f 17
legstar85 13:5ad65a688f3f 18 #include <vector>
legstar85 13:5ad65a688f3f 19
legstar85 13:5ad65a688f3f 20 // Forward declarations
legstar85 13:5ad65a688f3f 21 class N5110;
legstar85 13:5ad65a688f3f 22
legstar85 13:5ad65a688f3f 23 /**
legstar85 13:5ad65a688f3f 24 * @brief A black & white bitmap that can be rendered on an N5110 screen
legstar85 13:5ad65a688f3f 25 *
legstar85 13:5ad65a688f3f 26 *
legstar85 13:5ad65a688f3f 27 * @code
legstar85 13:5ad65a688f3f 28 // First declare the pixel map data using '1' for black,
legstar85 13:5ad65a688f3f 29 // or '0' for white pixels
legstar85 13:5ad65a688f3f 30 static int sprite_data[] = {
legstar85 13:5ad65a688f3f 31 0,0,1,0,0,
legstar85 13:5ad65a688f3f 32 0,1,1,1,0,
legstar85 13:5ad65a688f3f 33 0,0,1,0,0,
legstar85 13:5ad65a688f3f 34 0,1,1,1,0,
legstar85 13:5ad65a688f3f 35 1,1,1,1,1,
legstar85 13:5ad65a688f3f 36 1,1,1,1,1,
legstar85 13:5ad65a688f3f 37 1,1,0,1,1,
legstar85 13:5ad65a688f3f 38 1,1,0,1,1
legstar85 13:5ad65a688f3f 39 };
legstar85 13:5ad65a688f3f 40
legstar85 13:5ad65a688f3f 41 // Instantiate the Bitmap object using the data above
legstar85 13:5ad65a688f3f 42 Bitmap sprite(sprite_data, 8, 5); // Specify rows and columns in sprite
legstar85 13:5ad65a688f3f 43
legstar85 13:5ad65a688f3f 44 // We can render the bitmap wherever we want on the screen
legstar85 13:5ad65a688f3f 45 sprite.render(lcd, 20, 6); // x and y locations for rendering
legstar85 13:5ad65a688f3f 46 sprite.render(lcd, 30, 10);
legstar85 13:5ad65a688f3f 47
legstar85 13:5ad65a688f3f 48 // We can also print its values to the terminal
legstar85 13:5ad65a688f3f 49 sprite.print();
legstar85 13:5ad65a688f3f 50 * @endcode
legstar85 13:5ad65a688f3f 51 */
legstar85 13:5ad65a688f3f 52 class Bitmap
legstar85 13:5ad65a688f3f 53 {
legstar85 13:5ad65a688f3f 54 private:
legstar85 13:5ad65a688f3f 55 /**
legstar85 13:5ad65a688f3f 56 * @brief The contents of the drawing, with pixels stored in row-major order
legstar85 13:5ad65a688f3f 57 * @details '1' represents a black pixel; '0' represents white
legstar85 13:5ad65a688f3f 58 */
legstar85 13:5ad65a688f3f 59 std::vector<int> _contents;
legstar85 13:5ad65a688f3f 60
legstar85 13:5ad65a688f3f 61 unsigned int _height; ///< The height of the drawing in pixels
legstar85 13:5ad65a688f3f 62 unsigned int _width; ///< The width of the drawing in pixels
legstar85 13:5ad65a688f3f 63
legstar85 13:5ad65a688f3f 64 public:
legstar85 13:5ad65a688f3f 65 Bitmap(int const *contents,
legstar85 13:5ad65a688f3f 66 unsigned int const height,
legstar85 13:5ad65a688f3f 67 unsigned int const width);
legstar85 13:5ad65a688f3f 68
legstar85 13:5ad65a688f3f 69 int get_pixel(unsigned int const row,
legstar85 13:5ad65a688f3f 70 unsigned int const column) const;
legstar85 13:5ad65a688f3f 71
legstar85 13:5ad65a688f3f 72 void print() const;
legstar85 13:5ad65a688f3f 73
legstar85 13:5ad65a688f3f 74 void render(N5110 &lcd,
legstar85 13:5ad65a688f3f 75 unsigned int const x0,
legstar85 13:5ad65a688f3f 76 unsigned int const y0) const;
legstar85 13:5ad65a688f3f 77 };
legstar85 13:5ad65a688f3f 78
legstar85 13:5ad65a688f3f 79 #endif // BITMAP_H