mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
add heltec meshpocket board.
This commit is contained in:
parent
88fbb41016
commit
c9671d7d8d
12 changed files with 560 additions and 19 deletions
|
|
@ -5,9 +5,6 @@
|
|||
#define DISPLAY_ROTATION 3
|
||||
#endif
|
||||
|
||||
#define SCALE_X 1.5625f // 200 / 128
|
||||
#define SCALE_Y 1.5625f // 200 / 128
|
||||
|
||||
bool GxEPDDisplay::begin() {
|
||||
display.epd2.selectSPI(SPI1, SPISettings(4000000, MSBFIRST, SPI_MODE0));
|
||||
SPI1.begin();
|
||||
|
|
@ -77,7 +74,7 @@ void GxEPDDisplay::setColor(Color c) {
|
|||
}
|
||||
|
||||
void GxEPDDisplay::setCursor(int x, int y) {
|
||||
display.setCursor(x*SCALE_X, (y+10)*SCALE_Y);
|
||||
display.setCursor((x+offset_x)*scale_x, (y+offset_y)*scale_y);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::print(const char* str) {
|
||||
|
|
@ -85,17 +82,17 @@ void GxEPDDisplay::print(const char* str) {
|
|||
}
|
||||
|
||||
void GxEPDDisplay::fillRect(int x, int y, int w, int h) {
|
||||
display.fillRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _curr_color);
|
||||
display.fillRect(x*scale_x, y*scale_y, w*scale_x, h*scale_y, _curr_color);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::drawRect(int x, int y, int w, int h) {
|
||||
display.drawRect(x*SCALE_X, y*SCALE_Y, w*SCALE_X, h*SCALE_Y, _curr_color);
|
||||
display.drawRect(x*scale_x, y*scale_y, w*scale_x, h*scale_y, _curr_color);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
||||
// Calculate the base position in display coordinates
|
||||
uint16_t startX = x * SCALE_X;
|
||||
uint16_t startY = y * SCALE_Y;
|
||||
uint16_t startX = x * scale_x;
|
||||
uint16_t startY = y * scale_y;
|
||||
|
||||
// Width in bytes for bitmap processing
|
||||
uint16_t widthInBytes = (w + 7) / 8;
|
||||
|
|
@ -103,15 +100,15 @@ void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
|
|||
// Process the bitmap row by row
|
||||
for (uint16_t by = 0; by < h; by++) {
|
||||
// Calculate the target y-coordinates for this logical row
|
||||
int y1 = startY + (int)(by * SCALE_Y);
|
||||
int y2 = startY + (int)((by + 1) * SCALE_Y);
|
||||
int y1 = startY + (int)(by * scale_y);
|
||||
int y2 = startY + (int)((by + 1) * scale_y);
|
||||
int block_h = y2 - y1;
|
||||
|
||||
// Scan across the row bit by bit
|
||||
for (uint16_t bx = 0; bx < w; bx++) {
|
||||
// Calculate the target x-coordinates for this logical column
|
||||
int x1 = startX + (int)(bx * SCALE_X);
|
||||
int x2 = startX + (int)((bx + 1) * SCALE_X);
|
||||
int x1 = startX + (int)(bx * scale_x);
|
||||
int x2 = startX + (int)((bx + 1) * scale_x);
|
||||
int block_w = x2 - x1;
|
||||
|
||||
// Get the current bit
|
||||
|
|
@ -132,7 +129,7 @@ uint16_t GxEPDDisplay::getTextWidth(const char* str) {
|
|||
int16_t x1, y1;
|
||||
uint16_t w, h;
|
||||
display.getTextBounds(str, 0, 0, &x1, &y1, &w, &h);
|
||||
return ceil((w + 1) / SCALE_X);
|
||||
return ceil((w + 1) / scale_x);
|
||||
}
|
||||
|
||||
void GxEPDDisplay::endFrame() {
|
||||
|
|
|
|||
|
|
@ -13,11 +13,8 @@
|
|||
#include <Fonts/FreeSansBold12pt7b.h>
|
||||
#include <Fonts/FreeSans18pt7b.h>
|
||||
|
||||
#define GxEPD2_DISPLAY_CLASS GxEPD2_BW
|
||||
#define GxEPD2_DRIVER_CLASS GxEPD2_150_BN // DEPG0150BN 200x200, SSD1681, (FPC8101), TTGO T5 V2.4.1
|
||||
|
||||
#include <epd/GxEPD2_150_BN.h> // 1.54" b/w
|
||||
|
||||
#include <epd/GxEPD2_213_B74.h> // 2.13" b/w
|
||||
#include "DisplayDriver.h"
|
||||
|
||||
//GxEPD2_BW<GxEPD2_150_BN, 200> display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)); // DEPG0150BN 200x200, SSD1681, TTGO T5 V2.4.1
|
||||
|
|
@ -25,15 +22,30 @@
|
|||
|
||||
class GxEPDDisplay : public DisplayDriver {
|
||||
|
||||
#if defined(HELTEC_MESH_POCKET)
|
||||
GxEPD2_BW<EINK_DISPLAY_MODEL, EINK_DISPLAY_MODEL::HEIGHT> display;
|
||||
const float scale_x = EINK_SCALE_X;
|
||||
const float scale_y = EINK_SCALE_Y;
|
||||
const float offset_x = EINK_X_OFFSET;
|
||||
const float offset_y = EINK_Y_OFFSET;
|
||||
#else
|
||||
GxEPD2_BW<GxEPD2_150_BN, 200> display;
|
||||
const float scale_x = 1.5625f;
|
||||
const float scale_y = 1.5625f;
|
||||
const float offset_x = 0;
|
||||
const float offset_y = 10;
|
||||
#endif
|
||||
bool _init = false;
|
||||
bool _isOn = false;
|
||||
uint16_t _curr_color;
|
||||
|
||||
public:
|
||||
// there is a margin in y...
|
||||
GxEPDDisplay() : DisplayDriver(128, 128), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {
|
||||
}
|
||||
#if defined(HELTEC_MESH_POCKET)
|
||||
GxEPDDisplay() : DisplayDriver(128, 128), display(EINK_DISPLAY_MODEL(PIN_DISPLAY_CS, PIN_DISPLAY_DC, PIN_DISPLAY_RST, PIN_DISPLAY_BUSY)) {}
|
||||
#else
|
||||
GxEPDDisplay() : DisplayDriver(128, 128), display(GxEPD2_150_BN(DISP_CS, DISP_DC, DISP_RST, DISP_BUSY)) {}
|
||||
#endif
|
||||
|
||||
bool begin();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue