|
1 | 1 | #include "HyperDisplay_SSD1309.h"
|
2 | 2 |
|
3 |
| - |
| 3 | +const SSD1309_Bite_t ON = { 0x01 }; |
| 4 | +const SSD1309_Bite_t OFF = { 0x00 }; |
4 | 5 |
|
5 | 6 | SSD1309::SSD1309(uint16_t xSize, uint16_t ySize, SSD1309_Intfc_t interface) : hyperdisplay(xSize, ySize)
|
6 | 7 | {
|
@@ -37,8 +38,29 @@ color_t getOffsetColor(color_t base, uint32_t numPixels); // (required by hyper
|
37 | 38 | */
|
38 | 39 | color_t SSD1309::getOffsetColor(color_t base, uint32_t numPixels)
|
39 | 40 | {
|
| 41 | + // For the SSD1309 this function will depend on the current window if it is available |
| 42 | + wind_info_t* pwindow = pCurrentWindow; |
| 43 | + if(pwindow != NULL){ |
| 44 | + SSD1309_Bite_t* mirror = (SSD1309_Bite_t*)pwindow->data; |
| 45 | + if(mirror != NULL){ |
| 46 | + // Assume left->right top->bottom for full window width |
| 47 | + uint8_t window_width = (pwindow->xMax - pwindow->xMin + 1); |
| 48 | + uint8_t x = numPixels % window_width; |
| 49 | + uint8_t y = numPixels / window_width; |
| 50 | + uint8_t temp = (*(mirror + ((window_width * (y/8)) + x))).bite; |
| 51 | + if(temp & (0x01 << (y % 8))){ |
| 52 | + return (color_t)0x01; |
| 53 | + }else{ |
| 54 | + return (color_t)0x00; |
| 55 | + } |
| 56 | + }else{ |
| 57 | + return base; // Also be dumb when there is no mirror data |
| 58 | + } |
| 59 | + }else{ |
| 60 | + // When little information available fall back to 'dumb' implementation |
| 61 | + return base; |
| 62 | + } |
40 | 63 | return base;
|
41 |
| - // return (color_t)(((SSD1309_Bite_t*)base + numPixels/8)); |
42 | 64 | }
|
43 | 65 |
|
44 | 66 | SSD1309_Status_t SSD1309::refreshDisplay( void )
|
@@ -142,6 +164,14 @@ void SSD1309::hwpixel(hd_hw_extent_t x0, hd_hw_extent_t y0, color_t data, hd_col
|
142 | 164 | startColorOffset = getNewColorOffset(colorCycleLength, startColorOffset, 0); // This line is needed to condition the user's input start color offset because it could be greater than the cycle length
|
143 | 165 | color_t value = getOffsetColor(data, startColorOffset);
|
144 | 166 |
|
| 167 | + // If value is either 0 or 1 then interpret it as a direct value... |
| 168 | + if((uint32_t)data == 0x00){ |
| 169 | + value = (color_t)&OFF; |
| 170 | + } |
| 171 | + if((uint32_t)data == 0x01){ |
| 172 | + value = (color_t)&ON; |
| 173 | + } |
| 174 | + |
145 | 175 | SSD1309_Bite_t user = *((SSD1309_Bite_t*)value);
|
146 | 176 | if(user.b0){ // Check if the user's bit is set or not (this implies that the user should always set bit 0 of a 'bite' to the pixel value they want)
|
147 | 177 | // Need to set the pixel high
|
@@ -213,7 +243,8 @@ void SSD1309::swpixel( hd_extent_t x0, hd_extent_t y0, color_t data, hd_colors_t
|
213 | 243 | if(colorCycleLength == 0){ return; }
|
214 | 244 |
|
215 | 245 | startColorOffset = getNewColorOffset(colorCycleLength, startColorOffset, 0); // This line is needed to condition the user's input start color offset because it could be greater than the cycle length
|
216 |
| - color_t value = getOffsetColor(data, startColorOffset); |
| 246 | + // color_t value = getOffsetColor(data, startColorOffset); |
| 247 | + color_t value = data; // have to skip color sequences in buffered writing mode |
217 | 248 |
|
218 | 249 | hd_hw_extent_t x0w = (hd_hw_extent_t)x0; // Cast to hw extent type to be sure of integer values
|
219 | 250 | hd_hw_extent_t y0w = (hd_hw_extent_t)y0;
|
|
0 commit comments