Adjust left limit for drawing (#219)
* adjust left limit for drawing do draw area also if part just of it is visible - e.g. do not skip whole letter in rolling description if half of it can be shown * render just visible area part * fix visible area part computation
This commit is contained in:
committed by
Ben V. Brown
parent
a30569eda2
commit
b46c17078b
@@ -286,25 +286,32 @@ void OLED::drawSymbol(uint8_t symbolID) {
|
||||
void OLED::drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height,
|
||||
const uint8_t* ptr) {
|
||||
// Splat this from x->x+wide in two strides
|
||||
if (x < 0)
|
||||
if (x <= -wide)
|
||||
return; //cutoffleft
|
||||
if ((x) > 96)
|
||||
if (x > 96)
|
||||
return; //cutoff right
|
||||
uint8_t width = wide;
|
||||
if ((x + wide) > 96)
|
||||
width = 96 - x; // trimming to draw partials
|
||||
|
||||
uint8_t visibleStart = 0;
|
||||
uint8_t visibleEnd = wide;
|
||||
|
||||
// trimming to draw partials
|
||||
if(x < 0) {
|
||||
visibleStart -= x; //subtract negative value == add absolute value
|
||||
}
|
||||
if(x + wide > 96) {
|
||||
visibleEnd = 96 - x;
|
||||
}
|
||||
|
||||
if (y == 0) {
|
||||
//Splat first line of data
|
||||
for (uint8_t xx = 0; xx < (width); xx++) {
|
||||
for (uint8_t xx = visibleStart; xx < visibleEnd; xx++) {
|
||||
firstStripPtr[xx + x] = ptr[xx];
|
||||
}
|
||||
}
|
||||
if (y == 8 || height == 16) {
|
||||
// Splat the second line
|
||||
for (uint8_t xx = 0; xx < width; xx++) {
|
||||
for (uint8_t xx = visibleStart; xx < visibleEnd; xx++) {
|
||||
secondStripPtr[x + xx] = ptr[xx + (height == 16 ? wide : 0)];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user