diff options
author | Jan Krupička <[email protected]> | 2018-03-07 02:01:59 +0100 |
---|---|---|
committer | Ben V. Brown <[email protected]> | 2018-03-07 12:01:59 +1100 |
commit | b46c17078baf5d5f2a2da048c5756119bc186d76 (patch) | |
tree | e69829eebaa5386a5537a344fc6afb78bba381f8 | |
parent | a30569eda256dd29dc4ec76a82a92853ee4b931b (diff) | |
download | IronOS-b46c17078baf5d5f2a2da048c5756119bc186d76.tar.gz IronOS-b46c17078baf5d5f2a2da048c5756119bc186d76.zip |
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
-rw-r--r-- | workspace/TS100/src/OLED.cpp | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/workspace/TS100/src/OLED.cpp b/workspace/TS100/src/OLED.cpp index b7527cd2..46850485 100644 --- a/workspace/TS100/src/OLED.cpp +++ b/workspace/TS100/src/OLED.cpp @@ -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)]; - } } } |