diff options
| author | XScorpion2 <rcalt2vt@gmail.com> | 2019-06-07 19:02:05 -0500 |
|---|---|---|
| committer | MechMerlin <30334081+mechmerlin@users.noreply.github.com> | 2019-06-07 17:02:05 -0700 |
| commit | 09968ba035f3bfa4df5b1d142dddfa669aefb2d7 (patch) | |
| tree | cfb29848ea7bfd0ca5f77cd51c5a5f568d3a88ba /drivers | |
| parent | 54ac80d4a5a34661283b413e14f88e955bedeeef (diff) | |
| download | qmk_firmware-09968ba035f3bfa4df5b1d142dddfa669aefb2d7.tar.gz qmk_firmware-09968ba035f3bfa4df5b1d142dddfa669aefb2d7.zip | |
Fixing OLED Driver for 128x64 displays (#6085)
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/oled/oled_driver.c | 6 | ||||
| -rw-r--r-- | drivers/oled/oled_driver.h | 47 |
2 files changed, 49 insertions, 4 deletions
diff --git a/drivers/oled/oled_driver.c b/drivers/oled/oled_driver.c index 96ea58ccb..643e52894 100644 --- a/drivers/oled/oled_driver.c +++ b/drivers/oled/oled_driver.c | |||
| @@ -63,6 +63,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 63 | #define COM_SCAN_DEC 0xC8 | 63 | #define COM_SCAN_DEC 0xC8 |
| 64 | #define DISPLAY_OFFSET 0xD3 | 64 | #define DISPLAY_OFFSET 0xD3 |
| 65 | #define COM_PINS 0xDA | 65 | #define COM_PINS 0xDA |
| 66 | #define COM_PINS_SEQ 0x02 | ||
| 67 | #define COM_PINS_ALT 0x12 | ||
| 68 | #define COM_PINS_SEQ_LR 0x22 | ||
| 69 | #define COM_PINS_ALT_LR 0x32 | ||
| 66 | 70 | ||
| 67 | // Timing & Driving Commands | 71 | // Timing & Driving Commands |
| 68 | #define DISPLAY_CLOCK 0xD5 | 72 | #define DISPLAY_CLOCK 0xD5 |
| @@ -182,7 +186,7 @@ bool oled_init(uint8_t rotation) { | |||
| 182 | 186 | ||
| 183 | static const uint8_t PROGMEM display_setup2[] = { | 187 | static const uint8_t PROGMEM display_setup2[] = { |
| 184 | I2C_CMD, | 188 | I2C_CMD, |
| 185 | COM_PINS, 0x02, | 189 | COM_PINS, OLED_COM_PINS, |
| 186 | CONTRAST, 0x8F, | 190 | CONTRAST, 0x8F, |
| 187 | PRE_CHARGE_PERIOD, 0xF1, | 191 | PRE_CHARGE_PERIOD, 0xF1, |
| 188 | VCOM_DETECT, 0x40, | 192 | VCOM_DETECT, 0x40, |
diff --git a/drivers/oled/oled_driver.h b/drivers/oled/oled_driver.h index ec07f1d9b..abbdde57e 100644 --- a/drivers/oled/oled_driver.h +++ b/drivers/oled/oled_driver.h | |||
| @@ -24,17 +24,39 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 24 | // Expected user to implement the necessary defines | 24 | // Expected user to implement the necessary defines |
| 25 | #elif defined(OLED_DISPLAY_128X64) | 25 | #elif defined(OLED_DISPLAY_128X64) |
| 26 | // Double height 128x64 | 26 | // Double height 128x64 |
| 27 | #ifndef OLED_DISPLAY_WIDTH | ||
| 27 | #define OLED_DISPLAY_WIDTH 128 | 28 | #define OLED_DISPLAY_WIDTH 128 |
| 29 | #endif | ||
| 30 | #ifndef OLED_DISPLAY_HEIGHT | ||
| 28 | #define OLED_DISPLAY_HEIGHT 64 | 31 | #define OLED_DISPLAY_HEIGHT 64 |
| 32 | #endif | ||
| 33 | #ifndef OLED_MATRIX_SIZE | ||
| 29 | #define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed) | 34 | #define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 1024 (compile time mathed) |
| 30 | #define OLED_BLOCK_TYPE uint32_t | 35 | #endif |
| 36 | #ifndef OLED_BLOCK_TYPE | ||
| 37 | #define OLED_BLOCK_TYPE uint16_t | ||
| 38 | #endif | ||
| 39 | #ifndef OLED_BLOCK_COUNT | ||
| 31 | #define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed) | 40 | #define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 32 (compile time mathed) |
| 41 | #endif | ||
| 42 | #ifndef OLED_BLOCK_SIZE | ||
| 32 | #define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) | 43 | #define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) |
| 44 | #endif | ||
| 45 | #ifndef OLED_COM_PINS | ||
| 46 | #define OLED_COM_PINS COM_PINS_ALT | ||
| 47 | #endif | ||
| 33 | 48 | ||
| 34 | // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays | 49 | // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays |
| 35 | // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode | 50 | // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode |
| 36 | #define OLED_SOURCE_MAP { 32, 40, 48, 56 } | 51 | #ifndef OLED_SOURCE_MAP |
| 37 | #define OLED_TARGET_MAP { 24, 16, 8, 0 } | 52 | #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } |
| 53 | #endif | ||
| 54 | #ifndef OLED_TARGET_MAP | ||
| 55 | #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 } | ||
| 56 | #endif | ||
| 57 | // If OLED_BLOCK_TYPE is uint32_t, these tables would look like: | ||
| 58 | // #define OLED_SOURCE_MAP { 32, 40, 48, 56 } | ||
| 59 | // #define OLED_TARGET_MAP { 24, 16, 8, 0 } | ||
| 38 | // If OLED_BLOCK_TYPE is uint16_t, these tables would look like: | 60 | // If OLED_BLOCK_TYPE is uint16_t, these tables would look like: |
| 39 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } | 61 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } |
| 40 | // #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 } | 62 | // #define OLED_TARGET_MAP { 56, 48, 40, 32, 24, 16, 8, 0 } |
| @@ -43,17 +65,36 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 43 | // #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } | 65 | // #define OLED_TARGET_MAP { 56, 120, 48, 112, 40, 104, 32, 96, 24, 88, 16, 80, 8, 72, 0, 64 } |
| 44 | #else // defined(OLED_DISPLAY_128X64) | 66 | #else // defined(OLED_DISPLAY_128X64) |
| 45 | // Default 128x32 | 67 | // Default 128x32 |
| 68 | #ifndef OLED_DISPLAY_WIDTH | ||
| 46 | #define OLED_DISPLAY_WIDTH 128 | 69 | #define OLED_DISPLAY_WIDTH 128 |
| 70 | #endif | ||
| 71 | #ifndef OLED_DISPLAY_HEIGHT | ||
| 47 | #define OLED_DISPLAY_HEIGHT 32 | 72 | #define OLED_DISPLAY_HEIGHT 32 |
| 73 | #endif | ||
| 74 | #ifndef OLED_MATRIX_SIZE | ||
| 48 | #define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed) | 75 | #define OLED_MATRIX_SIZE (OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH) // 512 (compile time mathed) |
| 76 | #endif | ||
| 77 | #ifndef OLED_BLOCK_TYPE | ||
| 49 | #define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only | 78 | #define OLED_BLOCK_TYPE uint16_t // Type to use for segmenting the oled display for smart rendering, use unsigned types only |
| 79 | #endif | ||
| 80 | #ifndef OLED_BLOCK_COUNT | ||
| 50 | #define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) | 81 | #define OLED_BLOCK_COUNT (sizeof(OLED_BLOCK_TYPE) * 8) // 16 (compile time mathed) |
| 82 | #endif | ||
| 83 | #ifndef OLED_BLOCK_SIZE | ||
| 51 | #define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) | 84 | #define OLED_BLOCK_SIZE (OLED_MATRIX_SIZE / OLED_BLOCK_COUNT) // 32 (compile time mathed) |
| 85 | #endif | ||
| 86 | #ifndef OLED_COM_PINS | ||
| 87 | #define OLED_COM_PINS COM_PINS_SEQ | ||
| 88 | #endif | ||
| 52 | 89 | ||
| 53 | // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays | 90 | // For 90 degree rotation, we map our internal matrix to oled matrix using fixed arrays |
| 54 | // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode | 91 | // The OLED writes to it's memory horizontally, starting top left, but our memory starts bottom left in this mode |
| 92 | #ifndef OLED_SOURCE_MAP | ||
| 55 | #define OLED_SOURCE_MAP { 0, 8, 16, 24 } | 93 | #define OLED_SOURCE_MAP { 0, 8, 16, 24 } |
| 94 | #endif | ||
| 95 | #ifndef OLED_TARGET_MAP | ||
| 56 | #define OLED_TARGET_MAP { 24, 16, 8, 0 } | 96 | #define OLED_TARGET_MAP { 24, 16, 8, 0 } |
| 97 | #endif | ||
| 57 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: | 98 | // If OLED_BLOCK_TYPE is uint8_t, these tables would look like: |
| 58 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } | 99 | // #define OLED_SOURCE_MAP { 0, 8, 16, 24, 32, 40, 48, 56 } |
| 59 | // #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 } | 100 | // #define OLED_TARGET_MAP { 48, 32, 16, 0, 56, 40, 24, 8 } |
