mirror of
https://github.com/usetrmnl/bb_epaper.git
synced 2026-04-29 13:43:26 -07:00
Fixed boundary issue with character drawing
This commit is contained in:
@@ -18,6 +18,20 @@ int iDataTime, iOpTime;
|
||||
#define CLK_PIN 36
|
||||
#define MOSI_PIN 35
|
||||
#define POWER_PIN 39
|
||||
#define BUTTON1 1
|
||||
#define BUTTON2 3
|
||||
#elif defined (ARDUINO_ESP32C6_DEV) // Our C6 epaper PCB
|
||||
#define CS_PIN 2
|
||||
#define DC_PIN 3
|
||||
#define RESET_PIN 5
|
||||
#define BUSY_PIN 4
|
||||
#define CLK_PIN 1
|
||||
#define MOSI_PIN 0
|
||||
#define POWER_PIN -1
|
||||
#define BUTTON1 18
|
||||
#define BUTTON2 19
|
||||
#define SDA_PIN 7
|
||||
#define SCL_PIN 6
|
||||
#else // must be Laska_Kit ESPInk
|
||||
#define CS_PIN 5
|
||||
#define DC_PIN 17
|
||||
@@ -26,10 +40,10 @@ int iDataTime, iOpTime;
|
||||
#define CLK_PIN 18
|
||||
#define MOSI_PIN 23
|
||||
#define POWER_PIN 2
|
||||
#endif
|
||||
|
||||
#define BUTTON1 1
|
||||
#define BUTTON2 3
|
||||
#endif
|
||||
|
||||
#else
|
||||
// These pin assignments are for a custom e-paper
|
||||
// adapter add-on with 2 push buttons
|
||||
@@ -80,6 +94,9 @@ const char *szPanelNames[] = {
|
||||
"EP29YR_168x384 ", // GDEY029F51H
|
||||
"EP583_648x480 ", // DEPG0583BN
|
||||
"EP26R_152x296 ", // Solum 2.6" B/W/R ESL harvested panel
|
||||
"EP73_800x480 ", // GEDY073D46
|
||||
"EP73_SPECTRA ", // 800x480 Spectra 6 (faster)
|
||||
"EP097R_88x184 ", // GDEM0097F51 B/W/R
|
||||
NULL
|
||||
};
|
||||
// names of the operating modes
|
||||
@@ -96,7 +113,7 @@ enum {
|
||||
|
||||
// List of supported colors for each panel type
|
||||
// 2 = Black/White, 3 = Black/White/Red
|
||||
const uint8_t u8PanelColors[] = {2,2,2,2,2,2,2,2,2,2,3,2,3,3,3,2,2,2,2,3,2,2,4,4,4,2,3};
|
||||
const uint8_t u8PanelColors[] = {2,2,2,2,2,2,2,2,2,2,3,2,3,3,3,2,2,2,2,3,2,2,4,4,4,2,3,7,7,3};
|
||||
|
||||
void WaitForButton(void)
|
||||
{
|
||||
@@ -377,6 +394,9 @@ void setup() {
|
||||
// Serial.begin(115200);
|
||||
// delay(3000);
|
||||
// Serial.println("Starting...");
|
||||
#ifdef SDA_PIN
|
||||
oled.setI2CPins(SDA_PIN, SCL_PIN);
|
||||
#endif
|
||||
oled.I2Cbegin();
|
||||
oled.fillScreen(OBD_WHITE);
|
||||
pinMode(BUTTON1, INPUT_PULLUP);
|
||||
|
||||
@@ -30,13 +30,24 @@
|
||||
#include <bb_epaper.h>
|
||||
//BBEPAPER bbep(EP27B_176x264);
|
||||
//BBEPAPER bbep(EP213B_122x250);
|
||||
BBEPAPER bbep(EP583_648x480);
|
||||
//BBEPAPER bbep(EP295_128x296);
|
||||
//BBEPAPER bbep(EP583_648x480);
|
||||
BBEPAPER bbep(EP295_128x296);
|
||||
// My Arduino Nano 33 BLE e-paper adapter
|
||||
#ifdef ARDUINO_ARCH_NRF52840
|
||||
#define DC_PIN 16
|
||||
#define BUSY_PIN 15
|
||||
#define RESET_PIN 14
|
||||
#define CS_PIN 10
|
||||
#define MOSI_PIN MOSI
|
||||
#define SCK_PIN SCK
|
||||
#else // Fasani/Bank C6 epaper PCB
|
||||
#define DC_PIN 3
|
||||
#define BUSY_PIN 4
|
||||
#define RESET_PIN 5
|
||||
#define CS_PIN 2
|
||||
#define MOSI_PIN 0
|
||||
#define SCK_PIN 1
|
||||
#endif
|
||||
// Badger2040
|
||||
//#define CS_PIN 17
|
||||
//#define BUSY_PIN 26
|
||||
@@ -61,7 +72,7 @@ void DrawScene(int i, int iPlane)
|
||||
void setup()
|
||||
{
|
||||
int i = 0;
|
||||
bbep.initIO(DC_PIN, RESET_PIN, BUSY_PIN, CS_PIN);
|
||||
bbep.initIO(DC_PIN, RESET_PIN, BUSY_PIN, CS_PIN, MOSI_PIN, SCK_PIN, 8000000);
|
||||
bbep.setRotation(90); // use panel in landscape orientation
|
||||
// work in bufferless mode (no memory on MCU needed)
|
||||
DrawScene(i, PLANE_DUPLICATE); // draw "old" data (full refresh only needs "old" data plane)
|
||||
|
||||
+15
-1
@@ -61,6 +61,19 @@ const uint8_t epd35r_init_sequence_full[] PROGMEM = {
|
||||
0x00
|
||||
};
|
||||
|
||||
// init sequence for GDEM0097F51
|
||||
const uint8_t epd097r_init_sequence_full[] PROGMEM = {
|
||||
0x03, UC8151_PSR, 0xcf, 0x8d,
|
||||
0x06, UC8151_PWR, 0x03, 0x10, 0x3f, 0x3f, 0x0d,
|
||||
0x01, UC8151_PON, // power on
|
||||
BUSY_WAIT,
|
||||
0x03, UC8151_TRES, 88, 184, // resolution
|
||||
0x04, UC8151_BTST, 0x17,0x17,0x17, // booster soft-start config - START_10MS | STRENGTH_3 | OFF_6_58US
|
||||
// 0x02, 0x00, 0x0f, // LUT from OTP
|
||||
0x02, UC8151_CDI, 0x5c, // inverted, white border
|
||||
0x00
|
||||
};
|
||||
|
||||
// init sequence for GDEW042Z15
|
||||
const uint8_t epd42r2_init_sequence_full[] PROGMEM = {
|
||||
0x03, UC8151_PSR, 0xcf, 0x8d,
|
||||
@@ -1297,9 +1310,10 @@ const EPD_PANEL panelDefs[] PROGMEM = {
|
||||
{648, 480, 0, epd583_init_sequence_full, NULL, epd583_init_sequence_part, 0, BBEP_CHIP_UC81xx}, // EP583_648x480
|
||||
{128, 296, 0, epd293_init_sequence_full, epd293_init_sequence_fast, epd296_init_sequence_part, BBEP_PARTIAL2, BBEP_CHIP_SSD16xx}, // EP296_128x296 Waveshare 2.9" V2 B/W
|
||||
{152, 296, 0, epd26r_init_sequence_full, NULL, NULL, BBEP_3COLOR, BBEP_CHIP_SSD16xx}, // EP26R_152x296 Solum ESL harvested 2.6" panel B/W/R
|
||||
{540, 960, 0, (const uint8_t *)epd47_it8951_init, NULL, NULL, 0, BBEP_CHIP_IT8951}, // EP47_540x960 = M5Paper (original)
|
||||
// {540, 960, 0, (const uint8_t *)epd47_it8951_init, NULL, NULL, 0, BBEP_CHIP_IT8951}, // EP47_540x960 = M5Paper (original)
|
||||
{800, 480, 0, epd73_init, NULL, NULL, BBEP_7COLOR, BBEP_CHIP_UC81xx}, // EP73_800x480 GEDY073D4 6 7-color 800x480
|
||||
{800, 480, 0, epd73_spectra_init, NULL, NULL, BBEP_7COLOR, BBEP_CHIP_UC81xx}, // EP73_800x480 Spectra 6 7-color 800x480
|
||||
{88, 184, 0, epd097r_init_sequence_full, NULL, NULL, BBEP_3COLOR, BBEP_CHIP_UC81xx}, // EP097R_88x184 B/W/R and B/W/Y
|
||||
};
|
||||
//
|
||||
// Set the e-paper panel type
|
||||
|
||||
+21
-17
@@ -547,17 +547,17 @@ int bbepLoadG5(BBEPDISP *pBBEP, const uint8_t *pG5, int x, int y, int iFG, int i
|
||||
#ifndef NO_RAM
|
||||
src_mask = 0; // make it read a byte to start
|
||||
s = u8Cache;
|
||||
for (tx=0; tx<cx; tx++) {
|
||||
for (tx=x; tx<x+cx; tx++) {
|
||||
if (src_mask == 0) { // need to load the next byte
|
||||
u8 = *s++;
|
||||
src_mask = 0x80; // MSB on left
|
||||
}
|
||||
if (u8 & src_mask) {
|
||||
if (iFG != BBEP_TRANSPARENT)
|
||||
(*pBBEP->pfnSetPixelFast)(pBBEP, x+tx, y+ty, (uint8_t)iFG);
|
||||
(*pBBEP->pfnSetPixelFast)(pBBEP, tx, ty, (uint8_t)iFG);
|
||||
} else {
|
||||
if (iBG != BBEP_TRANSPARENT)
|
||||
(*pBBEP->pfnSetPixelFast)(pBBEP, x+tx, y+ty, (uint8_t)iBG);
|
||||
(*pBBEP->pfnSetPixelFast)(pBBEP, tx, ty, (uint8_t)iBG);
|
||||
}
|
||||
src_mask >>= 1;
|
||||
} // for tx
|
||||
@@ -800,7 +800,7 @@ void bbepSetTextWrap(BBEPDISP *pBBEP, int bWrap)
|
||||
//
|
||||
int bbepWriteStringCustom(BBEPDISP *pBBEP, BB_FONT *pFont, int x, int y, char *szMsg, int iColor, uint8_t iPlane)
|
||||
{
|
||||
int rc, i, h, w, j, end_y, dx, dy, tx, ty, iSrcPitch, iPitch, iBG;
|
||||
int rc, i, h, w, j, end_y, dx, dy, tx, ty, tw, iSrcPitch, iPitch, iBG;
|
||||
signed int n;
|
||||
unsigned int c, bInvert = 0;
|
||||
uint8_t *s, uc0, uc1;
|
||||
@@ -877,27 +877,31 @@ int bbepWriteStringCustom(BBEPDISP *pBBEP, BB_FONT *pFont, int x, int y, char *s
|
||||
}
|
||||
if (pBBEP->ucScreen) { // backbuffer, draw pixels
|
||||
#ifndef NO_RAM
|
||||
tw = w;
|
||||
if (x+tw > pBBEP->width) tw = pBBEP->width - x; // clip to right edge
|
||||
for (ty=dy; ty<end_y && ty < pBBEP->height; ty++) {
|
||||
uint8_t u8, u8Count;
|
||||
g5_decode_line(&g5dec, u8Cache);
|
||||
s = u8Cache;
|
||||
u8 = *s++;
|
||||
u8Count = 8;
|
||||
for (tx=x; tx<x+w; tx++) {
|
||||
if (u8 & 0x80) {
|
||||
if (iColor != BBEP_TRANSPARENT) {
|
||||
(*pBBEP->pfnSetPixelFast)(pBBEP, tx, ty, iColor);
|
||||
if (ty >= 0) {
|
||||
for (tx=x; tx<x+tw; tx++) {
|
||||
if (u8 & 0x80) {
|
||||
if (iColor != BBEP_TRANSPARENT) {
|
||||
(*pBBEP->pfnSetPixelFast)(pBBEP, tx, ty, iColor);
|
||||
}
|
||||
} else if (iBG != BBEP_TRANSPARENT) {
|
||||
(*pBBEP->pfnSetPixelFast)(pBBEP, tx, ty, iBG);
|
||||
}
|
||||
u8 <<= 1;
|
||||
u8Count--;
|
||||
if (u8Count == 0) {
|
||||
u8Count = 8;
|
||||
u8 = *s++;
|
||||
}
|
||||
} else if (iBG != BBEP_TRANSPARENT) {
|
||||
(*pBBEP->pfnSetPixelFast)(pBBEP, tx, ty, iBG);
|
||||
}
|
||||
u8 <<= 1;
|
||||
u8Count--;
|
||||
if (u8Count == 0) {
|
||||
u8Count = 8;
|
||||
u8 = *s++;
|
||||
}
|
||||
}
|
||||
} // on the screen
|
||||
}
|
||||
#endif // NO_RAM
|
||||
} else { // draw directly into EPD memory
|
||||
|
||||
+4
-4
@@ -133,9 +133,9 @@ enum {
|
||||
EP583_648x480, // DEPG0583BN
|
||||
EP296_128x296, // Waveshare 2.9" 128x296 B/W V2
|
||||
EP26R_152x296, // Solum 2.6" B/W/R harvested panel
|
||||
EP47_540x960, // M5Paper
|
||||
EP73_800x480, // GEDY073D46 (slower, EOL 7-color)
|
||||
EP73_SPECTRA_800x480, // Spectra 6 7-color 800x480
|
||||
EP097R_88x184, // GDEM0097F51 B/W/R B/W/YY
|
||||
// EP583R_600x448, // 4-bits per pixel needs different support
|
||||
EP_PANEL_COUNT
|
||||
};
|
||||
@@ -171,9 +171,9 @@ enum {
|
||||
#define BBEP_4COLOR 0x0008
|
||||
#define BBEP_4GRAY 0x0010
|
||||
#define BBEP_7COLOR 0x0020
|
||||
#define BBEP_16GRAY 0x0040
|
||||
#define BBEP_CS_EVERY_BYTE 0x0080
|
||||
#define BBEP_PARTIAL2 0x0100
|
||||
#define BBEP_16GRAY 0x0020
|
||||
#define BBEP_CS_EVERY_BYTE 0x0040
|
||||
#define BBEP_PARTIAL2 0x0080
|
||||
|
||||
#define BBEP_BLACK 0
|
||||
#define BBEP_WHITE 1
|
||||
|
||||
Reference in New Issue
Block a user