aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/feature_oled_driver.md9
-rw-r--r--drivers/oled/oled_driver.c6
-rw-r--r--drivers/oled/oled_driver.h47
3 files changed, 54 insertions, 8 deletions
diff --git a/docs/feature_oled_driver.md b/docs/feature_oled_driver.md
index fcc19515a..144b695b7 100644
--- a/docs/feature_oled_driver.md
+++ b/docs/feature_oled_driver.md
@@ -108,10 +108,11 @@ void oled_task_user(void) {
108|`OLED_DISPLAY_CUSTOM` |*Not defined* |Changes the display defines for use with custom displays.<br />Requires user to implement the below defines. | 108|`OLED_DISPLAY_CUSTOM` |*Not defined* |Changes the display defines for use with custom displays.<br />Requires user to implement the below defines. |
109|`OLED_DISPLAY_WIDTH` |`128` |The width of the OLED display. | 109|`OLED_DISPLAY_WIDTH` |`128` |The width of the OLED display. |
110|`OLED_DISPLAY_HEIGHT` |`32` |The height of the OLED display. | 110|`OLED_DISPLAY_HEIGHT` |`32` |The height of the OLED display. |
111|`OLED_MATRIX_SIZE` |`512` |The local buffer size to allocate.<br />`(OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH)`| 111|`OLED_MATRIX_SIZE` |`512` |The local buffer size to allocate.<br />`(OLED_DISPLAY_HEIGHT / 8 * OLED_DISPLAY_WIDTH)`. |
112|`OLED_BLOCK_TYPE` |`uint16_t` |The unsigned integer type to use for dirty rendering.| 112|`OLED_BLOCK_TYPE` |`uint16_t` |The unsigned integer type to use for dirty rendering. |
113|`OLED_BLOCK_COUNT` |`16` |The number of blocks the display is divided into for dirty rendering.<br />`(sizeof(OLED_BLOCK_TYPE) * 8)`| 113|`OLED_BLOCK_COUNT` |`16` |The number of blocks the display is divided into for dirty rendering.<br />`(sizeof(OLED_BLOCK_TYPE) * 8)`. |
114|`OLED_BLOCK_SIZE` |`32` |The size of each block for dirty rendering<br />`(OLED_MATRIX_SIZE / OLED_BLOCK_COUNT)`| 114|`OLED_BLOCK_SIZE` |`32` |The size of each block for dirty rendering<br />`(OLED_MATRIX_SIZE / OLED_BLOCK_COUNT)`. |
115|`OLED_COM_PINS` |`COM_PINS_SEQ` |How the SSD1306 chip maps it's memory to display.<br />Options are `COM_PINS_SEQ`, `COM_PINS_ALT`, `COM_PINS_SEQ_LR`, & `COM_PINS_ALT_LR`. |
115|`OLED_SOURCE_MAP` |`{ 0, ... N }` |Precalculated source array to use for mapping source buffer to target OLED memory in 90 degree rendering. | 116|`OLED_SOURCE_MAP` |`{ 0, ... N }` |Precalculated source array to use for mapping source buffer to target OLED memory in 90 degree rendering. |
116|`OLED_TARGET_MAP` |`{ 24, ... N }`|Precalculated target array to use for mapping source buffer to target OLED memory in 90 degree rendering. | 117|`OLED_TARGET_MAP` |`{ 24, ... N }`|Precalculated target array to use for mapping source buffer to target OLED memory in 90 degree rendering. |
117 118
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 }