Rev 3 | Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 3 | Rev 4 | ||
|---|---|---|---|
| Line 7... | Line 7... | ||
| 7 | 7 | ||
| 8 | #pragma once |
8 | #pragma once |
| 9 | #include <cstdint> |
9 | #include <cstdint> |
| 10 | #include "libOLED/fontclass.H" |
10 | #include "libOLED/fontclass.H" |
| 11 | 11 | ||
| - | 12 | inline int constexpr |
|
| 12 | inline int constexpr dataSize (int const width, int const height) |
13 | dataSize (int const width, int const height) |
| 13 | { |
14 | { |
| 14 | return (width * height /8); |
15 | return (width * height / 8); |
| 15 | } |
16 | } |
| 16 | 17 | ||
| 17 | enum colour_t |
18 | enum colour_t |
| 18 | { |
19 | { |
| 19 | BLACK, |
- | |
| 20 | WHITE, |
- | |
| 21 | INVERT |
20 | BLACK, WHITE, INVERT |
| 22 | }; |
21 | }; |
| 23 | 22 | ||
| 24 | class display_t |
23 | class display_t |
| 25 | { |
24 | { |
| 26 | public: |
25 | public: |
| 27 | display_t (int const width, int const height, int const ramwidth , uint8_t * const data); |
26 | display_t (int const width, int const height, int const ramwidth, |
| - | 27 | uint8_t *const data); |
|
| 28 | 28 | ||
| - | 29 | virtual |
|
| 29 | virtual ~display_t(); |
30 | ~display_t (); |
| 30 | 31 | ||
| - | 32 | uint8_t |
|
| 31 | uint8_t getRotation(); |
33 | getRotation (); |
| - | 34 | int16_t |
|
| 32 | int16_t width(); |
35 | width (); |
| - | 36 | int16_t |
|
| 33 | int16_t height(); |
37 | height (); |
| 34 | 38 | ||
| - | 39 | void |
|
| 35 | void init(); |
40 | init (); |
| 36 | 41 | ||
| - | 42 | void |
|
| 37 | void clearDisplay(); |
43 | clearDisplay (); |
| - | 44 | void |
|
| 38 | void invertDisplay(uint8_t i); |
45 | invertDisplay (uint8_t i); |
| - | 46 | void |
|
| 39 | void display(); |
47 | display (); |
| 40 | 48 | ||
| - | 49 | void |
|
| 41 | void startscrollright(uint8_t start, uint8_t stop); |
50 | startscrollright (uint8_t start, uint8_t stop); |
| - | 51 | void |
|
| 42 | void startscrollleft(uint8_t start, uint8_t stop); |
52 | startscrollleft (uint8_t start, uint8_t stop); |
| 43 | 53 | ||
| - | 54 | void |
|
| 44 | void startscrolldiagright(uint8_t start, uint8_t stop); |
55 | startscrolldiagright (uint8_t start, uint8_t stop); |
| - | 56 | void |
|
| 45 | void startscrolldiagleft(uint8_t start, uint8_t stop); |
57 | startscrolldiagleft (uint8_t start, uint8_t stop); |
| - | 58 | void |
|
| 46 | void stopscroll(void); |
59 | stopscroll (void); |
| 47 | 60 | ||
| - | 61 | void |
|
| 48 | void dim(uint8_t contrast); |
62 | dim (uint8_t contrast); |
| 49 | 63 | ||
| - | 64 | void |
|
| 50 | void drawPixel(int16_t x, int16_t y, colour_t color); |
65 | drawPixel (int16_t x, int16_t y, colour_t color); |
| 51 | 66 | ||
| - | 67 | void |
|
| 52 | void drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, colour_t color); |
68 | drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, colour_t color); |
| 53 | 69 | ||
| - | 70 | void |
|
| 54 | void gotoxy(int x, int y) {m_cursor_x = x; m_cursor_y=y;}; |
71 | gotoxy (int x, int y) |
| - | 72 | { |
|
| - | 73 | m_cursor_x = x; |
|
| - | 74 | m_cursor_y = y; |
|
| - | 75 | } |
|
| - | 76 | ; |
|
| 55 | 77 | ||
| - | 78 | // pixel to pixel plotting |
|
| - | 79 | /// \param font The font to use |
|
| - | 80 | /// \param string The characters to plot |
|
| - | 81 | /// \param length The length of the string |
|
| - | 82 | /// \param colour |
|
| - | 83 | void |
|
| - | 84 | printString (font_t &font, char const *string, uint16_t length, |
|
| - | 85 | colour_t colour); |
|
| 56 | 86 | ||
| - | 87 | // scaled plotting |
|
| - | 88 | /// \param font The font to use |
|
| - | 89 | /// \param string The characters to plot |
|
| - | 90 | /// \param length The length of the string |
|
| - | 91 | /// \param scale The scale factor is 256/scale so 256 is 1:1, 128 is twice the size |
|
| - | 92 | /// \param colour |
|
| - | 93 | void |
|
| 57 | void printString(font_t & font, char const * string, uint16_t length, colour_t colour); |
94 | printScaledString (font_t &font, char const *string, |
| - | 95 | uint16_t length, uint16_t scale, |
|
| - | 96 | colour_t colour); |
|
| 58 | 97 | ||
| - | 98 | void |
|
| 59 | void printChar (font_t &font, char c, colour_t colour); |
99 | printChar (font_t &font, char c, colour_t colour); |
| 60 | 100 | ||
| - | 101 | int |
|
| - | 102 | cursor_x () |
|
| - | 103 | { |
|
| 61 | int cursor_x() {return m_cursor_x;}; |
104 | return m_cursor_x; |
| - | 105 | } |
|
| - | 106 | ; |
|
| 62 | 107 | ||
| - | 108 | int |
|
| - | 109 | cursor_y () |
|
| - | 110 | { |
|
| 63 | int cursor_y() {return m_cursor_y;}; |
111 | return m_cursor_y; |
| - | 112 | } |
|
| - | 113 | ; |
|
| 64 | 114 | ||
| 65 | private: |
115 | private: |
| 66 | 116 | ||
| 67 | // set=1 means send data set=0 means send control |
117 | // set=1 means send data set=0 means send control |
| 68 | virtual void oledSetCD(uint8_t set) =0; |
118 | virtual void |
| 69 | - | ||
| 70 | virtual void oledWrite(uint8_t d) =0; |
119 | oledSetCD (uint8_t set) =0; |
| 71 | 120 | ||
| 72 | virtual void oledReset() = 0; |
121 | virtual void |
| - | 122 | oledWrite (uint8_t d) =0; |
|
| 73 | 123 | ||
| - | 124 | virtual void |
|
| 74 | virtual void oledWrite(uint8_t * buff, uint8_t len) = 0; |
125 | oledReset () = 0; |
| 75 | 126 | ||
| - | 127 | virtual void |
|
| - | 128 | oledWrite (uint8_t *buff, uint8_t len) = 0; |
|
| 76 | 129 | ||
| 77 | int const m_width; // pixel width |
130 | int const m_width; // pixel width |
| 78 | int const m_height; // pixel height |
131 | int const m_height; // pixel height |
| 79 | int const m_ramwidth; // OLED controller ram pixel width |
132 | int const m_ramwidth; // OLED controller ram pixel width |
| 80 | 133 | ||
| 81 | int m_cursor_x; |
134 | int m_cursor_x; |
| 82 | int m_cursor_y; |
135 | int m_cursor_y; |
| 83 | int m_rotation; |
136 | int m_rotation; |
| 84 | 137 | ||
| - | 138 | uint8_t *const m_data; |
|
| 85 | 139 | ||
| 86 | uint8_t * const m_data; |
- | |
| 87 | - | ||
| 88 | }; |
140 | }; |