55 #define DISPLAY_ROTATION 3
66#endif
77
8- #define SCALE_X 1 .5625f // 200 / 128
9- #define SCALE_Y 1 .5625f // 200 / 128
10-
118bool GxEPDDisplay::begin () {
129 display.epd2 .selectSPI (SPI1, SPISettings (4000000 , MSBFIRST, SPI_MODE0));
1310 SPI1.begin ();
@@ -77,41 +74,41 @@ void GxEPDDisplay::setColor(Color c) {
7774}
7875
7976void GxEPDDisplay::setCursor (int x, int y) {
80- display.setCursor (x*SCALE_X , (y+10 )*SCALE_Y );
77+ display.setCursor ((x+offset_x)*scale_x , (y+offset_y)*scale_y );
8178}
8279
8380void GxEPDDisplay::print (const char * str) {
8481 display.print (str);
8582}
8683
8784void GxEPDDisplay::fillRect (int x, int y, int w, int h) {
88- display.fillRect (x*SCALE_X , y*SCALE_Y , w*SCALE_X , h*SCALE_Y , _curr_color);
85+ display.fillRect (x*scale_x , y*scale_y , w*scale_x , h*scale_y , _curr_color);
8986}
9087
9188void GxEPDDisplay::drawRect (int x, int y, int w, int h) {
92- display.drawRect (x*SCALE_X , y*SCALE_Y , w*SCALE_X , h*SCALE_Y , _curr_color);
89+ display.drawRect (x*scale_x , y*scale_y , w*scale_x , h*scale_y , _curr_color);
9390}
9491
9592void GxEPDDisplay::drawXbm (int x, int y, const uint8_t * bits, int w, int h) {
9693 // Calculate the base position in display coordinates
97- uint16_t startX = x * SCALE_X ;
98- uint16_t startY = y * SCALE_Y ;
94+ uint16_t startX = x * scale_x ;
95+ uint16_t startY = y * scale_y ;
9996
10097 // Width in bytes for bitmap processing
10198 uint16_t widthInBytes = (w + 7 ) / 8 ;
10299
103100 // Process the bitmap row by row
104101 for (uint16_t by = 0 ; by < h; by++) {
105102 // Calculate the target y-coordinates for this logical row
106- int y1 = startY + (int )(by * SCALE_Y );
107- int y2 = startY + (int )((by + 1 ) * SCALE_Y );
103+ int y1 = startY + (int )(by * scale_y );
104+ int y2 = startY + (int )((by + 1 ) * scale_y );
108105 int block_h = y2 - y1;
109106
110107 // Scan across the row bit by bit
111108 for (uint16_t bx = 0 ; bx < w; bx++) {
112109 // Calculate the target x-coordinates for this logical column
113- int x1 = startX + (int )(bx * SCALE_X );
114- int x2 = startX + (int )((bx + 1 ) * SCALE_X );
110+ int x1 = startX + (int )(bx * scale_x );
111+ int x2 = startX + (int )((bx + 1 ) * scale_x );
115112 int block_w = x2 - x1;
116113
117114 // Get the current bit
@@ -132,7 +129,7 @@ uint16_t GxEPDDisplay::getTextWidth(const char* str) {
132129 int16_t x1, y1;
133130 uint16_t w, h;
134131 display.getTextBounds (str, 0 , 0 , &x1, &y1, &w, &h);
135- return ceil ((w + 1 ) / SCALE_X );
132+ return ceil ((w + 1 ) / scale_x );
136133}
137134
138135void GxEPDDisplay::endFrame () {
0 commit comments