Rev 4 | Rev 6 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2 | mjames | 1 | /* |
2 | * displayclass.H |
||
3 | * |
||
4 | * Created on: 31 Oct 2020 |
||
5 | * Author: mike |
||
6 | */ |
||
7 | |||
8 | #pragma once |
||
9 | #include <cstdint> |
||
3 | mjames | 10 | #include "libOLED/fontclass.H" |
2 | mjames | 11 | |
4 | mjames | 12 | inline int constexpr |
13 | dataSize (int const width, int const height) |
||
2 | mjames | 14 | { |
4 | mjames | 15 | return (width * height / 8); |
2 | mjames | 16 | } |
17 | |||
18 | enum colour_t |
||
19 | { |
||
4 | mjames | 20 | BLACK, WHITE, INVERT |
2 | mjames | 21 | }; |
22 | |||
23 | class display_t |
||
24 | { |
||
25 | public: |
||
4 | mjames | 26 | display_t (int const width, int const height, int const ramwidth, |
27 | uint8_t *const data); |
||
2 | mjames | 28 | |
4 | mjames | 29 | virtual |
30 | ~display_t (); |
||
2 | mjames | 31 | |
4 | mjames | 32 | uint8_t |
33 | getRotation (); |
||
34 | int16_t |
||
35 | width (); |
||
36 | int16_t |
||
37 | height (); |
||
2 | mjames | 38 | |
4 | mjames | 39 | void |
40 | init (); |
||
2 | mjames | 41 | |
4 | mjames | 42 | void |
43 | clearDisplay (); |
||
44 | void |
||
45 | invertDisplay (uint8_t i); |
||
46 | void |
||
47 | display (); |
||
2 | mjames | 48 | |
4 | mjames | 49 | void |
50 | startscrollright (uint8_t start, uint8_t stop); |
||
51 | void |
||
52 | startscrollleft (uint8_t start, uint8_t stop); |
||
2 | mjames | 53 | |
4 | mjames | 54 | void |
55 | startscrolldiagright (uint8_t start, uint8_t stop); |
||
56 | void |
||
57 | startscrolldiagleft (uint8_t start, uint8_t stop); |
||
58 | void |
||
59 | stopscroll (void); |
||
2 | mjames | 60 | |
4 | mjames | 61 | void |
62 | dim (uint8_t contrast); |
||
2 | mjames | 63 | |
4 | mjames | 64 | void |
65 | drawPixel (int16_t x, int16_t y, colour_t color); |
||
2 | mjames | 66 | |
4 | mjames | 67 | void |
68 | drawLine (int16_t x1, int16_t y1, int16_t x2, int16_t y2, colour_t color); |
||
2 | mjames | 69 | |
4 | mjames | 70 | void |
71 | gotoxy (int x, int y) |
||
72 | { |
||
73 | m_cursor_x = x; |
||
74 | m_cursor_y = y; |
||
75 | } |
||
76 | ; |
||
2 | mjames | 77 | |
4 | mjames | 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); |
||
2 | mjames | 86 | |
4 | mjames | 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 |
||
94 | printScaledString (font_t &font, char const *string, |
||
95 | uint16_t length, uint16_t scale, |
||
96 | colour_t colour); |
||
2 | mjames | 97 | |
4 | mjames | 98 | void |
5 | mjames | 99 | fontDigits (font_t &font, uint8_t digits, uint8_t dp_pos, int val); |
2 | mjames | 100 | |
5 | mjames | 101 | void |
102 | fontSigDigits (font_t &font,uint8_t x, uint8_t y, bool right_justify, uint8_t dp_pos, |
||
103 | int val); |
||
104 | |||
4 | mjames | 105 | int |
106 | cursor_x () |
||
107 | { |
||
108 | return m_cursor_x; |
||
109 | } |
||
110 | ; |
||
2 | mjames | 111 | |
4 | mjames | 112 | int |
113 | cursor_y () |
||
114 | { |
||
115 | return m_cursor_y; |
||
116 | } |
||
117 | ; |
||
2 | mjames | 118 | |
119 | private: |
||
120 | |||
121 | // set=1 means send data set=0 means send control |
||
4 | mjames | 122 | virtual void |
123 | oledSetCD (uint8_t set) =0; |
||
2 | mjames | 124 | |
4 | mjames | 125 | virtual void |
126 | oledWrite (uint8_t d) =0; |
||
2 | mjames | 127 | |
4 | mjames | 128 | virtual void |
129 | oledReset () = 0; |
||
2 | mjames | 130 | |
4 | mjames | 131 | virtual void |
132 | oledWrite (uint8_t *buff, uint8_t len) = 0; |
||
2 | mjames | 133 | |
5 | mjames | 134 | |
135 | uint8_t formatNum (char *buff, uint8_t siz, uint8_t digits, uint8_t dp_pos, int val); |
||
136 | |||
137 | |||
2 | mjames | 138 | int const m_width; // pixel width |
139 | int const m_height; // pixel height |
||
140 | int const m_ramwidth; // OLED controller ram pixel width |
||
141 | |||
142 | int m_cursor_x; |
||
4 | mjames | 143 | int m_cursor_y; |
144 | int m_rotation; |
||
2 | mjames | 145 | |
4 | mjames | 146 | uint8_t *const m_data; |
2 | mjames | 147 | |
4 | mjames | 148 | }; |