@@ -216,10 +216,11 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
216
216
uint8_t row_command , uint16_t set_current_column_command , uint16_t set_current_row_command ,
217
217
bool data_as_commands , bool always_toggle_chip_select ,
218
218
displayio_area_t * area , bool SH1107_addressing ) {
219
- uint16_t x1 = area -> x1 ;
220
- uint16_t x2 = area -> x2 ;
221
- uint16_t y1 = area -> y1 ;
222
- uint16_t y2 = area -> y2 ;
219
+ uint16_t x1 = area -> x1 + self -> colstart ;
220
+ uint16_t x2 = area -> x2 + self -> colstart ;
221
+ uint16_t y1 = area -> y1 + self -> rowstart ;
222
+ uint16_t y2 = area -> y2 + self -> rowstart ;
223
+
223
224
// Collapse down the dimension where multiple pixels are in a byte.
224
225
if (self -> colorspace .depth < 8 ) {
225
226
uint8_t pixels_per_byte = 8 / self -> colorspace .depth ;
@@ -232,6 +233,9 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
232
233
}
233
234
}
234
235
236
+ x2 -= 1 ;
237
+ y2 -= 1 ;
238
+
235
239
display_chip_select_behavior_t chip_select = CHIP_SELECT_UNTOUCHED ;
236
240
if (always_toggle_chip_select || data_as_commands ) {
237
241
chip_select = CHIP_SELECT_TOGGLE_EVERY_BYTE ;
@@ -249,25 +253,25 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
249
253
} else {
250
254
data_type = DISPLAY_COMMAND ;
251
255
}
256
+
252
257
if (self -> ram_width < 0x100 ) {
253
- data [data_length ++ ] = x1 + self -> colstart ;
254
- data [data_length ++ ] = x2 - 1 + self -> colstart ;
258
+ data [data_length ++ ] = x1 ;
259
+ data [data_length ++ ] = x2 ;
255
260
} else {
256
- x1 += self -> colstart ;
257
- x2 += self -> colstart - 1 ;
258
261
data [data_length ++ ] = x1 >> 8 ;
259
262
data [data_length ++ ] = x1 & 0xff ;
260
263
data [data_length ++ ] = x2 >> 8 ;
261
264
data [data_length ++ ] = x2 & 0xff ;
262
265
}
266
+
263
267
// Quirk for SH1107 "SH1107_addressing"
264
- // Note... column is y! page is x!
265
- // Page address command = 0xB0
268
+ // Column lower command = 0x00, Column upper command = 0x10
266
269
if (SH1107_addressing ) {
267
- // set the page to our x value
268
- data [0 ] = 0xB0 | ( x1 & 0x0F );
269
- data_length = 1 ;
270
+ data [ 0 ] = (( x1 >> 4 ) & 0x0F ) | 0x10 ; // 0x10 to 0x17
271
+ data [1 ] = x1 & 0x0F ; // 0x00 to 0x0F
272
+ data_length = 2 ;
270
273
}
274
+
271
275
self -> send (self -> bus , data_type , chip_select , data , data_length );
272
276
displayio_display_core_end_transaction (self );
273
277
@@ -288,27 +292,26 @@ void displayio_display_core_set_region_to_update(displayio_display_core_t *self,
288
292
self -> send (self -> bus , DISPLAY_COMMAND , CHIP_SELECT_UNTOUCHED , data , 1 );
289
293
data_length = 0 ;
290
294
}
295
+
291
296
if (self -> ram_height < 0x100 ) {
292
- data [data_length ++ ] = y1 + self -> rowstart ;
293
- data [data_length ++ ] = y2 - 1 + self -> rowstart ;
297
+ data [data_length ++ ] = y1 ;
298
+ data [data_length ++ ] = y2 ;
294
299
} else {
295
- y1 += self -> rowstart ;
296
- y2 += self -> rowstart - 1 ;
297
300
data [data_length ++ ] = y1 >> 8 ;
298
301
data [data_length ++ ] = y1 & 0xff ;
299
302
data [data_length ++ ] = y2 >> 8 ;
300
303
data [data_length ++ ] = y2 & 0xff ;
301
304
}
305
+
302
306
// Quirk for SH1107 "SH1107_addressing"
303
- // Note... column is y! page is x!
304
- // Column lower command = 0x00, Column upper command = 0x10
307
+ // Page address command = 0xB0
305
308
if (SH1107_addressing ) {
306
- data [ 0 ] = y1 & 0x0F ; // 0x00 to 0x0F
307
- data [1 ] = ( y1 >> 4 & 0x0F ) | 0x10 ; // 0x10 to 0x17
308
- data_length = 2 ;
309
+ // set the page to our y value
310
+ data [0 ] = 0xB0 | y1 ;
311
+ data_length = 1 ;
309
312
}
310
- self -> send (self -> bus , data_type , chip_select , data , data_length );
311
313
314
+ self -> send (self -> bus , data_type , chip_select , data , data_length );
312
315
displayio_display_core_end_transaction (self );
313
316
314
317
if (set_current_row_command != NO_COMMAND ) {
0 commit comments