aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorさくらんぼ <47372812+sakurachari@users.noreply.github.com>2019-04-12 01:07:39 +0900
committerMechMerlin <30334081+mechmerlin@users.noreply.github.com>2019-04-11 09:07:39 -0700
commitdc570b0b389d23b8ea8b46311294a7040b5e1e44 (patch)
tree8e47ebf2f6c291e960664e5d20afc308afa92e24
parentfa514e63aaed358dbe4d098e7dc31561f148aec0 (diff)
downloadqmk_firmware-dc570b0b389d23b8ea8b46311294a7040b5e1e44.tar.gz
qmk_firmware-dc570b0b389d23b8ea8b46311294a7040b5e1e44.zip
Keyboard: Add yosino58 Keyboard (#5465)
* Keyboard: Add yosino58 Keyboard * Keyboard: Add yosino58 Keyboard
-rw-r--r--keyboards/yosino58/config.h34
-rw-r--r--keyboards/yosino58/i2c.c162
-rw-r--r--keyboards/yosino58/i2c.h46
-rw-r--r--keyboards/yosino58/info.json20
-rw-r--r--keyboards/yosino58/keymaps/default/config.h43
-rw-r--r--keyboards/yosino58/keymaps/default/keymap.c337
-rw-r--r--keyboards/yosino58/keymaps/default/rules.mk30
-rw-r--r--keyboards/yosino58/keymaps/sakura/config.h50
-rw-r--r--keyboards/yosino58/keymaps/sakura/keymap.c337
-rw-r--r--keyboards/yosino58/keymaps/sakura/rules.mk30
-rw-r--r--keyboards/yosino58/lib/glcdfont.c275
-rw-r--r--keyboards/yosino58/lib/glcdfont_.c243
-rw-r--r--keyboards/yosino58/lib/host_led_state_reader.c15
-rw-r--r--keyboards/yosino58/lib/keylogger.c45
-rw-r--r--keyboards/yosino58/lib/layer_state_reader.c35
-rw-r--r--keyboards/yosino58/lib/logo_reader.c11
-rw-r--r--keyboards/yosino58/lib/mode_icon_reader.c15
-rw-r--r--keyboards/yosino58/lib/rgb_state_reader.c15
-rw-r--r--keyboards/yosino58/lib/timelogger.c16
-rw-r--r--keyboards/yosino58/pro_micro.h358
-rw-r--r--keyboards/yosino58/rev1/config.h72
-rw-r--r--keyboards/yosino58/rev1/matrix.c357
-rw-r--r--keyboards/yosino58/rev1/rev1.c8
-rw-r--r--keyboards/yosino58/rev1/rev1.h40
-rw-r--r--keyboards/yosino58/rev1/rules.mk3
-rw-r--r--keyboards/yosino58/rev1/serial_config.h4
-rw-r--r--keyboards/yosino58/rev1/serial_config_simpleapi.h5
-rw-r--r--keyboards/yosino58/rev1/split_scomm.c91
-rw-r--r--keyboards/yosino58/rev1/split_scomm.h24
-rw-r--r--keyboards/yosino58/rev1/split_util.c70
-rw-r--r--keyboards/yosino58/rev1/split_util.h19
-rw-r--r--keyboards/yosino58/rules.mk76
-rw-r--r--keyboards/yosino58/serial.c590
-rw-r--r--keyboards/yosino58/serial.h84
-rw-r--r--keyboards/yosino58/ssd1306.c348
-rw-r--r--keyboards/yosino58/ssd1306.h96
-rw-r--r--keyboards/yosino58/yosino58.c10
-rw-r--r--keyboards/yosino58/yosino58.h5
38 files changed, 4019 insertions, 0 deletions
diff --git a/keyboards/yosino58/config.h b/keyboards/yosino58/config.h
new file mode 100644
index 000000000..4357a218d
--- /dev/null
+++ b/keyboards/yosino58/config.h
@@ -0,0 +1,34 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3Copyright 2015 Jack Humbert
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#pragma once
20
21#include "config_common.h"
22#include <serial_config.h>
23
24#define USE_I2C
25#define USE_SERIAL
26
27#ifdef USE_Link_Time_Optimization
28 // LTO has issues with macros (action_get_macro) and "functions" (fn_actions),
29 // so just disable them
30 #define NO_ACTION_MACRO
31 #define NO_ACTION_FUNCTION
32
33 #define DISABLE_LEADER
34#endif // USE_Link_Time_Optimization
diff --git a/keyboards/yosino58/i2c.c b/keyboards/yosino58/i2c.c
new file mode 100644
index 000000000..4bee5c639
--- /dev/null
+++ b/keyboards/yosino58/i2c.c
@@ -0,0 +1,162 @@
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/yosino58/i2c.h b/keyboards/yosino58/i2c.h
new file mode 100644
index 000000000..710662c7a
--- /dev/null
+++ b/keyboards/yosino58/i2c.h
@@ -0,0 +1,46 @@
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/yosino58/info.json b/keyboards/yosino58/info.json
new file mode 100644
index 000000000..c591a41de
--- /dev/null
+++ b/keyboards/yosino58/info.json
@@ -0,0 +1,20 @@
1{
2 "keyboard_name": "yosino58 rev. 1",
3 "url": "https://github.com/sakurachari/yosino58",
4 "maintainer": "sakuranbo0046",
5 "width": 16.75,
6 "height": 6.25,
7 "layouts": {
8 "LAYOUT": {
9 "key_count": 58,
10 "layout": [
11 {"x":0, "y":1}, {"x":1, "y":1}, {"x":2, "y":0.25}, {"x":3, "y":0}, {"x":4, "y":0.25}, {"x":5, "y":0.5}, {"x":10.75, "y":0.5}, {"x":11.75, "y":0.25}, {"x":12.75, "y":0}, {"x":13.75, "y":0.25}, {"x":14.75, "y":1}, {"x":15.75, "y":1},
12 {"x":0, "y":2}, {"x":1, "y":2}, {"x":2, "y":1.25}, {"x":3, "y":1}, {"x":4, "y":1.25}, {"x":5, "y":1.5}, {"x":10.75, "y":1.5}, {"x":11.75, "y":1.25}, {"x":12.75, "y":1}, {"x":13.75, "y":1.25}, {"x":14.75, "y":2}, {"x":15.75, "y":2},
13 {"x":0, "y":3}, {"x":1, "y":3}, {"x":2, "y":2.25}, {"x":3, "y":2}, {"x":4, "y":2.25}, {"x":5, "y":2.5}, {"x":10.75, "y":2.5}, {"x":11.75, "y":2.25}, {"x":12.75, "y":2}, {"x":13.75, "y":2.25}, {"x":14.75, "y":3}, {"x":15.75, "y":3},
14 {"x":0, "y":4}, {"x":1, "y":4}, {"x":2, "y":3.25}, {"x":3, "y":3}, {"x":4, "y":3.25}, {"x":5, "y":3.5}, {"x":6.5, "y":4.25}, {"x":7.5, "y":4.25, "h":2}, {"x":8.5, "y":4.25, "h":2}, {"x":9.5, "y":4.25}, {"x":10.75, "y":3.5}, {"x":11.75, "y":3.25}, {"x":12.75, "y":3}, {"x":13.75, "y":3.25}, {"x":14.75, "y":4}, {"x":15.75, "y":4},
15 {"x":3.75, "y":4.25}, {"x":4.75, "y":4.5}, {"x":6.5, "y":5.25}, {"x":9.5, "y":5.25}, {"x":11, "y":4.5}, {"x":12, "y":4.25}
16 ]
17 }
18 }
19}
20
diff --git a/keyboards/yosino58/keymaps/default/config.h b/keyboards/yosino58/keymaps/default/config.h
new file mode 100644
index 000000000..21fc2d3b5
--- /dev/null
+++ b/keyboards/yosino58/keymaps/default/config.h
@@ -0,0 +1,43 @@
1/*
2This is the c configuration file for the keymap
3
4Copyright 2012 Jun Wako <wakojun@gmail.com>
5Copyright 2015 Jack Humbert
6
7This program is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#pragma once
22
23//#define USE_MATRIX_I2C
24
25/* Select hand configuration */
26
27#define MASTER_LEFT
28// #define MASTER_RIGHT
29// #define EE_HANDS
30
31#define SSD1306OLED
32// #define SSD1306_128X64
33
34#define TAPPING_FORCE_HOLD
35#define TAPPING_TERM 100
36
37#undef RGBLED_NUM
38#define RGBLIGHT_ANIMATIONS
39#define RGBLED_NUM 12
40#define RGBLIGHT_LIMIT_VAL 120
41#define RGBLIGHT_HUE_STEP 10
42#define RGBLIGHT_SAT_STEP 17
43#define RGBLIGHT_VAL_STEP 17 \ No newline at end of file
diff --git a/keyboards/yosino58/keymaps/default/keymap.c b/keyboards/yosino58/keymaps/default/keymap.c
new file mode 100644
index 000000000..79b507569
--- /dev/null
+++ b/keyboards/yosino58/keymaps/default/keymap.c
@@ -0,0 +1,337 @@
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
12#ifdef RGBLIGHT_ENABLE
13//Following line allows macro to read current RGB settings
14extern rgblight_config_t rgblight_config;
15#endif
16
17extern uint8_t is_master;
18
19// Each layer gets a name for readability, which is then used in the keymap matrix below.
20// The underscores don't mean anything - you can have a layer called STUFF or any other name.
21// Layer names don't all need to be of the same length, obviously, and you can also skip them
22// entirely and just use numbers.
23#define _QWERTY 0
24#define _LOWER 1
25#define _RAISE 2
26#define _ADJUST 3
27
28enum custom_keycodes {
29 QWERTY = SAFE_RANGE,
30 LOWER,
31 RAISE,
32 ADJUST,
33 RGBRST
34};
35
36const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
37/* QWERTY
38 * ,-----------------------------------------. ,-----------------------------------------.
39 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - |
40 * |------+------+------+------+------+------| |------+------+------+------+------+------|
41 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | = |
42 * |------+------+------+------+------+------| |------+------+------+------+------+------|
43 * |LShift| A | S | D | F | G | | H | J | K | L | ; | ' |
44 * |------+------+------+------+------+------| |------+------+------+------+------+------|
45 * |LCTRL | Z | X | C | V | B |-------.-------. ,---------------| N | M | , | . | / | \ |
46 * `-----------------------------------------/ Del / / \ \ Bksp \----------------------------------------'
47 * | LAlt |ADJUST| /-------/ Space / \ Enter \-------\ | [ | ] |
48 * | | |/ LOWER / / \ \ RAISE \ | | |
49 * `-----------------------------' '------------------------------'
50 */
51 [_QWERTY] = LAYOUT( \
52 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, \
53 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_EQL, \
54 KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
55 KC_LCTRL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_DEL, KC_SPC, KC_ENT, KC_BSPC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, \
56 KC_LALT, ADJUST, LOWER, RAISE, KC_LBRC, KC_RBRC\
57 ),
58
59/* LOWER
60 * ,-----------------------------------------. ,-----------------------------------------.
61 * | ESC | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 |
62 * |------+------+------+------+------+------| |------+------+------+------+------+------|
63 * | Tab | / | - | 7 | 8 | 9 | | ! | @ | # | $ | % | F12 |
64 * |------+------+------+------+------+------| |------+------+------+------+------+------|
65 * |LShift| * | + | 4 | 5 | 6 | | ^ | & | * | ( | ) | - |
66 * |------+------+------+------+------+------| |------+------+------+------+------+------|
67 * |LCTRL | . | 0 | 1 | 2 | 3 |-------.-------. ,---------------| | _ | + | { | } | | |
68 * `-----------------------------------------/ F11 / / \ \ F12 \----------------------------------------'
69 * | LAlt | LGUI | /-------/ Space / \ Enter \-------\ | Caps | Num |
70 * | | |/ LOWER / / \ \ \ | | |
71 * `-----------------------------' '------------------------------'
72 */
73 [_LOWER] = LAYOUT( \
74 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, \
75 _______, KC_PSLS, KC_PMNS, KC_P7, KC_P8, KC_P9, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_F12, \
76 _______, KC_PAST, KC_PPLS, KC_P4, KC_P5, KC_P6, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_TILD, \
77 _______, KC_PDOT, KC_P0, KC_P1, KC_P2, KC_P3, _______, _______, _______, _______, XXXXXXX, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
78 _______, KC_LGUI, _______, XXXXXXX, KC_CLCK, KC_NLCK\
79
80 ),
81
82/* RAISE
83 * ,-----------------------------------------. ,-----------------------------------------.
84 * | | | | | | | | | | | | | |
85 * |------+------+------+------+------+------| |------+------+------+------+------+------|
86 * | | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
87 * |------+------+------+------+------+------| |------+------+------+------+------+------|
88 * | F1 | F2 | F3 | F4 | F5 | F6 | | | | | | | |
89 * |------+------+------+------+------+------| |------+------+------+------+------+------|
90 * | F7 | F8 | F9 | F10 | F11 | F12 |-------.-------. ,---------------| | | | | | |
91 * `-----------------------------------------/ / / \ \ \----------------------------------------'
92 * | | | /-------/ Space / \ Enter \-------\ | | |
93 * | | |/ / / \ \ RAISE \ | | |
94 * `-----------------------------' '------------------------------'
95 */
96 [_RAISE] = LAYOUT( \
97 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
98 XXXXXXX, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, XXXXXXX, \
99 KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, XXXXXXX, KC_UP, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
100 KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, XXXXXXX, _______, _______, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, XXXXXXX, XXXXXXX, \
101 XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX \
102 ),
103
104/* ADJUST
105 * ,-----------------------------------------. ,-----------------------------------------.
106 * |RESET | | | | | | | Mute | Vol+ | Play | | | |
107 * |------+------+------+------+------+------| |------+------+------+------+------+------|
108 * | | | | PSCR | SLCK | Pause| | Prev | Vol- | Next | | | |
109 * |------+------+------+------+------+------| |------+------+------+------+------+------|
110 * | | | |Insert| Home |PageUP| | | |RGB ON| HUE+ | SAT+ | VAL+ |
111 * |------+------+------+------+------+------| |------+------+------+------+------+------|
112 * | | | | Del | End |PageDN|-------.-------. ,---------------| |RGB Re| MODE | HUE- | SAT- | VAL- |
113 * `-----------------------------------------/ / / \ \ \----------------------------------------'
114 * | |ADJUST| /-------/ Space / \ Enter \-------\ | | |
115 * | | |/ / / \ \ \ | | |
116 * `-----------------------------' '------------------------------'
117 */
118 [_ADJUST] = LAYOUT( \
119 RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MUTE, KC_VOLU, KC_MPLY, XXXXXXX, XXXXXXX, XXXXXXX, \
120 XXXXXXX, XXXXXXX, XXXXXXX, KC_PSCR, KC_SLCK, KC_PAUS, KC_MPRV, KC_VOLD, KC_MNXT, XXXXXXX, XXXXXXX, XXXXXXX, \
121 XXXXXXX, XXXXXXX, XXXXXXX, KC_INS, KC_HOME, KC_PGUP, XXXXXXX, XXXXXXX, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
122 XXXXXXX, XXXXXXX, XXXXXXX, KC_DEL, KC_END, KC_PGDN, XXXXXXX, _______, _______, XXXXXXX, XXXXXXX, RGBRST, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, \
123 XXXXXXX, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX \
124 )
125};
126
127
128int RGB_current_mode;
129
130void persistent_default_layer_set(uint16_t default_layer) {
131 eeconfig_update_default_layer(default_layer);
132 default_layer_set(default_layer);
133}
134
135// Setting ADJUST layer RGB back to default
136void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
137 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
138 layer_on(layer3);
139 } else {
140 layer_off(layer3);
141 }
142}
143
144void matrix_init_user(void) {
145 #ifdef RGBLIGHT_ENABLE
146 RGB_current_mode = rgblight_config.mode;
147 #endif
148 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
149 #ifdef SSD1306OLED
150 #ifdef SSD1306_128X64
151 iota_gfx_init(false); // turns on the display
152 #else
153 iota_gfx_init(!has_usb()); // turns on the display
154 #endif
155 #endif
156}
157
158//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
159#ifdef SSD1306OLED
160
161//assign the right code to your layers for OLED display
162#define L_QWERTY 0
163#define L_LOWER 2
164#define L_RAISE 4
165#define L_ADJUST 8
166
167// When add source files to SRC in rules.mk, you can use functions.
168const char *read_logo(void);
169
170void matrix_scan_user(void) {
171 iota_gfx_task();
172}
173
174void matrix_render_user(struct CharacterMatrix *matrix) {
175 if (is_master) {
176 static char indctr[2][20][5]=
177 {
178 // white icon
179 {
180 {0x80,0x81,0x82,0x83,0},
181 {0x88,0x89,0x8A,0x8B,0},
182 {0x90,0x91,0x92,0x93,0},
183 {0x98,0x99,0x9A,0x9B,0},
184 {0x01,0x02,0x03,0x04,0},
185 {0xA0,0xA1,0xA2,0xA3,0},
186 {0xA8,0xA9,0xAA,0xAB,0},
187 {0xB0,0xB1,0xB2,0xB3,0},
188 {0xB8,0xB9,0xBA,0xBB,0},
189 {0x21,0x22,0x23,0x24,0},
190 {0xC0,0xC1,0xC2,0xC3,0},
191 {0xC8,0xC9,0xCA,0xCB,0},
192 {0xD0,0xD1,0xD2,0xD3,0},
193 {0xD8,0xD9,0xDA,0xDB,0},
194 {0x41,0x42,0x43,0x44,0},
195 {0xE0,0xE1,0xE2,0xE3,0},
196 {0xE8,0xE9,0xEA,0xEB,0},
197 {0xF0,0xF1,0xF2,0xF3,0},
198 {0xF8,0xF9,0xFA,0xFB,0},
199 {0x61,0x62,0x63,0x64,0}
200 },
201 // Black icon
202 {
203 {0x84,0x85,0x86,0x87,0},
204 {0x8C,0x8D,0x8E,0x8F,0},
205 {0x94,0x95,0x96,0x97,0},
206 {0x9C,0x9D,0x9E,0x9F,0},
207 {0x05,0x06,0x07,0x08,0},
208 {0xA4,0xA5,0xA6,0xA7,0},
209 {0xAC,0xAD,0xAE,0xAF,0},
210 {0xB4,0xB5,0xB6,0xB7,0},
211 {0xBC,0xBD,0xBE,0xBF,0},
212 {0x25,0x26,0x27,0x28,0},
213 {0xC4,0xC5,0xC6,0xC7,0},
214 {0xCC,0xCD,0xCE,0xCF,0},
215 {0xD4,0xD5,0xD6,0xD7,0},
216 {0xDC,0xDD,0xDE,0xDF,0},
217 {0x45,0x46,0x47,0x48,0},
218 {0xE4,0xE5,0xE6,0xE7,0},
219 {0xEC,0xED,0xEE,0xEF,0},
220 {0xF4,0xF5,0xF6,0xF7,0},
221 {0xFC,0xFD,0xFE,0xFF,0},
222 {0x65,0x66,0x67,0x68,0}
223 }
224 };
225
226 int rown = 0;
227 int rowc = 0;
228 int rowl = 0;
229 int rowr = 0;
230 int rowa = 0;
231
232 //Set Indicator icon
233 if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { rown = 1; } else { rown = 0; }
234 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { rowc = 1; } else { rowc = 0; }
235 if (layer_state == L_LOWER) { rowl = 1; }
236 if (layer_state == L_RAISE) { rowr = 1; }
237 if (layer_state == L_ADJUST) { rowa = 1; }
238
239 matrix_write(matrix, indctr[rowl] [0]);
240 matrix_write(matrix, indctr[rowr] [1]);
241 matrix_write(matrix, indctr[rowa] [2]);
242 matrix_write(matrix, indctr[rowc] [3]);
243 matrix_write(matrix, indctr[rown] [4]);
244 matrix_write_char(matrix, 0x13);
245 matrix_write(matrix, indctr[rowl] [5]);
246 matrix_write(matrix, indctr[rowr] [6]);
247 matrix_write(matrix, indctr[rowa] [7]);
248 matrix_write(matrix, indctr[rowc] [8]);
249 matrix_write(matrix, indctr[rown] [9]);
250 matrix_write_char(matrix, 0x13);
251 matrix_write(matrix, indctr[rowl] [10]);
252 matrix_write(matrix, indctr[rowr] [11]);
253 matrix_write(matrix, indctr[rowa] [12]);
254 matrix_write(matrix, indctr[rowc] [13]);
255 matrix_write(matrix, indctr[rown] [14]);
256 matrix_write_char(matrix, 0x13);
257 matrix_write(matrix, indctr[rowl] [15]);
258 matrix_write(matrix, indctr[rowr] [16]);
259 matrix_write(matrix, indctr[rowa] [17]);
260 matrix_write(matrix, indctr[rowc] [18]);
261 matrix_write(matrix, indctr[rown] [19]);
262
263 }else{
264 matrix_write(matrix, read_logo());
265 }
266}
267
268void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
269 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
270 memcpy(dest->display, source->display, sizeof(dest->display));
271 dest->dirty = true;
272 }
273}
274
275void iota_gfx_task_user(void) {
276 struct CharacterMatrix matrix;
277 matrix_clear(&matrix);
278 matrix_render_user(&matrix);
279 matrix_update(&display, &matrix);
280}
281#endif//SSD1306OLED
282
283bool process_record_user(uint16_t keycode, keyrecord_t *record) {
284 switch (keycode) {
285 case QWERTY:
286 if (record->event.pressed) {
287 persistent_default_layer_set(1UL<<_QWERTY);
288 }
289 return false;
290 break;
291 case LOWER:
292 if (record->event.pressed) {
293 layer_on(_LOWER);
294 } else {
295 layer_off(_LOWER);
296 }
297 return false;
298 break;
299 case RAISE:
300 if (record->event.pressed) {
301 layer_on(_RAISE);
302 } else {
303 layer_off(_RAISE);
304 }
305 return false;
306 break;
307 case ADJUST:
308 if (record->event.pressed) {
309 layer_on(_ADJUST);
310 } else {
311 layer_off(_ADJUST);
312 }
313 return false;
314 break;
315 case RGB_MOD:
316 #ifdef RGBLIGHT_ENABLE
317 if (record->event.pressed) {
318 rgblight_mode(RGB_current_mode);
319 rgblight_step();
320 RGB_current_mode = rgblight_config.mode;
321 }
322 #endif
323 return false;
324 break;
325 case RGBRST:
326 #ifdef RGBLIGHT_ENABLE
327 if (record->event.pressed) {
328 eeconfig_update_rgblight_default();
329 rgblight_enable();
330 RGB_current_mode = rgblight_config.mode;
331 }
332 #endif
333 break;
334 }
335 return true;
336}
337
diff --git a/keyboards/yosino58/keymaps/default/rules.mk b/keyboards/yosino58/keymaps/default/rules.mk
new file mode 100644
index 000000000..131f5e1f8
--- /dev/null
+++ b/keyboards/yosino58/keymaps/default/rules.mk
@@ -0,0 +1,30 @@
1# Build Options
2# change to "no" to disable the options, or define them in the Makefile in
3# the appropriate keymap folder that will get included automatically
4#
5BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
6MOUSEKEY_ENABLE = no # Mouse keys(+4700)
7EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
8CONSOLE_ENABLE = no # Console for debug(+400)
9COMMAND_ENABLE = no # Commands for debug and configuration
10NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
11BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
12MIDI_ENABLE = no # MIDI controls
13AUDIO_ENABLE = no # Audio output on port C6
14UNICODE_ENABLE = no # Unicode
15BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
16RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight.
17SWAP_HANDS_ENABLE = no # Enable one-hand typing
18
19# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
20SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
21
22# If you want to change the display of OLED, you need to change here
23SRC += ./lib/glcdfont.c \
24 ./lib/logo_reader.c \
25 # ./lib/rgb_state_reader.c \
26 # ./lib/layer_state_reader.c \
27 # ./lib/keylogger.c \
28 # ./lib/mode_icon_reader.c \
29 # ./lib/host_led_state_reader.c \
30 # ./lib/timelogger.c \
diff --git a/keyboards/yosino58/keymaps/sakura/config.h b/keyboards/yosino58/keymaps/sakura/config.h
new file mode 100644
index 000000000..64962b0d2
--- /dev/null
+++ b/keyboards/yosino58/keymaps/sakura/config.h
@@ -0,0 +1,50 @@
1/*
2This is the c configuration file for the keymap
3
4Copyright 2012 Jun Wako <wakojun@gmail.com>
5Copyright 2015 Jack Humbert
6
7This program is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation, either version 2 of the License, or
10(at your option) any later version.
11
12This program is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with this program. If not, see <http://www.gnu.org/licenses/>.
19*/
20
21#pragma once
22
23//#define USE_MATRIX_I2C
24
25/* Select hand configuration */
26
27// #define MASTER_LEFT
28#define MASTER_RIGHT
29// #define EE_HANDS
30
31#define SSD1306OLED
32#define SSD1306_128X64
33
34#define TAPPING_FORCE_HOLD
35#define TAPPING_TERM 100
36
37#undef RGBLED_NUM
38#define RGBLIGHT_ANIMATIONS
39#define RGBLED_NUM 29
40#define RGBLIGHT_LIMIT_VAL 120
41#define RGBLIGHT_HUE_STEP 10
42#define RGBLIGHT_SAT_STEP 17
43#define RGBLIGHT_VAL_STEP 17
44
45#define MOUSEKEY_DELAY 50
46#define MOUSEKEY_INTERVAL 10
47#define MOUSEKEY_MAX_SPEED 3
48#define MOUSEKEY_TIME_TO_MAX 20
49#define MOUSEKEY_WHEEL_MAX_SPEED 8
50#define MOUSEKEY_WHEEL_TIME_TO_MAX 40
diff --git a/keyboards/yosino58/keymaps/sakura/keymap.c b/keyboards/yosino58/keymaps/sakura/keymap.c
new file mode 100644
index 000000000..0996f0e4e
--- /dev/null
+++ b/keyboards/yosino58/keymaps/sakura/keymap.c
@@ -0,0 +1,337 @@
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
12#ifdef RGBLIGHT_ENABLE
13//Following line allows macro to read current RGB settings
14extern rgblight_config_t rgblight_config;
15#endif
16
17extern uint8_t is_master;
18
19// Each layer gets a name for readability, which is then used in the keymap matrix below.
20// The underscores don't mean anything - you can have a layer called STUFF or any other name.
21// Layer names don't all need to be of the same length, obviously, and you can also skip them
22// entirely and just use numbers.
23#define _QWERTY 0
24#define _LOWER 1
25#define _RAISE 2
26#define _ADJUST 3
27
28enum custom_keycodes {
29 QWERTY = SAFE_RANGE,
30 LOWER,
31 RAISE,
32 ADJUST,
33 RGBRST
34};
35
36const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
37/* QWERTY
38 * ,-----------------------------------------. ,-----------------------------------------.
39 * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | - |
40 * |------+------+------+------+------+------| |------+------+------+------+------+------|
41 * | Tab | Q | W | E | R | T | | Y | U | I | O | P | = |
42 * |------+------+------+------+------+------| |------+------+------+------+------+------|
43 * |LShift| A | S | D | F | G | | H | J | K | L | ; | ' |
44 * |------+------+------+------+------+------| |------+------+------+------+------+------|
45 * |LCTRL | Z | X | C | V | B |-------.-------. ,---------------| N | M | , | . | / | \ |
46 * `-----------------------------------------/ Del / / \ \ Bksp \----------------------------------------'
47 * | LAlt | LGUI | /-------/ Space / \ Enter \-------\ | [ | ] |
48 * | | |/ LOWER / / \ \ RAISE \ | | |
49 * `-----------------------------' '------------------------------'
50 */
51 [_QWERTY] = LAYOUT( \
52 KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, \
53 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_EQL, \
54 KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
55 KC_LCTRL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_DEL, KC_SPC, KC_ENT, KC_BSPC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_BSLS, \
56 KC_LALT, KC_LGUI, LOWER, RAISE, KC_LBRC, KC_RBRC\
57 ),
58
59/* LOWER
60 * ,-----------------------------------------. ,-----------------------------------------.
61 * | ESC | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | |
62 * |------+------+------+------+------+------| |------+------+------+------+------+------|
63 * | Tab | / | - | 7 | 8 | 9 | | PSCR | SLCK | Pause| | | |
64 * |------+------+------+------+------+------| |------+------+------+------+------+------|
65 * |LShift| * | + | 4 | 5 | 6 | |Insert| Home |PageUP| | | |
66 * |------+------+------+------+------+------| |------+------+------+------+------+------|
67 * |LCTRL | . | 0 | 1 | 2 | 3 |-------.-------. ,---------------| Del | End |PageDN| | Num | Caps |
68 * `-----------------------------------------/ F11 / / \ \ F12 \----------------------------------------'
69 * | LAlt | LGUI | /-------/ Space / \ Enter \-------\ | | |
70 * | | |/ LOWER / / \ \ \ | | |
71 * `-----------------------------' '------------------------------'
72 */
73 [_LOWER] = LAYOUT( \
74 KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, XXXXXXX, \
75 _______, KC_PSLS, KC_PMNS, KC_P7, KC_P8, KC_P9, KC_PSCR, KC_SLCK, KC_PAUS, XXXXXXX, KC_UP, XXXXXXX, \
76 _______, KC_PAST, KC_PPLS, KC_P4, KC_P5, KC_P6, KC_INS, KC_HOME, KC_PGUP, XXXXXXX, KC_DOWN, KC_RGHT, \
77 _______, KC_PDOT, KC_P0, KC_P1, KC_P2, KC_P3, KC_F11, _______, _______, KC_F12, KC_DEL, KC_END, KC_PGDN, KC_LEFT, KC_NLCK, KC_CLCK, \
78 _______, _______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX\
79 ),
80
81/* RAISE
82 * ,-----------------------------------------. ,-----------------------------------------.
83 * |RESET | | | | | | | Mute | Vol+ | Play | | | |
84 * |------+------+------+------+------+------| |------+------+------+------+------+------|
85 * | | | | | | | | Prev | Vol- | Next | | | |
86 * |------+------+------+------+------+------| |------+------+------+------+------+------|
87 * | |MS_Bt1| MS_U |MS_Bt2|MS_WhU|MS_WhL| | | |RGB ON| HUE+ | SAT+ | VAL+ |
88 * |------+------+------+------+------+------| |------+------+------+------+------+------|
89 * | | MS_L | MS_D | MS_R |MS_WhD|MS_WhR|-------.-------. ,---------------| | | MODE | HUE- | SAT- | VAL- |
90 * `-----------------------------------------/ / / \ \ \----------------------------------------'
91 * | | | /-------/ Space / \ Enter \-------\ | | |
92 * | | |/ / / \ \ RAISE \ | | |
93 * `-----------------------------' '------------------------------'
94 */
95 [_RAISE] = LAYOUT( \
96 RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MUTE, KC_VOLU, KC_MPLY, XXXXXXX, XXXXXXX, XXXXXXX, \
97 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_MPRV, KC_VOLD, KC_MNXT, XXXXXXX, XXXXXXX, XXXXXXX, \
98 XXXXXXX, KC_BTN1, KC_MS_U, KC_BTN2, KC_WH_U, KC_WH_L, XXXXXXX, XXXXXXX, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, \
99 XXXXXXX, KC_MS_L, KC_MS_D, KC_MS_R, KC_WH_D, KC_WH_R, XXXXXXX, _______, _______, XXXXXXX, XXXXXXX, RGBRST, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, \
100 XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX \
101 )
102
103/* ADJUST
104 * ,-----------------------------------------. ,-----------------------------------------.
105 * |RESET | | | | | | | | | | | | |
106 * |------+------+------+------+------+------| |------+------+------+------+------+------|
107 * | | | | | | | | | | | | | |
108 * |------+------+------+------+------+------| |------+------+------+------+------+------|
109 * | | | | | | | | | | | | | |
110 * |------+------+------+------+------+------| |------+------+------+------+------+------|
111 * | | | | | | |-------.-------. ,---------------| | | | | | |
112 * `-----------------------------------------/ / / \ \ \----------------------------------------'
113 * | | | /-------/ / \ \-------\ | | |
114 * | | |/ / / \ \ \ | | |
115 * `-----------------------------' '------------------------------'
116
117 [_ADJUST] = LAYOUT( \
118 RESET, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
119 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
120 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
121 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \
122 XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX \
123 )
124*/
125};
126
127
128int RGB_current_mode;
129
130void persistent_default_layer_set(uint16_t default_layer) {
131 eeconfig_update_default_layer(default_layer);
132 default_layer_set(default_layer);
133}
134
135// Setting ADJUST layer RGB back to default
136void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) {
137 if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) {
138 layer_on(layer3);
139 } else {
140 layer_off(layer3);
141 }
142}
143
144void matrix_init_user(void) {
145 #ifdef RGBLIGHT_ENABLE
146 RGB_current_mode = rgblight_config.mode;
147 #endif
148 //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
149 #ifdef SSD1306OLED
150 #ifdef SSD1306_128X64
151 iota_gfx_init(false); // turns on the display
152 #else
153 iota_gfx_init(!has_usb()); // turns on the display
154 #endif
155 #endif
156}
157
158//SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
159#ifdef SSD1306OLED
160
161//assign the right code to your layers for OLED display
162#define L_QWERTY 0
163#define L_LOWER 2
164#define L_RAISE 4
165#define L_ADJUST 8
166
167// When add source files to SRC in rules.mk, you can use functions.
168const char *read_logo(void);
169
170void matrix_scan_user(void) {
171 iota_gfx_task();
172}
173
174void matrix_render_user(struct CharacterMatrix *matrix) {
175 if (is_master) {
176 static char indctr[2][20][5]=
177 {
178 // white icon
179 {
180 {0x80,0x81,0x82,0x83,0},
181 {0x88,0x89,0x8A,0x8B,0},
182 {0x90,0x91,0x92,0x93,0},
183 {0x98,0x99,0x9A,0x9B,0},
184 {0x01,0x02,0x03,0x04,0},
185 {0xA0,0xA1,0xA2,0xA3,0},
186 {0xA8,0xA9,0xAA,0xAB,0},
187 {0xB0,0xB1,0xB2,0xB3,0},
188 {0xB8,0xB9,0xBA,0xBB,0},
189 {0x21,0x22,0x23,0x24,0},
190 {0xC0,0xC1,0xC2,0xC3,0},
191 {0xC8,0xC9,0xCA,0xCB,0},
192 {0xD0,0xD1,0xD2,0xD3,0},
193 {0xD8,0xD9,0xDA,0xDB,0},
194 {0x41,0x42,0x43,0x44,0},
195 {0xE0,0xE1,0xE2,0xE3,0},
196 {0xE8,0xE9,0xEA,0xEB,0},
197 {0xF0,0xF1,0xF2,0xF3,0},
198 {0xF8,0xF9,0xFA,0xFB,0},
199 {0x61,0x62,0x63,0x64,0}
200 },
201 // Black icon
202 {
203 {0x84,0x85,0x86,0x87,0},
204 {0x8C,0x8D,0x8E,0x8F,0},
205 {0x94,0x95,0x96,0x97,0},
206 {0x9C,0x9D,0x9E,0x9F,0},
207 {0x05,0x06,0x07,0x08,0},
208 {0xA4,0xA5,0xA6,0xA7,0},
209 {0xAC,0xAD,0xAE,0xAF,0},
210 {0xB4,0xB5,0xB6,0xB7,0},
211 {0xBC,0xBD,0xBE,0xBF,0},
212 {0x25,0x26,0x27,0x28,0},
213 {0xC4,0xC5,0xC6,0xC7,0},
214 {0xCC,0xCD,0xCE,0xCF,0},
215 {0xD4,0xD5,0xD6,0xD7,0},
216 {0xDC,0xDD,0xDE,0xDF,0},
217 {0x45,0x46,0x47,0x48,0},
218 {0xE4,0xE5,0xE6,0xE7,0},
219 {0xEC,0xED,0xEE,0xEF,0},
220 {0xF4,0xF5,0xF6,0xF7,0},
221 {0xFC,0xFD,0xFE,0xFF,0},
222 {0x65,0x66,0x67,0x68,0}
223 }
224 };
225
226 int rown = 0;
227 int rowc = 0;
228 int rowl = 0;
229 int rowr = 0;
230 int rowa = 0;
231
232 //Set Indicator icon
233 if (host_keyboard_leds() & (1<<USB_LED_NUM_LOCK)) { rown = 1; } else { rown = 0; }
234 if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) { rowc = 1; } else { rowc = 0; }
235 if (layer_state == L_LOWER) { rowl = 1; }
236 if (layer_state == L_RAISE) { rowr = 1; }
237 if (layer_state == L_ADJUST) { rowa = 1; }
238
239 matrix_write(matrix, indctr[rowl] [0]);
240 matrix_write(matrix, indctr[rowr] [1]);
241 matrix_write(matrix, indctr[rowa] [2]);
242 matrix_write(matrix, indctr[rowc] [3]);
243 matrix_write(matrix, indctr[rown] [4]);
244 matrix_write_char(matrix, 0x13);
245 matrix_write(matrix, indctr[rowl] [5]);
246 matrix_write(matrix, indctr[rowr] [6]);
247 matrix_write(matrix, indctr[rowa] [7]);
248 matrix_write(matrix, indctr[rowc] [8]);
249 matrix_write(matrix, indctr[rown] [9]);
250 matrix_write_char(matrix, 0x13);
251 matrix_write(matrix, indctr[rowl] [10]);
252 matrix_write(matrix, indctr[rowr] [11]);
253 matrix_write(matrix, indctr[rowa] [12]);
254 matrix_write(matrix, indctr[rowc] [13]);
255 matrix_write(matrix, indctr[rown] [14]);
256 matrix_write_char(matrix, 0x13);
257 matrix_write(matrix, indctr[rowl] [15]);
258 matrix_write(matrix, indctr[rowr] [16]);
259 matrix_write(matrix, indctr[rowa] [17]);
260 matrix_write(matrix, indctr[rowc] [18]);
261 matrix_write(matrix, indctr[rown] [19]);
262
263 }else{
264 matrix_write(matrix, read_logo());
265 }
266}
267
268void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
269 if (memcmp(dest->display, source->display, sizeof(dest->display))) {
270 memcpy(dest->display, source->display, sizeof(dest->display));
271 dest->dirty = true;
272 }
273}
274
275void iota_gfx_task_user(void) {
276 struct CharacterMatrix matrix;
277 matrix_clear(&matrix);
278 matrix_render_user(&matrix);
279 matrix_update(&display, &matrix);
280}
281#endif//SSD1306OLED
282
283bool process_record_user(uint16_t keycode, keyrecord_t *record) {
284 switch (keycode) {
285 case QWERTY:
286 if (record->event.pressed) {
287 persistent_default_layer_set(1UL<<_QWERTY);
288 }
289 return false;
290 break;
291 case LOWER:
292 if (record->event.pressed) {
293 layer_on(_LOWER);
294 } else {
295 layer_off(_LOWER);
296 }
297 return false;
298 break;
299 case RAISE:
300 if (record->event.pressed) {
301 layer_on(_RAISE);
302 } else {
303 layer_off(_RAISE);
304 }
305 return false;
306 break;
307 case ADJUST:
308 if (record->event.pressed) {
309 layer_on(_ADJUST);
310 } else {
311 layer_off(_ADJUST);
312 }
313 return false;
314 break;
315 case RGB_MOD:
316 #ifdef RGBLIGHT_ENABLE
317 if (record->event.pressed) {
318 rgblight_mode(RGB_current_mode);
319 rgblight_step();
320 RGB_current_mode = rgblight_config.mode;
321 }
322 #endif
323 return false;
324 break;
325 case RGBRST:
326 #ifdef RGBLIGHT_ENABLE
327 if (record->event.pressed) {
328 eeconfig_update_rgblight_default();
329 rgblight_enable();
330 RGB_current_mode = rgblight_config.mode;
331 }
332 #endif
333 break;
334 }
335 return true;
336}
337
diff --git a/keyboards/yosino58/keymaps/sakura/rules.mk b/keyboards/yosino58/keymaps/sakura/rules.mk
new file mode 100644
index 000000000..296e53287
--- /dev/null
+++ b/keyboards/yosino58/keymaps/sakura/rules.mk
@@ -0,0 +1,30 @@
1# Build Options
2# change to "no" to disable the options, or define them in the Makefile in
3# the appropriate keymap folder that will get included automatically
4#
5BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
6MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
7EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
8CONSOLE_ENABLE = no # Console for debug(+400)
9COMMAND_ENABLE = no # Commands for debug and configuration
10NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
11BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
12MIDI_ENABLE = no # MIDI controls
13AUDIO_ENABLE = no # Audio output on port C6
14UNICODE_ENABLE = no # Unicode
15BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
16RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight.
17SWAP_HANDS_ENABLE = no # Enable one-hand typing
18
19# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
20SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
21
22# If you want to change the display of OLED, you need to change here
23SRC += ./lib/glcdfont.c \
24 ./lib/logo_reader.c \
25 # ./lib/rgb_state_reader.c \
26 # ./lib/layer_state_reader.c \
27 # ./lib/keylogger.c \
28 # ./lib/mode_icon_reader.c \
29 # ./lib/host_led_state_reader.c \
30 # ./lib/timelogger.c \
diff --git a/keyboards/yosino58/lib/glcdfont.c b/keyboards/yosino58/lib/glcdfont.c
new file mode 100644
index 000000000..01b656cc6
--- /dev/null
+++ b/keyboards/yosino58/lib/glcdfont.c
@@ -0,0 +1,275 @@
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.
3
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
15
16// Standard ASCII 5x7 font
17const unsigned char font[] PROGMEM = {
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19 0xFC, 0x02, 0x01, 0x01, 0x01, 0x01,
20 0x01, 0x81, 0xC1, 0xE1, 0xF1, 0xF9,
21 0xF9, 0xF9, 0xF9, 0x01, 0x01, 0x01,
22 0x01, 0x01, 0x01, 0x01, 0x02, 0xFC,
23 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF,
24 0xFF, 0x7F, 0x3F, 0x1F, 0x0F, 0x07,
25 0x07, 0x07, 0x07, 0xFF, 0xFF, 0xFF,
26 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC,
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
52 0x03, 0x03, 0x03, 0x01, 0x00, 0xFF,
53 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
54 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
55 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
56 0xFC, 0xFC, 0xFC, 0xFE, 0xFF, 0x00,
57 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
58 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0x00, 0xFC, 0xFE, 0xFC, 0x00, 0x00,
62 0x00, 0x00, 0x00, 0x00, 0x00, 0xFC,
63 0xFE, 0x00, 0x00, 0x80, 0xF8, 0xFC,
64 0x7C, 0x3E, 0x1E, 0x1E, 0x1E, 0x1E,
65 0x1E, 0x3E, 0x7C, 0xFC, 0xF8, 0x80,
66 0x00, 0x00, 0xC0, 0xF8, 0x7C, 0x3C,
67 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C,
68 0x3C, 0x3C, 0x18, 0x00, 0x38, 0x7C,
69 0x7C, 0x7C, 0x7C, 0x7C, 0xFC, 0xFC,
70 0x7C, 0x7C, 0x7C, 0x7C, 0x38, 0x00,
71 0x00, 0xC0, 0xF0, 0xF8, 0x7C, 0x3C,
72 0x1E, 0x1E, 0x1E, 0x3C, 0x7C, 0xF8,
73 0xF0, 0xC0, 0x00, 0x00, 0x80, 0xF8,
74 0xFC, 0x7C, 0x3E, 0x1E, 0x1E, 0x1E,
75 0x1E, 0x1E, 0x3E, 0x7C, 0xFC, 0xF8,
76 0x80, 0x00, 0x00, 0x00, 0xFC, 0xFE,
77 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
78 0x1E, 0x1E, 0x1E, 0x1E, 0x1C, 0x00,
79 0xE0, 0xF8, 0xFC, 0x3E, 0x1E, 0x1E,
80 0x1E, 0x1E, 0x1E, 0x1E, 0x3E, 0xFC,
81 0xF8, 0xE0, 0x00, 0x00, 0x00, 0x00,
82 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
83 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
84 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
85 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00,
86 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
87 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
88 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
89 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
90 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
91 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
92 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93 0x00, 0x03, 0x0F, 0x1F, 0x3C, 0x3C,
94 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0xFF,
95 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
96 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
97 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF,
98 0x00, 0x00, 0x03, 0x0F, 0x1E, 0x3C,
99 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C,
100 0x7C, 0xF8, 0xC0, 0x00, 0x00, 0x00,
101 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
102 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
103 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
104 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
105 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF,
106 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF,
108 0xFF, 0x00, 0x00, 0x00, 0x07, 0x0F,
109 0x0F, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
110 0x1E, 0x1E, 0xFE, 0xFC, 0xF0, 0x00,
111 0xC0, 0xF7, 0xFF, 0x3F, 0x3E, 0x1C,
112 0x1C, 0x1C, 0x1C, 0x3E, 0x3F, 0xFF,
113 0xF7, 0xC0, 0x00, 0x00, 0x00, 0x00,
114 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
115 0x3F, 0x40, 0x80, 0x80, 0x80, 0x80,
116 0x9C, 0x9E, 0x9E, 0x9E, 0x9E, 0x9F,
117 0x9F, 0x9F, 0x9F, 0x9E, 0x9E, 0x9E,
118 0x9E, 0x9C, 0x80, 0x80, 0x40, 0x3F,
119 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,
120 0xE3, 0xE1, 0xE1, 0xE1, 0xE1, 0xE0,
121 0xE0, 0xE0, 0xE0, 0xE1, 0xE1, 0xE1,
122 0xE1, 0xE3, 0xFF, 0xFF, 0x7F, 0x3F,
123 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
125 0x00, 0x18, 0x3C, 0x3C, 0x3C, 0x3C,
126 0x3C, 0x3C, 0x3C, 0x3C, 0x1F, 0x0F,
127 0x07, 0x00, 0x00, 0x00, 0x0F, 0x1F,
128 0x1F, 0x3E, 0x3C, 0x3C, 0x3C, 0x3C,
129 0x3C, 0x3E, 0x1F, 0x1F, 0x0F, 0x00,
130 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x3C,
131 0x3C, 0x3C, 0x3C, 0x3C, 0x3C, 0x3C,
132 0x3E, 0x1F, 0x03, 0x00, 0x1C, 0x3E,
133 0x3E, 0x3E, 0x3E, 0x3E, 0x3F, 0x3F,
134 0x3E, 0x3E, 0x3E, 0x3E, 0x1C, 0x00,
135 0x00, 0x3F, 0x3F, 0x1F, 0x00, 0x00,
136 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F,
137 0x3F, 0x3F, 0x00, 0x00, 0x00, 0x0F,
138 0x1F, 0x1F, 0x3E, 0x3C, 0x3C, 0x3C,
139 0x3C, 0x3C, 0x3E, 0x1F, 0x1F, 0x0F,
140 0x00, 0x00, 0x00, 0x00, 0x06, 0x1F,
141 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
142 0x1F, 0x1F, 0x0F, 0x07, 0x03, 0x00,
143 0x01, 0x07, 0x0F, 0x1E, 0x3C, 0x3C,
144 0x3C, 0x3C, 0x3C, 0x3C, 0x1E, 0x0F,
145 0x07, 0x01, 0x00, 0x00, 0x00, 0x00,
146 0xFC, 0x02, 0x01, 0x79, 0x79, 0x79,
147 0x79, 0xF9, 0xF9, 0xF9, 0x79, 0x79,
148 0x79, 0x79, 0x01, 0x01, 0x01, 0x01,
149 0x01, 0x01, 0x01, 0x01, 0x02, 0xFC,
150 0xFC, 0xFE, 0xFF, 0x87, 0x87, 0x87,
151 0x87, 0x07, 0x07, 0x07, 0x87, 0x87,
152 0x87, 0x87, 0xFF, 0xFF, 0xFF, 0xFF,
153 0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC,
154 0xFC, 0x02, 0x01, 0xE1, 0xE1, 0xE1,
155 0xE1, 0xE1, 0xE1, 0xE1, 0xE1, 0xE1,
156 0xE1, 0xE1, 0xE1, 0xE1, 0xC1, 0xC1,
157 0x81, 0x01, 0x01, 0x01, 0x02, 0xFC,
158 0xFC, 0xFE, 0xFF, 0x1F, 0x1F, 0x1F,
159 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
160 0x1F, 0x1F, 0x1F, 0x1F, 0x3F, 0x3F,
161 0x7F, 0xFF, 0xFF, 0xFF, 0xFE, 0xFC,
162 0xFC, 0x02, 0x01, 0x01, 0x01, 0x01,
163 0x01, 0x01, 0x01, 0x01, 0x01, 0x09,
164 0x89, 0xF9, 0xF9, 0xF9, 0xF9, 0xF9,
165 0xF9, 0x09, 0x09, 0x01, 0x02, 0xFC,
166 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF,
167 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7,
168 0x77, 0x07, 0x07, 0x07, 0x07, 0x07,
169 0x07, 0xF7, 0xF7, 0xFF, 0xFE, 0xFC,
170 0xFC, 0x02, 0x01, 0x01, 0x01, 0x01,
171 0x81, 0xC1, 0xE1, 0xF1, 0xF1, 0xF9,
172 0x79, 0x79, 0xF9, 0xF9, 0xF1, 0xF1,
173 0xE1, 0x81, 0x01, 0x01, 0x02, 0xFC,
174 0xFC, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF,
175 0x7F, 0x3F, 0x1F, 0x0F, 0x0F, 0x07,
176 0x87, 0x87, 0x07, 0x07, 0x0F, 0x0F,
177 0x1F, 0x7F, 0xFF, 0xFF, 0xFE, 0xFC,
178 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
182 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
183 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF,
184 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
185 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
186 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF,
187 0xFF, 0xFF, 0xC0, 0xC0, 0xC0, 0xC0,
188 0xC0, 0xC0, 0xC0, 0xC0, 0xE1, 0xFF,
189 0x7F, 0x1F, 0x00, 0x00, 0x00, 0xFF,
190 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
191 0x00, 0x00, 0x3F, 0x3F, 0x3F, 0x3F,
192 0x3F, 0x3F, 0x3F, 0x3F, 0x1E, 0x00,
193 0x80, 0xE0, 0xFF, 0xFF, 0xFF, 0xFF,
194 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
195 0x00, 0xC0, 0xF0, 0xFC, 0xFC, 0x3F,
196 0x0F, 0x03, 0x01, 0x01, 0xFF, 0xFF,
197 0xFF, 0xF8, 0x00, 0x00, 0x00, 0xFF,
198 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
199 0xFF, 0x3F, 0x0F, 0x03, 0x03, 0xC0,
200 0xF0, 0xFC, 0xFE, 0xFE, 0x00, 0x00,
201 0x00, 0x07, 0xFF, 0xFF, 0xFF, 0xFF,
202 0xFF, 0x00, 0x00, 0xE0, 0xFC, 0xFF,
203 0xFF, 0xFF, 0xFF, 0x1F, 0x03, 0x00,
204 0x00, 0x00, 0x18, 0x1F, 0x1F, 0x1F,
205 0x1F, 0x0F, 0x00, 0x00, 0x00, 0xFF,
206 0xFF, 0xFF, 0xFF, 0x1F, 0x03, 0x00,
207 0x00, 0x00, 0x00, 0xE0, 0xFC, 0xFF,
208 0xFF, 0xFF, 0xE7, 0xE0, 0xE0, 0xE0,
209 0xE0, 0xF0, 0xFF, 0xFF, 0xFF, 0xFF,
210 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00,
211 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0x00,
212 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
213 0x00, 0x80, 0xC0, 0xE0, 0x00, 0xFF,
214 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
215 0xFF, 0x00, 0x00, 0x00, 0xFF, 0xFF,
216 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
217 0xFF, 0x7F, 0x3F, 0x1F, 0xFF, 0xFF,
218 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF,
219 0xFF, 0xFF, 0x01, 0x01, 0x01, 0x01,
220 0x03, 0x0F, 0x3F, 0xFD, 0xF1, 0xC0,
221 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF,
222 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00,
223 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE,
224 0xFC, 0xF0, 0xC0, 0x02, 0x0F, 0x3F,
225 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
226 0xFF, 0x00, 0x00, 0x00, 0xF0, 0xFC,
227 0xFF, 0xFF, 0xFF, 0x73, 0x70, 0x70,
228 0x70, 0x70, 0x70, 0x70, 0xFF, 0xFF,
229 0xFF, 0xFF, 0xF8, 0x00, 0x00, 0xFF,
230 0xFF, 0xFF, 0xFF, 0xFF, 0x0F, 0x03,
231 0x00, 0x00, 0x00, 0x8C, 0x8F, 0x8F,
232 0x8F, 0x8F, 0x8F, 0x8F, 0x00, 0x00,
233 0x00, 0x00, 0x07, 0xFF, 0xFF, 0xFF,
234 0xFF, 0x00, 0x00, 0x3F, 0xFF, 0xFF,
235 0xFF, 0xFF, 0xFF, 0xC0, 0x80, 0x00,
236 0x00, 0x80, 0xC0, 0xE0, 0xF8, 0xF0,
237 0x20, 0x00, 0x00, 0x00, 0x00, 0xFF,
238 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00,
239 0x00, 0x00, 0x00, 0x3F, 0x7F, 0xFF,
240 0xFF, 0x7F, 0x3F, 0x1F, 0x07, 0x0F,
241 0xDF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
242 0x3F, 0x40, 0x80, 0x8F, 0x8F, 0x8F,
243 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F,
244 0x8F, 0x8F, 0x8F, 0x8F, 0x8F, 0x8F,
245 0x8F, 0x87, 0x83, 0x81, 0x40, 0x3F,
246 0x3F, 0x7F, 0xFF, 0xF0, 0xF0, 0xF0,
247 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
248 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0,
249 0xF0, 0xF8, 0xFC, 0xFE, 0x7F, 0x3F,
250 0x3F, 0x40, 0x80, 0x8E, 0x8E, 0x8F,
251 0x8F, 0x8F, 0x8E, 0x8E, 0x80, 0x80,
252 0x80, 0x80, 0x80, 0x80, 0x83, 0x8F,
253 0x8F, 0x8E, 0x8E, 0x80, 0x40, 0x3F,
254 0x3F, 0x7F, 0xFF, 0xF1, 0xF1, 0xF0,
255 0xF0, 0xF0, 0xF1, 0xF1, 0xFF, 0xFF,
256 0xFF, 0xFF, 0xFF, 0xFF, 0xFC, 0xF0,
257 0xF0, 0xF1, 0xF1, 0xFF, 0x7F, 0x3F,
258 0x3F, 0x40, 0x80, 0x80, 0x9F, 0x9F,
259 0x9F, 0x9F, 0x9F, 0x80, 0x80, 0x80,
260 0x80, 0x80, 0x80, 0x80, 0x9F, 0x9F,
261 0x9F, 0x9F, 0x9F, 0x80, 0x40, 0x3F,
262 0x3F, 0x7F, 0xFF, 0xFF, 0xE0, 0xE0,
263 0xE0, 0xE0, 0xE0, 0xFF, 0xFF, 0xFF,
264 0xFF, 0xFF, 0xFF, 0xFF, 0xE0, 0xE0,
265 0xE0, 0xE0, 0xE0, 0xFF, 0x7F, 0x3F,
266 0x3F, 0x40, 0x80, 0x80, 0x80, 0x81,
267 0x83, 0x87, 0x87, 0x8F, 0x8F, 0x8F,
268 0x8F, 0x87, 0x87, 0x83, 0x81, 0x80,
269 0x80, 0x80, 0x80, 0x80, 0x40, 0x3F,
270 0x3F, 0x7F, 0xFF, 0xFF, 0xFF, 0xFE,
271 0xFC, 0xF8, 0xF8, 0xF0, 0xF0, 0xF0,
272 0xF0, 0xF8, 0xF8, 0xFC, 0xFE, 0xFF,
273 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F
274};
275#endif // FONT5X7_H
diff --git a/keyboards/yosino58/lib/glcdfont_.c b/keyboards/yosino58/lib/glcdfont_.c
new file mode 100644
index 000000000..122b26afa
--- /dev/null
+++ b/keyboards/yosino58/lib/glcdfont_.c
@@ -0,0 +1,243 @@
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.
3
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
15
16// Standard ASCII 5x7 font
17const unsigned char font[] PROGMEM = {
18 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
22 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
23 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
24 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
25 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
26 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
31 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
32 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
33 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
35 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
40 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
41 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
42 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
43 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
44 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
48 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
49 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
50 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
51 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
52 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
57 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
58 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
59 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
60 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
61 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
62 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
63 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
64 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
66 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
67 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
68 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
71 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
72 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
74 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
75 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
79 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
80 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
81 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
82 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
83 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
84 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
85 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
86 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
87 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
88 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
89 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
90 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
91 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
92 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
93 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
94 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
95 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
96 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
97 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
98 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
99 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
100 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
101 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
102 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
103 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
104 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
105 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
113 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
114 0x00, 0xFE, 0x01, 0x01, 0x0D, 0xFD,
115 0xFD, 0x0D, 0x01, 0x01, 0x01, 0x01,
116 0x01, 0x01, 0x01, 0xFE, 0x00, 0x00,
117 0x00, 0xFE, 0x01, 0x01, 0x0D, 0xFD,
118 0xFD, 0x8D, 0x8D, 0x8D, 0x8D, 0xF9,
119 0x71, 0x01, 0x01, 0xFE, 0x00, 0x00,
120 0x00, 0xFE, 0x01, 0x01, 0x01, 0xC1,
121 0xF1, 0x39, 0x0D, 0x3D, 0xFD, 0xC1,
122 0x01, 0x01, 0x01, 0xFE, 0x00, 0x00,
123 0x00, 0xFE, 0x01, 0x01, 0x01, 0x01,
124 0x21, 0x31, 0xF9, 0xF9, 0x01, 0x01,
125 0x01, 0x01, 0x01, 0xFE, 0x00, 0x00,
126 0x00, 0x00, 0xC0, 0x80, 0xC0, 0xE0,
127 0xF0, 0xF0, 0x00, 0xC0, 0x80, 0x00,
128 0x80, 0xC0, 0x00, 0x00, 0x00, 0x00,
129 0x00, 0x02, 0x06, 0xEC, 0xD8, 0xB4,
130 0x6E, 0xDE, 0x82, 0x7A, 0x76, 0xAC,
131 0xD8, 0xF0, 0x00, 0x00, 0x00, 0x00,
132 0x00, 0x00, 0x00, 0x00, 0xB0, 0x70,
133 0xBC, 0x7C, 0xBC, 0x7C, 0xBC, 0x70,
134 0xB0, 0x00, 0x00, 0x00, 0x00, 0x00,
135 0x00, 0x00, 0x00, 0x00, 0xF0, 0x90,
136 0x9C, 0x84, 0x84, 0x84, 0x9C, 0x90,
137 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00,
138 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
139 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
140 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
141 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
142 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
143 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
144 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
145 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
146 0x00, 0x7F, 0x80, 0x80, 0x98, 0x9F,
147 0x9F, 0x98, 0x98, 0x98, 0x98, 0x9C,
148 0x9E, 0x80, 0x80, 0x7F, 0x00, 0x00,
149 0x00, 0x7F, 0x80, 0x80, 0x98, 0x9F,
150 0x9F, 0x99, 0x81, 0x83, 0x87, 0x9C,
151 0x98, 0x98, 0x80, 0x7F, 0x00, 0x00,
152 0x00, 0x7F, 0x80, 0x80, 0x9F, 0x9F,
153 0x86, 0x86, 0x86, 0x86, 0x9F, 0x9F,
154 0x80, 0x80, 0x80, 0x7F, 0x00, 0x00,
155 0x00, 0x7F, 0x80, 0x80, 0x80, 0x80,
156 0x98, 0x98, 0x9F, 0x9F, 0x98, 0x98,
157 0x80, 0x80, 0x80, 0x7F, 0x00, 0x00,
158 0x00, 0x00, 0x07, 0x03, 0x07, 0x0F,
159 0x1F, 0x1F, 0x00, 0x0C, 0x07, 0x03,
160 0x07, 0x0C, 0x00, 0x00, 0x00, 0x00,
161 0x00, 0x00, 0x00, 0x1F, 0x2F, 0x77,
162 0xFB, 0xFC, 0x81, 0xBB, 0xD6, 0x6D,
163 0x1B, 0x37, 0x60, 0xC0, 0x00, 0x00,
164 0x00, 0x00, 0x00, 0x00, 0x1B, 0x37,
165 0x3B, 0x37, 0x3B, 0x37, 0x3B, 0x37,
166 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00,
167 0x00, 0x00, 0x00, 0x00, 0x1B, 0x37,
168 0x3B, 0x37, 0x3B, 0x37, 0x3B, 0x37,
169 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00,
170 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
171 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
174 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
175 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
177 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0x00, 0xFE, 0xFF, 0xFF, 0xF3, 0x03,
179 0x03, 0xF3, 0xFF, 0xFF, 0xFF, 0xFF,
180 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00,
181 0x00, 0xFE, 0xFF, 0xFF, 0xF3, 0x03,
182 0x03, 0x73, 0x73, 0x73, 0x73, 0x07,
183 0x8F, 0xFF, 0xFF, 0xFE, 0x00, 0x00,
184 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0x3F,
185 0x0F, 0xC7, 0xF3, 0xC3, 0x03, 0x3F,
186 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00,
187 0x00, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF,
188 0xDF, 0xCF, 0x07, 0x07, 0xFF, 0xFF,
189 0xFF, 0xFF, 0xFF, 0xFE, 0x00, 0x00,
190 0x00, 0x00, 0xC0, 0x80, 0xC0, 0xE0,
191 0xF0, 0xF0, 0x00, 0x20, 0x20, 0x10,
192 0x10, 0x08, 0x00, 0x00, 0x00, 0x00,
193 0x00, 0x00, 0x00, 0xF0, 0xE8, 0xDC,
194 0xBE, 0x7E, 0x02, 0xFA, 0x76, 0xAC,
195 0xD8, 0xF0, 0x00, 0x00, 0x00, 0x00,
196 0x00, 0x00, 0x00, 0x00, 0xF0, 0x10,
197 0x1C, 0x04, 0x04, 0x04, 0x1C, 0x10,
198 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00,
199 0x00, 0x00, 0x00, 0x04, 0xF8, 0x30,
200 0x5C, 0x84, 0x04, 0x04, 0x1C, 0x10,
201 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00,
202 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
203 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
206 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
208 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
209 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
210 0x00, 0x7F, 0xFF, 0xFF, 0xE7, 0xE0,
211 0xE0, 0xE7, 0xE7, 0xE7, 0xE7, 0xE7,
212 0xE3, 0xE1, 0xFF, 0x7F, 0x00, 0x00,
213 0x00, 0x7F, 0xFF, 0xFF, 0xE7, 0xE0,
214 0xE0, 0xE6, 0xFE, 0xFC, 0xF8, 0xE3,
215 0xE7, 0xE7, 0xFF, 0x7F, 0x00, 0x00,
216 0x00, 0x7F, 0xFF, 0xFF, 0xE0, 0xE0,
217 0xF9, 0xF9, 0xF9, 0xF9, 0xE0, 0xE0,
218 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00,
219 0x00, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF,
220 0xE7, 0xE7, 0xE0, 0xE0, 0xE7, 0xE7,
221 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00,
222 0x00, 0x00, 0x07, 0x03, 0x07, 0x0F,
223 0x1F, 0x1F, 0x00, 0x09, 0x09, 0x11,
224 0x11, 0x21, 0x00, 0x00, 0x00, 0x00,
225 0x00, 0x00, 0x00, 0x1F, 0x2F, 0x77,
226 0xFB, 0xFD, 0x80, 0xBE, 0xDD, 0x6B,
227 0x37, 0x1F, 0x00, 0x00, 0x00, 0x00,
228 0x00, 0x00, 0x00, 0x00, 0x1F, 0x38,
229 0x38, 0x38, 0x38, 0x38, 0x38, 0x38,
230 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00,
231 0x00, 0x00, 0x00, 0x00, 0x1F, 0x20,
232 0x20, 0x20, 0x21, 0x22, 0x24, 0x28,
233 0x1F, 0x20, 0x00, 0x00, 0x00, 0x00,
234 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
235 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
236 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
237 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
238 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
239 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
240 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
241 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
242};
243#endif // FONT5X7_H
diff --git a/keyboards/yosino58/lib/host_led_state_reader.c b/keyboards/yosino58/lib/host_led_state_reader.c
new file mode 100644
index 000000000..2a17e0a33
--- /dev/null
+++ b/keyboards/yosino58/lib/host_led_state_reader.c
@@ -0,0 +1,15 @@
1#include <stdio.h>
2#include "yosino58.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/yosino58/lib/keylogger.c b/keyboards/yosino58/lib/keylogger.c
new file mode 100644
index 000000000..c50de94c2
--- /dev/null
+++ b/keyboards/yosino58/lib/keylogger.c
@@ -0,0 +1,45 @@
1#include <stdio.h>
2#include "yosino58.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/yosino58/lib/layer_state_reader.c b/keyboards/yosino58/lib/layer_state_reader.c
new file mode 100644
index 000000000..7e5747cb7
--- /dev/null
+++ b/keyboards/yosino58/lib/layer_state_reader.c
@@ -0,0 +1,35 @@
1
2#include QMK_KEYBOARD_H
3#include <stdio.h>
4#include "yosino58.h"
5
6#define L_BASE 0
7#define L_LOWER 8
8#define L_RAISE 16
9#define L_ADJUST 65536
10#define L_ADJUST_TRI 65560
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/yosino58/lib/logo_reader.c b/keyboards/yosino58/lib/logo_reader.c
new file mode 100644
index 000000000..96c9b897e
--- /dev/null
+++ b/keyboards/yosino58/lib/logo_reader.c
@@ -0,0 +1,11 @@
1#include "yosino58.h"
2
3const char *read_logo(void) {
4 static char logo[] = {
5 0x2B,0x2C,0x2D,0x2E,0x2F,0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
6 0x4B,0x4C,0x4D,0x4E,0x4F,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F,
7 0x6B,0x6C,0x6D,0x6E,0x6F,0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F,
8 0};
9
10 return logo;
11}
diff --git a/keyboards/yosino58/lib/mode_icon_reader.c b/keyboards/yosino58/lib/mode_icon_reader.c
new file mode 100644
index 000000000..865d9537d
--- /dev/null
+++ b/keyboards/yosino58/lib/mode_icon_reader.c
@@ -0,0 +1,15 @@
1#include <stdio.h>
2#include "yosino58.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/yosino58/lib/rgb_state_reader.c b/keyboards/yosino58/lib/rgb_state_reader.c
new file mode 100644
index 000000000..e0efe2e52
--- /dev/null
+++ b/keyboards/yosino58/lib/rgb_state_reader.c
@@ -0,0 +1,15 @@
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/yosino58/lib/timelogger.c b/keyboards/yosino58/lib/timelogger.c
new file mode 100644
index 000000000..ce8b0c270
--- /dev/null
+++ b/keyboards/yosino58/lib/timelogger.c
@@ -0,0 +1,16 @@
1#include <stdio.h>
2#include "yosino58.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/yosino58/pro_micro.h b/keyboards/yosino58/pro_micro.h
new file mode 100644
index 000000000..366633372
--- /dev/null
+++ b/keyboards/yosino58/pro_micro.h
@@ -0,0 +1,358 @@
1/*
2 pins_arduino.h - Pin definition functions for Arduino
3 Part of Arduino - http://www.arduino.cc/
4
5 Copyright (c) 2007 David A. Mellis
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General
18 Public License along with this library; if not, write to the
19 Free Software Foundation, Inc., 59 Temple Place, Suite 330,
20 Boston, MA 02111-1307 USA
21
22 $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $
23*/
24#pragma once
25
26#include <avr/pgmspace.h>
27
28// Workaround for wrong definitions in "iom32u4.h".
29// This should be fixed in the AVR toolchain.
30#undef UHCON
31#undef UHINT
32#undef UHIEN
33#undef UHADDR
34#undef UHFNUM
35#undef UHFNUML
36#undef UHFNUMH
37#undef UHFLEN
38#undef UPINRQX
39#undef UPINTX
40#undef UPNUM
41#undef UPRST
42#undef UPCONX
43#undef UPCFG0X
44#undef UPCFG1X
45#undef UPSTAX
46#undef UPCFG2X
47#undef UPIENX
48#undef UPDATX
49#undef TCCR2A
50#undef WGM20
51#undef WGM21
52#undef COM2B0
53#undef COM2B1
54#undef COM2A0
55#undef COM2A1
56#undef TCCR2B
57#undef CS20
58#undef CS21
59#undef CS22
60#undef WGM22
61#undef FOC2B
62#undef FOC2A
63#undef TCNT2
64#undef TCNT2_0
65#undef TCNT2_1
66#undef TCNT2_2
67#undef TCNT2_3
68#undef TCNT2_4
69#undef TCNT2_5
70#undef TCNT2_6
71#undef TCNT2_7
72#undef OCR2A
73#undef OCR2_0
74#undef OCR2_1
75#undef OCR2_2
76#undef OCR2_3
77#undef OCR2_4
78#undef OCR2_5
79#undef OCR2_6
80#undef OCR2_7
81#undef OCR2B
82#undef OCR2_0
83#undef OCR2_1
84#undef OCR2_2
85#undef OCR2_3
86#undef OCR2_4
87#undef OCR2_5
88#undef OCR2_6
89#undef OCR2_7
90
91#define NUM_DIGITAL_PINS 30
92#define NUM_ANALOG_INPUTS 12
93
94#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0)
95#define TXLED0 PORTD |= (1<<5)
96#define TXLED1 PORTD &= ~(1<<5)
97#define RXLED0 PORTB |= (1<<0)
98#define RXLED1 PORTB &= ~(1<<0)
99
100static const uint8_t SDA = 2;
101static const uint8_t SCL = 3;
102#define LED_BUILTIN 13
103
104// Map SPI port to 'new' pins D14..D17
105static const uint8_t SS = 17;
106static const uint8_t MOSI = 16;
107static const uint8_t MISO = 14;
108static const uint8_t SCK = 15;
109
110// Mapping of analog pins as digital I/O
111// A6-A11 share with digital pins
112static const uint8_t ADC0 = 18;
113static const uint8_t ADC1 = 19;
114static const uint8_t ADC2 = 20;
115static const uint8_t ADC3 = 21;
116static const uint8_t ADC4 = 22;
117static const uint8_t ADC5 = 23;
118static const uint8_t ADC6 = 24; // D4
119static const uint8_t ADC7 = 25; // D6
120static const uint8_t ADC8 = 26; // D8
121static const uint8_t ADC9 = 27; // D9
122static const uint8_t ADC10 = 28; // D10
123static const uint8_t ADC11 = 29; // D12
124
125#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0))
126#define digitalPinToPCICRbit(p) 0
127#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0))
128#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4))))))
129
130// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
131extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];
132#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) )
133
134#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))
135
136#ifdef ARDUINO_MAIN
137
138// On the Arduino board, digital pins are also used
139// for the analog output (software PWM). Analog input
140// pins are a separate set.
141
142// ATMEL ATMEGA32U4 / ARDUINO LEONARDO
143//
144// D0 PD2 RXD1/INT2
145// D1 PD3 TXD1/INT3
146// D2 PD1 SDA SDA/INT1
147// D3# PD0 PWM8/SCL OC0B/SCL/INT0
148// D4 A6 PD4 ADC8
149// D5# PC6 ??? OC3A/#OC4A
150// D6# A7 PD7 FastPWM #OC4D/ADC10
151// D7 PE6 INT6/AIN0
152//
153// D8 A8 PB4 ADC11/PCINT4
154// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5
155// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6
156// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7
157// D12 A11 PD6 T1/#OC4D/ADC9
158// D13# PC7 PWM10 CLK0/OC4A
159//
160// A0 D18 PF7 ADC7
161// A1 D19 PF6 ADC6
162// A2 D20 PF5 ADC5
163// A3 D21 PF4 ADC4
164// A4 D22 PF1 ADC1
165// A5 D23 PF0 ADC0
166//
167// New pins D14..D17 to map SPI port to digital pins
168//
169// MISO D14 PB3 MISO,PCINT3
170// SCK D15 PB1 SCK,PCINT1
171// MOSI D16 PB2 MOSI,PCINT2
172// SS D17 PB0 RXLED,SS/PCINT0
173//
174// Connected LEDs on board for TX and RX
175// TXLED D24 PD5 XCK1
176// RXLED D17 PB0
177// HWB PE2 HWB
178
179// these arrays map port names (e.g. port B) to the
180// appropriate addresses for various functions (e.g. reading
181// and writing)
182const uint16_t PROGMEM port_to_mode_PGM[] = {
183 NOT_A_PORT,
184 NOT_A_PORT,
185 (uint16_t) &DDRB,
186 (uint16_t) &DDRC,
187 (uint16_t) &DDRD,
188 (uint16_t) &DDRE,
189 (uint16_t) &DDRF,
190};
191
192const uint16_t PROGMEM port_to_output_PGM[] = {
193 NOT_A_PORT,
194 NOT_A_PORT,
195 (uint16_t) &PORTB,
196 (uint16_t) &PORTC,
197 (uint16_t) &PORTD,
198 (uint16_t) &PORTE,
199 (uint16_t) &PORTF,
200};
201
202const uint16_t PROGMEM port_to_input_PGM[] = {
203 NOT_A_PORT,
204 NOT_A_PORT,
205 (uint16_t) &PINB,
206 (uint16_t) &PINC,
207 (uint16_t) &PIND,
208 (uint16_t) &PINE,
209 (uint16_t) &PINF,
210};
211
212const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
213 PD, // D0 - PD2
214 PD, // D1 - PD3
215 PD, // D2 - PD1
216 PD, // D3 - PD0
217 PD, // D4 - PD4
218 PC, // D5 - PC6
219 PD, // D6 - PD7
220 PE, // D7 - PE6
221
222 PB, // D8 - PB4
223 PB, // D9 - PB5
224 PB, // D10 - PB6
225 PB, // D11 - PB7
226 PD, // D12 - PD6
227 PC, // D13 - PC7
228
229 PB, // D14 - MISO - PB3
230 PB, // D15 - SCK - PB1
231 PB, // D16 - MOSI - PB2
232 PB, // D17 - SS - PB0
233
234 PF, // D18 - A0 - PF7
235 PF, // D19 - A1 - PF6
236 PF, // D20 - A2 - PF5
237 PF, // D21 - A3 - PF4
238 PF, // D22 - A4 - PF1
239 PF, // D23 - A5 - PF0
240
241 PD, // D24 - PD5
242 PD, // D25 / D6 - A7 - PD7
243 PB, // D26 / D8 - A8 - PB4
244 PB, // D27 / D9 - A9 - PB5
245 PB, // D28 / D10 - A10 - PB6
246 PD, // D29 / D12 - A11 - PD6
247};
248
249const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
250 _BV(2), // D0 - PD2
251 _BV(3), // D1 - PD3
252 _BV(1), // D2 - PD1
253 _BV(0), // D3 - PD0
254 _BV(4), // D4 - PD4
255 _BV(6), // D5 - PC6
256 _BV(7), // D6 - PD7
257 _BV(6), // D7 - PE6
258
259 _BV(4), // D8 - PB4
260 _BV(5), // D9 - PB5
261 _BV(6), // D10 - PB6
262 _BV(7), // D11 - PB7
263 _BV(6), // D12 - PD6
264 _BV(7), // D13 - PC7
265
266 _BV(3), // D14 - MISO - PB3
267 _BV(1), // D15 - SCK - PB1
268 _BV(2), // D16 - MOSI - PB2
269 _BV(0), // D17 - SS - PB0
270
271 _BV(7), // D18 - A0 - PF7
272 _BV(6), // D19 - A1 - PF6
273 _BV(5), // D20 - A2 - PF5
274 _BV(4), // D21 - A3 - PF4
275 _BV(1), // D22 - A4 - PF1
276 _BV(0), // D23 - A5 - PF0
277
278 _BV(5), // D24 - PD5
279 _BV(7), // D25 / D6 - A7 - PD7
280 _BV(4), // D26 / D8 - A8 - PB4
281 _BV(5), // D27 / D9 - A9 - PB5
282 _BV(6), // D28 / D10 - A10 - PB6
283 _BV(6), // D29 / D12 - A11 - PD6
284};
285
286const uint8_t PROGMEM digital_pin_to_timer_PGM[] = {
287 NOT_ON_TIMER,
288 NOT_ON_TIMER,
289 NOT_ON_TIMER,
290 TIMER0B, /* 3 */
291 NOT_ON_TIMER,
292 TIMER3A, /* 5 */
293 TIMER4D, /* 6 */
294 NOT_ON_TIMER,
295
296 NOT_ON_TIMER,
297 TIMER1A, /* 9 */
298 TIMER1B, /* 10 */
299 TIMER0A, /* 11 */
300
301 NOT_ON_TIMER,
302 TIMER4A, /* 13 */
303
304 NOT_ON_TIMER,
305 NOT_ON_TIMER,
306 NOT_ON_TIMER,
307 NOT_ON_TIMER,
308 NOT_ON_TIMER,
309 NOT_ON_TIMER,
310
311 NOT_ON_TIMER,
312 NOT_ON_TIMER,
313 NOT_ON_TIMER,
314 NOT_ON_TIMER,
315 NOT_ON_TIMER,
316 NOT_ON_TIMER,
317 NOT_ON_TIMER,
318 NOT_ON_TIMER,
319 NOT_ON_TIMER,
320 NOT_ON_TIMER,
321};
322
323const uint8_t PROGMEM analog_pin_to_channel_PGM[] = {
324 7, // A0 PF7 ADC7
325 6, // A1 PF6 ADC6
326 5, // A2 PF5 ADC5
327 4, // A3 PF4 ADC4
328 1, // A4 PF1 ADC1
329 0, // A5 PF0 ADC0
330 8, // A6 D4 PD4 ADC8
331 10, // A7 D6 PD7 ADC10
332 11, // A8 D8 PB4 ADC11
333 12, // A9 D9 PB5 ADC12
334 13, // A10 D10 PB6 ADC13
335 9 // A11 D12 PD6 ADC9
336};
337
338#endif /* ARDUINO_MAIN */
339
340// These serial port names are intended to allow libraries and architecture-neutral
341// sketches to automatically default to the correct port name for a particular type
342// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,
343// the first hardware serial port whose RX/TX pins are not dedicated to another use.
344//
345// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor
346//
347// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial
348//
349// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library
350//
351// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins.
352//
353// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX
354// pins are NOT connected to anything by default.
355#define SERIAL_PORT_MONITOR Serial
356#define SERIAL_PORT_USBVIRTUAL Serial
357#define SERIAL_PORT_HARDWARE Serial1
358#define SERIAL_PORT_HARDWARE_OPEN Serial1
diff --git a/keyboards/yosino58/rev1/config.h b/keyboards/yosino58/rev1/config.h
new file mode 100644
index 000000000..a9f4f666e
--- /dev/null
+++ b/keyboards/yosino58/rev1/config.h
@@ -0,0 +1,72 @@
1/*
2Copyright 2012 Jun Wako <wakojun@gmail.com>
3Copyright 2015 Jack Humbert
4
5This program is free software: you can redistribute it and/or modify
6it under the terms of the GNU General Public License as published by
7the Free Software Foundation, either version 2 of the License, or
8(at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#pragma once
20
21/* USB Device descriptor parameter */
22#define VENDOR_ID 0x0F6A
23#define PRODUCT_ID 0x01B8
24#define DEVICE_VER 0x0001
25#define MANUFACTURER sakuranbo0046
26#define PRODUCT yosino58
27#define DESCRIPTION yosino58 is 6~4+5keys column-staggered split keyboard.
28
29/* key matrix size */
30// Rows are doubled-up
31#define MATRIX_ROWS 10
32#define MATRIX_COLS 6
33
34// wiring of each half
35#define MATRIX_ROW_PINS { D4, C6, D7, E6, B4 }
36#define MATRIX_COL_PINS { F4, F5, F6, F7, B1, B3 }
37
38/* define if matrix has ghost */
39//#define MATRIX_HAS_GHOST
40
41/* number of backlight levels */
42// #define BACKLIGHT_LEVELS 3
43
44/* Set 0 if debouncing isn't needed */
45#define DEBOUNCING_DELAY 5
46
47/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */
48//#define LOCKING_SUPPORT_ENABLE
49/* Locking resynchronize hack */
50//#define LOCKING_RESYNC_ENABLE
51
52/* ws2812 RGB LED */
53#define RGB_DI_PIN D3
54#define RGBLED_NUM 12 // Number of LEDs
55
56/*
57 * Feature disable options
58 * These options are also useful to firmware size reduction.
59 */
60
61/* disable debug print */
62// #define NO_DEBUG
63
64/* disable print */
65// #define NO_PRINT
66
67/* disable action features */
68//#define NO_ACTION_LAYER
69//#define NO_ACTION_TAPPING
70//#define NO_ACTION_ONESHOT
71//#define NO_ACTION_MACRO
72//#define NO_ACTION_FUNCTION
diff --git a/keyboards/yosino58/rev1/matrix.c b/keyboards/yosino58/rev1/matrix.c
new file mode 100644
index 000000000..718cc5744
--- /dev/null
+++ b/keyboards/yosino58/rev1/matrix.c
@@ -0,0 +1,357 @@
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 "pro_micro.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 TX_RX_LED_INIT;
106 TXLED0;
107 RXLED0;
108
109 // initialize matrix state: all keys off
110 for (uint8_t i=0; i < MATRIX_ROWS; i++) {
111 matrix[i] = 0;
112 matrix_debouncing[i] = 0;
113 }
114
115 is_master = has_usb();
116
117 matrix_init_quantum();
118}
119
120uint8_t _matrix_scan(void)
121{
122 // Right hand is stored after the left in the matirx so, we need to offset it
123 int offset = isLeftHand ? 0 : (ROWS_PER_HAND);
124
125 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
126 select_row(i);
127 _delay_us(30); // without this wait read unstable value.
128 matrix_row_t cols = read_cols();
129 if (matrix_debouncing[i+offset] != cols) {
130 matrix_debouncing[i+offset] = cols;
131 debouncing = DEBOUNCE;
132 }
133 unselect_rows();
134 }
135
136 if (debouncing) {
137 if (--debouncing) {
138 _delay_ms(1);
139 } else {
140 for (uint8_t i = 0; i < ROWS_PER_HAND; i++) {
141 matrix[i+offset] = matrix_debouncing[i+offset];
142 }
143 }
144 }
145
146 return 1;
147}
148
149#ifdef USE_MATRIX_I2C
150
151// Get rows from other half over i2c
152int i2c_transaction(void) {
153 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
154
155 int err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_WRITE);
156 if (err) goto i2c_error;
157
158 // start of matrix stored at 0x00
159 err = i2c_master_write(0x00);
160 if (err) goto i2c_error;
161
162 // Start read
163 err = i2c_master_start(SLAVE_I2C_ADDRESS + I2C_READ);
164 if (err) goto i2c_error;
165
166 if (!err) {
167 int i;
168 for (i = 0; i < ROWS_PER_HAND-1; ++i) {
169 matrix[slaveOffset+i] = i2c_master_read(I2C_ACK);
170 }
171 matrix[slaveOffset+i] = i2c_master_read(I2C_NACK);
172 i2c_master_stop();
173 } else {
174i2c_error: // the cable is disconnceted, or something else went wrong
175 i2c_reset_state();
176 return err;
177 }
178
179 return 0;
180}
181
182#else // USE_SERIAL
183
184int serial_transaction(int master_changed) {
185 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
186#ifdef SERIAL_USE_MULTI_TRANSACTION
187 int ret=serial_update_buffers(master_changed);
188#else
189 int ret=serial_update_buffers();
190#endif
191 if (ret ) {
192 if(ret==2) RXLED1;
193 return 1;
194 }
195 RXLED0;
196 memcpy(&matrix[slaveOffset],
197 (void *)serial_slave_buffer, SERIAL_SLAVE_BUFFER_LENGTH);
198 return 0;
199}
200#endif
201
202uint8_t matrix_scan(void)
203{
204 if (is_master) {
205 matrix_master_scan();
206 }else{
207 matrix_slave_scan();
208 int offset = (isLeftHand) ? ROWS_PER_HAND : 0;
209 memcpy(&matrix[offset],
210 (void *)serial_master_buffer, SERIAL_MASTER_BUFFER_LENGTH);
211 matrix_scan_quantum();
212 }
213 return 1;
214}
215
216
217uint8_t matrix_master_scan(void) {
218
219 int ret = _matrix_scan();
220 int mchanged = 1;
221
222 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
223
224#ifdef USE_MATRIX_I2C
225// for (int i = 0; i < ROWS_PER_HAND; ++i) {
226 /* i2c_slave_buffer[i] = matrix[offset+i]; */
227// i2c_slave_buffer[i] = matrix[offset+i];
228// }
229#else // USE_SERIAL
230 #ifdef SERIAL_USE_MULTI_TRANSACTION
231 mchanged = memcmp((void *)serial_master_buffer,
232 &matrix[offset], SERIAL_MASTER_BUFFER_LENGTH);
233 #endif
234 memcpy((void *)serial_master_buffer,
235 &matrix[offset], SERIAL_MASTER_BUFFER_LENGTH);
236#endif
237
238#ifdef USE_MATRIX_I2C
239 if( i2c_transaction() ) {
240#else // USE_SERIAL
241 if( serial_transaction(mchanged) ) {
242#endif
243 // turn on the indicator led when halves are disconnected
244 TXLED1;
245
246 error_count++;
247
248 if (error_count > ERROR_DISCONNECT_COUNT) {
249 // reset other half if disconnected
250 int slaveOffset = (isLeftHand) ? (ROWS_PER_HAND) : 0;
251 for (int i = 0; i < ROWS_PER_HAND; ++i) {
252 matrix[slaveOffset+i] = 0;
253 }
254 }
255 } else {
256 // turn off the indicator led on no error
257 TXLED0;
258 error_count = 0;
259 }
260 matrix_scan_quantum();
261 return ret;
262}
263
264void matrix_slave_scan(void) {
265 _matrix_scan();
266
267 int offset = (isLeftHand) ? 0 : ROWS_PER_HAND;
268
269#ifdef USE_MATRIX_I2C
270 for (int i = 0; i < ROWS_PER_HAND; ++i) {
271 /* i2c_slave_buffer[i] = matrix[offset+i]; */
272 i2c_slave_buffer[i] = matrix[offset+i];
273 }
274#else // USE_SERIAL
275 #ifdef SERIAL_USE_MULTI_TRANSACTION
276 int change = 0;
277 #endif
278 for (int i = 0; i < ROWS_PER_HAND; ++i) {
279 #ifdef SERIAL_USE_MULTI_TRANSACTION
280 if( serial_slave_buffer[i] != matrix[offset+i] )
281 change = 1;
282 #endif
283 serial_slave_buffer[i] = matrix[offset+i];
284 }
285 #ifdef SERIAL_USE_MULTI_TRANSACTION
286 slave_buffer_change_count += change;
287 #endif
288#endif
289}
290
291bool matrix_is_modified(void)
292{
293 if (debouncing) return false;
294 return true;
295}
296
297inline
298bool matrix_is_on(uint8_t row, uint8_t col)
299{
300 return (matrix[row] & ((matrix_row_t)1<<col));
301}
302
303inline
304matrix_row_t matrix_get_row(uint8_t row)
305{
306 return matrix[row];
307}
308
309void matrix_print(void)
310{
311 print("\nr/c 0123456789ABCDEF\n");
312 for (uint8_t row = 0; row < MATRIX_ROWS; row++) {
313 phex(row); print(": ");
314 pbin_reverse16(matrix_get_row(row));
315 print("\n");
316 }
317}
318
319uint8_t matrix_key_count(void)
320{
321 uint8_t count = 0;
322 for (uint8_t i = 0; i < MATRIX_ROWS; i++) {
323 count += bitpop16(matrix[i]);
324 }
325 return count;
326}
327
328static void init_cols(void)
329{
330 for(int x = 0; x < MATRIX_COLS; x++) {
331 _SFR_IO8((col_pins[x] >> 4) + 1) &= ~_BV(col_pins[x] & 0xF);
332 _SFR_IO8((col_pins[x] >> 4) + 2) |= _BV(col_pins[x] & 0xF);
333 }
334}
335
336static matrix_row_t read_cols(void)
337{
338 matrix_row_t result = 0;
339 for(int x = 0; x < MATRIX_COLS; x++) {
340 result |= (_SFR_IO8(col_pins[x] >> 4) & _BV(col_pins[x] & 0xF)) ? 0 : (1 << x);
341 }
342 return result;
343}
344
345static void unselect_rows(void)
346{
347 for(int x = 0; x < ROWS_PER_HAND; x++) {
348 _SFR_IO8((row_pins[x] >> 4) + 1) &= ~_BV(row_pins[x] & 0xF);
349 _SFR_IO8((row_pins[x] >> 4) + 2) |= _BV(row_pins[x] & 0xF);
350 }
351}
352
353static void select_row(uint8_t row)
354{
355 _SFR_IO8((row_pins[row] >> 4) + 1) |= _BV(row_pins[row] & 0xF);
356 _SFR_IO8((row_pins[row] >> 4) + 2) &= ~_BV(row_pins[row] & 0xF);
357}
diff --git a/keyboards/yosino58/rev1/rev1.c b/keyboards/yosino58/rev1/rev1.c
new file mode 100644
index 000000000..ef1f13e41
--- /dev/null
+++ b/keyboards/yosino58/rev1/rev1.c
@@ -0,0 +1,8 @@
1#include "yosino58.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/yosino58/rev1/rev1.h b/keyboards/yosino58/rev1/rev1.h
new file mode 100644
index 000000000..84d90737d
--- /dev/null
+++ b/keyboards/yosino58/rev1/rev1.h
@@ -0,0 +1,40 @@
1#pragma once
2
3#include "../yosino58.h"
4
5//void promicro_bootloader_jmp(bool program);
6#include "quantum.h"
7
8#ifdef RGBLIGHT_ENABLE
9//rgb led driver
10#include "ws2812.h"
11#endif
12
13#ifdef USE_I2C
14#include <stddef.h>
15#ifdef __AVR__
16 #include <avr/io.h>
17 #include <avr/interrupt.h>
18#endif
19#endif
20
21//void promicro_bootloader_jmp(bool program);
22#define LAYOUT( \
23 L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \
24 L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \
25 L20, L21, L22, L23, L24, L25, R20, R21, R22, R23, R24, R25, \
26 L30, L31, L32, L33, L34, L35, LT4, LT5, RT5, RT4, R30, R31, R32, R33, R34, R35, \
27 LT1, LT2, LT3, RT3, RT2, RT1 \
28 ) \
29 { \
30 { L00, L01, L02, L03, L04, L05 }, \
31 { L10, L11, L12, L13, L14, L15 }, \
32 { L20, L21, L22, L23, L24, L25 }, \
33 { L30, L31, L32, L33, L34, L35 }, \
34 { KC_NO, LT1, LT2, LT3, LT4, LT5 }, \
35 { R05, R04, R03, R02, R01, R00 }, \
36 { R15, R14, R13, R12, R11, R10 }, \
37 { R25, R24, R23, R22, R21, R20 }, \
38 { R35, R34, R33, R32, R31, R30 }, \
39 { KC_NO, RT1,RT2, RT3, RT4, RT5 }, \
40 }
diff --git a/keyboards/yosino58/rev1/rules.mk b/keyboards/yosino58/rev1/rules.mk
new file mode 100644
index 000000000..6028b5a5b
--- /dev/null
+++ b/keyboards/yosino58/rev1/rules.mk
@@ -0,0 +1,3 @@
1SRC += rev1/matrix.c
2SRC += rev1/split_util.c
3SRC += rev1/split_scomm.c
diff --git a/keyboards/yosino58/rev1/serial_config.h b/keyboards/yosino58/rev1/serial_config.h
new file mode 100644
index 000000000..4fab8e8dd
--- /dev/null
+++ b/keyboards/yosino58/rev1/serial_config.h
@@ -0,0 +1,4 @@
1#ifndef SOFT_SERIAL_PIN
2#define SOFT_SERIAL_PIN D2
3#define SERIAL_USE_MULTI_TRANSACTION
4#endif
diff --git a/keyboards/yosino58/rev1/serial_config_simpleapi.h b/keyboards/yosino58/rev1/serial_config_simpleapi.h
new file mode 100644
index 000000000..0e1dd9e4a
--- /dev/null
+++ b/keyboards/yosino58/rev1/serial_config_simpleapi.h
@@ -0,0 +1,5 @@
1#pragma once
2
3#undef SERIAL_USE_MULTI_TRANSACTION
4#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2
5#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2
diff --git a/keyboards/yosino58/rev1/split_scomm.c b/keyboards/yosino58/rev1/split_scomm.c
new file mode 100644
index 000000000..a1fe6ba5b
--- /dev/null
+++ b/keyboards/yosino58/rev1/split_scomm.c
@@ -0,0 +1,91 @@
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/yosino58/rev1/split_scomm.h b/keyboards/yosino58/rev1/split_scomm.h
new file mode 100644
index 000000000..873d8939d
--- /dev/null
+++ b/keyboards/yosino58/rev1/split_scomm.h
@@ -0,0 +1,24 @@
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/yosino58/rev1/split_util.c b/keyboards/yosino58/rev1/split_util.c
new file mode 100644
index 000000000..e1ff8b437
--- /dev/null
+++ b/keyboards/yosino58/rev1/split_util.c
@@ -0,0 +1,70 @@
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/yosino58/rev1/split_util.h b/keyboards/yosino58/rev1/split_util.h
new file mode 100644
index 000000000..687ca19bd
--- /dev/null
+++ b/keyboards/yosino58/rev1/split_util.h
@@ -0,0 +1,19 @@
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/yosino58/rules.mk b/keyboards/yosino58/rules.mk
new file mode 100644
index 000000000..f2934454d
--- /dev/null
+++ b/keyboards/yosino58/rules.mk
@@ -0,0 +1,76 @@
1SRC += i2c.c
2SRC += serial.c
3SRC += ssd1306.c
4
5# if firmware size over limit, try this option
6# CFLAGS += -flto
7
8# MCU name
9#MCU = at90usb1287
10MCU = atmega32u4
11
12# Processor frequency.
13# This will define a symbol, F_CPU, in all source code files equal to the
14# processor frequency in Hz. You can then use this symbol in your source code to
15# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
16# automatically to create a 32-bit value in your source code.
17#
18# This will be an integer division of F_USB below, as it is sourced by
19# F_USB after it has run through any CPU prescalers. Note that this value
20# does not *change* the processor frequency - it should merely be updated to
21# reflect the processor speed set externally so that the code can use accurate
22# software delays.
23F_CPU = 16000000
24
25#
26# LUFA specific
27#
28# Target architecture (see library "Board Types" documentation).
29ARCH = AVR8
30
31# Input clock frequency.
32# This will define a symbol, F_USB, in all source code files equal to the
33# input clock frequency (before any prescaling is performed) in Hz. This value may
34# differ from F_CPU if prescaling is used on the latter, and is required as the
35# raw input clock is fed directly to the PLL sections of the AVR for high speed
36# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
37# at the end, this will be done automatically to create a 32-bit value in your
38# source code.
39#
40# If no clock division is performed on the input clock inside the AVR (via the
41# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
42F_USB = $(F_CPU)
43
44# Bootloader
45# This definition is optional, and if your keyboard supports multiple bootloaders of
46# different sizes, comment this out, and the correct address will be loaded
47# automatically (+60). See bootloader.mk for all options.
48BOOTLOADER = caterina
49
50# Interrupt driven control endpoint task(+60)
51OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
52
53# Build Options
54# change to "no" to disable the options, or define them in the Makefile in
55# the appropriate keymap folder that will get included automatically
56#
57BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000)
58MOUSEKEY_ENABLE = no # Mouse keys(+4700)
59EXTRAKEY_ENABLE = no # Audio control and System control(+450)
60CONSOLE_ENABLE = no # Console for debug(+400)
61COMMAND_ENABLE = no # Commands for debug and configuration
62NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
63BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality
64MIDI_ENABLE = no # MIDI controls
65AUDIO_ENABLE = no # Audio output on port C6
66UNICODE_ENABLE = no # Unicode
67BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID
68RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight.
69SUBPROJECT_rev1 = no
70USE_I2C = yes
71# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE
72SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend
73
74CUSTOM_MATRIX = yes
75
76DEFAULT_FOLDER = yosino58/rev1
diff --git a/keyboards/yosino58/serial.c b/keyboards/yosino58/serial.c
new file mode 100644
index 000000000..325c29a3f
--- /dev/null
+++ b/keyboards/yosino58/serial.c
@@ -0,0 +1,590 @@
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//#include <pro_micro.h>
21
22#ifdef SOFT_SERIAL_PIN
23
24#ifdef __AVR_ATmega32U4__
25 // if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial.
26 #ifdef USE_I2C
27 #if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1
28 #error Using ATmega32U4 I2C, so can not use PD0, PD1
29 #endif
30 #endif
31
32 #if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3
33 #define SERIAL_PIN_DDR DDRD
34 #define SERIAL_PIN_PORT PORTD
35 #define SERIAL_PIN_INPUT PIND
36 #if SOFT_SERIAL_PIN == D0
37 #define SERIAL_PIN_MASK _BV(PD0)
38 #define EIMSK_BIT _BV(INT0)
39 #define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01)))
40 #define SERIAL_PIN_INTERRUPT INT0_vect
41 #elif SOFT_SERIAL_PIN == D1
42 #define SERIAL_PIN_MASK _BV(PD1)
43 #define EIMSK_BIT _BV(INT1)
44 #define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11)))
45 #define SERIAL_PIN_INTERRUPT INT1_vect
46 #elif SOFT_SERIAL_PIN == D2
47 #define SERIAL_PIN_MASK _BV(PD2)
48 #define EIMSK_BIT _BV(INT2)
49 #define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21)))
50 #define SERIAL_PIN_INTERRUPT INT2_vect
51 #elif SOFT_SERIAL_PIN == D3
52 #define SERIAL_PIN_MASK _BV(PD3)
53 #define EIMSK_BIT _BV(INT3)
54 #define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31)))
55 #define SERIAL_PIN_INTERRUPT INT3_vect
56 #endif
57 #elif SOFT_SERIAL_PIN == E6
58 #define SERIAL_PIN_DDR DDRE
59 #define SERIAL_PIN_PORT PORTE
60 #define SERIAL_PIN_INPUT PINE
61 #define SERIAL_PIN_MASK _BV(PE6)
62 #define EIMSK_BIT _BV(INT6)
63 #define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61)))
64 #define SERIAL_PIN_INTERRUPT INT6_vect
65 #else
66 #error invalid SOFT_SERIAL_PIN value
67 #endif
68
69#else
70 #error serial.c now support ATmega32U4 only
71#endif
72
73//////////////// for backward compatibility ////////////////////////////////
74#ifndef SERIAL_USE_MULTI_TRANSACTION
75/* --- USE Simple API (OLD API, compatible with let's split serial.c) */
76 #if SERIAL_SLAVE_BUFFER_LENGTH > 0
77 uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0};
78 #endif
79 #if SERIAL_MASTER_BUFFER_LENGTH > 0
80 uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0};
81 #endif
82 uint8_t volatile status0 = 0;
83
84SSTD_t transactions[] = {
85 { (uint8_t *)&status0,
86 #if SERIAL_MASTER_BUFFER_LENGTH > 0
87 sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer,
88 #else
89 0, (uint8_t *)NULL,
90 #endif
91 #if SERIAL_SLAVE_BUFFER_LENGTH > 0
92 sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer
93 #else
94 0, (uint8_t *)NULL,
95 #endif
96 }
97};
98
99void serial_master_init(void)
100{ soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); }
101
102void serial_slave_init(void)
103{ soft_serial_target_init(transactions, TID_LIMIT(transactions)); }
104
105// 0 => no error
106// 1 => slave did not respond
107// 2 => checksum error
108int serial_update_buffers()
109{
110 int result;
111 result = soft_serial_transaction();
112 return result;
113}
114
115#endif // end of Simple API (OLD API, compatible with let's split serial.c)
116////////////////////////////////////////////////////////////////////////////
117
118#define ALWAYS_INLINE __attribute__((always_inline))
119#define NO_INLINE __attribute__((noinline))
120#define _delay_sub_us(x) __builtin_avr_delay_cycles(x)
121
122// parity check
123#define ODD_PARITY 1
124#define EVEN_PARITY 0
125#define PARITY EVEN_PARITY
126
127#ifdef SERIAL_DELAY
128 // custom setup in config.h
129 // #define TID_SEND_ADJUST 2
130 // #define SERIAL_DELAY 6 // micro sec
131 // #define READ_WRITE_START_ADJUST 30 // cycles
132 // #define READ_WRITE_WIDTH_ADJUST 8 // cycles
133#else
134// ============ Standard setups ============
135
136#ifndef SELECT_SOFT_SERIAL_SPEED
137#define SELECT_SOFT_SERIAL_SPEED 1
138// 0: about 189kbps
139// 1: about 137kbps (default)
140// 2: about 75kbps
141// 3: about 39kbps
142// 4: about 26kbps
143// 5: about 20kbps
144#endif
145
146#if __GNUC__ < 6
147 #define TID_SEND_ADJUST 14
148#else
149 #define TID_SEND_ADJUST 2
150#endif
151
152#if SELECT_SOFT_SERIAL_SPEED == 0
153 // Very High speed
154 #define SERIAL_DELAY 4 // micro sec
155 #if __GNUC__ < 6
156 #define READ_WRITE_START_ADJUST 33 // cycles
157 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
158 #else
159 #define READ_WRITE_START_ADJUST 34 // cycles
160 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
161 #endif
162#elif SELECT_SOFT_SERIAL_SPEED == 1
163 // High speed
164 #define SERIAL_DELAY 6 // micro sec
165 #if __GNUC__ < 6
166 #define READ_WRITE_START_ADJUST 30 // cycles
167 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
168 #else
169 #define READ_WRITE_START_ADJUST 33 // cycles
170 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
171 #endif
172#elif SELECT_SOFT_SERIAL_SPEED == 2
173 // Middle speed
174 #define SERIAL_DELAY 12 // micro sec
175 #define READ_WRITE_START_ADJUST 30 // cycles
176 #if __GNUC__ < 6
177 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
178 #else
179 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
180 #endif
181#elif SELECT_SOFT_SERIAL_SPEED == 3
182 // Low speed
183 #define SERIAL_DELAY 24 // micro sec
184 #define READ_WRITE_START_ADJUST 30 // cycles
185 #if __GNUC__ < 6
186 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
187 #else
188 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
189 #endif
190#elif SELECT_SOFT_SERIAL_SPEED == 4
191 // Very Low speed
192 #define SERIAL_DELAY 36 // micro sec
193 #define READ_WRITE_START_ADJUST 30 // cycles
194 #if __GNUC__ < 6
195 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
196 #else
197 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
198 #endif
199#elif SELECT_SOFT_SERIAL_SPEED == 5
200 // Ultra Low speed
201 #define SERIAL_DELAY 48 // micro sec
202 #define READ_WRITE_START_ADJUST 30 // cycles
203 #if __GNUC__ < 6
204 #define READ_WRITE_WIDTH_ADJUST 3 // cycles
205 #else
206 #define READ_WRITE_WIDTH_ADJUST 7 // cycles
207 #endif
208#else
209#error invalid SELECT_SOFT_SERIAL_SPEED value
210#endif /* SELECT_SOFT_SERIAL_SPEED */
211#endif /* SERIAL_DELAY */
212
213#define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2)
214#define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2)
215
216#define SLAVE_INT_WIDTH_US 1
217#ifndef SERIAL_USE_MULTI_TRANSACTION
218 #define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY
219#else
220 #define SLAVE_INT_ACK_WIDTH_UNIT 2
221 #define SLAVE_INT_ACK_WIDTH 4
222#endif
223
224static SSTD_t *Transaction_table = NULL;
225static uint8_t Transaction_table_size = 0;
226
227inline static void serial_delay(void) ALWAYS_INLINE;
228inline static
229void serial_delay(void) {
230 _delay_us(SERIAL_DELAY);
231}
232
233inline static void serial_delay_half1(void) ALWAYS_INLINE;
234inline static
235void serial_delay_half1(void) {
236 _delay_us(SERIAL_DELAY_HALF1);
237}
238
239inline static void serial_delay_half2(void) ALWAYS_INLINE;
240inline static
241void serial_delay_half2(void) {
242 _delay_us(SERIAL_DELAY_HALF2);
243}
244
245inline static void serial_output(void) ALWAYS_INLINE;
246inline static
247void serial_output(void) {
248 SERIAL_PIN_DDR |= SERIAL_PIN_MASK;
249}
250
251// make the serial pin an input with pull-up resistor
252inline static void serial_input_with_pullup(void) ALWAYS_INLINE;
253inline static
254void serial_input_with_pullup(void) {
255 SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK;
256 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
257}
258
259inline static uint8_t serial_read_pin(void) ALWAYS_INLINE;
260inline static
261uint8_t serial_read_pin(void) {
262 return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK);
263}
264
265inline static void serial_low(void) ALWAYS_INLINE;
266inline static
267void serial_low(void) {
268 SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK;
269}
270
271inline static void serial_high(void) ALWAYS_INLINE;
272inline static
273void serial_high(void) {
274 SERIAL_PIN_PORT |= SERIAL_PIN_MASK;
275}
276
277void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size)
278{
279 Transaction_table = sstd_table;
280 Transaction_table_size = (uint8_t)sstd_table_size;
281 serial_output();
282 serial_high();
283}
284
285void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size)
286{
287 Transaction_table = sstd_table;
288 Transaction_table_size = (uint8_t)sstd_table_size;
289 serial_input_with_pullup();
290
291 // Enable INT0-INT3,INT6
292 EIMSK |= EIMSK_BIT;
293#if SERIAL_PIN_MASK == _BV(PE6)
294 // Trigger on falling edge of INT6
295 EICRB &= EICRx_BIT;
296#else
297 // Trigger on falling edge of INT0-INT3
298 EICRA &= EICRx_BIT;
299#endif
300}
301
302// Used by the sender to synchronize timing with the reciver.
303static void sync_recv(void) NO_INLINE;
304static
305void sync_recv(void) {
306 for (uint8_t i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) {
307 }
308 // This shouldn't hang if the target disconnects because the
309 // serial line will float to high if the target does disconnect.
310 while (!serial_read_pin());
311}
312
313// Used by the reciver to send a synchronization signal to the sender.
314static void sync_send(void) NO_INLINE;
315static
316void sync_send(void) {
317 serial_low();
318 serial_delay();
319 serial_high();
320}
321
322// Reads a byte from the serial line
323static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) NO_INLINE;
324static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) {
325 uint8_t byte, i, p, pb;
326
327 _delay_sub_us(READ_WRITE_START_ADJUST);
328 for( i = 0, byte = 0, p = PARITY; i < bit; i++ ) {
329 serial_delay_half1(); // read the middle of pulses
330 if( serial_read_pin() ) {
331 byte = (byte << 1) | 1; p ^= 1;
332 } else {
333 byte = (byte << 1) | 0; p ^= 0;
334 }
335 _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
336 serial_delay_half2();
337 }
338 /* recive parity bit */
339 serial_delay_half1(); // read the middle of pulses
340 pb = serial_read_pin();
341 _delay_sub_us(READ_WRITE_WIDTH_ADJUST);
342 serial_delay_half2();
343
344 *pterrcount += (p != pb)? 1 : 0;
345
346 return byte;
347}
348
349// Sends a byte with MSB ordering
350void serial_write_chunk(uint8_t data, uint8_t bit) NO_INLINE;
351void serial_write_chunk(uint8_t data, uint8_t bit) {
352 uint8_t b, p;
353 for( p = PARITY, b = 1<<(bit-1); b ; b >>= 1) {
354 if(data & b) {
355 serial_high(); p ^= 1;
356 } else {
357 serial_low(); p ^= 0;
358 }
359 serial_delay();
360 }
361 /* send parity bit */
362 if(p & 1) { serial_high(); }
363 else { serial_low(); }
364 serial_delay();
365
366 serial_low(); // sync_send() / senc_recv() need raise edge
367}
368
369static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
370static
371void serial_send_packet(uint8_t *buffer, uint8_t size) {
372 for (uint8_t i = 0; i < size; ++i) {
373 uint8_t data;
374 data = buffer[i];
375 sync_send();
376 serial_write_chunk(data,8);
377 }
378}
379
380static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) NO_INLINE;
381static
382uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) {
383 uint8_t pecount = 0;
384 for (uint8_t i = 0; i < size; ++i) {
385 uint8_t data;
386 sync_recv();
387 data = serial_read_chunk(&pecount, 8);
388 buffer[i] = data;
389 }
390 return pecount == 0;
391}
392
393inline static
394void change_sender2reciver(void) {
395 sync_send(); //0
396 serial_delay_half1(); //1
397 serial_low(); //2
398 serial_input_with_pullup(); //2
399 serial_delay_half1(); //3
400}
401
402inline static
403void change_reciver2sender(void) {
404 sync_recv(); //0
405 serial_delay(); //1
406 serial_low(); //3
407 serial_output(); //3
408 serial_delay_half1(); //4
409}
410
411static inline uint8_t nibble_bits_count(uint8_t bits)
412{
413 bits = (bits & 0x5) + (bits >> 1 & 0x5);
414 bits = (bits & 0x3) + (bits >> 2 & 0x3);
415 return bits;
416}
417
418// interrupt handle to be used by the target device
419ISR(SERIAL_PIN_INTERRUPT) {
420
421#ifndef SERIAL_USE_MULTI_TRANSACTION
422 serial_low();
423 serial_output();
424 SSTD_t *trans = Transaction_table;
425#else
426 // recive transaction table index
427 uint8_t tid, bits;
428 uint8_t pecount = 0;
429 sync_recv();
430 bits = serial_read_chunk(&pecount,7);
431 tid = bits>>3;
432 bits = (bits&7) != nibble_bits_count(tid);
433 if( bits || pecount> 0 || tid > Transaction_table_size ) {
434 return;
435 }
436 serial_delay_half1();
437
438 serial_high(); // response step1 low->high
439 serial_output();
440 _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT*SLAVE_INT_ACK_WIDTH);
441 SSTD_t *trans = &Transaction_table[tid];
442 serial_low(); // response step2 ack high->low
443#endif
444
445 // target send phase
446 if( trans->target2initiator_buffer_size > 0 )
447 serial_send_packet((uint8_t *)trans->target2initiator_buffer,
448 trans->target2initiator_buffer_size);
449 // target switch to input
450 change_sender2reciver();
451
452 // target recive phase
453 if( trans->initiator2target_buffer_size > 0 ) {
454 if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer,
455 trans->initiator2target_buffer_size) ) {
456 *trans->status = TRANSACTION_ACCEPTED;
457 } else {
458 *trans->status = TRANSACTION_DATA_ERROR;
459 }
460 } else {
461 *trans->status = TRANSACTION_ACCEPTED;
462 }
463
464 sync_recv(); //weit initiator output to high
465}
466
467/////////
468// start transaction by initiator
469//
470// int soft_serial_transaction(int sstd_index)
471//
472// Returns:
473// TRANSACTION_END
474// TRANSACTION_NO_RESPONSE
475// TRANSACTION_DATA_ERROR
476// this code is very time dependent, so we need to disable interrupts
477#ifndef SERIAL_USE_MULTI_TRANSACTION
478int soft_serial_transaction(void) {
479 SSTD_t *trans = Transaction_table;
480#else
481int soft_serial_transaction(int sstd_index) {
482 if( sstd_index > Transaction_table_size )
483 return TRANSACTION_TYPE_ERROR;
484 SSTD_t *trans = &Transaction_table[sstd_index];
485#endif
486 cli();
487
488 // signal to the target that we want to start a transaction
489 serial_output();
490 serial_low();
491 _delay_us(SLAVE_INT_WIDTH_US);
492
493#ifndef SERIAL_USE_MULTI_TRANSACTION
494 // wait for the target response
495 serial_input_with_pullup();
496 _delay_us(SLAVE_INT_RESPONSE_TIME);
497
498 // check if the target is present
499 if (serial_read_pin()) {
500 // target failed to pull the line low, assume not present
501 serial_output();
502 serial_high();
503 *trans->status = TRANSACTION_NO_RESPONSE;
504 sei();
505 return TRANSACTION_NO_RESPONSE;
506 }
507
508#else
509 // send transaction table index
510 int tid = (sstd_index<<3) | (7 & nibble_bits_count(sstd_index));
511 sync_send();
512 _delay_sub_us(TID_SEND_ADJUST);
513 serial_write_chunk(tid, 7);
514 serial_delay_half1();
515
516 // wait for the target response (step1 low->high)
517 serial_input_with_pullup();
518 while( !serial_read_pin() ) {
519 _delay_sub_us(2);
520 }
521
522 // check if the target is present (step2 high->low)
523 for( int i = 0; serial_read_pin(); i++ ) {
524 if (i > SLAVE_INT_ACK_WIDTH + 1) {
525 // slave failed to pull the line low, assume not present
526 serial_output();
527 serial_high();
528 *trans->status = TRANSACTION_NO_RESPONSE;
529 sei();
530 return TRANSACTION_NO_RESPONSE;
531 }
532 _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT);
533 }
534#endif
535
536 // initiator recive phase
537 // if the target is present syncronize with it
538 if( trans->target2initiator_buffer_size > 0 ) {
539 if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer,
540 trans->target2initiator_buffer_size) ) {
541 serial_output();
542 serial_high();
543 *trans->status = TRANSACTION_DATA_ERROR;
544 sei();
545 return TRANSACTION_DATA_ERROR;
546 }
547 }
548
549 // initiator switch to output
550 change_reciver2sender();
551
552 // initiator send phase
553 if( trans->initiator2target_buffer_size > 0 ) {
554 serial_send_packet((uint8_t *)trans->initiator2target_buffer,
555 trans->initiator2target_buffer_size);
556 }
557
558 // always, release the line when not in use
559 sync_send();
560
561 *trans->status = TRANSACTION_END;
562 sei();
563 return TRANSACTION_END;
564}
565
566#ifdef SERIAL_USE_MULTI_TRANSACTION
567int soft_serial_get_and_clean_status(int sstd_index) {
568 SSTD_t *trans = &Transaction_table[sstd_index];
569 cli();
570 int retval = *trans->status;
571 *trans->status = 0;;
572 sei();
573 return retval;
574}
575#endif
576
577#endif
578
579// Helix serial.c history
580// 2018-1-29 fork from let's split and add PD2, modify sync_recv() (#2308, bceffdefc)
581// 2018-6-28 bug fix master to slave comm and speed up (#3255, 1038bbef4)
582// (adjusted with avr-gcc 4.9.2)
583// 2018-7-13 remove USE_SERIAL_PD2 macro (#3374, f30d6dd78)
584// (adjusted with avr-gcc 4.9.2)
585// 2018-8-11 add support multi-type transaction (#3608, feb5e4aae)
586// (adjusted with avr-gcc 4.9.2)
587// 2018-10-21 fix serial and RGB animation conflict (#4191, 4665e4fff)
588// (adjusted with avr-gcc 7.3.0)
589// 2018-10-28 re-adjust compiler depend value of delay (#4269, 8517f8a66)
590// (adjusted with avr-gcc 5.4.0, 7.3.0)
diff --git a/keyboards/yosino58/serial.h b/keyboards/yosino58/serial.h
new file mode 100644
index 000000000..7e0c0847a
--- /dev/null
+++ b/keyboards/yosino58/serial.h
@@ -0,0 +1,84 @@
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/yosino58/ssd1306.c b/keyboards/yosino58/ssd1306.c
new file mode 100644
index 000000000..70b7301b3
--- /dev/null
+++ b/keyboards/yosino58/ssd1306.c
@@ -0,0 +1,348 @@
1#ifdef SSD1306OLED
2
3#include "ssd1306.h"
4#include "i2c.h"
5#include <string.h>
6#include "print.h"
7#ifdef ADAFRUIT_BLE_ENABLE
8#include "adafruit_ble.h"
9#endif
10#ifdef PROTOCOL_LUFA
11#include "lufa.h"
12#endif
13#include "sendchar.h"
14#include "timer.h"
15
16static const unsigned char font[] PROGMEM;
17
18// Set this to 1 to help diagnose early startup problems
19// when testing power-on with ble. Turn it off otherwise,
20// as the latency of printing most of the debug info messes
21// with the matrix scan, causing keys to drop.
22#define DEBUG_TO_SCREEN 0
23
24//static uint16_t last_battery_update;
25//static uint32_t vbat;
26//#define BatteryUpdateInterval 10000 /* milliseconds */
27
28// 'last_flush' is declared as uint16_t,
29// so this must be less than 65535
30#define ScreenOffInterval 30000 /* milliseconds */
31#if DEBUG_TO_SCREEN
32static uint8_t displaying;
33#endif
34static uint16_t last_flush;
35
36static bool force_dirty = true;
37
38// Write command sequence.
39// Returns true on success.
40static inline bool _send_cmd1(uint8_t cmd) {
41 bool res = false;
42
43 if (i2c_start_write(SSD1306_ADDRESS)) {
44 xprintf("failed to start write to %d\n", SSD1306_ADDRESS);
45 goto done;
46 }
47
48 if (i2c_master_write(0x0 /* command byte follows */)) {
49 print("failed to write control byte\n");
50
51 goto done;
52 }
53
54 if (i2c_master_write(cmd)) {
55 xprintf("failed to write command %d\n", cmd);
56 goto done;
57 }
58 res = true;
59done:
60 i2c_master_stop();
61 return res;
62}
63
64// Write 2-byte command sequence.
65// Returns true on success
66static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) {
67 if (!_send_cmd1(cmd)) {
68 return false;
69 }
70 return _send_cmd1(opr);
71}
72
73// Write 3-byte command sequence.
74// Returns true on success
75static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) {
76 if (!_send_cmd1(cmd)) {
77 return false;
78 }
79 if (!_send_cmd1(opr1)) {
80 return false;
81 }
82 return _send_cmd1(opr2);
83}
84
85#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;}
86#define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;}
87#define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;}
88
89static void clear_display(void) {
90 matrix_clear(&display);
91
92 // Clear all of the display bits (there can be random noise
93 // in the RAM on startup)
94 send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1);
95 send_cmd3(ColumnAddr, 0, DisplayWidth - 1);
96
97 if (i2c_start_write(SSD1306_ADDRESS)) {
98 goto done;
99 }
100 if (i2c_master_write(0x40)) {
101 // Data mode
102 goto done;
103 }
104 for (uint8_t row = 0; row < MatrixRows; ++row) {
105 for (uint8_t col = 0; col < DisplayWidth; ++col) {
106 i2c_master_write(0);
107 }
108 }
109
110 display.dirty = false;
111
112done:
113 i2c_master_stop();
114}
115
116#if DEBUG_TO_SCREEN
117#undef sendchar
118static int8_t capture_sendchar(uint8_t c) {
119 sendchar(c);
120 iota_gfx_write_char(c);
121
122 if (!displaying) {
123 iota_gfx_flush();
124 }
125 return 0;
126}
127#endif
128
129bool iota_gfx_init(bool rotate) {
130 bool success = false;
131
132 i2c_master_init();
133 send_cmd1(DisplayOff);
134 send_cmd2(SetDisplayClockDiv, 0x80);
135 send_cmd2(SetMultiPlex, DisplayHeight - 1);
136
137 send_cmd2(SetDisplayOffset, 0);
138
139
140 send_cmd1(SetStartLine | 0x0);
141 send_cmd2(SetChargePump, 0x14 /* Enable */);
142 send_cmd2(SetMemoryMode, 0 /* horizontal addressing */);
143
144 if(rotate){
145 // the following Flip the display orientation 180 degrees
146 send_cmd1(SegRemap);
147 send_cmd1(ComScanInc);
148 }else{
149 // Flips the display orientation 0 degrees
150 send_cmd1(SegRemap | 0x1);
151 send_cmd1(ComScanDec);
152 }
153
154#ifdef SSD1306_128X64
155 send_cmd2(SetComPins, 0x12);
156#else
157 send_cmd2(SetComPins, 0x2);
158#endif
159 send_cmd2(SetContrast, 0x8f);
160 send_cmd2(SetPreCharge, 0xf1);
161 send_cmd2(SetVComDetect, 0x40);
162 send_cmd1(DisplayAllOnResume);
163 send_cmd1(NormalDisplay);
164 send_cmd1(DeActivateScroll);
165 send_cmd1(DisplayOn);
166
167 send_cmd2(SetContrast, 0); // Dim
168
169 clear_display();
170
171 success = true;
172
173 iota_gfx_flush();
174
175#if DEBUG_TO_SCREEN
176 print_set_sendchar(capture_sendchar);
177#endif
178
179done:
180 return success;
181}
182
183bool iota_gfx_off(void) {
184 bool success = false;
185
186 send_cmd1(DisplayOff);
187 success = true;
188
189done:
190 return success;
191}
192
193bool iota_gfx_on(void) {
194 bool success = false;
195
196 send_cmd1(DisplayOn);
197 success = true;
198
199done:
200 return success;
201}
202
203void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) {
204 *matrix->cursor = c;
205 ++matrix->cursor;
206
207 if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) {
208 // We went off the end; scroll the display upwards by one line
209 memmove(&matrix->display[0], &matrix->display[1],
210 MatrixCols * (MatrixRows - 1));
211 matrix->cursor = &matrix->display[MatrixRows - 1][0];
212 memset(matrix->cursor, ' ', MatrixCols);
213 }
214}
215
216void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) {
217 matrix->dirty = true;
218
219 if (c == '\n') {
220 // Clear to end of line from the cursor and then move to the
221 // start of the next line
222 uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols;
223
224 while (cursor_col++ < MatrixCols) {
225 matrix_write_char_inner(matrix, ' ');
226 }
227 return;
228 }
229
230 matrix_write_char_inner(matrix, c);
231}
232
233void iota_gfx_write_char(uint8_t c) {
234 matrix_write_char(&display, c);
235}
236
237void matrix_write(struct CharacterMatrix *matrix, const char *data) {
238 const char *end = data + strlen(data);
239 while (data < end) {
240 matrix_write_char(matrix, *data);
241 ++data;
242 }
243}
244
245void matrix_write_ln(struct CharacterMatrix *matrix, const char *data) {
246 char data_ln[strlen(data)+2];
247 snprintf(data_ln, sizeof(data_ln), "%s\n", data);
248 matrix_write(matrix, data_ln);
249}
250
251void iota_gfx_write(const char *data) {
252 matrix_write(&display, data);
253}
254
255void matrix_write_P(struct CharacterMatrix *matrix, const char *data) {
256 while (true) {
257 uint8_t c = pgm_read_byte(data);
258 if (c == 0) {
259 return;
260 }
261 matrix_write_char(matrix, c);
262 ++data;
263 }
264}
265
266void iota_gfx_write_P(const char *data) {
267 matrix_write_P(&display, data);
268}
269
270void matrix_clear(struct CharacterMatrix *matrix) {
271 memset(matrix->display, ' ', sizeof(matrix->display));
272 matrix->cursor = &matrix->display[0][0];
273 matrix->dirty = true;
274}
275
276void iota_gfx_clear_screen(void) {
277 matrix_clear(&display);
278}
279
280void matrix_render(struct CharacterMatrix *matrix) {
281 last_flush = timer_read();
282 iota_gfx_on();
283#if DEBUG_TO_SCREEN
284 ++displaying;
285#endif
286
287 // Move to the home position
288 send_cmd3(PageAddr, 0, MatrixRows - 1);
289 send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1);
290
291 if (i2c_start_write(SSD1306_ADDRESS)) {
292 goto done;
293 }
294 if (i2c_master_write(0x40)) {
295 // Data mode
296 goto done;
297 }
298
299 for (uint8_t row = 0; row < MatrixRows; ++row) {
300 for (uint8_t col = 0; col < MatrixCols; ++col) {
301 const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth);
302
303 for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) {
304 uint8_t colBits = pgm_read_byte(glyph + glyphCol);
305 i2c_master_write(colBits);
306 }
307
308 // 1 column of space between chars (it's not included in the glyph)
309 //i2c_master_write(0);
310 }
311 }
312
313 matrix->dirty = false;
314
315done:
316 i2c_master_stop();
317#if DEBUG_TO_SCREEN
318 --displaying;
319#endif
320}
321
322void iota_gfx_flush(void) {
323 matrix_render(&display);
324}
325
326__attribute__ ((weak))
327void iota_gfx_task_user(void) {
328}
329
330void iota_gfx_task(void) {
331 iota_gfx_task_user();
332
333 if (display.dirty|| force_dirty) {
334 iota_gfx_flush();
335 force_dirty = false;
336 }
337
338 if (timer_elapsed(last_flush) > ScreenOffInterval) {
339 iota_gfx_off();
340 }
341}
342
343bool process_record_gfx(uint16_t keycode, keyrecord_t *record) {
344 force_dirty = true;
345 return true;
346}
347
348#endif
diff --git a/keyboards/yosino58/ssd1306.h b/keyboards/yosino58/ssd1306.h
new file mode 100644
index 000000000..de0a9a02a
--- /dev/null
+++ b/keyboards/yosino58/ssd1306.h
@@ -0,0 +1,96 @@
1#pragma once
2
3#include <stdbool.h>
4#include <stdio.h>
5#include "pincontrol.h"
6#include "action.h"
7
8enum ssd1306_cmds {
9 DisplayOff = 0xAE,
10 DisplayOn = 0xAF,
11
12 SetContrast = 0x81,
13 DisplayAllOnResume = 0xA4,
14
15 DisplayAllOn = 0xA5,
16 NormalDisplay = 0xA6,
17 InvertDisplay = 0xA7,
18 SetDisplayOffset = 0xD3,
19 SetComPins = 0xda,
20 SetVComDetect = 0xdb,
21 SetDisplayClockDiv = 0xD5,
22 SetPreCharge = 0xd9,
23 SetMultiPlex = 0xa8,
24 SetLowColumn = 0x00,
25 SetHighColumn = 0x10,
26 SetStartLine = 0x40,
27
28 SetMemoryMode = 0x20,
29 ColumnAddr = 0x21,
30 PageAddr = 0x22,
31
32 ComScanInc = 0xc0,
33 ComScanDec = 0xc8,
34 SegRemap = 0xa0,
35 SetChargePump = 0x8d,
36 ExternalVcc = 0x01,
37 SwitchCapVcc = 0x02,
38
39 ActivateScroll = 0x2f,
40 DeActivateScroll = 0x2e,
41 SetVerticalScrollArea = 0xa3,
42 RightHorizontalScroll = 0x26,
43 LeftHorizontalScroll = 0x27,
44 VerticalAndRightHorizontalScroll = 0x29,
45 VerticalAndLeftHorizontalScroll = 0x2a,
46};
47
48// Controls the SSD1306 128x32 OLED display via i2c
49
50#ifndef SSD1306_ADDRESS
51#define SSD1306_ADDRESS 0x3C
52#endif
53
54#ifdef SSD1306_128X64
55#define DisplayHeight 64
56#else
57#define DisplayHeight 32
58#endif
59#define DisplayWidth 128
60
61
62#define FontHeight 8
63#define FontWidth 6
64
65#define MatrixRows (DisplayHeight / FontHeight)
66#define MatrixCols (DisplayWidth / FontWidth)
67
68struct CharacterMatrix {
69 uint8_t display[MatrixRows][MatrixCols];
70 uint8_t *cursor;
71 bool dirty;
72};
73
74struct CharacterMatrix display;
75
76bool iota_gfx_init(bool rotate);
77void iota_gfx_task(void);
78bool iota_gfx_off(void);
79bool iota_gfx_on(void);
80void iota_gfx_flush(void);
81void iota_gfx_write_char(uint8_t c);
82void iota_gfx_write(const char *data);
83void iota_gfx_write_P(const char *data);
84void iota_gfx_clear_screen(void);
85
86void iota_gfx_task_user(void);
87
88void matrix_clear(struct CharacterMatrix *matrix);
89void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c);
90void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c);
91void matrix_write(struct CharacterMatrix *matrix, const char *data);
92void matrix_write_ln(struct CharacterMatrix *matrix, const char *data);
93void matrix_write_P(struct CharacterMatrix *matrix, const char *data);
94void matrix_render(struct CharacterMatrix *matrix);
95
96bool process_record_gfx(uint16_t keycode, keyrecord_t *record); \ No newline at end of file
diff --git a/keyboards/yosino58/yosino58.c b/keyboards/yosino58/yosino58.c
new file mode 100644
index 000000000..ff3ec10e5
--- /dev/null
+++ b/keyboards/yosino58/yosino58.c
@@ -0,0 +1,10 @@
1#include "yosino58.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/yosino58/yosino58.h b/keyboards/yosino58/yosino58.h
new file mode 100644
index 000000000..5414c31bd
--- /dev/null
+++ b/keyboards/yosino58/yosino58.h
@@ -0,0 +1,5 @@
1#pragma once
2
3#ifdef KEYBOARD_yosino58_rev1
4 #include "rev1.h"
5#endif