@@ -64,6 +64,8 @@ static int init_display(struct fbtft_par *par)
64
64
write_reg (par , 0x3F );
65
65
else if (par -> info -> var .yres == 48 )
66
66
write_reg (par , 0x2F );
67
+ else if (par -> info -> var .yres == 39 )
68
+ write_reg (par , 0x27 ); /* https://libstock.mikroe.com/projects/download/1111/2577/1411057038_oled_b_click___e_mikroc_arm.zip */
67
69
else
68
70
write_reg (par , 0x1F );
69
71
@@ -81,16 +83,24 @@ static int init_display(struct fbtft_par *par)
81
83
82
84
/* Set Memory Addressing Mode */
83
85
write_reg (par , 0x20 );
84
- /* Vertical addressing mode */
86
+ /* Vertical Addressing mode */
85
87
write_reg (par , 0x01 );
86
88
87
89
/* Set Segment Re-map */
88
- /* column address 127 is mapped to SEG0 */
89
- write_reg (par , 0xA0 | 0x1 );
90
+ if (par -> info -> var .yres == 39 )
91
+ /* no segment re-map */
92
+ write_reg (par , 0xA0 | 0x0 );
93
+ else
94
+ /* column address 127 is mapped to SEG0 */
95
+ write_reg (par , 0xA0 | 0x1 );
90
96
91
97
/* Set COM Output Scan Direction */
92
- /* remapped mode. Scan from COM[N-1] to COM0 */
93
- write_reg (par , 0xC8 );
98
+ if (par -> info -> var .yres == 39 )
99
+ /* no columnt re-map mode. Scan from COM0 to COM[N-1] */
100
+ write_reg (par , 0xC0 | 0x0 );
101
+ else
102
+ /* remapped mode. Scan from COM[N-1] to COM0 */
103
+ write_reg (par , 0xC0 | 0x8 );
94
104
95
105
/* Set COM Pins Hardware Configuration */
96
106
write_reg (par , 0xDA );
@@ -100,18 +110,27 @@ static int init_display(struct fbtft_par *par)
100
110
else if (par -> info -> var .yres == 48 )
101
111
/* A[4]=1b, Alternative COM pin configuration */
102
112
write_reg (par , 0x12 );
113
+ else if (par -> info -> var .yres == 39 )
114
+ /* A[4]=1b, Alternative COM pin configuration */
115
+ write_reg (par , 0x12 );
103
116
else
104
117
/* A[4]=0b, Sequential COM pin configuration */
105
118
write_reg (par , 0x02 );
106
119
107
120
/* Set Pre-charge Period */
108
121
write_reg (par , 0xD9 );
109
- write_reg (par , 0xF1 );
122
+ if (par -> info -> var .yres == 39 )
123
+ write_reg (par , 0x25 );
124
+ else
125
+ write_reg (par , 0xF1 );
110
126
111
127
/* Set VCOMH Deselect Level */
112
128
write_reg (par , 0xDB );
113
- /* according to the datasheet, this value is out of bounds */
114
- write_reg (par , 0x40 );
129
+ if (par -> info -> var .yres == 39 )
130
+ write_reg (par , 0x20 );
131
+ else
132
+ /* according to the datasheet, this value is out of bounds */
133
+ write_reg (par , 0x40 );
115
134
116
135
/* Entire Display ON */
117
136
/* Resume to RAM content display. Output follows RAM content */
@@ -142,17 +161,35 @@ static void set_addr_win_64x48(struct fbtft_par *par)
142
161
write_reg (par , 0x5 );
143
162
}
144
163
164
+ static void set_addr_win_96x39 (struct fbtft_par * par )
165
+ {
166
+ /* Set Page Address */
167
+ write_reg (par , 0xB0 );
168
+
169
+ /* Set Column Address */
170
+ write_reg (par , 0x21 );
171
+ write_reg (par , 0x00 );
172
+ write_reg (par , 0x5F );
173
+
174
+ /* Set Page Address Range */
175
+ write_reg (par , 0x22 );
176
+ write_reg (par , 0x0 );
177
+ write_reg (par , 0x4 );
178
+ }
179
+
145
180
static void set_addr_win (struct fbtft_par * par , int xs , int ys , int xe , int ye )
146
181
{
147
- /* Set Lower Column Start Address for Page Addressing Mode */
182
+ /* Set Lower Column Start Address for Vertical Addressing Mode */
148
183
write_reg (par , 0x00 | 0x0 );
149
- /* Set Higher Column Start Address for Page Addressing Mode */
184
+ /* Set Higher Column Start Address for Vertical Addressing Mode */
150
185
write_reg (par , 0x10 | 0x0 );
151
186
/* Set Display Start Line */
152
187
write_reg (par , 0x40 | 0x0 );
153
188
154
189
if (par -> info -> var .xres == 64 && par -> info -> var .yres == 48 )
155
190
set_addr_win_64x48 (par );
191
+ else if (par -> info -> var .xres == 96 && par -> info -> var .yres == 39 )
192
+ set_addr_win_96x39 (par );
156
193
}
157
194
158
195
static int blank (struct fbtft_par * par , bool on )
@@ -196,11 +233,19 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
196
233
* buf |= (vmem16 [(y * 8 + i ) * xres + x ] ? 1 : 0 ) << i ;
197
234
buf ++ ;
198
235
}
236
+ if (yres % 8 ) {
237
+ * buf = 0x00 ;
238
+ for (i = 0 ; i < (yres - (y * 8 )); i ++ )
239
+ * buf |= (vmem16 [(y * 8 + i ) * xres + x ] ? 1 : 0 ) << i ;
240
+ buf ++ ;
241
+ y ++ ;
242
+ }
199
243
}
200
244
201
245
/* Write data */
202
246
gpio_set_value (par -> gpio .dc , 1 );
203
- ret = par -> fbtftops .write (par , par -> txbuf .buf , xres * yres / 8 );
247
+ ret = par -> fbtftops .write (par , par -> txbuf .buf , xres * (yres / 8 + (yres % 8 != 0 )));
248
+ //ret = par->fbtftops.write(par, par->txbuf.buf, xres * 128 / 8);
204
249
if (ret < 0 )
205
250
dev_err (par -> info -> device , "write failed and returned: %d\n" ,
206
251
ret );
0 commit comments