lib/unigraphic/SSD1322.h

Sun, 03 Oct 2021 22:58:49 +0200

author
David Douard <david.douard@sdfa3.org>
date
Sun, 03 Oct 2021 22:58:49 +0200
changeset 64
897330ee6e9d
parent 45
2da50a3d4e9f
child 66
48f29a1d43d6
permissions
-rw-r--r--

Make USBSerial work -- at last

It needs the revision 4587080d of mbed-os to work (i.e. mbed-os>6.15.0)

5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
1 #ifndef MBED_SSD1322_H
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
2 #define MBED_SSD1322_H
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
3
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
4 #include "mbed.h"
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
5 #include "GraphicsDisplay.h"
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
6
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
7 //Display module specs
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
8 #define DISPLAY_WIDTH (256)
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
9 #define DISPLAY_HEIGHT (64)
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
10 #define DISPLAY_BUFFER_TYPE uint8_t
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
11 #define DISPLAY_BUFFER_TYPE_SIZE (2) // 2 pixel / byte
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
12 #define DISPLAY_BUFFER_ELEMENTS 8192 // 256*64 / 2 (because 2 pixels/byte)
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
13
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
14
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
15 /** Mirror mode */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
16 enum mirror_t {X, Y, XY, NONE};
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
17
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
18 typedef enum {
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
19 IDLE, // No operation currently ongoing
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
20 CLEARING, // In the process of clearing the display
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
21 WRITING, // In the process of sending a display update
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
22 WAIT_CLEAR, // Going to clear after CS pin timeout
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
23 WAIT_WRITE, // Going to write after CS pin timeout
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
24 TRANSFERS_DONE, // Last transfer in progress
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
25 DONE, // Done with transmission, waiting for CS pin to become high
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
26 } SSD1322_state_t;
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
27
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
28 /** A common base class for monochrome Display
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
29 */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
30 class SSD1322: public GraphicsDisplay
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
31 {
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
32
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
33 public:
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
34
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
35
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
36 /** Create a monochrome SSD1322 SPI interface
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
37 * @param name The name used by the parent class to access the interface
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
38 */
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
39 SSD1322(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC,
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
40 const char* name);
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
41
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
42 /** Destructor
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
43 * will free framebuffer
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
44 */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
45 virtual ~SSD1322() {};
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
46
40
069bbd5ee3e4 SSD1322: add power off/on methods
David Douard <david.douard@sdf3.org>
parents: 26
diff changeset
47 void power_off();
069bbd5ee3e4 SSD1322: add power off/on methods
David Douard <david.douard@sdf3.org>
parents: 26
diff changeset
48 void power_on();
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
49
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
50 /////// functions that come for free, but can be overwritten///////////////////////////////////////////////////
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
51 /////// ----------------------------------------------------///////////////////////////////////////////////////
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
52
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
53 /** Draw a pixel in the specified color.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
54 * @param x is the horizontal offset to this pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
55 * @param y is the vertical offset to this pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
56 * @param color defines the color for the pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
57 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
58 virtual void pixel(int x, int y, unsigned short color);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
59
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
60 /** Set the window, which controls where items are written to the screen.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
61 * When something hits the window width, it wraps back to the left side
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
62 * and down a row. If the initial write is outside the window, it will
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
63 * be captured into the window when it crosses a boundary.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
64 * @param x is the left edge in pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
65 * @param y is the top edge in pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
66 * @param w is the window width in pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
67 * @param h is the window height in pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
68 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
69 virtual void window(int x, int y, int w, int h);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
70
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
71 /** Read pixel color at location
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
72 * @param x is the horizontal offset to this pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
73 * @param y is the vertical offset to this pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
74 * @returns 16bit color, 0000=Black(pixel set), FFFF=White(pixel clear).
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
75 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
76 virtual unsigned short pixelread(int x, int y);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
77
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
78 /** Push a single pixel into the window and increment position.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
79 * You must first call window() then push pixels in loop.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
80 * @param color is the pixel color.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
81 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
82 virtual void window_pushpixel(unsigned short color);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
83
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
84 /** Push some pixels of the same color into the window and increment position.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
85 * You must first call window() then push pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
86 * @param color is the pixel color.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
87 * @param count: how many
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
88 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
89 virtual void window_pushpixel(unsigned short color, unsigned int count);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
90
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
91 /** Push array of pixel colors into the window and increment position.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
92 * You must first call window() then push pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
93 * @param color is the pixel color.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
94 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
95 virtual void window_pushpixelbuf(unsigned short* color, unsigned int lenght);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
96
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
97 /** Framebuffer is used, it needs to be sent to SSD1322 from time to time
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
98 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
99 virtual void copy_to_lcd();
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
100
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
101 /** set the contrast of the screen
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
102 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
103 * @param o contrast 0-63
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
104 * @note may be overrided in case of not standard command
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
105 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
106 virtual void set_contrast(int o);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
107
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
108 /** read the contrast level
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
109 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
110 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
111 int get_contrast(void);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
112
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
113 /** display inverted colors
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
114 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
115 * @param o = 0 normal, 1 invert
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
116 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
117 void invert(unsigned char o);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
118
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
119 /** clear the entire screen
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
120 * The inherited one sets windomax then fill with background color
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
121 * We override it to speedup
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
122 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
123 virtual void cls();
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
124
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
125 /** Set the orientation of the screen
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
126 * x,y: 0,0 is always top left
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
127 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
128 * @param o direction to use the screen (0-3)
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
129 * 0 = -90°
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
130 * 1 = default 0°
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
131 * 2 = +90°
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
132 * 3 = +180°
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
133 *
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
134 */
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
135 void set_orientation(int o);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
136
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
137 /** Set ChipSelect high or low
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
138 * @param enable 0/1
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
139 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
140 virtual void bus_enable(bool enable);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
141
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
142 /** get display X size in pixels (native, orientation independent)
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
143 * @returns X size in pixels
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
144 */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
145 int sizeX() {return screensize_X;};
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
146
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
147 /** get display Y size in pixels (native, orientation independent)
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
148 * @returns Y size in pixels
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
149 */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
150 int sizeY() {return screensize_Y;};
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
151
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
152 ////////////////////////////////////////////////////////////////////////////////
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
153 // not implemented yet
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
154 //////////////////////////////////////////////////////////////////
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
155 // virtual unsigned short pixelread(int x, int y){return 0;};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
156 virtual void window4read(int x, int y, int w, int h){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
157 void setscrollarea (int startY, int areasize){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
158 void scroll (int lines){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
159 void scrollreset(){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
160 void FastWindow(bool enable){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
161
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
162 unsigned int buffsize() { return _PAGES*screensize_X;};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
163 unsigned short pixelpos(int x, int y);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
164 void clrbuff(const unsigned char value=0x00);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
165 unsigned long buffaddr(unsigned int i);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
166 void fills(const unsigned char value=0xFF);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
167
6
8cb67d7afd79 [SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents: 5
diff changeset
168 void set_row_address(unsigned char start_row=0x00, unsigned char end_row=0x3F);
8cb67d7afd79 [SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents: 5
diff changeset
169 void set_column_address(unsigned char start_col=0x00, unsigned char end_col=0x3F);
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
170
6
8cb67d7afd79 [SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents: 5
diff changeset
171 virtual void copy_to_lcd(unsigned char from_col, unsigned char to_col,
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
172 unsigned char from_row, unsigned char to_row);
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
173
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
174 protected:
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
175 /** Setup some stuff (malloc the buffer, etc)
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
176 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
177 void init();
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
178
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
179 /** set mirror mode
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
180 * @note may be overridden by specific display init class in case of not standard cmds or inverted wiring
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
181 * @param mode NONE, X, Y, XY
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
182 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
183 virtual void mirrorXY(mirror_t mode);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
184
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
185 ////// functions needed by parent class ///////////////////////////////////////
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
186 ////// -------------------------------- ///////////////////////////////////////
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
187
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
188 /** Send 8bit command to display controller
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
189 *
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
190 * @param cmd: byte to send
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
191 * @note if protocol is SPI16, it will insert NOP cmd before, so if cmd is a 2byte cmd, the second cmd will be broken. Use wr_cmd16 for 2bytes cmds
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
192 */
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
193 void wr_cmd8(unsigned char cmd);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
194
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
195 /** Send 8bit data to display controller
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
196 *
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
197 * @param data: byte to send
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
198 *
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
199 */
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
200 void wr_data8(unsigned char data);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
201
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
202 /** HW reset sequence (without display init commands)
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
203 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
204 void hw_reset();
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
205
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
206 int contrast;
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
207
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
208 protected:
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
209
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
210 mbed::SPI _spi;
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
211 DigitalOut _CS;
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
212 DigitalOut _RST;
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
213 DigitalOut _DC;
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
214 volatile DISPLAY_BUFFER_TYPE _pixelBuffer[DISPLAY_BUFFER_ELEMENTS]; // one full frame buffer
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
215 DISPLAY_BUFFER_TYPE _trBuffer[DISPLAY_BUFFER_ELEMENTS]; // for sending
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
216
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
217 const int screensize_X;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
218 const int screensize_Y;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
219 const int _PAGES;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
220 const int _BPP;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
221 const int _IC_X_SEGS;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
222 const int _IC_Y_COMS;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
223 const int _IC_PAGES;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
224
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
225 // pixel location
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
226 int cur_x;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
227 int cur_y;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
228 // window location
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
229 int win_x1;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
230 int win_x2;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
231 int win_y1;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
232 int win_y2;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
233 int orientation;
45
2da50a3d4e9f Adjust font rendering
David Douard <david.douard@sdf3.org>
parents: 40
diff changeset
234 Mutex pixel_buffer_mutex; // used when being copied to the transerf buffer
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
235 SSD1322_state_t _state;
17
162fe523c37d almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents: 8
diff changeset
236 #ifdef DEVICE_SPI_ASYNCH
162fe523c37d almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents: 8
diff changeset
237 event_callback_t _spiEventCb;
162fe523c37d almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents: 8
diff changeset
238 #endif
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
239
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
240 };
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
241
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
242 #endif

mercurial