lib/unigraphic/SSD1322.h

Tue, 11 Oct 2016 00:46:18 +0200

author
David Douard <david.douard@logilab.fr>
date
Tue, 11 Oct 2016 00:46:18 +0200
changeset 9
e5254c6aa0c8
parent 8
55021f3f1929
child 17
162fe523c37d
permissions
-rw-r--r--

use only one USART

with a front "AND" gate to combine both serial lines

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
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
33 public:
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
34
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
35
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
36 /** Create a monochrome SSD1322 SPI interface
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
37 * @param name The name used by the parent class to access the interface
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
38 */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
39 SSD1322(int Hz, PinName mosi, PinName miso, PinName sclk, PinName CS, PinName reset, PinName DC,
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
40 const char* name);
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
41
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
42 /** Destructor
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
43 * will free framebuffer
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
44 */
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
45 virtual ~SSD1322() {};
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
46
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
47
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
48
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);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
69
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);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
82
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);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
89
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);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
95
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();
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
99
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();
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
123
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
124 /** Set the orientation of the screen
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
125 * x,y: 0,0 is always top left
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 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
133 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
134 void set_orientation(int o);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
135
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
136 /** Set ChipSelect high or low
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
137 * @param enable 0/1
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);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
140
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;};
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
150
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
151 ////////////////////////////////////////////////////////////////////////////////
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);
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
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,
8cb67d7afd79 [SSD1322] add a copy_to_lcd method that accepts an area
David Douard <david.douard@logilab.fr>
parents: 5
diff changeset
171 unsigned char from_row, unsigned char to_row);
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
172
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
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
179 * @note may be overridden by specific display init class in case of not standard cmds or inverted wiring
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
180 * @param mode NONE, X, Y, XY
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
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
187 /** Send 8bit command to display controller
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
188 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
189 * @param cmd: byte to send
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
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
191 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
192 void wr_cmd8(unsigned char cmd);
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
193
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
194 /** Send 8bit data to display controller
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
195 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
196 * @param data: byte to send
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
197 *
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
198 */
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
199 void wr_data8(unsigned char data);
8
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
200
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
201 /** HW reset sequence (without display init commands)
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();
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
204
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
205 int contrast;
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
206
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
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
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;
55021f3f1929 pff so many stuff
David Douard <david.douard@logilab.fr>
parents: 6
diff changeset
235
5
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
236 };
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
237
f1c85c2500f2 several improvements
David Douard <david.douard@logilab.fr>
parents:
diff changeset
238 #endif

mercurial