3535#define __BB_EP__
3636#pragma GCC optimize("O2")
3737
38+ const uint8_t ucMirror[256 ] PROGMEM =
39+ {0 , 128 , 64 , 192 , 32 , 160 , 96 , 224 , 16 , 144 , 80 , 208 , 48 , 176 , 112 , 240 ,
40+ 8 , 136 , 72 , 200 , 40 , 168 , 104 , 232 , 24 , 152 , 88 , 216 , 56 , 184 , 120 , 248 ,
41+ 4 , 132 , 68 , 196 , 36 , 164 , 100 , 228 , 20 , 148 , 84 , 212 , 52 , 180 , 116 , 244 ,
42+ 12 , 140 , 76 , 204 , 44 , 172 , 108 , 236 , 28 , 156 , 92 , 220 , 60 , 188 , 124 , 252 ,
43+ 2 , 130 , 66 , 194 , 34 , 162 , 98 , 226 , 18 , 146 , 82 , 210 , 50 , 178 , 114 , 242 ,
44+ 10 , 138 , 74 , 202 , 42 , 170 , 106 , 234 , 26 , 154 , 90 , 218 , 58 , 186 , 122 , 250 ,
45+ 6 , 134 , 70 , 198 , 38 , 166 , 102 , 230 , 22 , 150 , 86 , 214 , 54 , 182 , 118 , 246 ,
46+ 14 , 142 , 78 , 206 , 46 , 174 , 110 , 238 , 30 , 158 , 94 , 222 , 62 , 190 , 126 , 254 ,
47+ 1 , 129 , 65 , 193 , 33 , 161 , 97 , 225 , 17 , 145 , 81 , 209 , 49 , 177 , 113 , 241 ,
48+ 9 , 137 , 73 , 201 , 41 , 169 , 105 , 233 , 25 , 153 , 89 , 217 , 57 , 185 , 121 , 249 ,
49+ 5 , 133 , 69 , 197 , 37 , 165 , 101 , 229 , 21 , 149 , 85 , 213 , 53 , 181 , 117 , 245 ,
50+ 13 , 141 , 77 , 205 , 45 , 173 , 109 , 237 , 29 , 157 , 93 , 221 , 61 , 189 , 125 , 253 ,
51+ 3 , 131 , 67 , 195 , 35 , 163 , 99 , 227 , 19 , 147 , 83 , 211 , 51 , 179 , 115 , 243 ,
52+ 11 , 139 , 75 , 203 , 43 , 171 , 107 , 235 , 27 , 155 , 91 , 219 , 59 , 187 , 123 , 251 ,
53+ 7 , 135 , 71 , 199 , 39 , 167 , 103 , 231 , 23 , 151 , 87 , 215 , 55 , 183 , 119 , 247 ,
54+ 15 , 143 , 79 , 207 , 47 , 175 , 111 , 239 , 31 , 159 , 95 , 223 , 63 , 191 , 127 , 255 };
55+
3856// For measuring the performance of each stage of updates
3957// #define SHOW_TIME
4058// 8 columns by 16 rows. From white (15) to each gray (0-black to 15-white) at 20C
@@ -1734,6 +1752,10 @@ int bbepSetDefinedPanel(FASTEPDSTATE *pState, int iPanel)
17341752 bbepSetPanelSize (pState, 1872 , 1404 , BB_PANEL_FLAG_MIRROR_X, -1600 );
17351753 bbepSetCustomMatrix (pState, u8TenPointThreeMatrix, sizeof (u8TenPointThreeMatrix));
17361754 break ;
1755+ case BBEP_DISPLAY_ED078KC2:
1756+ bbepSetPanelSize (pState, 1872 , 1404 , BB_PANEL_FLAG_NONE, -1600 );
1757+ bbepSetCustomMatrix (pState, u8TenPointThreeMatrix, sizeof (u8TenPointThreeMatrix));
1758+ break ;
17371759 case BBEP_DISPLAY_ED052TC4:
17381760 bbepSetPanelSize (pState, 1280 , 720 , BB_PANEL_FLAG_MIRROR_X, -1600 );
17391761 bbepSetCustomMatrix (pState, u8FivePointTwoMatrix, sizeof (u8FivePointTwoMatrix));
@@ -1778,6 +1800,7 @@ int bbepSetPanelSize(FASTEPDSTATE *pState, int width, int height, int flags, int
17781800 free (pState->pCurrent );
17791801 return BBEP_ERROR_NO_MEMORY;
17801802 }
1803+ #endif // LINUX
17811804 if (pState->iPanelType == BB_PANEL_IT8951) {
17821805 pState->pfnSetPixel = bbepSetPixel2Clr;
17831806 pState->pfnSetPixelFast = bbepSetPixelFast2Clr;
@@ -1789,7 +1812,6 @@ int bbepSetPanelSize(FASTEPDSTATE *pState, int width, int height, int flags, int
17891812 pState->rotation = 0 ;
17901813 return BBEP_SUCCESS; // for it8951 only
17911814 }
1792- #endif // !__LINUX__
17931815
17941816 // Allocate memory for each line to transmit
17951817#ifndef __LINUX__
@@ -2146,7 +2168,7 @@ IT8951DevInfo dev_info_;
21462168
21472169void it8951WriteFramebuffer1Bit (FASTEPDSTATE *pState)
21482170{
2149- uint8_t *s;
2171+ uint8_t *s, *d ;
21502172int iPitch;
21512173
21522174 IT8951EinkPower (pState, 1 );
@@ -2172,22 +2194,22 @@ int iPitch;
21722194 iPitch = (pState->native_width + 7 )/8 ;
21732195 for (int y = 0 ; y < pState->native_height ; y++) {
21742196 if (pState->iFlags & BB_PANEL_FLAG_MIRROR_X) {
2175- uint8_t * d = pState->pTemp ;
2197+ d = pState->pTemp ;
21762198 for (int x = 0 ; x<iPitch; x++) {
21772199 d[iPitch - 1 - x] = s[x];
21782200 }
2179- #ifdef ARDUINO
2180- SPI.writeBytes (d, iPitch);
2181- #elif defined(__LINUX__)
2182- linux_spi_write (d, iPitch, pState->spi_frequency );
2183- #endif
21842201 } else {
2202+ d = pState->pTemp ;
2203+ for (int x = 0 ; x<iPitch; x+=2 ) { // work 16-bits at a time
2204+ d[x+1 ] = ucMirror[s[x]];
2205+ d[x] = ucMirror[s[x+1 ]];
2206+ }
2207+ }
21852208#ifdef ARDUINO
2186- SPI.writeBytes (s , iPitch);
2209+ SPI.writeBytes (d , iPitch);
21872210#elif defined(__LINUX__)
2188- linux_spi_write (s , iPitch, pState->spi_frequency );
2211+ linux_spi_write (d , iPitch, pState->spi_frequency );
21892212#endif
2190- }
21912213 if ((y & 0x07 ) == 0 ) {
21922214 yield ();
21932215 }
@@ -2209,7 +2231,7 @@ int iPitch;
22092231
22102232void it8951WriteFramebuffer4Bit (FASTEPDSTATE *pState)
22112233{
2212- uint8_t *s;
2234+ uint8_t *s, *d ;
22132235int iPitch;
22142236
22152237 IT8951EinkPower (pState, 1 );
@@ -2236,22 +2258,22 @@ int iPitch;
22362258 iPitch = (pState->native_width + 1 )/2 ;
22372259 for (int y = 0 ; y < pState->native_height ; y++) {
22382260 if (pState->iFlags & BB_PANEL_FLAG_MIRROR_X) {
2239- uint8_t * d = pState->pTemp ;
2261+ d = pState->pTemp ;
22402262 for (int x = 0 ; x<iPitch; x++) {
22412263 d[iPitch - 1 - x] = (s[x] >> 4 ) | (s[x] << 4 );
22422264 }
2243- #ifdef ARDUINO
2244- SPI.writeBytes (d, iPitch);
2245- #elif defined(__LINUX__)
2246- linux_spi_write (d, iPitch, pState->spi_frequency );
2247- #endif
22482265 } else {
2266+ d = pState->pTemp ;
2267+ for (int x = 0 ; x<iPitch; x+=2 ) { // work 16-bits at a time
2268+ d[x+1 ] = (s[x] >> 4 ) | (s[x] << 4 );
2269+ d[x] = (s[x+1 ] >> 4 ) | (s[x+1 ] << 4 );
2270+ }
2271+ }
22492272#ifdef ARDUINO
2250- SPI.writeBytes (s , iPitch);
2273+ SPI.writeBytes (d , iPitch);
22512274#elif defined(__LINUX__)
2252- linux_spi_write (s , iPitch, pState->spi_frequency );
2275+ linux_spi_write (d , iPitch, pState->spi_frequency );
22532276#endif
2254- }
22552277 if ((y & 0x07 ) == 0 ) {
22562278 yield ();
22572279 }
@@ -2269,7 +2291,7 @@ int iPitch;
22692291
22702292void it8951WriteFramebuffer2Bit (FASTEPDSTATE *pState)
22712293{
2272- uint8_t *s;
2294+ uint8_t *s, *d ;
22732295int iPitch;
22742296
22752297 IT8951EinkPower (pState, 1 );
@@ -2295,23 +2317,24 @@ int iPitch;
22952317 iPitch = (pState->native_width + 3 )/4 ;
22962318 for (int y = 0 ; y < pState->native_height ; y++) {
22972319 if (pState->iFlags & BB_PANEL_FLAG_MIRROR_X) {
2298- uint8_t * d = pState->pTemp ;
2320+ d = pState->pTemp ;
22992321 for (int x = 0 ; x<iPitch; x++) {
23002322 uint8_t a = s[x];
23012323 d[iPitch - 1 - x] = (a >> 6 ) | ((a >> 2 ) & 0xc ) | ((a & 0xc ) << 2 ) | ((a & 3 ) << 6 );
23022324 }
2303- #ifdef ARDUINO
2304- SPI.writeBytes (d, iPitch);
2305- #elif defined(__LINUX__)
2306- linux_spi_write (d, iPitch, pState->spi_frequency );
2307- #endif
23082325 } else {
2326+ d = pState->pTemp ;
2327+ for (int x = 0 ; x<iPitch; x+=2 ) { // work 16-bits at a time
2328+ uint8_t a = s[x], b = s[x+1 ];
2329+ d[x+1 ] = (a >> 6 ) | ((a >> 2 ) & 0xc ) | ((a & 0xc ) << 2 ) | ((a & 3 ) << 6 );
2330+ d[x] = (b >> 6 ) | ((b >> 2 ) & 0xc ) | ((b & 0xc ) << 2 ) | ((b & 3 ) << 6 );
2331+ }
2332+ }
23092333#ifdef ARDUINO
2310- SPI.writeBytes (s , iPitch);
2334+ SPI.writeBytes (d , iPitch);
23112335#elif defined(__LINUX__)
2312- linux_spi_write (s , iPitch, pState->spi_frequency );
2336+ linux_spi_write (d , iPitch, pState->spi_frequency );
23132337#endif
2314- }
23152338 if ((y & 0x07 ) == 0 ) {
23162339 yield ();
23172340 }
@@ -2351,7 +2374,7 @@ int bbepInitIT8951(FASTEPDSTATE *pState, uint8_t u8MOSI, uint8_t u8MISO, uint8_t
23512374 gpio_set_level ((gpio_num_t )u8ITE_EN, HIGH);
23522375#ifdef ARDUINO
23532376 SPI.begin (u8CLK, u8MISO, u8MOSI, -1 );
2354- #else
2377+ #elif defined(__LINUX__)
23552378 linux_spi_init (u8MISO, u8MOSI, u8CLK);
23562379#endif // ARDUINO
23572380 pState->spi_frequency = IT8951_SPI_PROBE_FREQUENCY;
@@ -2421,7 +2444,7 @@ int bbepInitIT8951(FASTEPDSTATE *pState, uint8_t u8MOSI, uint8_t u8MISO, uint8_t
24212444 it8951WriteCmdCode (pState, USDEF_I80_CMD_TEMP);
24222445 it8951WriteData (pState, 0x0001 );
24232446 it8951WriteData (pState, 14 );
2424- // Serial.println ("IT8951 initialization complete");
2447+ // printf ("IT8951 initialization complete\n ");
24252448 pState->iPanelType = BB_PANEL_IT8951;
24262449 pState->spi_frequency = IT8951_SPI_RUN_FREQUENCY; // switch to data frequency
24272450 return BBEP_SUCCESS;
0 commit comments