]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboards/yosino58/ssd1306.h
Remove more commented out MCUs
[qmk_firmware.git] / keyboards / yosino58 / ssd1306.h
1 #pragma once
2
3 #include <stdbool.h>
4 #include <stdio.h>
5 #include "pincontrol.h"
6 #include "action.h"
7
8 enum ssd1306_cmds {
9   DisplayOff = 0xAE,
10   DisplayOn = 0xAF,
11
12   SetContrast = 0x81,
13   DisplayAllOnResume = 0xA4,
14
15   DisplayAllOn = 0xA5,
16   NormalDisplay = 0xA6,
17   InvertDisplay = 0xA7,
18   SetDisplayOffset = 0xD3,
19   SetComPins = 0xda,
20   SetVComDetect = 0xdb,
21   SetDisplayClockDiv = 0xD5,
22   SetPreCharge = 0xd9,
23   SetMultiPlex = 0xa8,
24   SetLowColumn = 0x00,
25   SetHighColumn = 0x10,
26   SetStartLine = 0x40,
27
28   SetMemoryMode = 0x20,
29   ColumnAddr = 0x21,
30   PageAddr = 0x22,
31
32   ComScanInc = 0xc0,
33   ComScanDec = 0xc8,
34   SegRemap = 0xa0,
35   SetChargePump = 0x8d,
36   ExternalVcc = 0x01,
37   SwitchCapVcc = 0x02,
38
39   ActivateScroll = 0x2f,
40   DeActivateScroll = 0x2e,
41   SetVerticalScrollArea = 0xa3,
42   RightHorizontalScroll = 0x26,
43   LeftHorizontalScroll = 0x27,
44   VerticalAndRightHorizontalScroll = 0x29,
45   VerticalAndLeftHorizontalScroll = 0x2a,
46 };
47
48 // Controls the SSD1306 128x32 OLED display via i2c
49
50 #ifndef SSD1306_ADDRESS
51 #define SSD1306_ADDRESS 0x3C
52 #endif
53
54 #ifdef SSD1306_128X64
55 #define DisplayHeight 64
56 #else
57 #define DisplayHeight 32
58 #endif
59 #define DisplayWidth 128
60
61
62 #define FontHeight 8
63 #define FontWidth 6
64
65 #define MatrixRows (DisplayHeight / FontHeight)
66 #define MatrixCols (DisplayWidth / FontWidth)
67
68 struct CharacterMatrix {
69   uint8_t display[MatrixRows][MatrixCols];
70   uint8_t *cursor;
71   bool dirty;
72 };
73
74 struct CharacterMatrix display;
75
76 bool iota_gfx_init(bool rotate);
77 void iota_gfx_task(void);
78 bool iota_gfx_off(void);
79 bool iota_gfx_on(void);
80 void iota_gfx_flush(void);
81 void iota_gfx_write_char(uint8_t c);
82 void iota_gfx_write(const char *data);
83 void iota_gfx_write_P(const char *data);
84 void iota_gfx_clear_screen(void);
85
86 void iota_gfx_task_user(void);
87
88 void matrix_clear(struct CharacterMatrix *matrix);
89 void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
90 void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
91 void matrix_write(struct CharacterMatrix *matrix, const char *data);
92 void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
93 void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
94 void matrix_render(struct CharacterMatrix *matrix);
95
96 bool process_record_gfx(uint16_t keycode, keyrecord_t *record);