Use compact message text and sender lines on all small displays
This commit is contained in:
1 parent
a7f088290b
commit
eeea15ef01
19 files changed
+507
-141
No files matched your search
@@ -26,6 +26,14 @@
|
||||
#define MESHCORE_HAS_SMALL_DISPLAY 1
|
||||
#endif
|
||||
|
||||
#ifndef UI_SMALL_MESSAGE_FONT
|
||||
#if defined(MESHCORE_HAS_SMALL_DISPLAY)
|
||||
#define UI_SMALL_MESSAGE_FONT 1
|
||||
#else
|
||||
#define UI_SMALL_MESSAGE_FONT 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#undef MESHCORE_DISPLAY_TOKEN_JOIN
|
||||
#undef MESHCORE_DISPLAY_TOKEN_JOIN_INNER
|
||||
#undef MESHCORE_SMALL_DISPLAY_CLASS_U8g2Display
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
#pragma once
|
||||
|
||||
// Picopixel by Sebastian Weber, from Adafruit GFX Library 1.12.6.
|
||||
// Data is unchanged; the type names are independent of a display library.
|
||||
// Source: https://github.com/adafruit/Adafruit-GFX-Library/blob/1.12.6/Fonts/Picopixel.h
|
||||
/*
|
||||
Software License Agreement (BSD License)
|
||||
|
||||
Copyright (c) 2012 Adafruit Industries. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
namespace mesh {
|
||||
namespace ui {
|
||||
|
||||
struct Pixel5Glyph {
|
||||
uint16_t bitmap_offset;
|
||||
uint8_t width, height, advance;
|
||||
int8_t x_offset, y_offset;
|
||||
};
|
||||
|
||||
static const uint8_t pixel5Bitmaps[] = {
|
||||
0xE8, 0xB4, 0x57, 0xD5, 0xF5, 0x00, 0x4E, 0x3E, 0x80, 0xA5, 0x4A, 0x4A,
|
||||
0x5A, 0x50, 0xC0, 0x6A, 0x40, 0x95, 0x80, 0xAA, 0x80, 0x5D, 0x00, 0x60,
|
||||
0xE0, 0x80, 0x25, 0x48, 0x56, 0xD4, 0x75, 0x40, 0xC5, 0x4E, 0xC5, 0x1C,
|
||||
0x97, 0x92, 0xF3, 0x1C, 0x53, 0x54, 0xE5, 0x48, 0x55, 0x54, 0x55, 0x94,
|
||||
0xA0, 0x46, 0x64, 0xE3, 0x80, 0x98, 0xC5, 0x04, 0x56, 0xC6, 0x57, 0xDA,
|
||||
0xD7, 0x5C, 0x72, 0x46, 0xD6, 0xDC, 0xF3, 0xCE, 0xF3, 0x48, 0x72, 0xD4,
|
||||
0xB7, 0xDA, 0xF8, 0x24, 0xD4, 0xBB, 0x5A, 0x92, 0x4E, 0x8E, 0xEB, 0x58,
|
||||
0x80, 0x9D, 0xB9, 0x90, 0x56, 0xD4, 0xD7, 0x48, 0x56, 0xD4, 0x40, 0xD7,
|
||||
0x5A, 0x71, 0x1C, 0xE9, 0x24, 0xB6, 0xD4, 0xB6, 0xA4, 0x8C, 0x6B, 0x55,
|
||||
0x00, 0xB5, 0x5A, 0xB5, 0x24, 0xE5, 0x4E, 0xEA, 0xC0, 0x91, 0x12, 0xD5,
|
||||
0xC0, 0x54, 0xF0, 0x90, 0xC7, 0xF0, 0x93, 0x5E, 0x71, 0x80, 0x25, 0xDE,
|
||||
0x5E, 0x30, 0x6E, 0x80, 0x77, 0x9C, 0x93, 0x5A, 0xB8, 0x45, 0x60, 0x92,
|
||||
0xEA, 0xAA, 0x40, 0xD5, 0x6A, 0xD6, 0x80, 0x55, 0x00, 0xD7, 0x40, 0x75,
|
||||
0x90, 0xE8, 0x71, 0xE0, 0xBA, 0x40, 0xB5, 0x80, 0xB5, 0x00, 0x8D, 0x54,
|
||||
0xAA, 0x80, 0xAC, 0xE0, 0xE5, 0x70, 0x6A, 0x26, 0xFC, 0xC8, 0xAC, 0x5A};
|
||||
|
||||
static const Pixel5Glyph pixel5Glyphs[] = {{0, 0, 0, 2, 0, 1}, // 0x20 ' '
|
||||
{0, 1, 5, 2, 0, -4}, // 0x21 '!'
|
||||
{1, 3, 2, 4, 0, -4}, // 0x22 '"'
|
||||
{2, 5, 5, 6, 0, -4}, // 0x23 '#'
|
||||
{6, 3, 6, 4, 0, -4}, // 0x24 '$'
|
||||
{9, 3, 5, 4, 0, -4}, // 0x25 '%'
|
||||
{11, 4, 5, 5, 0, -4}, // 0x26 '&'
|
||||
{14, 1, 2, 2, 0, -4}, // 0x27 '''
|
||||
{15, 2, 5, 3, 0, -4}, // 0x28 '('
|
||||
{17, 2, 5, 3, 0, -4}, // 0x29 ')'
|
||||
{19, 3, 3, 4, 0, -3}, // 0x2A '*'
|
||||
{21, 3, 3, 4, 0, -3}, // 0x2B '+'
|
||||
{23, 2, 2, 3, 0, 0}, // 0x2C ','
|
||||
{24, 3, 1, 4, 0, -2}, // 0x2D '-'
|
||||
{25, 1, 1, 2, 0, 0}, // 0x2E '.'
|
||||
{26, 3, 5, 4, 0, -4}, // 0x2F '/'
|
||||
{28, 3, 5, 4, 0, -4}, // 0x30 '0'
|
||||
{30, 2, 5, 3, 0, -4}, // 0x31 '1'
|
||||
{32, 3, 5, 4, 0, -4}, // 0x32 '2'
|
||||
{34, 3, 5, 4, 0, -4}, // 0x33 '3'
|
||||
{36, 3, 5, 4, 0, -4}, // 0x34 '4'
|
||||
{38, 3, 5, 4, 0, -4}, // 0x35 '5'
|
||||
{40, 3, 5, 4, 0, -4}, // 0x36 '6'
|
||||
{42, 3, 5, 4, 0, -4}, // 0x37 '7'
|
||||
{44, 3, 5, 4, 0, -4}, // 0x38 '8'
|
||||
{46, 3, 5, 4, 0, -4}, // 0x39 '9'
|
||||
{48, 1, 3, 2, 0, -3}, // 0x3A ':'
|
||||
{49, 2, 4, 3, 0, -3}, // 0x3B ';'
|
||||
{50, 2, 3, 3, 0, -3}, // 0x3C '<'
|
||||
{51, 3, 3, 4, 0, -3}, // 0x3D '='
|
||||
{53, 2, 3, 3, 0, -3}, // 0x3E '>'
|
||||
{54, 3, 5, 4, 0, -4}, // 0x3F '?'
|
||||
{56, 3, 5, 4, 0, -4}, // 0x40 '@'
|
||||
{58, 3, 5, 4, 0, -4}, // 0x41 'A'
|
||||
{60, 3, 5, 4, 0, -4}, // 0x42 'B'
|
||||
{62, 3, 5, 4, 0, -4}, // 0x43 'C'
|
||||
{64, 3, 5, 4, 0, -4}, // 0x44 'D'
|
||||
{66, 3, 5, 4, 0, -4}, // 0x45 'E'
|
||||
{68, 3, 5, 4, 0, -4}, // 0x46 'F'
|
||||
{70, 3, 5, 4, 0, -4}, // 0x47 'G'
|
||||
{72, 3, 5, 4, 0, -4}, // 0x48 'H'
|
||||
{74, 1, 5, 2, 0, -4}, // 0x49 'I'
|
||||
{75, 3, 5, 4, 0, -4}, // 0x4A 'J'
|
||||
{77, 3, 5, 4, 0, -4}, // 0x4B 'K'
|
||||
{79, 3, 5, 4, 0, -4}, // 0x4C 'L'
|
||||
{81, 5, 5, 6, 0, -4}, // 0x4D 'M'
|
||||
{85, 4, 5, 5, 0, -4}, // 0x4E 'N'
|
||||
{88, 3, 5, 4, 0, -4}, // 0x4F 'O'
|
||||
{90, 3, 5, 4, 0, -4}, // 0x50 'P'
|
||||
{92, 3, 6, 4, 0, -4}, // 0x51 'Q'
|
||||
{95, 3, 5, 4, 0, -4}, // 0x52 'R'
|
||||
{97, 3, 5, 4, 0, -4}, // 0x53 'S'
|
||||
{99, 3, 5, 4, 0, -4}, // 0x54 'T'
|
||||
{101, 3, 5, 4, 0, -4}, // 0x55 'U'
|
||||
{103, 3, 5, 4, 0, -4}, // 0x56 'V'
|
||||
{105, 5, 5, 6, 0, -4}, // 0x57 'W'
|
||||
{109, 3, 5, 4, 0, -4}, // 0x58 'X'
|
||||
{111, 3, 5, 4, 0, -4}, // 0x59 'Y'
|
||||
{113, 3, 5, 4, 0, -4}, // 0x5A 'Z'
|
||||
{115, 2, 5, 3, 0, -4}, // 0x5B '['
|
||||
{117, 3, 5, 4, 0, -4}, // 0x5C '\'
|
||||
{119, 2, 5, 3, 0, -4}, // 0x5D ']'
|
||||
{121, 3, 2, 4, 0, -4}, // 0x5E '^'
|
||||
{122, 4, 1, 4, 0, 1}, // 0x5F '_'
|
||||
{123, 2, 2, 3, 0, -4}, // 0x60 '`'
|
||||
{124, 3, 4, 4, 0, -3}, // 0x61 'a'
|
||||
{126, 3, 5, 4, 0, -4}, // 0x62 'b'
|
||||
{128, 3, 3, 4, 0, -2}, // 0x63 'c'
|
||||
{130, 3, 5, 4, 0, -4}, // 0x64 'd'
|
||||
{132, 3, 4, 4, 0, -3}, // 0x65 'e'
|
||||
{134, 2, 5, 3, 0, -4}, // 0x66 'f'
|
||||
{136, 3, 5, 4, 0, -3}, // 0x67 'g'
|
||||
{138, 3, 5, 4, 0, -4}, // 0x68 'h'
|
||||
{140, 1, 5, 2, 0, -4}, // 0x69 'i'
|
||||
{141, 2, 6, 3, 0, -4}, // 0x6A 'j'
|
||||
{143, 3, 5, 4, 0, -4}, // 0x6B 'k'
|
||||
{145, 2, 5, 3, 0, -4}, // 0x6C 'l'
|
||||
{147, 5, 3, 6, 0, -2}, // 0x6D 'm'
|
||||
{149, 3, 3, 4, 0, -2}, // 0x6E 'n'
|
||||
{151, 3, 3, 4, 0, -2}, // 0x6F 'o'
|
||||
{153, 3, 4, 4, 0, -2}, // 0x70 'p'
|
||||
{155, 3, 4, 4, 0, -2}, // 0x71 'q'
|
||||
{157, 2, 3, 3, 0, -2}, // 0x72 'r'
|
||||
{158, 3, 4, 4, 0, -3}, // 0x73 's'
|
||||
{160, 2, 5, 3, 0, -4}, // 0x74 't'
|
||||
{162, 3, 3, 4, 0, -2}, // 0x75 'u'
|
||||
{164, 3, 3, 4, 0, -2}, // 0x76 'v'
|
||||
{166, 5, 3, 6, 0, -2}, // 0x77 'w'
|
||||
{168, 3, 3, 4, 0, -2}, // 0x78 'x'
|
||||
{170, 3, 4, 4, 0, -2}, // 0x79 'y'
|
||||
{172, 3, 4, 4, 0, -3}, // 0x7A 'z'
|
||||
{174, 3, 5, 4, 0, -4}, // 0x7B '{'
|
||||
{176, 1, 6, 2, 0, -4}, // 0x7C '|'
|
||||
{177, 3, 5, 4, 0, -4}, // 0x7D '}'
|
||||
{179, 4, 2, 5, 0, -3}}; // 0x7E '~'
|
||||
|
||||
|
||||
} // namespace ui
|
||||
} // namespace mesh
|
||||
@@ -0,0 +1,97 @@
|
||||
#pragma once
|
||||
|
||||
#include "DisplayDriver.h"
|
||||
#include "DisplayTextLayout.h"
|
||||
#include "Pixel5FontData.h"
|
||||
|
||||
namespace mesh {
|
||||
namespace ui {
|
||||
|
||||
// Draw through the common pixel interface so OLED, TFT and U8g2 panels use
|
||||
// identical glyphs. This stack wrapper leaves the driver's normal font alone.
|
||||
class Pixel5Text : public DisplayDriver {
|
||||
DisplayDriver& _display;
|
||||
int _x = 0, _y = 0;
|
||||
|
||||
static const Pixel5Glyph& glyph(uint8_t c) {
|
||||
return pixel5Glyphs[(c >= 32 && c <= 126 ? c : '?') - 32];
|
||||
}
|
||||
|
||||
public:
|
||||
explicit Pixel5Text(DisplayDriver& display)
|
||||
: DisplayDriver(display.width(), display.height()), _display(display) {}
|
||||
static constexpr int line_height = 7;
|
||||
static constexpr int glyph_height = 6; // 5px capitals plus descenders
|
||||
|
||||
bool isOn() override { return _display.isOn(); }
|
||||
void turnOn() override { _display.turnOn(); }
|
||||
void turnOff() override { _display.turnOff(); }
|
||||
void clear() override { _display.clear(); }
|
||||
void startFrame(ColorVal bkg) override { _display.startFrame(bkg); }
|
||||
void endFrame() override { _display.endFrame(); }
|
||||
void setTextSize(int) override {} // This font deliberately has one size.
|
||||
void setColor(ColorVal color) override { _display.setColor(color); }
|
||||
void setCursor(int x, int y) override { _x = x; _y = y; }
|
||||
void fillRect(int x, int y, int w, int h) override {
|
||||
_display.fillRect(x, y, w, h);
|
||||
}
|
||||
void drawRect(int x, int y, int w, int h) override {
|
||||
_display.drawRect(x, y, w, h);
|
||||
}
|
||||
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override {
|
||||
_display.drawXbm(x, y, bits, w, h);
|
||||
}
|
||||
uint16_t getTextWidth(const char* str) override {
|
||||
uint16_t result = 0;
|
||||
while (*str) result += glyph((uint8_t)*str++).advance;
|
||||
return result;
|
||||
}
|
||||
void print(const char* str) override {
|
||||
while (*str) {
|
||||
const Pixel5Glyph& g = glyph((uint8_t)*str++);
|
||||
for (int row = 0; row < g.height; ++row) {
|
||||
const int y = _y + 4 + g.y_offset + row;
|
||||
if (y < 0 || y >= height()) continue;
|
||||
for (int col = 0; col < g.width; ++col) {
|
||||
const int bit = row * g.width + col;
|
||||
if (!(pixel5Bitmaps[g.bitmap_offset + bit / 8]
|
||||
& (0x80 >> (bit % 8)))) continue;
|
||||
const int x = _x + g.x_offset + col;
|
||||
if (x >= 0 && x < width()) _display.fillRect(x, y, 1, 1);
|
||||
}
|
||||
}
|
||||
_x += g.advance;
|
||||
}
|
||||
}
|
||||
void printWordWrap(const char* str, int max_width) override {
|
||||
if (max_width > width() - _x) max_width = width() - _x;
|
||||
const int lines = (height() - _y + line_height - glyph_height) / line_height;
|
||||
drawTextWrapped(*this, _x, _y, max_width, line_height, lines, str);
|
||||
}
|
||||
};
|
||||
|
||||
inline int smallMessageLineCount(int height, int message_y) {
|
||||
const int remaining = height - message_y;
|
||||
return remaining < Pixel5Text::glyph_height ? 0
|
||||
: (remaining + Pixel5Text::line_height - Pixel5Text::glyph_height)
|
||||
/ Pixel5Text::line_height;
|
||||
}
|
||||
|
||||
inline void drawSmallMessageBody(DisplayDriver& display, const char* origin,
|
||||
const char* message, int origin_y = 14,
|
||||
int message_y = 21, int bottom = -1) {
|
||||
Pixel5Text text(display);
|
||||
char translated[161];
|
||||
text.translateUTF8ToBlocks(translated, origin, sizeof(translated));
|
||||
text.setColor(UIColor::secondary_txt);
|
||||
text.drawTextEllipsized(0, origin_y, display.width(), translated);
|
||||
text.translateUTF8ToBlocks(translated, message, sizeof(translated));
|
||||
text.setColor(UIColor::primary_txt);
|
||||
const int height = bottom < 0 || bottom > display.height()
|
||||
? display.height() : bottom;
|
||||
drawTextWrapped(text, 0, message_y, display.width(), Pixel5Text::line_height,
|
||||
smallMessageLineCount(height, message_y), translated);
|
||||
}
|
||||
|
||||
} // namespace ui
|
||||
} // namespace mesh
|
||||
@@ -1,16 +1,5 @@
|
||||
#include "SSD1306Display.h"
|
||||
|
||||
#if defined(UI_SSD1306_PICOPIXEL_MESSAGES) && UI_SSD1306_PICOPIXEL_MESSAGES == 1
|
||||
#include <Fonts/Picopixel.h>
|
||||
#include "DisplayTextLayout.h"
|
||||
|
||||
// The message UI has already replaced unsupported UTF-8 with CP437 blocks.
|
||||
// Picopixel is ASCII-only; retain a visible placeholder for those characters.
|
||||
static uint8_t picopixelCharacter(uint8_t c) {
|
||||
return c >= 0x20 && c <= 0x7E ? c : '?';
|
||||
}
|
||||
#endif
|
||||
|
||||
bool SSD1306Display::i2c_probe(TwoWire& wire, uint8_t addr) {
|
||||
wire.beginTransmission(addr);
|
||||
uint8_t error = wire.endTransmission();
|
||||
@@ -123,43 +112,13 @@ void SSD1306Display::setColor(ColorVal c) {
|
||||
}
|
||||
|
||||
void SSD1306Display::setCursor(int x, int y) {
|
||||
#if defined(UI_SSD1306_PICOPIXEL_MESSAGES) && UI_SSD1306_PICOPIXEL_MESSAGES == 1
|
||||
// GFX custom fonts take a baseline; the shared UI takes a top coordinate.
|
||||
if (_picopixel_message) y += 4;
|
||||
#endif
|
||||
display.setCursor(x, y);
|
||||
}
|
||||
|
||||
void SSD1306Display::print(const char* str) {
|
||||
#if defined(UI_SSD1306_PICOPIXEL_MESSAGES) && UI_SSD1306_PICOPIXEL_MESSAGES == 1
|
||||
if (_picopixel_message) {
|
||||
while (*str) display.write(picopixelCharacter((uint8_t)*str++));
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
display.print(str);
|
||||
}
|
||||
|
||||
#if defined(UI_SSD1306_PICOPIXEL_MESSAGES) && UI_SSD1306_PICOPIXEL_MESSAGES == 1
|
||||
void SSD1306Display::printWordWrap(const char* str, int max_width) {
|
||||
const int x = display.getCursorX();
|
||||
const int y = display.getCursorY();
|
||||
if (max_width > width() - x) max_width = width() - x;
|
||||
// Capitals are 5px high; descenders can use a sixth pixel. Leave one blank
|
||||
// row between lines and never start a partially visible final line.
|
||||
const int max_lines = (height() - y + 1) / 7;
|
||||
display.setFont(&Picopixel);
|
||||
display.setTextSize(1);
|
||||
display.setTextWrap(false);
|
||||
_picopixel_message = true;
|
||||
mesh::ui::drawTextWrapped(*this, x, y, max_width, 7, max_lines, str);
|
||||
_picopixel_message = false;
|
||||
display.setFont(nullptr);
|
||||
display.setTextWrap(true);
|
||||
display.setCursor(x, y);
|
||||
}
|
||||
#endif
|
||||
|
||||
void SSD1306Display::fillRect(int x, int y, int w, int h) {
|
||||
display.fillRect(x, y, w, h, _color);
|
||||
}
|
||||
@@ -173,17 +132,6 @@ void SSD1306Display::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
||||
}
|
||||
|
||||
uint16_t SSD1306Display::getTextWidth(const char* str) {
|
||||
#if defined(UI_SSD1306_PICOPIXEL_MESSAGES) && UI_SSD1306_PICOPIXEL_MESSAGES == 1
|
||||
if (_picopixel_message) {
|
||||
// Include advances for spaces; GFX's ink bounds omit trailing whitespace.
|
||||
uint16_t width = 0;
|
||||
while (*str) {
|
||||
const uint8_t c = picopixelCharacter((uint8_t)*str++);
|
||||
width += pgm_read_byte(&PicopixelGlyphs[c - 0x20].xAdvance);
|
||||
}
|
||||
return width;
|
||||
}
|
||||
#endif
|
||||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||
|
||||
@@ -27,9 +27,6 @@ class SSD1306Display : public DisplayDriver {
|
||||
#endif
|
||||
uint8_t _color;
|
||||
RefCountedDigitalPin* _peripher_power;
|
||||
#if defined(UI_SSD1306_PICOPIXEL_MESSAGES) && UI_SSD1306_PICOPIXEL_MESSAGES == 1
|
||||
bool _picopixel_message = false;
|
||||
#endif
|
||||
|
||||
bool i2c_probe(TwoWire& wire, uint8_t addr);
|
||||
void applyRotation();
|
||||
@@ -54,9 +51,6 @@ public:
|
||||
void setColor(ColorVal c) override;
|
||||
void setCursor(int x, int y) override;
|
||||
void print(const char* str) override;
|
||||
#if defined(UI_SSD1306_PICOPIXEL_MESSAGES) && UI_SSD1306_PICOPIXEL_MESSAGES == 1
|
||||
void printWordWrap(const char* str, int max_width) override;
|
||||
#endif
|
||||
void fillRect(int x, int y, int w, int h) override;
|
||||
void drawRect(int x, int y, int w, int h) override;
|
||||
void drawXbm(int x, int y, const uint8_t* bits, int w, int h) override;
|
||||
|
||||
@@ -632,7 +632,10 @@ void ST7735Display::print(const char* str) {
|
||||
|
||||
void ST7735Display::fillRect(int x, int y, int w, int h) {
|
||||
if (!spriteReady()) return;
|
||||
sprite->fillRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, curr_color);
|
||||
// Scale the edges, so adjacent 1px font cells meet at fractional scaling.
|
||||
const int left = x*SCALE_X, top = y*SCALE_Y;
|
||||
sprite->fillRect(left, top, int((x+w)*SCALE_X)-left,
|
||||
int((y+h)*SCALE_Y)-top, curr_color);
|
||||
}
|
||||
|
||||
void ST7735Display::drawRect(int x, int y, int w, int h) {
|
||||
|
||||
Reference in new issue
Block a user