Rev 2 | Rev 4 | 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 | |
12 | inline int constexpr dataSize (int const width, int const height) |
||
13 | { |
||
14 | return (width * height /8); |
||
15 | } |
||
16 | |||
17 | enum colour_t |
||
18 | { |
||
19 | BLACK, |
||
20 | WHITE, |
||
21 | INVERT |
||
22 | }; |
||
23 | |||
24 | class display_t |
||
25 | { |
||
26 | public: |
||
27 | display_t (int const width, int const height, int const ramwidth , uint8_t * const data); |
||
28 | |||
29 | virtual ~display_t(); |
||
30 | |||
31 | uint8_t getRotation(); |
||
32 | int16_t width(); |
||
33 | int16_t height(); |
||
34 | |||
35 | void init(); |
||
36 | |||
37 | void clearDisplay(); |
||
38 | void invertDisplay(uint8_t i); |
||
39 | void display(); |
||
40 | |||
41 | void startscrollright(uint8_t start, uint8_t stop); |
||
42 | void startscrollleft(uint8_t start, uint8_t stop); |
||
43 | |||
44 | void startscrolldiagright(uint8_t start, uint8_t stop); |
||
45 | void startscrolldiagleft(uint8_t start, uint8_t stop); |
||
46 | void stopscroll(void); |
||
47 | |||
48 | void dim(uint8_t contrast); |
||
49 | |||
50 | void drawPixel(int16_t x, int16_t y, colour_t color); |
||
51 | |||
52 | void drawLine(int16_t x1, int16_t y1, int16_t x2, int16_t y2, colour_t color); |
||
53 | |||
54 | void gotoxy(int x, int y) {m_cursor_x = x; m_cursor_y=y;}; |
||
55 | |||
56 | |||
3 | mjames | 57 | void printString(font_t & font, char const * string, uint16_t length, colour_t colour); |
2 | mjames | 58 | |
59 | void printChar (font_t &font, char c, colour_t colour); |
||
60 | |||
61 | int cursor_x() {return m_cursor_x;}; |
||
62 | |||
63 | int cursor_y() {return m_cursor_y;}; |
||
64 | |||
65 | private: |
||
66 | |||
67 | // set=1 means send data set=0 means send control |
||
68 | virtual void oledSetCD(uint8_t set) =0; |
||
69 | |||
70 | virtual void oledWrite(uint8_t d) =0; |
||
71 | |||
72 | virtual void oledReset() = 0; |
||
73 | |||
74 | virtual void oledWrite(uint8_t * buff, uint8_t len) = 0; |
||
75 | |||
76 | |||
77 | int const m_width; // pixel width |
||
78 | int const m_height; // pixel height |
||
79 | int const m_ramwidth; // OLED controller ram pixel width |
||
80 | |||
81 | int m_cursor_x; |
||
82 | int m_cursor_y; |
||
83 | int m_rotation; |
||
84 | |||
85 | |||
86 | uint8_t * const m_data; |
||
87 | |||
88 | }; |