Inky Frame: Update C++ library to support 4.0"

This commit is contained in:
Phil Howard 2022-10-05 09:57:16 +01:00
parent 9663be2787
commit 00ca53a30b
3 changed files with 21 additions and 9 deletions

View File

@ -8,7 +8,7 @@
using namespace pimoroni;
InkyFrame inky;
InkyFrame inky(640, 400);
datetime_t now;
datetime_t today;
@ -79,7 +79,7 @@ int days_in_month(datetime_t &dt)
void center_text(std::string message, int y, float scale = 1.0f) {
int32_t tw = inky.measure_text(message, scale);
inky.text(message, {(600 / 2) - (tw / 2), y}, scale);
inky.text(message, {(inky.width / 2) - (tw / 2), y}, scale);
}
void center_text(std::string message, int x, int y, int w, float scale = 1.0f) {
@ -94,7 +94,7 @@ void render_calendar_view() {
//inky.text_aspect(1.1f);
inky.set_pen(InkyFrame::RED);
inky.rectangle({0, 0, width, 448});
inky.rectangle({0, 0, width, inky.height});
inky.set_pen(InkyFrame::WHITE);
@ -343,7 +343,7 @@ void render_calendar_entries() {
int spacing = 5;
int xoff = 240 + spacing;
int yoff = spacing;
int width = 600 - xoff - spacing;
int width = inky.width - xoff - spacing;
int row_height = 50;
//inky.text_tracking(1.0f);

View File

@ -142,7 +142,7 @@ namespace pimoroni {
// Display an image that fills the screen (286*128)
void InkyFrame::image(const uint8_t* data) {
image(data, WIDTH, 0, 0, WIDTH, HEIGHT, 0, 0);
image(data, width, 0, 0, width, height, 0, 0);
}
// Display an image smaller than the screen (sw*sh) at dx, dy

View File

@ -89,14 +89,26 @@ namespace pimoroni {
I2C i2c;
PCF85063A rtc;
int width;
int height;
[[deprecated("Use instance variable width.")]]
static const int WIDTH = 600;
[[deprecated("Use instance variable height.")]]
static const int HEIGHT = 448;
InkyFrame() :
PicoGraphics_Pen3Bit(WIDTH, HEIGHT, nullptr),
uc8159(WIDTH, HEIGHT, {spi0, EINK_CS, CLK, MOSI, PIN_UNUSED, EINK_DC, PIN_UNUSED}),
// Default 5.7" constructor
InkyFrame() : InkyFrame(600, 448) {};
// 600x448 for 5.7"
// 640x400 for 4.0"
InkyFrame(int width, int height) :
PicoGraphics_Pen3Bit(width, height, nullptr),
uc8159(width, height, {spi0, EINK_CS, CLK, MOSI, PIN_UNUSED, EINK_DC, PIN_UNUSED}),
i2c(4, 5),
rtc(&i2c) {
rtc(&i2c),
width(width),
height(height) {
}
void init();