From: Torbjorn Tyridal Date: Fri, 15 Sep 2017 12:51:39 +0000 (+0200) Subject: parts/ssd1306: Add dummy handlers for various commands X-Git-Tag: v1.6~18 X-Git-Url: https://git.htl-mechatronik.at/public/?a=commitdiff_plain;h=da8631592d0a35f9016594d917846747fbef3527;p=sx%2Fsimavr.git parts/ssd1306: Add dummy handlers for various commands in particular, commands used by adafruit driver. Since some commands are multibyte, this prevents us getting out of sync or misinterpreting commands. --- diff --git a/examples/parts/ssd1306_virt.c b/examples/parts/ssd1306_virt.c index 681ba16..fe4c4c8 100644 --- a/examples/parts/ssd1306_virt.c +++ b/examples/parts/ssd1306_virt.c @@ -139,15 +139,39 @@ ssd1306_update_command_register (ssd1306_t *part) //printf ("SSD1306: SET COM OUTPUT SCAN DIRECTION REMAPPED \n"); SSD1306_CLEAR_COMMAND_REG(part); return; + case SSD1306_VIRT_SCROLL_RIGHT: + case SSD1306_VIRT_SCROLL_LEFT: + part->command_register = part->spi_data; + part->reg_write_sz = 6; + return; + case SSD1306_VIRT_SCROLL_VR: + case SSD1306_VIRT_SCROLL_VL: + part->command_register = part->spi_data; + part->reg_write_sz = 5; + return; + case SSD1306_VIRT_SET_RATIO_OSC: + case SSD1306_VIRT_MULTIPLEX: + case SSD1306_VIRT_SET_OFFSET: case SSD1306_VIRT_MEM_ADDRESSING: + case SSD1306_VIRT_SET_LINE: + case SSD1306_VIRT_SET_PADS: + case SSD1306_VIRT_SET_CHARGE: + case SSD1306_VIRT_SET_VCOM: part->command_register = part->spi_data; return; + case SSD1306_VIRT_VERT_SCROLL_A: case SSD1306_VIRT_SET_PAGE_ADDR: case SSD1306_VIRT_SET_COL_ADDR: part->reg_write_sz = 2; part->command_register = part->spi_data; return; + case SSD1306_VIRT_SCROLL_ON: + case SSD1306_VIRT_SCROLL_OFF: + case SSD1306_VIRT_RESUME_TO_RAM_CONTENT: + SSD1306_CLEAR_COMMAND_REG(part); + return; default: + printf ("SSD1306: WARNING: unknown/not implemented command %x\n", part->spi_data); // Unknown command return; } @@ -195,8 +219,26 @@ ssd1306_update_setting (ssd1306_t *part) //printf ("SSD1306: ADDRESSING MODE: 0x%02x\n", part->addr_mode); SSD1306_CLEAR_COMMAND_REG(part); return; + case SSD1306_VIRT_SET_LINE: + case SSD1306_VIRT_SET_RATIO_OSC: + case SSD1306_VIRT_MULTIPLEX: + case SSD1306_VIRT_SET_OFFSET: + case SSD1306_VIRT_SET_CHARGE: + case SSD1306_VIRT_SET_VCOM: + case SSD1306_VIRT_SET_PADS: + SSD1306_CLEAR_COMMAND_REG(part); + return; + case SSD1306_VIRT_SCROLL_RIGHT: + case SSD1306_VIRT_SCROLL_LEFT: + case SSD1306_VIRT_SCROLL_VR: + case SSD1306_VIRT_SCROLL_VL: + case SSD1306_VIRT_VERT_SCROLL_A: + if (! --part->reg_write_sz) + SSD1306_CLEAR_COMMAND_REG(part); + return; default: // Unknown command + printf("SSD1306: error: unknown update command %x\n",part->command_register); return; } }