Final Commit

Dependencies:   mbed

Committer:
JRM1986
Date:
Wed Feb 28 10:00:40 2018 +0000
Revision:
0:53ee0f689634
Initial Commit- ; Project named; Libraries imported; Libraries converted to folders

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JRM1986 0:53ee0f689634 1 #ifndef BITMAP_H
JRM1986 0:53ee0f689634 2 #define BITMAP_H
JRM1986 0:53ee0f689634 3
JRM1986 0:53ee0f689634 4 #include <vector>
JRM1986 0:53ee0f689634 5
JRM1986 0:53ee0f689634 6 // Forward declarations
JRM1986 0:53ee0f689634 7 class N5110;
JRM1986 0:53ee0f689634 8
JRM1986 0:53ee0f689634 9 /**
JRM1986 0:53ee0f689634 10 * @brief A black & white bitmap that can be rendered on an N5110 screen
JRM1986 0:53ee0f689634 11 * @author Alex Valavanis <a.valavanis@leeds.ac.uk>
JRM1986 0:53ee0f689634 12 *
JRM1986 0:53ee0f689634 13 * @code
JRM1986 0:53ee0f689634 14 // First declare the pixel map data using '1' for black,
JRM1986 0:53ee0f689634 15 // or '0' for white pixels
JRM1986 0:53ee0f689634 16 static int sprite_data[] = {
JRM1986 0:53ee0f689634 17 0,0,1,0,0,
JRM1986 0:53ee0f689634 18 0,1,1,1,0,
JRM1986 0:53ee0f689634 19 0,0,1,0,0,
JRM1986 0:53ee0f689634 20 0,1,1,1,0,
JRM1986 0:53ee0f689634 21 1,1,1,1,1,
JRM1986 0:53ee0f689634 22 1,1,1,1,1,
JRM1986 0:53ee0f689634 23 1,1,0,1,1,
JRM1986 0:53ee0f689634 24 1,1,0,1,1
JRM1986 0:53ee0f689634 25 };
JRM1986 0:53ee0f689634 26
JRM1986 0:53ee0f689634 27 // Instantiate the Bitmap object using the data above
JRM1986 0:53ee0f689634 28 Bitmap sprite(sprite_data, 8, 5); // Specify rows and columns in sprite
JRM1986 0:53ee0f689634 29
JRM1986 0:53ee0f689634 30 // We can render the bitmap wherever we want on the screen
JRM1986 0:53ee0f689634 31 sprite.render(lcd, 20, 6); // x and y locations for rendering
JRM1986 0:53ee0f689634 32 sprite.render(lcd, 30, 10);
JRM1986 0:53ee0f689634 33
JRM1986 0:53ee0f689634 34 // We can also print its values to the terminal
JRM1986 0:53ee0f689634 35 sprite.print();
JRM1986 0:53ee0f689634 36 * @endcode
JRM1986 0:53ee0f689634 37 */
JRM1986 0:53ee0f689634 38 class Bitmap
JRM1986 0:53ee0f689634 39 {
JRM1986 0:53ee0f689634 40 private:
JRM1986 0:53ee0f689634 41 /**
JRM1986 0:53ee0f689634 42 * @brief The contents of the drawing, with pixels stored in row-major order
JRM1986 0:53ee0f689634 43 * @details '1' represents a black pixel; '0' represents white
JRM1986 0:53ee0f689634 44 */
JRM1986 0:53ee0f689634 45 std::vector<int> _contents;
JRM1986 0:53ee0f689634 46
JRM1986 0:53ee0f689634 47 unsigned int _height; ///< The height of the drawing in pixels
JRM1986 0:53ee0f689634 48 unsigned int _width; ///< The width of the drawing in pixels
JRM1986 0:53ee0f689634 49
JRM1986 0:53ee0f689634 50 public:
JRM1986 0:53ee0f689634 51 Bitmap(int const *contents,
JRM1986 0:53ee0f689634 52 unsigned int const height,
JRM1986 0:53ee0f689634 53 unsigned int const width);
JRM1986 0:53ee0f689634 54
JRM1986 0:53ee0f689634 55 int get_pixel(unsigned int const row,
JRM1986 0:53ee0f689634 56 unsigned int const column) const;
JRM1986 0:53ee0f689634 57
JRM1986 0:53ee0f689634 58 void print() const;
JRM1986 0:53ee0f689634 59
JRM1986 0:53ee0f689634 60 void render(N5110 &lcd,
JRM1986 0:53ee0f689634 61 unsigned int const x0,
JRM1986 0:53ee0f689634 62 unsigned int const y0) const;
JRM1986 0:53ee0f689634 63 };
JRM1986 0:53ee0f689634 64
JRM1986 0:53ee0f689634 65 #endif // BITMAP_H