diff --git a/platform/drivers/display/SSD1306_Mod17.c b/platform/drivers/display/SSD1306_Mod17.c
index 8faf2abf..d12e46eb 100644
--- a/platform/drivers/display/SSD1306_Mod17.c
+++ b/platform/drivers/display/SSD1306_Mod17.c
@@ -15,6 +15,16 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
+ * As a special exception, if other files instantiate templates or use *
+ * macros or inline functions from this file, or you compile this file *
+ * and link it with other works to produce a work based on this file, *
+ * this file does not by itself cause the resulting work to be covered *
+ * by the GNU General Public License. However the source code for this *
+ * file must still be made available in accordance with the GNU General *
+ * Public License. This exception does not invalidate any other reasons *
+ * why a work based on this file might be covered by the GNU General *
+ * Public License. *
+ * *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, see *
***************************************************************************/
@@ -87,34 +97,30 @@ void display_init()
gpio_clearPin(LCD_CS);
gpio_clearPin(LCD_RS); /* RS low -> command mode */
- spi2_sendRecv(0xAE); /* Disable Display */
- spi2_sendRecv(0x20); /* Set Memory Addressing Mode to horizontal addressing Mode */
+ spi2_sendRecv(0xAE); // SH110X_DISPLAYOFF,
+ spi2_sendRecv(0xd5); // SH110X_SETDISPLAYCLOCKDIV, 0x51,
+ spi2_sendRecv(0x51);
+ spi2_sendRecv(0x20); // SH110X_MEMORYMODE,
spi2_sendRecv(0x00);
- spi2_sendRecv(0xB0); /* Set Page Start Address for Page Addressing Mode */
- spi2_sendRecv(0xC8); /* Set COM Output Scan Direction */
- spi2_sendRecv(0x00); /* Set low column address */
- spi2_sendRecv(0x10); /* Set high column address */
- spi2_sendRecv(0x40); /* Set start line address */
- spi2_sendRecv(0x81); /* Set contrast */
- spi2_sendRecv(0xCF);
- spi2_sendRecv(0xA1); /* Set segment re-map 0 to 127 */
- spi2_sendRecv(0xA6); /* Set normal color */
- spi2_sendRecv(0xA8); /* Set multiplex ratio (1 to 64) */
- spi2_sendRecv(0x3F);
- spi2_sendRecv(0xA4); /* Output follows RAM content */
- spi2_sendRecv(0xD3); /* Set display offset */
- spi2_sendRecv(0x00); /* Not offset */
- spi2_sendRecv(0xD5); /* Set display clock divide ratio/oscillator frequency */
- spi2_sendRecv(0xF0); /* Set divide ratio */
- spi2_sendRecv(0xD9); /* Set pre-charge period */
+ spi2_sendRecv(0x81); // SH110X_SETCONTRAST, 0x4F,
+ spi2_sendRecv(0x4F);
+ spi2_sendRecv(0xAD); // SH110X_DCDC, 0x8A,
+ spi2_sendRecv(0x8A);
+ spi2_sendRecv(0xA0); // SH110X_SEGREMAP,
+ spi2_sendRecv(0xC0); // SH110X_COMSCANINC,
+ spi2_sendRecv(0xDC); // SH110X_SETDISPSTARTLINE, 0x0,
+ spi2_sendRecv(0x00);
+ spi2_sendRecv(0xd3); // SH110X_SETDISPLAYOFFSET, 0x60,
+ spi2_sendRecv(0x60);
+ spi2_sendRecv(0xd9); // SH110X_SETPRECHARGE, 0x22,
spi2_sendRecv(0x22);
- spi2_sendRecv(0xDA); /* Set com pins hardware configuration */
- spi2_sendRecv(0x12);
- spi2_sendRecv(0xDB); /* Set vcomh */
- spi2_sendRecv(0x40);
- spi2_sendRecv(0x8D); /* Set DC-DC enable */
- spi2_sendRecv(0x14);
- spi2_sendRecv(0xAF); /* Enable Display */
+ spi2_sendRecv(0xdb); // SH110X_SETVCOMDETECT, 0x35,
+ spi2_sendRecv(0x35);
+ spi2_sendRecv(0xa8); // SH110X_SETMULTIPLEX, 0x3F,
+ spi2_sendRecv(0x3f);
+ spi2_sendRecv(0xa4); // SH110X_DISPLAYALLON_RESUME,
+ spi2_sendRecv(0xa6); // SH110X_NORMALDISPLAY,
+ spi2_sendRecv(0xAF); // SH110x_DISPLAYON
gpio_setPin(LCD_CS);
}
@@ -130,36 +136,31 @@ void display_terminate()
void display_renderRow(uint8_t row)
{
- /* magic stuff */
- uint8_t *buf = (frameBuffer + 128 * row);
- for (uint8_t i = 0; i<16; i++)
- {
- uint8_t tmp[8] = {0};
- for (uint8_t j = 0; j < 8; j++)
- {
- uint8_t tmp_buf = buf[j*16 + i];
- int count = __builtin_popcount(tmp_buf);
- while (count > 0)
- {
- int pos = __builtin_ctz(tmp_buf);
- tmp[pos] |= 1UL << j;
- tmp_buf &= ~(1 << pos);
- count--;
- }
- }
+ uint8_t *buf = (frameBuffer);
+
+ for(uint16_t i=0; i<64; i++)
+ {
+ //for(uint8_t k=0; k<8; k++)
+ {
+ //spi2_sendRecv(buf[(j+1)*16 - (16-row)]);
+ uint8_t out=0, tmp=buf[i*16 + 15-row];
+
+ for(uint8_t j=0; j<8; j++)
+ {
+ out|=((tmp>>(7-j))&1)< command mode */
(void) spi2_sendRecv(0xB0 | row); /* Set Y position */
@@ -168,13 +169,13 @@ void display_renderRows(uint8_t startRow, uint8_t endRow)
gpio_setPin(LCD_RS); /* RS high -> data mode */
display_renderRow(row);
}
-
+
gpio_setPin(LCD_CS);
}
void display_render()
{
- display_renderRows(0, SCREEN_HEIGHT / 8);
+ display_renderRows(0, SCREEN_WIDTH / 8 - 1);
}
bool display_renderingInProgress()