Updated standard library
Diff: RA8875.cpp
- Revision:
- 153:8a85efb3eb71
- Parent:
- 152:a013ac0133e4
- Child:
- 154:ad2450fc3dc3
--- a/RA8875.cpp Mon Nov 06 01:41:55 2017 +0000 +++ b/RA8875.cpp Sun Jul 29 00:32:51 2018 +0000 @@ -115,6 +115,7 @@ obj_callback = NULL; method_callback = NULL; idle_callback = NULL; + fontScaleX = fontScaleY = 1; } @@ -132,6 +133,7 @@ obj_callback = NULL; method_callback = NULL; idle_callback = NULL; + fontScaleX = fontScaleY = 1; // Cap touch panel config m_addr = (FT5206_I2C_ADDRESS << 1); @@ -1013,6 +1015,8 @@ if (vScale == -1) vScale = hScale; if (hScale >= 1 && hScale <= 4 && vScale >= 1 && vScale <= 4) { + fontScaleX = hScale; // save for use with a Soft Font + fontScaleY = vScale; reg &= 0xF0; // keep the high nibble as is. reg |= ((hScale - 1) << 2); reg |= ((vScale - 1) << 0); @@ -1077,7 +1081,7 @@ cursor_y = windowrect.p1.y; // @todo Should it scroll? } (void)character(cursor_x, cursor_y, c); - cursor_x += charWidth; + cursor_x += charWidth * fontScaleX; } } } @@ -1309,38 +1313,48 @@ return(noerror); } +// With a font scale X = 1, a pixel stream is "abcdefg..." +// With a font scale X = 2, a pixel stream is "aabbccddeeffgg..." +// With a font scale Y = 2, a pixel stream is "abcdefg..." +// "abcdefg..." +// RetCode_t RA8875::booleanStream(loc_t x, loc_t y, dim_t w, dim_t h, const uint8_t * boolStream) { PERFORMANCE_RESET; + const uint8_t * rowStream; rect_t restore = windowrect; - - window(x, y, w, h); + window(x, y, w * fontScaleX, h * fontScaleY); // Scale from font scale factors SetGraphicsCursor(x, y); _StartGraphicsStream(); _select(true); _spiwrite(0x00); // Cmd: write data while (h--) { - uint8_t pixels = w; - uint8_t bitmask = 0x01; - - while (pixels) { - uint8_t byte = *boolStream; - //INFO("byte, mask: %02X, %02X", byte, bitmask); - color_t c = (byte & bitmask) ? _foreground : _background; - if (screenbpp == 16) { - _spiwrite(c >> 8); - _spiwrite(c & 0xFF); - } else { - _spiwrite(_cvt16to8(c)); + for (int dy=0; dy<fontScaleY; dy++) { // Vertical Font Scale Factor + uint8_t pixels = w; + uint8_t bitmask = 0x01; + rowStream = boolStream; + while (pixels) { + uint8_t byte = *rowStream; + //INFO("byte, mask: %02X, %02X", byte, bitmask); + color_t c = (byte & bitmask) ? _foreground : _background; + + for (int dx=0; dx<fontScaleX; dx++) { // Horizontal Font Scale Factor + if (screenbpp == 16) { + _spiwrite(c >> 8); + _spiwrite(c & 0xFF); + } else { + _spiwrite(_cvt16to8(c)); + } } - bitmask <<= 1; - if (pixels > 1 && bitmask == 0) { - bitmask = 0x01; - boolStream++; + bitmask <<= 1; + if (pixels > 1 && bitmask == 0) { + bitmask = 0x01; + rowStream++; + } + pixels--; } - pixels--; } - boolStream++; + boolStream += (rowStream - boolStream + 1); } _select(false); _EndGraphicsStream();