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 ();
@@ -84,7 +81,7 @@ void GxEPDDisplay::setColor(Color c) {
8481void GxEPDDisplay::setCursor (int x, int y) {
8582 display_crc.update <int >(x);
8683 display_crc.update <int >(y);
87- display.setCursor (x*SCALE_X , (y+10 )*SCALE_Y );
84+ display.setCursor ((x+offset_x)*scale_x , (y+offset_y)*scale_y );
8885}
8986
9087void GxEPDDisplay::print (const char * str) {
@@ -97,15 +94,15 @@ void GxEPDDisplay::fillRect(int x, int y, int w, int h) {
9794 display_crc.update <int >(y);
9895 display_crc.update <int >(w);
9996 display_crc.update <int >(h);
100- display.fillRect (x*SCALE_X , y*SCALE_Y , w*SCALE_X , h*SCALE_Y , _curr_color);
97+ display.fillRect (x*scale_x , y*scale_y , w*scale_x , h*scale_y , _curr_color);
10198}
10299
103100void GxEPDDisplay::drawRect (int x, int y, int w, int h) {
104101 display_crc.update <int >(x);
105102 display_crc.update <int >(y);
106103 display_crc.update <int >(w);
107104 display_crc.update <int >(h);
108- display.drawRect (x*SCALE_X , y*SCALE_Y , w*SCALE_X , h*SCALE_Y , _curr_color);
105+ display.drawRect (x*scale_x , y*scale_y , w*scale_x , h*scale_y , _curr_color);
109106}
110107
111108void GxEPDDisplay::drawXbm (int x, int y, const uint8_t * bits, int w, int h) {
@@ -115,24 +112,24 @@ void GxEPDDisplay::drawXbm(int x, int y, const uint8_t* bits, int w, int h) {
115112 display_crc.update <int >(h);
116113 display_crc.update <uint8_t >(bits, w * h / 8 );
117114 // Calculate the base position in display coordinates
118- uint16_t startX = x * SCALE_X ;
119- uint16_t startY = y * SCALE_Y ;
115+ uint16_t startX = x * scale_x ;
116+ uint16_t startY = y * scale_y ;
120117
121118 // Width in bytes for bitmap processing
122119 uint16_t widthInBytes = (w + 7 ) / 8 ;
123120
124121 // Process the bitmap row by row
125122 for (uint16_t by = 0 ; by < h; by++) {
126123 // Calculate the target y-coordinates for this logical row
127- int y1 = startY + (int )(by * SCALE_Y );
128- int y2 = startY + (int )((by + 1 ) * SCALE_Y );
124+ int y1 = startY + (int )(by * scale_y );
125+ int y2 = startY + (int )((by + 1 ) * scale_y );
129126 int block_h = y2 - y1;
130127
131128 // Scan across the row bit by bit
132129 for (uint16_t bx = 0 ; bx < w; bx++) {
133130 // Calculate the target x-coordinates for this logical column
134- int x1 = startX + (int )(bx * SCALE_X );
135- int x2 = startX + (int )((bx + 1 ) * SCALE_X );
131+ int x1 = startX + (int )(bx * scale_x );
132+ int x2 = startX + (int )((bx + 1 ) * scale_x );
136133 int block_w = x2 - x1;
137134
138135 // Get the current bit
@@ -153,7 +150,7 @@ uint16_t GxEPDDisplay::getTextWidth(const char* str) {
153150 int16_t x1, y1;
154151 uint16_t w, h;
155152 display.getTextBounds (str, 0 , 0 , &x1, &y1, &w, &h);
156- return ceil ((w + 1 ) / SCALE_X );
153+ return ceil ((w + 1 ) / scale_x );
157154}
158155
159156void GxEPDDisplay::endFrame () {
0 commit comments