f77: Add jackhill's layout
[jackhill/qmk/firmware.git] / keyboards / claw44 / 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 #define DisplayHeight 32
55 #define DisplayWidth 128
56
57 #define FontHeight 8
58 #define FontWidth 6
59
60 #define MatrixRows (DisplayHeight / FontHeight)
61 #define MatrixCols (DisplayWidth / FontWidth)
62
63 struct CharacterMatrix {
64 uint8_t display[MatrixRows][MatrixCols];
65 uint8_t *cursor;
66 bool dirty;
67 };
68
69 struct CharacterMatrix display;
70
71 bool iota_gfx_init(bool rotate);
72 void iota_gfx_task(void);
73 bool iota_gfx_off(void);
74 bool iota_gfx_on(void);
75 void iota_gfx_flush(void);
76 void iota_gfx_write_char(uint8_t c);
77 void iota_gfx_write(const char *data);
78 void iota_gfx_write_P(const char *data);
79 void iota_gfx_clear_screen(void);
80
81 void iota_gfx_task_user(void);
82
83 void matrix_clear(struct CharacterMatrix *matrix);
84 void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
85 void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
86 void matrix_write(struct CharacterMatrix *matrix, const char *data);
87 void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
88 void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
89 void matrix_render(struct CharacterMatrix *matrix);
90
91 bool process_record_gfx(uint16_t keycode, keyrecord_t *record);