aboutsummaryrefslogtreecommitdiff
path: root/keyboards
diff options
context:
space:
mode:
authoryfuku <30647434+yfuku@users.noreply.github.com>2020-11-10 14:07:12 +0900
committerGitHub <noreply@github.com>2020-11-10 16:07:12 +1100
commit7595f538562437fa6d13ede5be7a5a4b5d582c6b (patch)
tree8649d7399f8f5c5699a7a07cb85a38840d73cf3c /keyboards
parent8af767cb1d36222a4d0ec8286d346d4896e923d4 (diff)
downloadqmk_firmware-7595f538562437fa6d13ede5be7a5a4b5d582c6b.tar.gz
qmk_firmware-7595f538562437fa6d13ede5be7a5a4b5d582c6b.zip
refactor SPLIT_KEYBOARD, OLED_DRIVER_ENABLE (#10405)
Diffstat (limited to 'keyboards')
-rw-r--r--keyboards/claw44/claw44.c9
-rw-r--r--keyboards/claw44/config.h4
-rw-r--r--keyboards/claw44/i2c.c162
-rw-r--r--keyboards/claw44/i2c.h46
-rw-r--r--keyboards/claw44/keymaps/default/config.h12
-rw-r--r--keyboards/claw44/keymaps/default/keymap.c199
-rw-r--r--keyboards/claw44/keymaps/oled/config.h (renamed from keyboards/claw44/keymaps/yfuku/config.h)14
-rw-r--r--keyboards/claw44/keymaps/oled/keymap.c137
-rw-r--r--keyboards/claw44/keymaps/oled/rules.mk1
-rw-r--r--keyboards/claw44/keymaps/yfuku/keymap.c221
-rw-r--r--keyboards/claw44/lib/glcdfont.c13
-rw-r--r--keyboards/claw44/lib/host_led_state_reader.c15
-rw-r--r--keyboards/claw44/lib/keylogger.c45
-rw-r--r--keyboards/claw44/lib/layer_state_reader.c35
-rw-r--r--keyboards/claw44/lib/logo_reader.c11
-rw-r--r--keyboards/claw44/lib/mode_icon_reader.c15
-rw-r--r--keyboards/claw44/lib/rgb_state_reader.c15
-rw-r--r--keyboards/claw44/lib/timelogger.c16
-rw-r--r--keyboards/claw44/rev1/config.h23
-rw-r--r--keyboards/claw44/rev1/matrix.c358
-rw-r--r--keyboards/claw44/rev1/rev1.c9
-rw-r--r--keyboards/claw44/rev1/rev1.h74
-rw-r--r--keyboards/claw44/rev1/rules.mk16
-rw-r--r--keyboards/claw44/rev1/serial_config.h4
-rw-r--r--keyboards/claw44/rev1/split_scomm.c91
-rw-r--r--keyboards/claw44/rev1/split_scomm.h24
-rw-r--r--keyboards/claw44/rev1/split_util.c70
-rw-r--r--keyboards/claw44/rev1/split_util.h19
-rw-r--r--keyboards/claw44/rules.mk9
-rw-r--r--keyboards/claw44/serial.c589
-rw-r--r--keyboards/claw44/serial.h84
-rw-r--r--keyboards/claw44/ssd1306.c345
-rw-r--r--keyboards/claw44/ssd1306.h90
33 files changed, 236 insertions, 2539 deletions
diff --git a/keyboards/claw44/claw44.c b/keyboards/claw44/claw44.c
index f564fb623..d87103065 100644
--- a/keyboards/claw44/claw44.c
+++ b/keyboards/claw44/claw44.c
@@ -1,10 +1 @@
1#include "claw44.h" #include "claw44.h"
2#include "ssd1306.h"
3
4bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
5#ifdef SSD1306OLED
6 return process_record_gfx(keycode,record) && process_record_user(keycode, record);
7#else
8 return process_record_user(keycode, record);
9#endif
10}
diff --git a/keyboards/claw44/config.h b/keyboards/claw44/config.h
index fb1cdf396..0bd74ff83 100644
--- a/keyboards/claw44/config.h
+++ b/keyboards/claw44/config.h
@@ -19,10 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once 19#pragma once
20 20
21#include "config_common.h" 21#include "config_common.h"
22#include <serial_config.h>
23
24#define USE_I2C
25#define USE_SERIAL
26 22
27#define NO_ACTION_MACRO 23#define NO_ACTION_MACRO
28#define NO_ACTION_FUNCTION 24#define NO_ACTION_FUNCTION
diff --git a/keyboards/claw44/i2c.c b/keyboards/claw44/i2c.c
deleted file mode 100644
index 4bee5c639..000000000
--- a/keyboards/claw44/i2c.c
+++ /dev/null
@@ -1,162 +0,0 @@
1#include <util/twi.h>
2#include <avr/io.h>
3#include <stdlib.h>
4#include <avr/interrupt.h>
5#include <util/twi.h>
6#include <stdbool.h>
7#include "i2c.h"
8
9#ifdef USE_I2C
10
11// Limits the amount of we wait for any one i2c transaction.
12// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is
13// 9 bits, a single transaction will take around 90μs to complete.
14//
15// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit
16// poll loop takes at least 8 clock cycles to execute
17#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8
18
19#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE)
20
21volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
22
23static volatile uint8_t slave_buffer_pos;
24static volatile bool slave_has_register_set = false;
25
26// Wait for an i2c operation to finish
27inline static
28void i2c_delay(void) {
29 uint16_t lim = 0;
30 while(!(TWCR & (1<<TWINT)) && lim < I2C_LOOP_TIMEOUT)
31 lim++;
32
33 // easier way, but will wait slightly longer
34 // _delay_us(100);
35}
36
37// Setup twi to run at 100kHz or 400kHz (see ./i2c.h SCL_CLOCK)
38void i2c_master_init(void) {
39 // no prescaler
40 TWSR = 0;
41 // Set TWI clock frequency to SCL_CLOCK. Need TWBR>10.
42 // Check datasheets for more info.
43 TWBR = ((F_CPU/SCL_CLOCK)-16)/2;
44}
45
46// Start a transaction with the given i2c slave address. The direction of the
47// transfer is set with I2C_READ and I2C_WRITE.
48// returns: 0 => success
49// 1 => error
50uint8_t i2c_master_start(uint8_t address) {
51 TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTA);
52
53 i2c_delay();
54
55 // check that we started successfully
56 if ( (TW_STATUS != TW_START) && (TW_STATUS != TW_REP_START))
57 return 1;
58
59 TWDR = address;
60 TWCR = (1<<TWINT) | (1<<TWEN);
61
62 i2c_delay();
63
64 if ( (TW_STATUS != TW_MT_SLA_ACK) && (TW_STATUS != TW_MR_SLA_ACK) )
65 return 1; // slave did not acknowledge
66 else
67 return 0; // success
68}
69
70
71// Finish the i2c transaction.
72void i2c_master_stop(void) {
73 TWCR = (1<<TWINT) | (1<<TWEN) | (1<<TWSTO);
74
75 uint16_t lim = 0;
76 while(!(TWCR & (1<<TWSTO)) && lim < I2C_LOOP_TIMEOUT)
77 lim++;
78}
79
80// Write one byte to the i2c slave.
81// returns 0 => slave ACK
82// 1 => slave NACK
83uint8_t i2c_master_write(uint8_t data) {
84 TWDR = data;
85 TWCR = (1<<TWINT) | (1<<TWEN);
86
87 i2c_delay();
88
89 // check if the slave acknowledged us
90 return (TW_STATUS == TW_MT_DATA_ACK) ? 0 : 1;
91}
92
93// Read one byte from the i2c slave. If ack=1 the slave is acknowledged,
94// if ack=0 the acknowledge bit is not set.
95// returns: byte read from i2c device
96uint8_t i2c_master_read(int ack) {
97 TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA);
98
99 i2c_delay();
100 return TWDR;
101}
102
103void i2c_reset_state(void) {
104 TWCR = 0;
105}
106
107void i2c_slave_init(uint8_t address) {
108 TWAR = address << 0; // slave i2c address
109 // TWEN - twi enable
110 // TWEA - enable address acknowledgement
111 // TWINT - twi interrupt flag
112 // TWIE - enable the twi interrupt
113 TWCR = (1<<TWIE) | (1<<TWEA) | (1<<TWINT) | (1<<TWEN);
114}
115
116ISR(TWI_vect);
117
118ISR(TWI_vect) {
119 uint8_t ack = 1;
120 switch(TW_STATUS) {
121 case TW_SR_SLA_ACK:
122 // this device has been addressed as a slave receiver
123 slave_has_register_set = false;
124 break;
125
126 case TW_SR_DATA_ACK:
127 // this device has received data as a slave receiver
128 // The first byte that we receive in this transaction sets the location
129 // of the read/write location of the slaves memory that it exposes over
130 // i2c. After that, bytes will be written at slave_buffer_pos, incrementing
131 // slave_buffer_pos after each write.
132 if(!slave_has_register_set) {
133 slave_buffer_pos = TWDR;
134 // don't acknowledge the master if this memory loctaion is out of bounds
135 if ( slave_buffer_pos >= SLAVE_BUFFER_SIZE ) {
136 ack = 0;
137 slave_buffer_pos = 0;
138 }
139 slave_has_register_set = true;
140 } else {
141 i2c_slave_buffer[slave_buffer_pos] = TWDR;
142 BUFFER_POS_INC();
143 }
144 break;
145
146 case TW_ST_SLA_ACK:
147 case TW_ST_DATA_ACK:
148 // master has addressed this device as a slave transmitter and is
149 // requesting data.
150 TWDR = i2c_slave_buffer[slave_buffer_pos];
151 BUFFER_POS_INC();
152 break;
153
154 case TW_BUS_ERROR: // something went wrong, reset twi state
155 TWCR = 0;
156 default:
157 break;
158 }
159 // Reset everything, so we are ready for the next TWI interrupt
160 TWCR |= (1<<TWIE) | (1<<TWINT) | (ack<<TWEA) | (1<<TWEN);
161}
162#endif
diff --git a/keyboards/claw44/i2c.h b/keyboards/claw44/i2c.h
deleted file mode 100644
index 710662c7a..000000000
--- a/keyboards/claw44/i2c.h
+++ /dev/null
@@ -1,46 +0,0 @@
1#pragma once
2
3#include <stdint.h>
4
5#ifndef F_CPU
6#define F_CPU 16000000UL
7#endif
8
9#define I2C_READ 1
10#define I2C_WRITE 0
11
12#define I2C_ACK 1
13#define I2C_NACK 0
14
15#define SLAVE_BUFFER_SIZE 0x10
16
17// i2c SCL clock frequency 400kHz
18#define SCL_CLOCK 400000L
19
20extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE];
21
22void i2c_master_init(void);
23uint8_t i2c_master_start(uint8_t address);
24void i2c_master_stop(void);
25uint8_t i2c_master_write(uint8_t data);
26uint8_t i2c_master_read(int);
27void i2c_reset_state(void);
28void i2c_slave_init(uint8_t address);
29
30
31static inline unsigned char i2c_start_read(unsigned char addr) {
32 return i2c_master_start((addr << 1) | I2C_READ);
33}
34
35static inline unsigned char i2c_start_write(unsigned char addr) {
36 return i2c_master_start((addr << 1) | I2C_WRITE);
37}
38
39// from SSD1306 scrips
40extern unsigned char i2c_rep_start(unsigned char addr);
41extern void i2c_start_wait(unsigned char addr);
42extern unsigned char i2c_readAck(void);
43extern unsigned char i2c_readNak(void);
44extern unsigned char i2c_read(unsigned char ack);
45
46#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak();
diff --git a/keyboards/claw44/keymaps/default/config.h b/keyboards/claw44/keymaps/default/config.h
index eff6ad3c7..d2ea02545 100644
--- a/keyboards/claw44/keymaps/default/config.h
+++ b/keyboards/claw44/keymaps/default/config.h
@@ -20,16 +20,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20 20
21#pragma once 21#pragma once
22 22
23//#define USE_MATRIX_I2C
24
25/* Select hand configuration */
26
27#define MASTER_LEFT 23#define MASTER_LEFT
28// #define MASTER_RIGHT
29// #define EE_HANDS
30
31#define SSD1306OLED
32
33#define USE_SERIAL_PD2
34
35#define TAPPING_TERM 200
diff --git a/keyboards/claw44/keymaps/default/keymap.c b/keyboards/claw44/keymaps/default/keymap.c
index 088087c77..65dbd67d9 100644
--- a/keyboards/claw44/keymaps/default/keymap.c
+++ b/keyboards/claw44/keymaps/default/keymap.c
@@ -1,168 +1,59 @@
1#include QMK_KEYBOARD_H 1#include QMK_KEYBOARD_H
2#ifdef PROTOCOL_LUFA
3 #include "lufa.h"
4 #include "split_util.h"
5#endif
6#ifdef SSD1306OLED
7 #include "ssd1306.h"
8#endif
9
10
11extern uint8_t is_master;
12 2
13// Each layer gets a name for readability, which is then used in the keymap matrix below. 3// Each layer gets a name for readability, which is then used in the keymap matrix below.
14// The underscores don't mean anything - you can have a layer called STUFF or any other name. 4// The underscores don't mean anything - you can have a layer called STUFF or any other name.
15// Layer names don't all need to be of the same length, obviously, and you can also skip them 5// Layer names don't all need to be of the same length, obviously, and you can also skip them
16// entirely and just use numbers. 6// entirely and just use numbers.
17 7
18enum custom_keycodes { 8enum layer_number {
19 QWERTY = SAFE_RANGE, 9 _QWERTY = 0,
20 LOWER, 10 _RAISE,
21 RAISE 11 _LOWER,
22};
23
24enum macro_keycodes {
25 KC_SAMPLEMACRO,
26}; 12};
27 13
28#define KC_ KC_TRNS 14#define KC_ KC_TRNS
29#define KC_RST RESET 15#define KC_RST RESET
30#define KC_L_SPC LT(_LOWER, KC_SPC) // lower 16#define KC_L_SPC LT(_LOWER, KC_SPC) // lower
31#define KC_R_ENT LT(_RAISE, KC_ENT) // raise 17#define KC_R_ENT LT(_RAISE, KC_ENT) // raise
32#define KC_G_JA LGUI_T(KC_LANG1) // cmd or win 18#define KC_G_JA LGUI_T(KC_LANG1) // cmd or win
33#define KC_G_EN LGUI_T(KC_LANG2) // cmd or win 19#define KC_G_EN LGUI_T(KC_LANG2) // cmd or win
34#define KC_C_BS LCTL_T(KC_BSPC) // ctrl 20#define KC_C_BS LCTL_T(KC_BSPC) // ctrl
35#define KC_A_DEL ALT_T(KC_DEL) // alt 21#define KC_A_DEL ALT_T(KC_DEL) // alt
36 22
37const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 23const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
38 24 [_QWERTY] = LAYOUT( \
39 [_QWERTY] = LAYOUT( \ 25 //,--------+--------+---------+--------+---------+--------. ,--------+---------+--------+---------+--------+--------.
40 //,--------+--------+---------+--------+---------+--------. ,--------+---------+--------+---------+--------+--------. 26 KC_ESC , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_MINS,
41 KC_ESC , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_MINS, 27 //|--------+--------+---------+--------+---------+--------| |--------+---------+--------+---------+--------+--------|
42 //|--------+--------+---------+--------+---------+--------| |--------+---------+--------+---------+--------+--------| 28 KC_TAB , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT,
43 KC_TAB , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT, 29 //|--------+--------+---------+--------+---------+--------| |--------+---------+--------+---------+--------+--------|
44 //|--------+--------+---------+--------+---------+--------| |--------+---------+--------+---------+--------+--------| 30 KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT,
45 KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT, 31 //`--------+--------+---------+--------+---------+--------/ \--------+---------+--------+---------+--------+--------'
46 //`--------+--------+---------+--------+---------+--------/ \--------+---------+--------+---------+--------+--------' 32 KC_A_DEL, KC_G_EN, KC_L_SPC, KC_C_BS, KC_C_BS, KC_R_ENT, KC_G_JA, KC_A_DEL
47 KC_A_DEL, KC_G_EN, KC_L_SPC, KC_C_BS, KC_C_BS, KC_R_ENT, KC_G_JA, KC_A_DEL 33 // `----------+--------+---------+--------' `--------+---------+--------+---------'
48 // `----------+--------+---------+--------' `--------+---------+--------+---------' 34 ),
49 ), 35
50 36 [_RAISE] = LAYOUT( \
51 // \ ^ ! & | @ = + * % - 37 //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------.
52 // ( # $ " ' ~ ← ↓ ↑ → ` ) 38 _______, KC_BSLS, KC_CIRC, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT , KC_EQL , KC_PLUS, KC_ASTR, KC_PERC, KC_MINS,
53 // { [ ] } 39 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
54 40 KC_LPRN, KC_HASH, KC_DLR , KC_DQT , KC_QUOT, KC_TILD, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT, KC_GRV , KC_RPRN,
55 [_RAISE] = LAYOUT( \ 41 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
56 //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------. 42 _______, _______, _______, _______, KC_LCBR, KC_LBRC, KC_RBRC, KC_RCBR, _______, _______, _______, _______,
57 _______, KC_BSLS, KC_CIRC, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT , KC_EQL , KC_PLUS, KC_ASTR, KC_PERC, KC_MINS, 43 //`--------+--------+--------+--------+--------+--------/ \--------+--------+--------+--------+--------+--------'
58 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| 44 _______, _______, _______, _______, _______, _______, _______, RESET
59 KC_LPRN, KC_HASH, KC_DLR , KC_DQT , KC_QUOT, KC_TILD, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT, KC_GRV , KC_RPRN, 45 // `--------+--------+--------+--------' `--------+--------+--------+--------'
60 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| 46 ),
61 _______, _______, _______, _______, KC_LCBR, KC_LBRC, KC_RBRC, KC_RCBR, _______, _______, _______, _______, 47
62 //`--------+--------+--------+--------+--------+--------/ \--------+--------+--------+--------+--------+--------' 48 [_LOWER] = LAYOUT( \
63 _______, _______, _______, _______, _______, _______, _______, RESET 49 //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------.
64 // `--------+--------+--------+--------' `--------+--------+--------+--------' 50 KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , _______, KC_EQL , KC_PLUS, KC_ASTR, KC_PERC, KC_MINS,
65 ), 51 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
66 52 _______, KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , _______,
67 [_LOWER] = LAYOUT( \ 53 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
68 //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------. 54 KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , _______, _______, KC_COMM, KC_DOT , KC_SLSH, _______,
69 KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , _______, KC_EQL , KC_PLUS, KC_ASTR, KC_PERC, KC_MINS, 55 //`--------+--------+--------+--------+--------+--------/ \--------+--------+--------+--------+--------+--------'
70 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| 56 RESET , _______, _______, _______, _______, _______, _______, _______
71 _______, KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , _______, 57 // `--------+--------+--------+--------' `--------+--------+--------+--------'
72 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------| 58 ),
73 KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , _______, _______, KC_COMM, KC_DOT , KC_SLSH, _______,
74 //`--------+--------+--------+--------+--------+--------/ \--------+--------+--------+--------+--------+--------'
75 RESET , _______, _______, _______, _______, _______, _______, _______
76 // `--------+--------+--------+--------' `--------+--------+--------+--------'
77 ),
78}; 59};
79
80void matrix_init_user(void) {
81 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
82 #ifdef SSD1306OLED
83 iota_gfx_init(!has_usb()); // turns on the display
84 #endif
85}
86
87//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
88#ifdef SSD1306OLED
89
90// When add source files to SRC in rules.mk, you can use functions.
91const char *read_layer_state(void);
92const char *read_logo(void);
93void set_keylog(uint16_t keycode, keyrecord_t *record);
94const char *read_keylog(void);
95const char *read_keylogs(void);
96
97// const char *read_mode_icon(bool swap);
98// const char *read_host_led_state(void);
99// void set_timelog(void);
100// const char *read_timelog(void);
101
102void matrix_scan_user(void) {
103 iota_gfx_task();
104}
105
106void matrix_render_user(struct CharacterMatrix *matrix) {
107 if (is_master) {
108 // If you want to change the display of OLED, you need to change here
109 matrix_write_ln(matrix, read_layer_state());
110 matrix_write_ln(matrix, read_keylog());
111 matrix_write_ln(matrix, read_keylogs());
112 //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui));
113 //matrix_write_ln(matrix, read_host_led_state());
114 //matrix_write_ln(matrix, read_timelog());
115 } else {
116 matrix_write(matrix, read_logo());
117 }
118}
119
120void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
121 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
122 memcpy(dest->display, source->display, sizeof(dest->display));
123 dest->dirty = true;
124 }
125}
126
127void iota_gfx_task_user(void) {
128 struct CharacterMatrix matrix;
129 matrix_clear(&matrix);
130 matrix_render_user(&matrix);
131 matrix_update(&display, &matrix);
132}
133#endif//SSD1306OLED
134
135bool process_record_user(uint16_t keycode, keyrecord_t *record) {
136 if (record->event.pressed) {
137#ifdef SSD1306OLED
138 set_keylog(keycode, record);
139#endif
140 // set_timelog();
141 }
142
143 switch (keycode) {
144 case QWERTY:
145 if (record->event.pressed) {
146 set_single_persistent_default_layer(_QWERTY);
147 }
148 return false;
149 break;
150 case LOWER:
151 if (record->event.pressed) {
152 layer_on(_LOWER);
153 } else {
154 layer_off(_LOWER);
155 }
156 return false;
157 break;
158 case RAISE:
159 if (record->event.pressed) {
160 layer_on(_RAISE);
161 } else {
162 layer_off(_RAISE);
163 }
164 return false;
165 break;
166 }
167 return true;
168}
diff --git a/keyboards/claw44/keymaps/yfuku/config.h b/keyboards/claw44/keymaps/oled/config.h
index 244ffa709..edde2c67c 100644
--- a/keyboards/claw44/keymaps/yfuku/config.h
+++ b/keyboards/claw44/keymaps/oled/config.h
@@ -20,17 +20,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
20 20
21#pragma once 21#pragma once
22 22
23//#define USE_MATRIX_I2C
24
25/* Select hand configuration */
26
27#define MASTER_LEFT 23#define MASTER_LEFT
28// #define MASTER_RIGHT 24#define OLED_FONT_H "keyboards/claw44/lib/glcdfont.c"
29// #define EE_HANDS
30
31#define SSD1306OLED
32
33#define USE_SERIAL_PD2
34
35#define TAPPING_TERM 180
36#define IGNORE_MOD_TAP_INTERRUPT
diff --git a/keyboards/claw44/keymaps/oled/keymap.c b/keyboards/claw44/keymaps/oled/keymap.c
new file mode 100644
index 000000000..0d10c371a
--- /dev/null
+++ b/keyboards/claw44/keymaps/oled/keymap.c
@@ -0,0 +1,137 @@
1#include QMK_KEYBOARD_H
2#include <stdio.h>
3
4// Each layer gets a name for readability, which is then used in the keymap matrix below.
5// The underscores don't mean anything - you can have a layer called STUFF or any other name.
6// Layer names don't all need to be of the same length, obviously, and you can also skip them
7// entirely and just use numbers.
8
9enum layer_number {
10 _QWERTY = 0,
11 _RAISE,
12 _LOWER,
13};
14
15#define KC_ KC_TRNS
16#define KC_RST RESET
17#define KC_L_SPC LT(_LOWER, KC_SPC) // lower
18#define KC_R_ENT LT(_RAISE, KC_ENT) // raise
19#define KC_G_JA LGUI_T(KC_LANG1) // cmd or win
20#define KC_G_EN LGUI_T(KC_LANG2) // cmd or win
21#define KC_C_BS LCTL_T(KC_BSPC) // ctrl
22#define KC_A_DEL ALT_T(KC_DEL) // alt
23
24const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
25 [_QWERTY] = LAYOUT( \
26 //,--------+--------+---------+--------+---------+--------. ,--------+---------+--------+---------+--------+--------.
27 KC_ESC , KC_Q , KC_W , KC_E , KC_R , KC_T , KC_Y , KC_U , KC_I , KC_O , KC_P , KC_MINS,
28 //|--------+--------+---------+--------+---------+--------| |--------+---------+--------+---------+--------+--------|
29 KC_TAB , KC_A , KC_S , KC_D , KC_F , KC_G , KC_H , KC_J , KC_K , KC_L , KC_SCLN, KC_QUOT,
30 //|--------+--------+---------+--------+---------+--------| |--------+---------+--------+---------+--------+--------|
31 KC_LSFT, KC_Z , KC_X , KC_C , KC_V , KC_B , KC_N , KC_M , KC_COMM, KC_DOT , KC_SLSH, KC_RSFT,
32 //`--------+--------+---------+--------+---------+--------/ \--------+---------+--------+---------+--------+--------'
33 KC_A_DEL, KC_G_EN, KC_L_SPC, KC_C_BS, KC_C_BS, KC_R_ENT, KC_G_JA, KC_A_DEL
34 // `----------+--------+---------+--------' `--------+---------+--------+---------'
35 ),
36
37 [_RAISE] = LAYOUT( \
38 //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------.
39 _______, KC_BSLS, KC_CIRC, KC_EXLM, KC_AMPR, KC_PIPE, KC_AT , KC_EQL , KC_PLUS, KC_ASTR, KC_PERC, KC_MINS,
40 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
41 KC_LPRN, KC_HASH, KC_DLR , KC_DQT , KC_QUOT, KC_TILD, KC_LEFT, KC_DOWN, KC_UP , KC_RGHT, KC_GRV , KC_RPRN,
42 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
43 _______, _______, _______, _______, KC_LCBR, KC_LBRC, KC_RBRC, KC_RCBR, _______, _______, _______, _______,
44 //`--------+--------+--------+--------+--------+--------/ \--------+--------+--------+--------+--------+--------'
45 _______, _______, _______, _______, _______, _______, _______, RESET
46 // `--------+--------+--------+--------' `--------+--------+--------+--------'
47 ),
48
49 [_LOWER] = LAYOUT( \
50 //,--------+--------+--------+--------+--------+--------. ,--------+--------+--------+--------+--------+--------.
51 KC_F1 , KC_F2 , KC_F3 , KC_F4 , KC_F5 , KC_F6 , _______, KC_EQL , KC_PLUS, KC_ASTR, KC_PERC, KC_MINS,
52 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
53 _______, KC_1 , KC_2 , KC_3 , KC_4 , KC_5 , KC_6 , KC_7 , KC_8 , KC_9 , KC_0 , _______,
54 //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
55 KC_F7 , KC_F8 , KC_F9 , KC_F10 , KC_F11 , KC_F12 , _______, _______, KC_COMM, KC_DOT , KC_SLSH, _______,
56 //`--------+--------+--------+--------+--------+--------/ \--------+--------+--------+--------+--------+--------'
57 RESET , _______, _______, _______, _______, _______, _______, _______
58 // `--------+--------+--------+--------' `--------+--------+--------+--------'
59 ),
60};
61
62#ifdef OLED_DRIVER_ENABLE
63
64void render_layer_state(void) {
65 switch (get_highest_layer(layer_state)) {
66 case _QWERTY:
67 oled_write_ln_P(PSTR("Layer: Default"), false);
68 break;
69 case _RAISE:
70 oled_write_ln_P(PSTR("Layer: Raise"), false);
71 break;
72 case _LOWER:
73 oled_write_ln_P(PSTR("Layer: Lower"), false);
74 break;
75 default:
76 oled_write_ln_P(PSTR("Layer: Undefined"), false);
77 }
78}
79
80void render_logo(void) {
81 static const char PROGMEM logo[] = {0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0};
82 oled_write_P(logo, false);
83}
84
85char keylog_str[24] = {};
86char keylogs_str[21] = {};
87int keylogs_str_idx = 0;
88
89const char code_to_name[60] = {' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'R', 'E', 'B', 'T', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ';', '\'', ' ', ',', '.', '/', ' ', ' ', ' '};
90
91void set_keylog(uint16_t keycode, keyrecord_t *record) {
92 char name = ' ';
93 if (keycode < 60) {
94 name = code_to_name[keycode];
95 }
96
97 // update keylog
98 snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c", record->event.key.row, record->event.key.col, keycode, name);
99
100 // update keylogs
101 if (keylogs_str_idx == sizeof(keylogs_str) - 1) {
102 keylogs_str_idx = 0;
103 for (int i = 0; i < sizeof(keylogs_str) - 1; i++) {
104 keylogs_str[i] = ' ';
105 }
106 }
107
108 keylogs_str[keylogs_str_idx] = name;
109 keylogs_str_idx++;
110}
111
112const char *read_keylog(void) { return keylog_str; }
113const char *read_keylogs(void) { return keylogs_str; }
114
115void oled_task_user(void) {
116 if (is_keyboard_master()) {
117 render_layer_state();
118 oled_write_ln(read_keylog(), false);
119 oled_write_ln(read_keylogs(), false);
120 } else {
121 render_logo();
122 }
123}
124
125bool process_record_user(uint16_t keycode, keyrecord_t *record) {
126 if (record->event.pressed) {
127 set_keylog(keycode, record);
128 }
129 return true;
130}
131
132oled_rotation_t oled_init_user(oled_rotation_t rotation) {
133 if (!is_keyboard_master()) return OLED_ROTATION_180;
134 return rotation;
135}
136
137#endif
diff --git a/keyboards/claw44/keymaps/oled/rules.mk b/keyboards/claw44/keymaps/oled/rules.mk
new file mode 100644
index 000000000..c58266213
--- /dev/null
+++ b/keyboards/claw44/keymaps/oled/rules.mk
@@ -0,0 +1 @@
OLED_DRIVER_ENABLE = yes
diff --git a/keyboards/claw44/keymaps/yfuku/keymap.c b/keyboards/claw44/keymaps/yfuku/keymap.c
deleted file mode 100644
index 77d459b92..000000000
--- a/keyboards/claw44/keymaps/yfuku/keymap.c
+++ /dev/null
@@ -1,221 +0,0 @@
1#include QMK_KEYBOARD_H
2#ifdef PROTOCOL_LUFA
3 #include "lufa.h"
4 #include "split_util.h"
5#endif
6#ifdef SSD1306OLED
7 #include "ssd1306.h"
8#endif
9
10extern keymap_config_t keymap_config;
11
12extern uint8_t is_master;
13
14// Each layer gets a name for readability, which is then used in the keymap matrix below.
15// The underscores don't mean anything - you can have a layer called STUFF or any other name.
16// Layer names don't all need to be of the same length, obviously, and you can also skip them
17// entirely and just use numbers.
18enum custom_keycodes {
19 QWERTY = SAFE_RANGE,
20 LOWER,
21 RAISE
22};
23
24enum macro_keycodes {
25 KC_SAMPLEMACRO,
26};
27
28// common
29#define KC_ KC_TRNS
30#define KC_XXXX KC_NO
31#define KC_RST RESET
32#define KC_VD KC__VOLDOWN
33#define KC_VU KC__VOLUP
34
35// layer
36#define KC_L_SPC LT(_LOWER, KC_SPC)
37#define KC_R_ENT LT(_RAISE, KC_ENT)
38
39// shift_t
40#define KC_S_TAB LSFT_T(KC_TAB)
41#define KC_S_ESC LSFT_T(KC_ESC)
42#define KC_S_JA LSFT_T(KC_LANG1)
43#define KC_S_EN LSFT_T(KC_LANG2)
44
45// cmd_t
46#define KC_M_F LCMD_T(KC_F)
47#define KC_M_D LCMD_T(KC_D)
48#define KC_M_J LCMD_T(KC_J)
49#define KC_M_K LCMD_T(KC_K)
50
51// ctl_t
52#define KC_C_S LCTL_T(KC_S)
53#define KC_C_L LCTL_T(KC_L)
54#define KC_C_BS LCTL_T(KC_BSPC)
55
56// alt_t
57#define KC_A_D ALT_T(KC_D)
58#define KC_A_K ALT_T(KC_K)
59#define KC_A_Z ALT_T(KC_Z)
60#define KC_A_SL ALT_T(KC_SLSH)
61#define KC_A_DEL ALT_T(KC_DEL)
62
63// cmd+shift_t
64#define KC_MS_Q SCMD_T(KC_Q)
65#define KC_MS_A SCMD_T(KC_A)
66#define KC_MS_S SCMD_T(KC_S)
67#define KC_MS_SC SCMD_T(KC_SCLN)
68#define KC_MS_ESC SCMD_T(KC_ESC)
69
70//
71#define KC_MR RCMD(KC_R)
72#define KC_MF RCMD(KC_F)
73#define KC_MW RCMD(KC_W)
74#define KC_MX RCMD(KC_X)
75#define KC_MC RCMD(KC_C)
76#define KC_MV RCMD(KC_V)
77#define KC_MTAB RCMD(KC_TAB)
78#define KC_MSF RCMD(RSFT(KC_F))
79#define KC_MSR RCMD(RSFT(KC_R))
80#define KC_MST RCMD(RSFT(KC_T))
81
82const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
83
84 // M_ = LCMD_T(
85 // A_ = ALT_T(
86 // C_ = LCTL_T(
87 // MS_ = SMD_T(
88 // R_ = LT(_RAISE
89 // L_ = LT(_LOWER
90
91 [_QWERTY] = LAYOUT_kc( \
92 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
93 ESC , Q , W , E , R , T , Y , U , I , O , P ,MINS,
94 //|----+----+----+----+----+----| |----+----+----+----+----+----|
95 S_TAB, A ,C_S , D ,M_F , G , H ,M_J , K ,C_L ,SCLN,S_ESC,
96 //|----+----+----+----+----+----+ |----+----+----+----+----+----|
97 , Z , X , C , V , B , N , M ,COMM,DOT ,SLSH, ,
98 //`----+----+----+----+----+----/ \----+----+----+----+----+----'
99 A_DEL,S_EN,L_SPC,C_BS, C_BS,R_ENT,S_JA,A_DEL
100 // `----+----+----+----' `----+----+----+----'
101 ),
102
103 // \ ^ ! & | @ = + * % -
104 // ( # $ " ' ~ ← ↓ ↑ → ` )
105 // { [ ] }
106
107 [_RAISE] = LAYOUT_kc( \
108 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
109 ,BSLS,CIRC,EXLM,AMPR,PIPE, AT ,EQL ,PLUS,ASTR,PERC,MINS,
110 //|----+----+----+----+----+----| |----+----+----+----+----+----|
111 LPRN,HASH,DLR ,DQT ,QUOT,TILD, LEFT,DOWN, UP ,RGHT,GRV ,RPRN,
112 //|----+----+----+----+----+----| |----+----+----+----+----+----|
113 , , , ,LCBR,LBRC, RBRC,RCBR, , , , ,
114 //`----+----+----+----+----+----/ \----+----+----+----+----+----'
115 , ,BSPC, , , , ,RST
116 // `----+----+----+----' `----+----+----+----'
117 ),
118
119 [_LOWER] = LAYOUT_kc( \
120 //,----+----+----+----+----+----. ,----+----+----+----+----+----.
121 , , ,MSF ,MSR ,MST , ,EQL ,PLUS,ASTR,PERC,MINS,
122 //|----+----+----+----+----+----| |----+----+----+----+----+----|
123 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 0 , ,
124 //|----+----+----+----+----+----| |----+----+----+----+----+----|
125 , , , , , , , ,COMM,DOT ,SLSH, ,
126 //`----+----+----+--+-+----+----/ \----+----+----+----+----+----'
127 RST , , , , ,DEL , ,
128 // `----+----+----+----' `----+----+----+----'
129 ),
130};
131
132void matrix_init_user(void) {
133 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
134 #ifdef SSD1306OLED
135 iota_gfx_init(!has_usb()); // turns on the display
136 #endif
137}
138
139//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
140#ifdef SSD1306OLED
141
142// When add source files to SRC in rules.mk, you can use functions.
143const char *read_layer_state(void);
144const char *read_logo(void);
145void set_keylog(uint16_t keycode, keyrecord_t *record);
146const char *read_keylog(void);
147const char *read_keylogs(void);
148
149// const char *read_mode_icon(bool swap);
150// const char *read_host_led_state(void);
151// void set_timelog(void);
152// const char *read_timelog(void);
153
154void matrix_scan_user(void) {
155 iota_gfx_task();
156}
157
158void matrix_render_user(struct CharacterMatrix *matrix) {
159 if (is_master) {
160 // If you want to change the display of OLED, you need to change here
161 matrix_write_ln(matrix, read_layer_state());
162 matrix_write_ln(matrix, read_keylog());
163 matrix_write_ln(matrix, read_keylogs());
164 //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui));
165 //matrix_write_ln(matrix, read_host_led_state());
166 //matrix_write_ln(matrix, read_timelog());
167 } else {
168 matrix_write(matrix, read_logo());
169 }
170}
171
172void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
173 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
174 memcpy(dest->display, source->display, sizeof(dest->display));
175 dest->dirty = true;
176 }
177}
178
179void iota_gfx_task_user(void) {
180 struct CharacterMatrix matrix;
181 matrix_clear(&matrix);
182 matrix_render_user(&matrix);
183 matrix_update(&display, &matrix);
184}
185#endif//SSD1306OLED
186
187bool process_record_user(uint16_t keycode, keyrecord_t *record) {
188 if (record->event.pressed) {
189#ifdef SSD1306OLED
190 set_keylog(keycode, record);
191#endif
192 // set_timelog();
193 }
194
195 switch (keycode) {
196 case QWERTY:
197 if (record->event.pressed) {
198 set_single_persistent_default_layer(_QWERTY);
199 }
200 return false;
201 break;
202 case LOWER:
203 if (record->event.pressed) {
204 layer_on(_LOWER);
205 } else {
206 layer_off(_LOWER);
207 }
208 return false;
209 break;
210 case RAISE:
211 if (record->event.pressed) {
212 layer_on(_RAISE);
213 } else {
214 layer_off(_RAISE);
215 }
216 return false;
217 break;
218 }
219 return true;
220}
221
diff --git a/keyboards/claw44/lib/glcdfont.c b/keyboards/claw44/lib/glcdfont.c
index 9fa1c806a..91f53d9c2 100644
--- a/keyboards/claw44/lib/glcdfont.c
+++ b/keyboards/claw44/lib/glcdfont.c
@@ -1,7 +1,17 @@
1// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. 1// This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0.
2// See gfxfont.h for newer custom bitmap font info. 2// See gfxfont.h for newer custom bitmap font info.
3 3
4#include "progmem.h" 4#ifndef FONT5X7_H
5#define FONT5X7_H
6
7#ifdef __AVR__
8 #include <avr/io.h>
9 #include <avr/pgmspace.h>
10#elif defined(ESP8266)
11 #include <pgmspace.h>
12#else
13 #define PROGMEM
14#endif
5 15
6// Standard ASCII 5x7 font 16// Standard ASCII 5x7 font
7const unsigned char font[] PROGMEM = { 17const unsigned char font[] PROGMEM = {
@@ -230,3 +240,4 @@ const unsigned char font[] PROGMEM = {
2300x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2400x00, 0x00, 0x00, 0x00, 0x00, 0x00,
2310x00, 0x00, 0x00, 0x00, 0x00, 0x00, 2410x00, 0x00, 0x00, 0x00, 0x00, 0x00,
232}; 242};
243#endif // FONT5X7_H
diff --git a/keyboards/claw44/lib/host_led_state_reader.c b/keyboards/claw44/lib/host_led_state_reader.c
deleted file mode 100644
index 980823b31..000000000
--- a/keyboards/claw44/lib/host_led_state_reader.c
+++ /dev/null
@@ -1,15 +0,0 @@
1#include <stdio.h>
2#include "claw44.h"
3
4char host_led_state_str[24];
5
6const char *read_host_led_state(void)
7{
8 uint8_t leds = host_keyboard_leds();
9 snprintf(host_led_state_str, sizeof(host_led_state_str), "NL:%s CL:%s SL:%s",
10 (leds & (1 << USB_LED_NUM_LOCK)) ? "on" : "- ",
11 (leds & (1 << USB_LED_CAPS_LOCK)) ? "on" : "- ",
12 (leds & (1 << USB_LED_SCROLL_LOCK)) ? "on" : "- ");
13
14 return host_led_state_str;
15}
diff --git a/keyboards/claw44/lib/keylogger.c b/keyboards/claw44/lib/keylogger.c
deleted file mode 100644
index 092b6929b..000000000
--- a/keyboards/claw44/lib/keylogger.c
+++ /dev/null
@@ -1,45 +0,0 @@
1#include <stdio.h>
2#include "claw44.h"
3
4char keylog_str[24] = {};
5char keylogs_str[21] = {};
6int keylogs_str_idx = 0;
7
8const char code_to_name[60] = {
9 ' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f',
10 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
11 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
12 '1', '2', '3', '4', '5', '6', '7', '8', '9', '0',
13 'R', 'E', 'B', 'T', ' ', ' ', ' ', ' ', ' ', ' ',
14 ' ', ';', '\'', ' ', ',', '.', '/', ' ', ' ', ' '};
15
16void set_keylog(uint16_t keycode, keyrecord_t *record) {
17 char name = ' ';
18 if (keycode < 60) {
19 name = code_to_name[keycode];
20 }
21
22 // update keylog
23 snprintf(keylog_str, sizeof(keylog_str), "%dx%d, k%2d : %c",
24 record->event.key.row, record->event.key.col,
25 keycode, name);
26
27 // update keylogs
28 if (keylogs_str_idx == sizeof(keylogs_str) - 1) {
29 keylogs_str_idx = 0;
30 for (int i = 0; i < sizeof(keylogs_str) - 1; i++) {
31 keylogs_str[i] = ' ';
32 }
33 }
34
35 keylogs_str[keylogs_str_idx] = name;
36 keylogs_str_idx++;
37}
38
39const char *read_keylog(void) {
40 return keylog_str;
41}
42
43const char *read_keylogs(void) {
44 return keylogs_str;
45}
diff --git a/keyboards/claw44/lib/layer_state_reader.c b/keyboards/claw44/lib/layer_state_reader.c
deleted file mode 100644
index d92b6df58..000000000
--- a/keyboards/claw44/lib/layer_state_reader.c
+++ /dev/null
@@ -1,35 +0,0 @@
1
2#include QMK_KEYBOARD_H
3#include <stdio.h>
4#include "claw44.h"
5
6#define L_BASE 0
7#define L_LOWER (1<<_LOWER)
8#define L_RAISE (1<<_RAISE)
9#define L_ADJUST (1<<_ADJUST)
10#define L_ADJUST_TRI (L_ADJUST|L_RAISE|L_LOWER)
11
12char layer_state_str[24];
13
14const char *read_layer_state(void) {
15 switch (layer_state)
16 {
17 case L_BASE:
18 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Default");
19 break;
20 case L_RAISE:
21 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Raise");
22 break;
23 case L_LOWER:
24 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Lower");
25 break;
26 case L_ADJUST:
27 case L_ADJUST_TRI:
28 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Adjust");
29 break;
30 default:
31 snprintf(layer_state_str, sizeof(layer_state_str), "Layer: Undef-%ld", layer_state);
32 }
33
34 return layer_state_str;
35}
diff --git a/keyboards/claw44/lib/logo_reader.c b/keyboards/claw44/lib/logo_reader.c
deleted file mode 100644
index b5b437b2b..000000000
--- a/keyboards/claw44/lib/logo_reader.c
+++ /dev/null
@@ -1,11 +0,0 @@
1#include "claw44.h"
2
3const char *read_logo(void) {
4 static char logo[] = {
5 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94,
6 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4,
7 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4,
8 0};
9
10 return logo;
11}
diff --git a/keyboards/claw44/lib/mode_icon_reader.c b/keyboards/claw44/lib/mode_icon_reader.c
deleted file mode 100644
index a9272bb9a..000000000
--- a/keyboards/claw44/lib/mode_icon_reader.c
+++ /dev/null
@@ -1,15 +0,0 @@
1#include <stdio.h>
2#include "claw44.h"
3
4char mode_icon[24];
5
6const char *read_mode_icon(bool swap) {
7 static char logo[][2][3] = {{{0x95, 0x96, 0}, {0xb5, 0xb6, 0}}, {{0x97, 0x98, 0}, {0xb7, 0xb8, 0}}};
8 if (swap == false) {
9 snprintf(mode_icon, sizeof(mode_icon), "%s\n%s", logo[0][0], logo[0][1]);
10 } else {
11 snprintf(mode_icon, sizeof(mode_icon), "%s\n%s", logo[1][0], logo[1][1]);
12 }
13
14 return mode_icon;
15}
diff --git a/keyboards/claw44/lib/rgb_state_reader.c b/keyboards/claw44/lib/rgb_state_reader.c
deleted file mode 100644
index e0efe2e52..000000000
--- a/keyboards/claw44/lib/rgb_state_reader.c
+++ /dev/null
@@ -1,15 +0,0 @@
1#ifdef RGBLIGHT_ENABLE
2
3#include QMK_KEYBOARD_H
4#include <stdio.h>
5
6extern rgblight_config_t rgblight_config;
7char rbf_info_str[24];
8const char *read_rgb_info(void) {
9
10 snprintf(rbf_info_str, sizeof(rbf_info_str), "%s %2d h%3d s%3d v%3d",
11 rgblight_config.enable ? "on" : "- ", rgblight_config.mode,
12 rgblight_config.hue, rgblight_config.sat, rgblight_config.val);
13 return rbf_info_str;
14}
15#endif
diff --git a/keyboards/claw44/lib/timelogger.c b/keyboards/claw44/lib/timelogger.c
deleted file mode 100644
index ecd4ed3ea..000000000
--- a/keyboards/claw44/lib/timelogger.c
+++ /dev/null
@@ -1,16 +0,0 @@
1#include <stdio.h>
2#include "claw44.h"
3
4char timelog_str[24] = {};
5int last_time = 0;
6int elapsed_time = 0;
7
8void set_timelog(void) {
9 elapsed_time = timer_elapsed(last_time);
10 last_time = timer_read();
11 snprintf(timelog_str, sizeof(timelog_str), "lt:%5d, et:%5d", last_time, elapsed_time);
12}
13
14const char *read_timelog(void) {
15 return timelog_str;
16}
diff --git a/keyboards/claw44/rev1/config.h b/keyboards/claw44/rev1/config.h
index f3406fee5..dc6e49dd9 100644
--- a/keyboards/claw44/rev1/config.h
+++ b/keyboards/claw44/rev1/config.h
@@ -19,22 +19,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
19#pragma once 19#pragma once
20 20
21/* USB Device descriptor parameter */ 21/* USB Device descriptor parameter */
22#define VENDOR_ID 0xFEED 22#define VENDOR_ID 0xFEED
23#define PRODUCT_ID 0x3060 23#define PRODUCT_ID 0x3060
24#define DEVICE_VER 0x0001 24#define DEVICE_VER 0x0001
25#define MANUFACTURER yfuku 25#define MANUFACTURER yfuku
26#define PRODUCT claw44 26#define PRODUCT claw44
27#define DESCRIPTION A split keyboard with 3x6 vertically staggered keys and 4 thumb keys 27#define DESCRIPTION A split keyboard with 3x6 vertically staggered keys and 4 thumb keys
28 28
29/* key matrix size */ 29/* key matrix size */
30// Rows are doubled-up
31#define MATRIX_ROWS 8 30#define MATRIX_ROWS 8
32#define MATRIX_COLS 7 31#define MATRIX_COLS 6
33#define MATRIX_ROW_PINS { D4, C6, D7, E6 } 32#define MATRIX_ROW_PINS { D4, C6, D7, E6 }
34 33#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3 }
35// wiring of each half 34#define UNUSED_PINS
36#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3, B2 } 35#define DIODE_DIRECTION COL2ROW
37// #define MATRIX_COL_PINS { B2, B3, B1, F7, F6, F5, F4 } //uncomment this line and comment line above if you need to reverse left-to-right key order 36#define SOFT_SERIAL_PIN D2
38 37
39/* define if matrix has ghost */ 38/* define if matrix has ghost */
40//#define MATRIX_HAS_GHOST 39//#define MATRIX_HAS_GHOST
diff --git a/keyboards/claw44/rev1/matrix.c b/keyboards/claw44/rev1/matrix.c
deleted file mode 100644
index a5896d979..000000000
--- a/keyboards/claw44/rev1/matrix.c
+++ /dev/null
@@ -1,358 +0,0 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/*
19 * scan matrix
20 */
21#include <stdint.h>
22#include <stdbool.h>
23#include <string.h>
24#include <avr/io.h>
25#include <avr/wdt.h>
26#include <avr/interrupt.h>
27#include <util/delay.h>
28#include "print.h"
29#include "debug.h"
30#include "util.h"
31#include "matrix.h"
32#include "split_util.h"
33#include "quantum.h"
34
35#ifdef USE_MATRIX_I2C
36# include "i2c.h"
37#else // USE_SERIAL
38# include "split_scomm.h"
39#endif
40
41#ifndef DEBOUNCE
42# define DEBOUNCE 5
43#endif
44
45#define ERROR_DISCONNECT_COUNT 5
46
47static uint8_t debouncing = DEBOUNCE;
48static const int ROWS_PER_HAND = MATRIX_ROWS/2;
49static uint8_t error_count = 0;
50uint8_t is_master = 0 ;
51
52static const uint8_t row_pins[MATRIX_ROWS] = MATRIX_ROW_PINS;
53static const uint8_t col_pins[MATRIX_COLS] = MATRIX_COL_PINS;
54
55/* matrix state(1:on, 0:off) */
56static matrix_row_t matrix[MATRIX_ROWS];
57static matrix_row_t matrix_debouncing[MATRIX_ROWS];
58
59static matrix_row_t read_cols(void);
60static void init_cols(void);
61static void unselect_rows(void);
62static void select_row(uint8_t row);
63static uint8_t matrix_master_scan(void);
64
65
66__attribute__ ((weak))
67void matrix_init_kb(void) {
68 matrix_init_user();
69}
70
71__attribute__ ((weak))
72void matrix_scan_kb(void) {
73 matrix_scan_user();
74}
75
76__attribute__ ((weak))
77void matrix_init_user(void) {
78}
79
80__attribute__ ((weak))
81void matrix_scan_user(void) {
82}
83
84inline
85uint8_t matrix_rows(void)
86{
87 return MATRIX_ROWS;
88}
89
90inline
91uint8_t matrix_cols(void)
92{
93 return MATRIX_COLS;
94}
95
96void matrix_init(void)
97{
98 debug_enable = true;
99 debug_matrix = true;
100 debug_mouse = true;
101 // initialize row and col
102 unselect_rows();
103 init_cols();
104
105 setPinOutput(B0);
106 setPinOutput(D5);
107 writePinHigh(B0);
108 writePinHigh(D5);
109
110 // initialize matrix state: all keys off
111 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
112 matrix[i] = 0;
113 matrix_debouncing[i] = 0;
114 }
115
116 is_master = has_usb();
117
118 matrix_init_quantum();
119}
120
121uint8_t _matrix_scan(void)
122{
123 // Right hand is stored after the left in the matirx so, we need to offset it
124 int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
125
126 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
127 select_row(i);
128 _delay_us(30); // without this wait read unstable value.
129 matrix_row_t cols = read_cols();
130 if (matrix_debouncing[i+offset] != cols) {
131 matrix_debouncing[i+offset] = cols;
132 debouncing = DEBOUNCE;
133 }
134 unselect_rows();
135 }
136
137 if (debouncing) {
138 if (--debouncing) {
139 _delay_ms(1);
140 } else {
141 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
142 matrix[i+offset] = matrix_debouncing[i+offset];
143 }
144 }
145 }
146
147 return 1;
148}
149
150#ifdef USE_MATRIX_I2C
151
152// Get rows from other half over i2c
153int i2c_transaction(void) {
154 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
155
156 int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
157 if (err) goto i2c_error;
158
159 // start of matrix stored at 0x00
160 err = i2c_master_write(0x00);
161 if (err) goto i2c_error;
162
163 // Start read
164 err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
165 if (err) goto i2c_error;
166
167 if (!err) {
168 int i;
169 for (i = 0; i < ROWS_PER_HAND-1; ++i) {
170 matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
171 }
172 matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
173 i2c_master_stop();
174 } else {
175i2c_error: // the cable is disconnceted, or something else went wrong
176 i2c_reset_state();
177 return err;
178 }
179
180 return 0;
181}
182
183#else // USE_SERIAL
184
185int serial_transaction(int master_changed) {
186 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
187#ifdef SERIAL_USE_MULTI_TRANSACTION
188 int ret=serial_update_buffers(master_changed);
189#else
190 int ret=serial_update_buffers();
191#endif
192 if (ret ) {
193 if(ret==2) writePinLow(B0);
194 return 1;
195 }
196 writePinHigh(B0);
197 memcpy(&matrix[slaveOffset],
198 (void *)serial_slave_buffer, SERIAL_SLAVE_BUFFER_LENGTH);
199 return 0;
200}
201#endif
202
203uint8_t matrix_scan(void)
204{
205 if (is_master) {
206 matrix_master_scan();
207 }else{
208 matrix_slave_scan();
209 int offset = (isLeftHand) ? ROWS_PER_HAND : 0;
210 memcpy(&matrix[offset],
211 (void *)serial_master_buffer, SERIAL_MASTER_BUFFER_LENGTH);
212 matrix_scan_quantum();
213 }
214 return 1;
215}
216
217
218uint8_t matrix_master_scan(void) {
219
220 int ret = _matrix_scan();
221 int mchanged = 1;
222
223 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
224
225#ifdef USE_MATRIX_I2C
226// for (int i = 0; i < ROWS_PER_HAND; ++i) {
227 /* i2c_slave_buffer[i] = matrix[offset+i]; */
228// i2c_slave_buffer[i] = matrix[offset+i];
229// }
230#else // USE_SERIAL
231 #ifdef SERIAL_USE_MULTI_TRANSACTION
232 mchanged = memcmp((void *)serial_master_buffer,
233 &matrix[offset], SERIAL_MASTER_BUFFER_LENGTH);
234 #endif
235 memcpy((void *)serial_master_buffer,
236 &matrix[offset], SERIAL_MASTER_BUFFER_LENGTH);
237#endif
238
239#ifdef USE_MATRIX_I2C
240 if( i2c_transaction() ) {
241#else // USE_SERIAL
242 if( serial_transaction(mchanged) ) {
243#endif
244 // turn on the indicator led when halves are disconnected
245 writePinLow(D5);
246
247 error_count++;
248
249 if (error_count > ERROR_DISCONNECT_COUNT) {
250 // reset other half if disconnected
251 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
252 for (int i = 0; i < ROWS_PER_HAND; ++i) {
253 matrix[slaveOffset+i] = 0;
254 }
255 }
256 } else {
257 // turn off the indicator led on no error
258 writePinHigh(D5);
259 error_count = 0;
260 }
261 matrix_scan_quantum();
262 return ret;
263}
264
265void matrix_slave_scan(void) {
266 _matrix_scan();
267
268 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
269
270#ifdef USE_MATRIX_I2C
271 for (int i = 0; i < ROWS_PER_HAND; ++i) {
272 /* i2c_slave_buffer[i] = matrix[offset+i]; */
273 i2c_slave_buffer[i] = matrix[offset+i];
274 }
275#else // USE_SERIAL
276 #ifdef SERIAL_USE_MULTI_TRANSACTION
277 int change = 0;
278 #endif
279 for (int i = 0; i < ROWS_PER_HAND; ++i) {
280 #ifdef SERIAL_USE_MULTI_TRANSACTION
281 if( serial_slave_buffer[i] != matrix[offset+i] )
282 change = 1;
283 #endif
284 serial_slave_buffer[i] = matrix[offset+i];
285 }
286 #ifdef SERIAL_USE_MULTI_TRANSACTION
287 slave_buffer_change_count += change;
288 #endif
289#endif
290}
291
292bool matrix_is_modified(void)
293{
294 if (debouncing) return false;
295 return true;
296}
297
298inline
299bool matrix_is_on(uint8_t row, uint8_t col)
300{
301 return (matrix[row] & ((matrix_row_t)1<<col));
302}
303
304inline
305matrix_row_t matrix_get_row(uint8_t row)
306{
307 return matrix[row];
308}
309
310void matrix_print(void)
311{
312 print("\nr/c 0123456789ABCDEF\n");
313 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
314 phex(row); print(": ");
315 pbin_reverse16(matrix_get_row(row));
316 print("\n");
317 }
318}
319
320uint8_t matrix_key_count(void)
321{
322 uint8_t count = 0;
323 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
324 count += bitpop16(matrix[i]);
325 }
326 return count;
327}
328
329static void init_cols(void)
330{
331 for(int x = 0; x < MATRIX_COLS; x++) {
332 _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
333 _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
334 }
335}
336
337static matrix_row_t read_cols(void)
338{
339 matrix_row_t result = 0;
340 for(int x = 0; x < MATRIX_COLS; x++) {
341 result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
342 }
343 return result;
344}
345
346static void unselect_rows(void)
347{
348 for(int x = 0; x < ROWS_PER_HAND; x++) {
349 _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
350 _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
351 }
352}
353
354static void select_row(uint8_t row)
355{
356 _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
357 _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
358}
diff --git a/keyboards/claw44/rev1/rev1.c b/keyboards/claw44/rev1/rev1.c
index 9529636f5..520a869e5 100644
--- a/keyboards/claw44/rev1/rev1.c
+++ b/keyboards/claw44/rev1/rev1.c
@@ -1,8 +1 @@
1#include "claw44.h" #include "rev1.h"
2
3#ifdef SSD1306OLED
4void led_set_kb(uint8_t usb_led) {
5 // put your keyboard LED indicator (ex: Caps Lock LED) toggling code here
6 //led_set_user(usb_led);
7}
8#endif
diff --git a/keyboards/claw44/rev1/rev1.h b/keyboards/claw44/rev1/rev1.h
index c6c9057fd..79ae9586d 100644
--- a/keyboards/claw44/rev1/rev1.h
+++ b/keyboards/claw44/rev1/rev1.h
@@ -1,55 +1,33 @@
1#pragma once 1#pragma once
2 2
3#include "../claw44.h"
4
5#include "quantum.h" 3#include "quantum.h"
6 4
7#ifdef RGBLIGHT_ENABLE
8//rgb led driver
9#include "ws2812.h"
10#endif
11
12#ifdef USE_I2C
13#include <stddef.h>
14#ifdef __AVR__
15 #include <avr/io.h>
16 #include <avr/interrupt.h>
17#endif
18#endif
19
20#define LAYOUT( \ 5#define LAYOUT( \
21 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ 6 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
22 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ 7 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
23 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ 8 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
24 L30, L31, L32, L33, R30, R31, R32, R33 \ 9 L30, L31, L32, L33, R30, R31, R32, R33 \
25 ) \ 10 ) \
26 { \ 11 { \
27 { L00, L01, L02, L03, L04, L05 }, \ 12 { L00, L01, L02, L03, L04, L05 }, \
28 { L10, L11, L12, L13, L14, L15 }, \ 13 { L10, L11, L12, L13, L14, L15 }, \
29 { L20, L21, L22, L23, L24, L25 }, \ 14 { L20, L21, L22, L23, L24, L25 }, \
30 { KC_NO, KC_NO, L30, L31, L32, L33 }, \ 15 { KC_NO, KC_NO, L30, L31, L32, L33 }, \
31 { R05, R04, R03, R02, R01, R00 }, \ 16 { R05, R04, R03, R02, R01, R00 }, \
32 { R15, R14, R13, R12, R11, R10 }, \ 17 { R15, R14, R13, R12, R11, R10 }, \
33 { R25, R24, R23, R22, R21, R20 }, \ 18 { R25, R24, R23, R22, R21, R20 }, \
34 { KC_NO, KC_NO, R33, R32, R31, R30 } \ 19 { KC_NO, KC_NO, R33, R32, R31, R30 } \
35 } 20 }
36 21
37#define LAYOUT_kc( \ 22#define LAYOUT_kc( \
38 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ 23 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
39 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ 24 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
40 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \ 25 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
41 L30, L31, L32, L33, R30, R31, R32, R33 \ 26 L30, L31, L32, L33, R30, R31, R32, R33 \
42 ) \ 27 ) \
43 LAYOUT( \ 28 LAYOUT( \
44 KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \ 29 KC_##L00, KC_##L01, KC_##L02, KC_##L03, KC_##L04, KC_##L05, KC_##R00, KC_##R01, KC_##R02, KC_##R03, KC_##R04, KC_##R05, \
45 KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ 30 KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \
46 KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ 31 KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \
47 KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##R30, KC_##R31, KC_##R32, KC_##R33 \ 32 KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##R30, KC_##R31, KC_##R32, KC_##R33 \
48 ) 33 )
49
50enum layer_number {
51 _QWERTY = 0,
52 _LOWER,
53 _RAISE,
54 _ADJUST,
55};
diff --git a/keyboards/claw44/rev1/rules.mk b/keyboards/claw44/rev1/rules.mk
index 016bc362a..b1af22c59 100644
--- a/keyboards/claw44/rev1/rules.mk
+++ b/keyboards/claw44/rev1/rules.mk
@@ -1,7 +1,3 @@
1SRC += rev1/matrix.c
2SRC += rev1/split_util.c
3SRC += rev1/split_scomm.c
4
5# Build Options 1# Build Options
6BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration 2BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration
7MOUSEKEY_ENABLE = no # Mouse keys 3MOUSEKEY_ENABLE = no # Mouse keys
@@ -10,7 +6,6 @@ CONSOLE_ENABLE = no # Console for debug
10COMMAND_ENABLE = no # Commands for debug and configuration 6COMMAND_ENABLE = no # Commands for debug and configuration
11NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 7NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
12BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 8BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
13MIDI_ENABLE = no # MIDI controls
14AUDIO_ENABLE = no # Audio output on port C6 9AUDIO_ENABLE = no # Audio output on port C6
15UNICODE_ENABLE = no # Unicode 10UNICODE_ENABLE = no # Unicode
16BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID 11BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
@@ -20,12 +15,5 @@ SWAP_HANDS_ENABLE = no # Enable one-hand typing
20# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 15# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
21SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend 16SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
22 17
23# If you want to change the display of OLED, you need to change here 18OLED_DRIVER_ENABLE = no # Add OLED displays support
24SRC += ./lib/glcdfont.c \ 19SPLIT_KEYBOARD = yes
25 ./lib/layer_state_reader.c \
26 ./lib/logo_reader.c \
27 ./lib/keylogger.c \
28 # ./lib/rgb_state_reader.c \
29 # ./lib/mode_icon_reader.c \
30 # ./lib/host_led_state_reader.c \
31 # ./lib/timelogger.c \
diff --git a/keyboards/claw44/rev1/serial_config.h b/keyboards/claw44/rev1/serial_config.h
deleted file mode 100644
index 4fab8e8dd..000000000
--- a/keyboards/claw44/rev1/serial_config.h
+++ /dev/null
@@ -1,4 +0,0 @@
1#ifndef SOFT_SERIAL_PIN
2#define SOFT_SERIAL_PIN D2
3#define SERIAL_USE_MULTI_TRANSACTION
4#endif
diff --git a/keyboards/claw44/rev1/split_scomm.c b/keyboards/claw44/rev1/split_scomm.c
deleted file mode 100644
index a1fe6ba5b..000000000
--- a/keyboards/claw44/rev1/split_scomm.c
+++ /dev/null
@@ -1,91 +0,0 @@
1#ifdef USE_SERIAL
2#ifdef SERIAL_USE_MULTI_TRANSACTION
3/* --- USE flexible API (using multi-type transaction function) --- */
4
5#include <stdbool.h>
6#include <stdint.h>
7#include <stddef.h>
8#include <split_scomm.h>
9#include "serial.h"
10#ifdef CONSOLE_ENABLE
11 #include <print.h>
12#endif
13
14uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
15uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
16uint8_t volatile status_com = 0;
17uint8_t volatile status1 = 0;
18uint8_t slave_buffer_change_count = 0;
19uint8_t s_change_old = 0xff;
20uint8_t s_change_new = 0xff;
21
22SSTD_t transactions[] = {
23#define GET_SLAVE_STATUS 0
24 /* master buffer not changed, only recive slave_buffer_change_count */
25 { (uint8_t *)&status_com,
26 0, NULL,
27 sizeof(slave_buffer_change_count), &slave_buffer_change_count,
28 },
29#define PUT_MASTER_GET_SLAVE_STATUS 1
30 /* master buffer changed need send, and recive slave_buffer_change_count */
31 { (uint8_t *)&status_com,
32 sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
33 sizeof(slave_buffer_change_count), &slave_buffer_change_count,
34 },
35#define GET_SLAVE_BUFFER 2
36 /* recive serial_slave_buffer */
37 { (uint8_t *)&status1,
38 0, NULL,
39 sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
40 }
41};
42
43void serial_master_init(void)
44{
45 soft_serial_initiator_init(transactions, TID_LIMIT(transactions));
46}
47
48void serial_slave_init(void)
49{
50 soft_serial_target_init(transactions, TID_LIMIT(transactions));
51}
52
53// 0 => no error
54// 1 => slave did not respond
55// 2 => checksum error
56int serial_update_buffers(int master_update)
57{
58 int status, smatstatus;
59 static int need_retry = 0;
60
61 if( s_change_old != s_change_new ) {
62 smatstatus = soft_serial_transaction(GET_SLAVE_BUFFER);
63 if( smatstatus == TRANSACTION_END ) {
64 s_change_old = s_change_new;
65#ifdef CONSOLE_ENABLE
66 uprintf("slave matrix = %b %b %b %b\n",
67 serial_slave_buffer[0], serial_slave_buffer[1],
68 serial_slave_buffer[2], serial_slave_buffer[3]);
69#endif
70 }
71 } else {
72 // serial_slave_buffer dosen't change
73 smatstatus = TRANSACTION_END; // dummy status
74 }
75
76 if( !master_update && !need_retry) {
77 status = soft_serial_transaction(GET_SLAVE_STATUS);
78 } else {
79 status = soft_serial_transaction(PUT_MASTER_GET_SLAVE_STATUS);
80 }
81 if( status == TRANSACTION_END ) {
82 s_change_new = slave_buffer_change_count;
83 need_retry = 0;
84 } else {
85 need_retry = 1;
86 }
87 return smatstatus;
88}
89
90#endif // SERIAL_USE_MULTI_TRANSACTION
91#endif /* USE_SERIAL */
diff --git a/keyboards/claw44/rev1/split_scomm.h b/keyboards/claw44/rev1/split_scomm.h
deleted file mode 100644
index 873d8939d..000000000
--- a/keyboards/claw44/rev1/split_scomm.h
+++ /dev/null
@@ -1,24 +0,0 @@
1#ifndef SPLIT_COMM_H
2#define SPLIT_COMM_H
3
4#ifndef SERIAL_USE_MULTI_TRANSACTION
5/* --- USE Simple API (OLD API, compatible with let's split serial.c) --- */
6#include "serial.h"
7
8#else
9/* --- USE flexible API (using multi-type transaction function) --- */
10// Buffers for master - slave communication
11#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
12#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
13
14extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
15extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
16extern uint8_t slave_buffer_change_count;
17
18void serial_master_init(void);
19void serial_slave_init(void);
20int serial_update_buffers(int master_changed);
21
22#endif
23
24#endif /* SPLIT_COMM_H */
diff --git a/keyboards/claw44/rev1/split_util.c b/keyboards/claw44/rev1/split_util.c
deleted file mode 100644
index e1ff8b437..000000000
--- a/keyboards/claw44/rev1/split_util.c
+++ /dev/null
@@ -1,70 +0,0 @@
1#include <avr/io.h>
2#include <avr/wdt.h>
3#include <avr/power.h>
4#include <avr/interrupt.h>
5#include <util/delay.h>
6#include <avr/eeprom.h>
7#include "split_util.h"
8#include "matrix.h"
9#include "keyboard.h"
10
11#ifdef USE_MATRIX_I2C
12# include "i2c.h"
13#else
14# include "split_scomm.h"
15#endif
16
17volatile bool isLeftHand = true;
18
19static void setup_handedness(void) {
20 #ifdef EE_HANDS
21 isLeftHand = eeprom_read_byte(EECONFIG_HANDEDNESS);
22 #else
23 // I2C_MASTER_RIGHT is deprecated, use MASTER_RIGHT instead, since this works for both serial and i2c
24 #if defined(I2C_MASTER_RIGHT) || defined(MASTER_RIGHT)
25 isLeftHand = !has_usb();
26 #else
27 isLeftHand = has_usb();
28 #endif
29 #endif
30}
31
32static void keyboard_master_setup(void) {
33
34#ifdef USE_MATRIX_I2C
35 i2c_master_init();
36#else
37 serial_master_init();
38#endif
39}
40
41static void keyboard_slave_setup(void) {
42
43#ifdef USE_MATRIX_I2C
44 i2c_slave_init(SLAVE_I2C_ADDRESS);
45#else
46 serial_slave_init();
47#endif
48}
49
50bool has_usb(void) {
51 USBCON |= (1 << OTGPADE); //enables VBUS pad
52 _delay_us(5);
53 return (USBSTA & (1<<VBUS)); //checks state of VBUS
54}
55
56void split_keyboard_setup(void) {
57 setup_handedness();
58
59 if (has_usb()) {
60 keyboard_master_setup();
61 } else {
62 keyboard_slave_setup();
63 }
64 sei();
65}
66
67// this code runs before the usb and keyboard is initialized
68void matrix_setup(void) {
69 split_keyboard_setup();
70}
diff --git a/keyboards/claw44/rev1/split_util.h b/keyboards/claw44/rev1/split_util.h
deleted file mode 100644
index 687ca19bd..000000000
--- a/keyboards/claw44/rev1/split_util.h
+++ /dev/null
@@ -1,19 +0,0 @@
1#ifndef SPLIT_KEYBOARD_UTIL_H
2#define SPLIT_KEYBOARD_UTIL_H
3
4#include <stdbool.h>
5#include "eeconfig.h"
6
7#define SLAVE_I2C_ADDRESS 0x32
8
9extern volatile bool isLeftHand;
10
11// slave version of matix scan, defined in matrix.c
12void matrix_slave_scan(void);
13
14void split_keyboard_setup(void);
15bool has_usb(void);
16
17void matrix_master_OLED_init (void);
18
19#endif
diff --git a/keyboards/claw44/rules.mk b/keyboards/claw44/rules.mk
index f872b9ebf..f4d44b23b 100644
--- a/keyboards/claw44/rules.mk
+++ b/keyboards/claw44/rules.mk
@@ -22,7 +22,6 @@ CONSOLE_ENABLE = no # Console for debug
22COMMAND_ENABLE = no # Commands for debug and configuration 22COMMAND_ENABLE = no # Commands for debug and configuration
23NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work 23NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
24BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality 24BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
25MIDI_ENABLE = no # MIDI controls
26AUDIO_ENABLE = no # Audio output on port C6 25AUDIO_ENABLE = no # Audio output on port C6
27UNICODE_ENABLE = no # Unicode 26UNICODE_ENABLE = no # Unicode
28BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID 27BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
@@ -30,12 +29,4 @@ RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
30# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE 29# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
31SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend 30SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
32 31
33CUSTOM_MATRIX = yes
34SRC += i2c.c
35SRC += serial.c
36SRC += ssd1306.c
37
38# if firmware size over limit, try this option
39# CFLAGS += -flto
40
41DEFAULT_FOLDER = claw44/rev1 32DEFAULT_FOLDER = claw44/rev1
diff --git a/keyboards/claw44/serial.c b/keyboards/claw44/serial.c
deleted file mode 100644
index f6293c3dc..000000000
--- a/keyboards/claw44/serial.c
+++ /dev/null
@@ -1,589 +0,0 @@
1/*
2 * WARNING: be careful changing this code, it is very timing dependent
3 *
4 * 2018-10-28 checked
5 * avr-gcc 4.9.2
6 * avr-gcc 5.4.0
7 * avr-gcc 7.3.0
8 */
9
10#ifndef F_CPU
11#define F_CPU 16000000
12#endif
13
14#include <avr/io.h>
15#include <avr/interrupt.h>
16#include <util/delay.h>
17#include <stddef.h>
18#include <stdbool.h>
19#include "serial.h"
20
21#ifdef SOFT_SERIAL_PIN
22
23#ifdef __AVR_ATmega32U4__
24 // if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial.
25 #ifdef USE_I2C
26 #if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1
27 #error Using ATmega32U4 I2C, so can not use PD0, PD1
28 #endif
29 #endif
30
31 #if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3
32 #define SERIAL_PIN_DDR DDRD
33 #define SERIAL_PIN_PORT PORTD
34 #define SERIAL_PIN_INPUT PIND
35 #if SOFT_SERIAL_PIN == D0
36 #define SERIAL_PIN_MASK _BV(PD0)
37 #define EIMSK_BIT _BV(INT0)
38 #define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01)))
39 #define SERIAL_PIN_INTERRUPT INT0_vect
40 #elif SOFT_SERIAL_PIN == D1
41 #define SERIAL_PIN_MASK _BV(PD1)
42 #define EIMSK_BIT _BV(INT1)
43 #define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11)))
44 #define SERIAL_PIN_INTERRUPT INT1_vect
45 #elif SOFT_SERIAL_PIN == D2
46 #define SERIAL_PIN_MASK _BV(PD2)
47 #define EIMSK_BIT _BV(INT2)
48 #define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21)))
49 #define SERIAL_PIN_INTERRUPT INT2_vect
50 #elif SOFT_SERIAL_PIN == D3
51 #define SERIAL_PIN_MASK _BV(PD3)
52 #define EIMSK_BIT _BV(INT3)
53 #define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31)))
54 #define SERIAL_PIN_INTERRUPT INT3_vect
55 #endif
56 #elif SOFT_SERIAL_PIN == E6
57 #define SERIAL_PIN_DDR DDRE
58 #define SERIAL_PIN_PORT PORTE
59 #define SERIAL_PIN_INPUT PINE
60 #define SERIAL_PIN_MASK _BV(PE6)
61 #define EIMSK_BIT _BV(INT6)
62 #define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
63 #define SERIAL_PIN_INTERRUPT INT6_vect
64 #else
65 #error invalid SOFT_SERIAL_PIN value
66 #endif
67
68#else
69 #error serial.c now support ATmega32U4 only
70#endif
71
72//////////////// for backward compatibility ////////////////////////////////
73#ifndef SERIAL_USE_MULTI_TRANSACTION
74/* --- USE Simple API (OLD API, compatible with let's split serial.c) */
75 #if SERIAL_SLAVE_BUFFER_LENGTH > 0
76 uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
77 #endif
78 #if SERIAL_MASTER_BUFFER_LENGTH > 0
79 uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
80 #endif
81 uint8_t volatile status0 = 0;
82
83SSTD_t transactions[] = {
84 { (uint8_t *)&status0,
85 #if SERIAL_MASTER_BUFFER_LENGTH > 0
86 sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
87 #else
88 0, (uint8_t *)NULL,
89 #endif
90 #if SERIAL_SLAVE_BUFFER_LENGTH > 0
91 sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
92 #else
93 0, (uint8_t *)NULL,
94 #endif
95 }
96};
97
98void serial_master_init(void)
99{ soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); }
100
101void serial_slave_init(void)
102{ soft_serial_target_init(transactions, TID_LIMIT(transactions)); }
103
104// 0 => no error
105// 1 => slave did not respond
106// 2 => checksum error
107int serial_update_buffers()
108{
109 int result;
110 result = soft_serial_transaction();
111 return result;
112}
113
114#endif // end of Simple API (OLD API, compatible with let's split serial.c)
115////////////////////////////////////////////////////////////////////////////
116
117#define ALWAYS_INLINE __attribute__((always_inline))
118#define NO_INLINE __attribute__((noinline))
119#define _delay_sub_us(x) __builtin_avr_delay_cycles(x)
120
121// parity check
122#define ODD_PARITY 1
123#define EVEN_PARITY 0
124#define PARITY EVEN_PARITY
125
126#ifdef SERIAL_DELAY
127 // custom setup in config.h
128 // #define TID_SEND_ADJUST 2
129 // #define SERIAL_DELAY 6 // micro sec
130 // #define READ_WRITE_START_ADJUST 30 // cycles
131 // #define READ_WRITE_WIDTH_ADJUST 8 // cycles
132#else
133// ============ Standard setups ============
134
135#ifndef SELECT_SOFT_SERIAL_SPEED
136#define SELECT_SOFT_SERIAL_SPEED 1
137// 0: about 189kbps
138// 1: about 137kbps (default)
139// 2: about 75kbps
140// 3: about 39kbps
141// 4: about 26kbps
142// 5: about 20kbps
143#endif
144
145#if __GNUC__ < 6
146 #define TID_SEND_ADJUST 14
147#else
148 #define TID_SEND_ADJUST 2
149#endif
150
151#if SELECT_SOFT_SERIAL_SPEED == 0
152 // Very High speed
153 #define SERIAL_DELAY 4 // micro sec
154 #if __GNUC__ < 6
155 #define READ_WRITE_START_ADJUST 33 // cycles
156 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
157 #else
158 #define READ_WRITE_START_ADJUST 34 // cycles
159 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
160 #endif
161#elif SELECT_SOFT_SERIAL_SPEED == 1
162 // High speed
163 #define SERIAL_DELAY 6 // micro sec
164 #if __GNUC__ < 6
165 #define READ_WRITE_START_ADJUST 30 // cycles
166 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
167 #else
168 #define READ_WRITE_START_ADJUST 33 // cycles
169 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
170 #endif
171#elif SELECT_SOFT_SERIAL_SPEED == 2
172 // Middle speed
173 #define SERIAL_DELAY 12 // micro sec
174 #define READ_WRITE_START_ADJUST 30 // cycles
175 #if __GNUC__ < 6
176 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
177 #else
178 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
179 #endif
180#elif SELECT_SOFT_SERIAL_SPEED == 3
181 // Low speed
182 #define SERIAL_DELAY 24 // micro sec
183 #define READ_WRITE_START_ADJUST 30 // cycles
184 #if __GNUC__ < 6
185 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
186 #else
187 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
188 #endif
189#elif SELECT_SOFT_SERIAL_SPEED == 4
190 // Very Low speed
191 #define SERIAL_DELAY 36 // micro sec
192 #define READ_WRITE_START_ADJUST 30 // cycles
193 #if __GNUC__ < 6
194 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
195 #else
196 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
197 #endif
198#elif SELECT_SOFT_SERIAL_SPEED == 5
199 // Ultra Low speed
200 #define SERIAL_DELAY 48 // micro sec
201 #define READ_WRITE_START_ADJUST 30 // cycles
202 #if __GNUC__ < 6
203 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
204 #else
205 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
206 #endif
207#else
208#error invalid SELECT_SOFT_SERIAL_SPEED value
209#endif /* SELECT_SOFT_SERIAL_SPEED */
210#endif /* SERIAL_DELAY */
211
212#define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2)
213#define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2)
214
215#define SLAVE_INT_WIDTH_US 1
216#ifndef SERIAL_USE_MULTI_TRANSACTION
217 #define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY
218#else
219 #define SLAVE_INT_ACK_WIDTH_UNIT 2
220 #define SLAVE_INT_ACK_WIDTH 4
221#endif
222
223static SSTD_t *Transaction_table = NULL;
224static uint8_t Transaction_table_size = 0;
225
226inline static void serial_delay(void) ALWAYS_INLINE;
227inline static
228void serial_delay(void) {
229 _delay_us(SERIAL_DELAY);
230}
231
232inline static void serial_delay_half1(void) ALWAYS_INLINE;
233inline static
234void serial_delay_half1(void) {
235 _delay_us(SERIAL_DELAY_HALF1);
236}
237
238inline static void serial_delay_half2(void) ALWAYS_INLINE;
239inline static
240void serial_delay_half2(void) {
241 _delay_us(SERIAL_DELAY_HALF2);
242}
243
244inline static void serial_output(void) ALWAYS_INLINE;
245inline static
246void serial_output(void) {
247 SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
248}
249
250// make the serial pin an input with pull-up resistor
251inline static void serial_input_with_pullup(void) ALWAYS_INLINE;
252inline static
253void serial_input_with_pullup(void) {
254 SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
255 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
256}
257
258inline static uint8_t serial_read_pin(void) ALWAYS_INLINE;
259inline static
260uint8_t serial_read_pin(void) {
261 return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
262}
263
264inline static void serial_low(void) ALWAYS_INLINE;
265inline static
266void serial_low(void) {
267 SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
268}
269
270inline static void serial_high(void) ALWAYS_INLINE;
271inline static
272void serial_high(void) {
273 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
274}
275
276void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size)
277{
278 Transaction_table = sstd_table;
279 Transaction_table_size = (uint8_t)sstd_table_size;
280 serial_output();
281 serial_high();
282}
283
284void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size)
285{
286 Transaction_table = sstd_table;
287 Transaction_table_size = (uint8_t)sstd_table_size;
288 serial_input_with_pullup();
289
290 // Enable INT0-INT3,INT6
291 EIMSK |= EIMSK_BIT;
292#if SERIAL_PIN_MASK == _BV(PE6)
293 // Trigger on falling edge of INT6
294 EICRB &= EICRx_BIT;
295#else
296 // Trigger on falling edge of INT0-INT3
297 EICRA &= EICRx_BIT;
298#endif
299}
300
301// Used by the sender to synchronize timing with the reciver.
302static void sync_recv(void) NO_INLINE;
303static
304void sync_recv(void) {
305 for (uint8_t i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) {
306 }
307 // This shouldn't hang if the target disconnects because the
308 // serial line will float to high if the target does disconnect.
309 while (!serial_read_pin());
310}
311
312// Used by the reciver to send a synchronization signal to the sender.
313static void sync_send(void) NO_INLINE;
314static
315void sync_send(void) {
316 serial_low();
317 serial_delay();
318 serial_high();
319}
320
321// Reads a byte from the serial line
322static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) NO_INLINE;
323static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) {
324 uint8_t byte, i, p, pb;
325
326 _delay_sub_us(READ_WRITE_START_ADJUST);
327 for( i = 0, byte = 0, p = PARITY; i < bit; i++ ) {
328 serial_delay_half1(); // read the middle of pulses
329 if( serial_read_pin() ) {
330 byte = (byte << 1) | 1; p ^= 1;
331 } else {
332 byte = (byte << 1) | 0; p ^= 0;
333 }
334 _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
335 serial_delay_half2();
336 }
337 /* recive parity bit */
338 serial_delay_half1(); // read the middle of pulses
339 pb = serial_read_pin();
340 _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
341 serial_delay_half2();
342
343 *pterrcount += (p != pb)? 1 : 0;
344
345 return byte;
346}
347
348// Sends a byte with MSB ordering
349void serial_write_chunk(uint8_t data, uint8_t bit) NO_INLINE;
350void serial_write_chunk(uint8_t data, uint8_t bit) {
351 uint8_t b, p;
352 for( p = PARITY, b = 1<<(bit-1); b ; b >>= 1) {
353 if(data & b) {
354 serial_high(); p ^= 1;
355 } else {
356 serial_low(); p ^= 0;
357 }
358 serial_delay();
359 }
360 /* send parity bit */
361 if(p & 1) { serial_high(); }
362 else { serial_low(); }
363 serial_delay();
364
365 serial_low(); // sync_send() / senc_recv() need raise edge
366}
367
368static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
369static
370void serial_send_packet(uint8_t *buffer, uint8_t size) {
371 for (uint8_t i = 0; i < size; ++i) {
372 uint8_t data;
373 data = buffer[i];
374 sync_send();
375 serial_write_chunk(data,8);
376 }
377}
378
379static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
380static
381uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) {
382 uint8_t pecount = 0;
383 for (uint8_t i = 0; i < size; ++i) {
384 uint8_t data;
385 sync_recv();
386 data = serial_read_chunk(&pecount, 8);
387 buffer[i] = data;
388 }
389 return pecount == 0;
390}
391
392inline static
393void change_sender2reciver(void) {
394 sync_send(); //0
395 serial_delay_half1(); //1
396 serial_low(); //2
397 serial_input_with_pullup(); //2
398 serial_delay_half1(); //3
399}
400
401inline static
402void change_reciver2sender(void) {
403 sync_recv(); //0
404 serial_delay(); //1
405 serial_low(); //3
406 serial_output(); //3
407 serial_delay_half1(); //4
408}
409
410static inline uint8_t nibble_bits_count(uint8_t bits)
411{
412 bits = (bits & 0x5) + (bits >> 1 & 0x5);
413 bits = (bits & 0x3) + (bits >> 2 & 0x3);
414 return bits;
415}
416
417// interrupt handle to be used by the target device
418ISR(SERIAL_PIN_INTERRUPT) {
419
420#ifndef SERIAL_USE_MULTI_TRANSACTION
421 serial_low();
422 serial_output();
423 SSTD_t *trans = Transaction_table;
424#else
425 // recive transaction table index
426 uint8_t tid, bits;
427 uint8_t pecount = 0;
428 sync_recv();
429 bits = serial_read_chunk(&pecount,7);
430 tid = bits>>3;
431 bits = (bits&7) != nibble_bits_count(tid);
432 if( bits || pecount> 0 || tid > Transaction_table_size ) {
433 return;
434 }
435 serial_delay_half1();
436
437 serial_high(); // response step1 low->high
438 serial_output();
439 _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT*SLAVE_INT_ACK_WIDTH);
440 SSTD_t *trans = &Transaction_table[tid];
441 serial_low(); // response step2 ack high->low
442#endif
443
444 // target send phase
445 if( trans->target2initiator_buffer_size > 0 )
446 serial_send_packet((uint8_t *)trans->target2initiator_buffer,
447 trans->target2initiator_buffer_size);
448 // target switch to input
449 change_sender2reciver();
450
451 // target recive phase
452 if( trans->initiator2target_buffer_size > 0 ) {
453 if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer,
454 trans->initiator2target_buffer_size) ) {
455 *trans->status = TRANSACTION_ACCEPTED;
456 } else {
457 *trans->status = TRANSACTION_DATA_ERROR;
458 }
459 } else {
460 *trans->status = TRANSACTION_ACCEPTED;
461 }
462
463 sync_recv(); //weit initiator output to high
464}
465
466/////////
467// start transaction by initiator
468//
469// int soft_serial_transaction(int sstd_index)
470//
471// Returns:
472// TRANSACTION_END
473// TRANSACTION_NO_RESPONSE
474// TRANSACTION_DATA_ERROR
475// this code is very time dependent, so we need to disable interrupts
476#ifndef SERIAL_USE_MULTI_TRANSACTION
477int soft_serial_transaction(void) {
478 SSTD_t *trans = Transaction_table;
479#else
480int soft_serial_transaction(int sstd_index) {
481 if( sstd_index > Transaction_table_size )
482 return TRANSACTION_TYPE_ERROR;
483 SSTD_t *trans = &Transaction_table[sstd_index];
484#endif
485 cli();
486
487 // signal to the target that we want to start a transaction
488 serial_output();
489 serial_low();
490 _delay_us(SLAVE_INT_WIDTH_US);
491
492#ifndef SERIAL_USE_MULTI_TRANSACTION
493 // wait for the target response
494 serial_input_with_pullup();
495 _delay_us(SLAVE_INT_RESPONSE_TIME);
496
497 // check if the target is present
498 if (serial_read_pin()) {
499 // target failed to pull the line low, assume not present
500 serial_output();
501 serial_high();
502 *trans->status = TRANSACTION_NO_RESPONSE;
503 sei();
504 return TRANSACTION_NO_RESPONSE;
505 }
506
507#else
508 // send transaction table index
509 int tid = (sstd_index<<3) | (7 & nibble_bits_count(sstd_index));
510 sync_send();
511 _delay_sub_us(TID_SEND_ADJUST);
512 serial_write_chunk(tid, 7);
513 serial_delay_half1();
514
515 // wait for the target response (step1 low->high)
516 serial_input_with_pullup();
517 while( !serial_read_pin() ) {
518 _delay_sub_us(2);
519 }
520
521 // check if the target is present (step2 high->low)
522 for( int i = 0; serial_read_pin(); i++ ) {
523 if (i > SLAVE_INT_ACK_WIDTH + 1) {
524 // slave failed to pull the line low, assume not present
525 serial_output();
526 serial_high();
527 *trans->status = TRANSACTION_NO_RESPONSE;
528 sei();
529 return TRANSACTION_NO_RESPONSE;
530 }
531 _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT);
532 }
533#endif
534
535 // initiator recive phase
536 // if the target is present syncronize with it
537 if( trans->target2initiator_buffer_size > 0 ) {
538 if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer,
539 trans->target2initiator_buffer_size) ) {
540 serial_output();
541 serial_high();
542 *trans->status = TRANSACTION_DATA_ERROR;
543 sei();
544 return TRANSACTION_DATA_ERROR;
545 }
546 }
547
548 // initiator switch to output
549 change_reciver2sender();
550
551 // initiator send phase
552 if( trans->initiator2target_buffer_size > 0 ) {
553 serial_send_packet((uint8_t *)trans->initiator2target_buffer,
554 trans->initiator2target_buffer_size);
555 }
556
557 // always, release the line when not in use
558 sync_send();
559
560 *trans->status = TRANSACTION_END;
561 sei();
562 return TRANSACTION_END;
563}
564
565#ifdef SERIAL_USE_MULTI_TRANSACTION
566int soft_serial_get_and_clean_status(int sstd_index) {
567 SSTD_t *trans = &Transaction_table[sstd_index];
568 cli();
569 int retval = *trans->status;
570 *trans->status = 0;;
571 sei();
572 return retval;
573}
574#endif
575
576#endif
577
578// Helix serial.c history
579// 2018-1-29 fork from let's split and add PD2, modify sync_recv() (#2308, bceffdefc)
580// 2018-6-28 bug fix master to slave comm and speed up (#3255, 1038bbef4)
581// (adjusted with avr-gcc 4.9.2)
582// 2018-7-13 remove USE_SERIAL_PD2 macro (#3374, f30d6dd78)
583// (adjusted with avr-gcc 4.9.2)
584// 2018-8-11 add support multi-type transaction (#3608, feb5e4aae)
585// (adjusted with avr-gcc 4.9.2)
586// 2018-10-21 fix serial and RGB animation conflict (#4191, 4665e4fff)
587// (adjusted with avr-gcc 7.3.0)
588// 2018-10-28 re-adjust compiler depend value of delay (#4269, 8517f8a66)
589// (adjusted with avr-gcc 5.4.0, 7.3.0)
diff --git a/keyboards/claw44/serial.h b/keyboards/claw44/serial.h
deleted file mode 100644
index 7e0c0847a..000000000
--- a/keyboards/claw44/serial.h
+++ /dev/null
@@ -1,84 +0,0 @@
1#ifndef SOFT_SERIAL_H
2#define SOFT_SERIAL_H
3
4#include <stdbool.h>
5
6// /////////////////////////////////////////////////////////////////
7// Need Soft Serial defines in config.h
8// /////////////////////////////////////////////////////////////////
9// ex.
10// #define SOFT_SERIAL_PIN ?? // ?? = D0,D1,D2,D3,E6
11// OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5
12// // 1: about 137kbps (default)
13// // 2: about 75kbps
14// // 3: about 39kbps
15// // 4: about 26kbps
16// // 5: about 20kbps
17//
18// //// USE Simple API (OLD API, compatible with let's split serial.c)
19// ex.
20// #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
21// #define SERIAL_MASTER_BUFFER_LENGTH 1
22//
23// //// USE flexible API (using multi-type transaction function)
24// #define SERIAL_USE_MULTI_TRANSACTION
25//
26// /////////////////////////////////////////////////////////////////
27
28
29#ifndef SERIAL_USE_MULTI_TRANSACTION
30/* --- USE Simple API (OLD API, compatible with let's split serial.c) */
31#if SERIAL_SLAVE_BUFFER_LENGTH > 0
32extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH];
33#endif
34#if SERIAL_MASTER_BUFFER_LENGTH > 0
35extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH];
36#endif
37
38void serial_master_init(void);
39void serial_slave_init(void);
40int serial_update_buffers(void);
41
42#endif // USE Simple API
43
44// Soft Serial Transaction Descriptor
45typedef struct _SSTD_t {
46 uint8_t *status;
47 uint8_t initiator2target_buffer_size;
48 uint8_t *initiator2target_buffer;
49 uint8_t target2initiator_buffer_size;
50 uint8_t *target2initiator_buffer;
51} SSTD_t;
52#define TID_LIMIT( table ) (sizeof(table) / sizeof(SSTD_t))
53
54// initiator is transaction start side
55void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size);
56// target is interrupt accept side
57void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size);
58
59// initiator resullt
60#define TRANSACTION_END 0
61#define TRANSACTION_NO_RESPONSE 0x1
62#define TRANSACTION_DATA_ERROR 0x2
63#define TRANSACTION_TYPE_ERROR 0x4
64#ifndef SERIAL_USE_MULTI_TRANSACTION
65int soft_serial_transaction(void);
66#else
67int soft_serial_transaction(int sstd_index);
68#endif
69
70// target status
71// *SSTD_t.status has
72// initiator:
73// TRANSACTION_END
74// or TRANSACTION_NO_RESPONSE
75// or TRANSACTION_DATA_ERROR
76// target:
77// TRANSACTION_DATA_ERROR
78// or TRANSACTION_ACCEPTED
79#define TRANSACTION_ACCEPTED 0x8
80#ifdef SERIAL_USE_MULTI_TRANSACTION
81int soft_serial_get_and_clean_status(int sstd_index);
82#endif
83
84#endif /* SOFT_SERIAL_H */
diff --git a/keyboards/claw44/ssd1306.c b/keyboards/claw44/ssd1306.c
deleted file mode 100644
index 7dea1cc17..000000000
--- a/keyboards/claw44/ssd1306.c
+++ /dev/null
@@ -1,345 +0,0 @@
1#ifdef SSD1306OLED
2
3#include "ssd1306.h"
4#include "i2c.h"
5#include <string.h>
6#include "print.h"
7#ifdef PROTOCOL_LUFA
8#include "lufa.h"
9#endif
10#include "sendchar.h"
11#include "timer.h"
12
13struct CharacterMatrix display;
14
15extern const unsigned char font[] PROGMEM;
16
17// Set this to 1 to help diagnose early startup problems
18// when testing power-on with ble. Turn it off otherwise,
19// as the latency of printing most of the debug info messes
20// with the matrix scan, causing keys to drop.
21#define DEBUG_TO_SCREEN 0
22
23//static uint16_t last_battery_update;
24//static uint32_t vbat;
25//#define BatteryUpdateInterval 10000 /* milliseconds */
26
27// 'last_flush' is declared as uint16_t,
28// so this must be less than 65535
29#define ScreenOffInterval 60000 /* milliseconds */
30#if DEBUG_TO_SCREEN
31static uint8_t displaying;
32#endif
33static uint16_t last_flush;
34
35static bool force_dirty = true;
36
37// Write command sequence.
38// Returns true on success.
39static inline bool _send_cmd1(uint8_t cmd) {
40 bool res = false;
41
42 if (i2c_start_write(SSD1306_ADDRESS)) {
43 xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
44 goto done;
45 }
46
47 if (i2c_master_write(0x0 /* command byte follows */)) {
48 print("failed to write control byte\n");
49
50 goto done;
51 }
52
53 if (i2c_master_write(cmd)) {
54 xprintf("failed to write command %d\n", cmd);
55 goto done;
56 }
57 res = true;
58done:
59 i2c_master_stop();
60 return res;
61}
62
63// Write 2-byte command sequence.
64// Returns true on success
65static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) {
66 if (!_send_cmd1(cmd)) {
67 return false;
68 }
69 return _send_cmd1(opr);
70}
71
72// Write 3-byte command sequence.
73// Returns true on success
74static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) {
75 if (!_send_cmd1(cmd)) {
76 return false;
77 }
78 if (!_send_cmd1(opr1)) {
79 return false;
80 }
81 return _send_cmd1(opr2);
82}
83
84#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;}
85#define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;}
86#define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;}
87
88static void clear_display(void) {
89 matrix_clear(&display);
90
91 // Clear all of the display bits (there can be random noise
92 // in the RAM on startup)
93 send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1);
94 send_cmd3(ColumnAddr, 0, DisplayWidth - 1);
95
96 if (i2c_start_write(SSD1306_ADDRESS)) {
97 goto done;
98 }
99 if (i2c_master_write(0x40)) {
100 // Data mode
101 goto done;
102 }
103 for (uint8_t row = 0; row < MatrixRows; ++row) {
104 for (uint8_t col = 0; col < DisplayWidth; ++col) {
105 i2c_master_write(0);
106 }
107 }
108
109 display.dirty = false;
110
111done:
112 i2c_master_stop();
113}
114
115#if DEBUG_TO_SCREEN
116#undef sendchar
117static int8_t capture_sendchar(uint8_t c) {
118 sendchar(c);
119 iota_gfx_write_char(c);
120
121 if (!displaying) {
122 iota_gfx_flush();
123 }
124 return 0;
125}
126#endif
127
128bool iota_gfx_init(bool rotate) {
129 bool success = false;
130
131 i2c_master_init();
132 send_cmd1(DisplayOff);
133 send_cmd2(SetDisplayClockDiv, 0x80);
134 send_cmd2(SetMultiPlex, DisplayHeight - 1);
135
136 send_cmd2(SetDisplayOffset, 0);
137
138
139 send_cmd1(SetStartLine | 0x0);
140 send_cmd2(SetChargePump, 0x14 /* Enable */);
141 send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
142
143 if(rotate){
144 // the following Flip the display orientation 180 degrees
145 send_cmd1(SegRemap);
146 send_cmd1(ComScanInc);
147 }else{
148 // Flips the display orientation 0 degrees
149 send_cmd1(SegRemap | 0x1);
150 send_cmd1(ComScanDec);
151 }
152
153 send_cmd2(SetComPins, 0x2);
154 send_cmd2(SetContrast, 0x8f);
155 send_cmd2(SetPreCharge, 0xf1);
156 send_cmd2(SetVComDetect, 0x40);
157 send_cmd1(DisplayAllOnResume);
158 send_cmd1(NormalDisplay);
159 send_cmd1(DeActivateScroll);
160 send_cmd1(DisplayOn);
161
162 send_cmd2(SetContrast, 0); // Dim
163
164 clear_display();
165
166 success = true;
167
168 iota_gfx_flush();
169
170#if DEBUG_TO_SCREEN
171 print_set_sendchar(capture_sendchar);
172#endif
173
174done:
175 return success;
176}
177
178bool iota_gfx_off(void) {
179 bool success = false;
180
181 send_cmd1(DisplayOff);
182 success = true;
183
184done:
185 return success;
186}
187
188bool iota_gfx_on(void) {
189 bool success = false;
190
191 send_cmd1(DisplayOn);
192 success = true;
193
194done:
195 return success;
196}
197
198void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
199 *matrix->cursor = c;
200 ++matrix->cursor;
201
202 if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) {
203 // We went off the end; scroll the display upwards by one line
204 memmove(&matrix->display[0], &matrix->display[1],
205 MatrixCols * (MatrixRows - 1));
206 matrix->cursor = &matrix->display[MatrixRows - 1][0];
207 memset(matrix->cursor, ' ', MatrixCols);
208 }
209}
210
211void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) {
212 matrix->dirty = true;
213
214 if (c == '\n') {
215 // Clear to end of line from the cursor and then move to the
216 // start of the next line
217 uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols;
218
219 while (cursor_col++ < MatrixCols) {
220 matrix_write_char_inner(matrix, ' ');
221 }
222 return;
223 }
224
225 matrix_write_char_inner(matrix, c);
226}
227
228void iota_gfx_write_char(uint8_t c) {
229 matrix_write_char(&display, c);
230}
231
232void matrix_write(struct CharacterMatrix *matrix, const char *data) {
233 const char *end = data + strlen(data);
234 while (data < end) {
235 matrix_write_char(matrix, *data);
236 ++data;
237 }
238}
239
240void matrix_write_ln(struct CharacterMatrix *matrix, const char *data) {
241 char data_ln[strlen(data)+2];
242 snprintf(data_ln, sizeof(data_ln), "%s\n", data);
243 matrix_write(matrix, data_ln);
244}
245
246void iota_gfx_write(const char *data) {
247 matrix_write(&display, data);
248}
249
250void matrix_write_P(struct CharacterMatrix *matrix, const char *data) {
251 while (true) {
252 uint8_t c = pgm_read_byte(data);
253 if (c == 0) {
254 return;
255 }
256 matrix_write_char(matrix, c);
257 ++data;
258 }
259}
260
261void iota_gfx_write_P(const char *data) {
262 matrix_write_P(&display, data);
263}
264
265void matrix_clear(struct CharacterMatrix *matrix) {
266 memset(matrix->display, ' ', sizeof(matrix->display));
267 matrix->cursor = &matrix->display[0][0];
268 matrix->dirty = true;
269}
270
271void iota_gfx_clear_screen(void) {
272 matrix_clear(&display);
273}
274
275void matrix_render(struct CharacterMatrix *matrix) {
276 last_flush = timer_read();
277 iota_gfx_on();
278#if DEBUG_TO_SCREEN
279 ++displaying;
280#endif
281
282 // Move to the home position
283 send_cmd3(PageAddr, 0, MatrixRows - 1);
284 send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1);
285
286 if (i2c_start_write(SSD1306_ADDRESS)) {
287 goto done;
288 }
289 if (i2c_master_write(0x40)) {
290 // Data mode
291 goto done;
292 }
293
294 for (uint8_t row = 0; row < MatrixRows; ++row) {
295 for (uint8_t col = 0; col < MatrixCols; ++col) {
296 const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth);
297
298 for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) {
299 uint8_t colBits = pgm_read_byte(glyph + glyphCol);
300 i2c_master_write(colBits);
301 }
302
303 // 1 column of space between chars (it's not included in the glyph)
304 //i2c_master_write(0);
305 }
306 }
307
308 matrix->dirty = false;
309
310done:
311 i2c_master_stop();
312#if DEBUG_TO_SCREEN
313 --displaying;
314#endif
315}
316
317void iota_gfx_flush(void) {
318 matrix_render(&display);
319}
320
321__attribute__ ((weak))
322void iota_gfx_task_user(void) {
323}
324
325void iota_gfx_task(void) {
326 iota_gfx_task_user();
327
328 if (display.dirty|| force_dirty) {
329 iota_gfx_flush();
330 force_dirty = false;
331 }
332
333 /*
334 if (timer_elapsed(last_flush) > ScreenOffInterval) {
335 iota_gfx_off();
336 }
337 */
338}
339
340bool process_record_gfx(uint16_t keycode, keyrecord_t *record) {
341 force_dirty = true;
342 return true;
343}
344
345#endif
diff --git a/keyboards/claw44/ssd1306.h b/keyboards/claw44/ssd1306.h
deleted file mode 100644
index 11a3cc67f..000000000
--- a/keyboards/claw44/ssd1306.h
+++ /dev/null
@@ -1,90 +0,0 @@
1#pragma once
2
3#include <stdbool.h>
4#include <stdio.h>
5#include "action.h"
6
7enum ssd1306_cmds {
8 DisplayOff = 0xAE,
9 DisplayOn = 0xAF,
10
11 SetContrast = 0x81,
12 DisplayAllOnResume = 0xA4,
13
14 DisplayAllOn = 0xA5,
15 NormalDisplay = 0xA6,
16 InvertDisplay = 0xA7,
17 SetDisplayOffset = 0xD3,
18 SetComPins = 0xda,
19 SetVComDetect = 0xdb,
20 SetDisplayClockDiv = 0xD5,
21 SetPreCharge = 0xd9,
22 SetMultiPlex = 0xa8,
23 SetLowColumn = 0x00,
24 SetHighColumn = 0x10,
25 SetStartLine = 0x40,
26
27 SetMemoryMode = 0x20,
28 ColumnAddr = 0x21,
29 PageAddr = 0x22,
30
31 ComScanInc = 0xc0,
32 ComScanDec = 0xc8,
33 SegRemap = 0xa0,
34 SetChargePump = 0x8d,
35 ExternalVcc = 0x01,
36 SwitchCapVcc = 0x02,
37
38 ActivateScroll = 0x2f,
39 DeActivateScroll = 0x2e,
40 SetVerticalScrollArea = 0xa3,
41 RightHorizontalScroll = 0x26,
42 LeftHorizontalScroll = 0x27,
43 VerticalAndRightHorizontalScroll = 0x29,
44 VerticalAndLeftHorizontalScroll = 0x2a,
45};
46
47// Controls the SSD1306 128x32 OLED display via i2c
48
49#ifndef SSD1306_ADDRESS
50#define SSD1306_ADDRESS 0x3C
51#endif
52
53#define DisplayHeight 32
54#define DisplayWidth 128
55
56#define FontHeight 8
57#define FontWidth 6
58
59#define MatrixRows (DisplayHeight / FontHeight)
60#define MatrixCols (DisplayWidth / FontWidth)
61
62struct CharacterMatrix {
63 uint8_t display[MatrixRows][MatrixCols];
64 uint8_t *cursor;
65 bool dirty;
66};
67
68extern struct CharacterMatrix display;
69
70bool iota_gfx_init(bool rotate);
71void iota_gfx_task(void);
72bool iota_gfx_off(void);
73bool iota_gfx_on(void);
74void iota_gfx_flush(void);
75void iota_gfx_write_char(uint8_t c);
76void iota_gfx_write(const char *data);
77void iota_gfx_write_P(const char *data);
78void iota_gfx_clear_screen(void);
79
80void iota_gfx_task_user(void);
81
82void matrix_clear(struct CharacterMatrix *matrix);
83void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
84void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
85void matrix_write(struct CharacterMatrix *matrix, const char *data);
86void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
87void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
88void matrix_render(struct CharacterMatrix *matrix);
89
90bool process_record_gfx(uint16_t keycode, keyrecord_t *record);