lib/unigraphic/SSD1322.h

Mon, 26 Oct 2020 00:16:13 +0100

author
David Douard <david.douard@sdf3.org>
date
Mon, 26 Oct 2020 00:16:13 +0100
changeset 37
07e8ca2bdf6d
parent 26
86f099bda525
child 40
069bbd5ee3e4
permissions
-rw-r--r--

Extracted the display related functions in a Display class

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
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
47
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
48
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
49 /////// functions that come for free, but can be overwritten///////////////////////////////////////////////////
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
50 /////// ----------------------------------------------------///////////////////////////////////////////////////
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 /** Draw a pixel in the specified color.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
53 * @param x is the horizontal offset to this pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
54 * @param y is the vertical offset to this pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
55 * @param color defines the color for the pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
56 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
57 virtual void pixel(int x, int y, unsigned short color);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
58
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
59 /** Set the window, which controls where items are written to the screen.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
60 * 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
61 * 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
62 * be captured into the window when it crosses a boundary.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
63 * @param x is the left edge in pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
64 * @param y is the top edge in pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
65 * @param w is the window width in pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
66 * @param h is the window height in pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
67 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
68 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
69
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
70 /** Read pixel color at location
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
71 * @param x is the horizontal offset to this pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
72 * @param y is the vertical offset to this pixel.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
73 * @returns 16bit color, 0000=Black(pixel set), FFFF=White(pixel clear).
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
74 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
75 virtual unsigned short pixelread(int x, int y);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
76
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
77 /** Push a single pixel into the window and increment position.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
78 * You must first call window() then push pixels in loop.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
79 * @param color is the pixel color.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
80 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
81 virtual void window_pushpixel(unsigned short color);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
82
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
83 /** 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
84 * You must first call window() then push pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
85 * @param color is the pixel color.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
86 * @param count: how many
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
87 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
88 virtual void window_pushpixel(unsigned short color, unsigned int count);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
89
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
90 /** Push array of pixel colors into the window and increment position.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
91 * You must first call window() then push pixels.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
92 * @param color is the pixel color.
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
93 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
94 virtual void window_pushpixelbuf(unsigned short* color, unsigned int lenght);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
95
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
96 /** 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
97 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
98 virtual void copy_to_lcd();
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
99
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
100 /** set the contrast of the screen
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
101 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
102 * @param o contrast 0-63
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
103 * @note may be overrided in case of not standard command
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
104 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
105 virtual void set_contrast(int o);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
106
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
107 /** read the contrast level
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
108 *
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 int get_contrast(void);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
111
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
112 /** display inverted colors
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
113 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
114 * @param o = 0 normal, 1 invert
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
115 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
116 void invert(unsigned char o);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
117
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
118 /** clear the entire screen
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
119 * The inherited one sets windomax then fill with background color
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
120 * We override it to speedup
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
121 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
122 virtual void cls();
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
123
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
124 /** Set the orientation of the screen
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
125 * x,y: 0,0 is always top left
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
126 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
127 * @param o direction to use the screen (0-3)
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
128 * 0 = -90°
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
129 * 1 = default 0°
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
130 * 2 = +90°
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
131 * 3 = +180°
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
132 *
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
133 */
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
134 void set_orientation(int o);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
135
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
136 /** Set ChipSelect high or low
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
137 * @param enable 0/1
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
138 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
139 virtual void bus_enable(bool enable);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
140
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
141 /** get display X size in pixels (native, orientation independent)
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
142 * @returns X size in pixels
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
143 */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
144 int sizeX() {return screensize_X;};
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
145
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
146 /** get display Y size in pixels (native, orientation independent)
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
147 * @returns Y size in pixels
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
148 */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
149 int sizeY() {return screensize_Y;};
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
150
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
151 ////////////////////////////////////////////////////////////////////////////////
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
152 // not implemented yet
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
153 //////////////////////////////////////////////////////////////////
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
154 // virtual unsigned short pixelread(int x, int y){return 0;};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
155 virtual void window4read(int x, int y, int w, int h){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
156 void setscrollarea (int startY, int areasize){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
157 void scroll (int lines){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
158 void scrollreset(){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
159 void FastWindow(bool enable){};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
160
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
161 unsigned int buffsize() { return _PAGES*screensize_X;};
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
162 unsigned short pixelpos(int x, int y);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
163 void clrbuff(const unsigned char value=0x00);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
164 unsigned long buffaddr(unsigned int i);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
165 void fills(const unsigned char value=0xFF);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
166
6
8cb67d7afd79 [SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents: 5
diff changeset
167 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
168 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
169
6
8cb67d7afd79 [SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents: 5
diff changeset
170 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
171 unsigned char from_row, unsigned char to_row);
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
172
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
173 protected:
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
174 /** Setup some stuff (malloc the buffer, etc)
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
175 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
176 void init();
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
177
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
178 /** set mirror mode
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
179 * @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
180 * @param mode NONE, X, Y, XY
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
181 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
182 virtual void mirrorXY(mirror_t mode);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
183
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
184 ////// functions needed by parent class ///////////////////////////////////////
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
185 ////// -------------------------------- ///////////////////////////////////////
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
186
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
187 /** Send 8bit command to display controller
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
188 *
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
189 * @param cmd: byte to send
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
190 * @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
191 */
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
192 void wr_cmd8(unsigned char cmd);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
193
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
194 /** Send 8bit data to display controller
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
195 *
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
196 * @param data: byte to send
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
197 *
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
198 */
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
199 void wr_data8(unsigned char data);
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
200
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
201 /** HW reset sequence (without display init commands)
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
202 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
203 void hw_reset();
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
204
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
205 int contrast;
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
206
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
207 protected:
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
208
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
209 mbed::SPI _spi;
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
210 DigitalOut _CS;
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
211 DigitalOut _RST;
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
212 DigitalOut _DC;
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
213 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
214 DISPLAY_BUFFER_TYPE _trBuffer[DISPLAY_BUFFER_ELEMENTS]; // for sending
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
215
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
216 const int screensize_X;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
217 const int screensize_Y;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
218 const int _PAGES;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
219 const int _BPP;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
220 const int _IC_X_SEGS;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
221 const int _IC_Y_COMS;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
222 const int _IC_PAGES;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
223
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
224 // pixel location
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
225 int cur_x;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
226 int cur_y;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
227 // window location
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
228 int win_x1;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
229 int win_x2;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
230 int win_y1;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
231 int win_y2;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
232 int orientation;
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
233
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
234 SSD1322_state_t _state;
17
162fe523c37d almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents: 8
diff changeset
235 #ifdef DEVICE_SPI_ASYNCH
162fe523c37d almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents: 8
diff changeset
236 event_callback_t _spiEventCb;
162fe523c37d almost working... before killing the 87C51...
David Douard <david.douard@logilab.fr>
parents: 8
diff changeset
237 #endif
26
86f099bda525 Several stuff
David Douard <david.douard@sdfa3.org>
parents: 17
diff changeset
238
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
239 };
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 #endif

mercurial