diff options
| author | James Young <18669334+noroadsleft@users.noreply.github.com> | 2020-05-30 13:14:59 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-30 13:14:59 -0700 |
| commit | fced377ac007d27f2650ccffbe0b18abcdcfe23d (patch) | |
| tree | bd5b141987394a5a16cfc416bfe2b9efdb14d067 /keyboards/lily58 | |
| parent | 7b8a013826ad90714a05ea522de53adf964ab3b9 (diff) | |
| download | qmk_firmware-fced377ac007d27f2650ccffbe0b18abcdcfe23d.tar.gz qmk_firmware-fced377ac007d27f2650ccffbe0b18abcdcfe23d.zip | |
2020 May 30 Breaking Changes Update (#9215)
* Branch point for 2020 May 30 Breaking Change
* Migrate `ACTION_LAYER_TOGGLE` to `TG()` (#8954)
* Migrate `ACTION_MODS_ONESHOT` to `OSM()` (#8957)
* Migrate `ACTION_DEFAULT_LAYER_SET` to `DF()` (#8958)
* Migrate `ACTION_LAYER_MODS` to `LM()` (#8959)
* Migrate `ACTION_MODS_TAP_KEY` to `MT()` (#8968)
* Convert V-USB usbdrv to a submodule (#8321)
* Unify Tap Hold functions and documentation (#8348)
* Changing board names to prevent confusion (#8412)
* Move the Keyboardio Model01 to a keyboardio/ subdir (#8499)
* Move spaceman keyboards (#8830)
* Migrate miscellaneous `fn_actions` entries (#8977)
* Migrate `ACTION_MODS_KEY` to chained mod keycodes (#8979)
* Organizing my keyboards (plaid, tartan, ergoinu) (#8537)
* Refactor Lily58 to use split_common (#6260)
* Refactor zinc to use split_common (#7114)
* Add a message if bin/qmk doesn't work (#9000)
* Fix conflicting types for 'tfp_printf' (#8269)
* Fixed RGB_DISABLE_AFTER_TIMEOUT to be seconds based & small internals cleanup (#6480)
* Refactor and updates to TKC1800 code (#8472)
* Switch to qmk forks for everything (#9019)
* audio refactor: replace deprecated PLAY_NOTE_ARRAY (#8484)
* Audio enable corrections (2/3) (#8903)
* Split HHKB to ANSI and JP layouts and Add VIA support for each (#8582)
* Audio enable corrections (Part 4) (#8974)
* Fix typo from PR7114 (#9171)
* Augment future branch Changelogs (#8978)
* Revert "Branch point for 2020 May 30 Breaking Change"
Diffstat (limited to 'keyboards/lily58')
28 files changed, 373 insertions, 975 deletions
diff --git a/keyboards/lily58/config.h b/keyboards/lily58/config.h index 50bf2beb3..0bdaa1f76 100644 --- a/keyboards/lily58/config.h +++ b/keyboards/lily58/config.h | |||
| @@ -19,10 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 19 | #pragma once | 19 | #pragma once |
| 20 | 20 | ||
| 21 | #include "config_common.h" | 21 | #include "config_common.h" |
| 22 | #include <serial_config.h> | ||
| 23 | 22 | ||
| 24 | #define USE_I2C | 23 | #ifndef SOFT_SERIAL_PIN |
| 25 | #define USE_SERIAL | 24 | #define SOFT_SERIAL_PIN D2 |
| 25 | #define SERIAL_USE_MULTI_TRANSACTION | ||
| 26 | #endif | ||
| 26 | 27 | ||
| 27 | #if !defined(NO_ACTION_MACRO) | 28 | #if !defined(NO_ACTION_MACRO) |
| 28 | #define NO_ACTION_MACRO | 29 | #define NO_ACTION_MACRO |
| @@ -30,3 +31,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 30 | #if !defined(NO_ACTION_FUNCTION) | 31 | #if !defined(NO_ACTION_FUNCTION) |
| 31 | #define NO_ACTION_FUNCTION | 32 | #define NO_ACTION_FUNCTION |
| 32 | #endif | 33 | #endif |
| 34 | |||
| 35 | #define DIODE_DIRECTION COL2ROW | ||
| 36 | |||
| 37 | // Use the lily version to get the Lily58 logo instead of the qmk logo | ||
| 38 | #define OLED_FONT_H "lib/glcdfont_lily.c" | ||
diff --git a/keyboards/lily58/i2c.c b/keyboards/lily58/i2c.c deleted file mode 100755 index 4bee5c639..000000000 --- a/keyboards/lily58/i2c.c +++ /dev/null | |||
| @@ -1,162 +0,0 @@ | |||
| 1 | #include <util/twi.h> | ||
| 2 | #include <avr/io.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | #include <avr/interrupt.h> | ||
| 5 | #include <util/twi.h> | ||
| 6 | #include <stdbool.h> | ||
| 7 | #include "i2c.h" | ||
| 8 | |||
| 9 | #ifdef USE_I2C | ||
| 10 | |||
| 11 | // Limits the amount of we wait for any one i2c transaction. | ||
| 12 | // Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is | ||
| 13 | // 9 bits, a single transaction will take around 90μs to complete. | ||
| 14 | // | ||
| 15 | // (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit | ||
| 16 | // poll loop takes at least 8 clock cycles to execute | ||
| 17 | #define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8 | ||
| 18 | |||
| 19 | #define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE) | ||
| 20 | |||
| 21 | volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
| 22 | |||
| 23 | static volatile uint8_t slave_buffer_pos; | ||
| 24 | static volatile bool slave_has_register_set = false; | ||
| 25 | |||
| 26 | // Wait for an i2c operation to finish | ||
| 27 | inline static | ||
| 28 | void 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) | ||
| 38 | void 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 | ||
| 50 | uint8_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. | ||
| 72 | void 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 | ||
| 83 | uint8_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 | ||
| 96 | uint8_t i2c_master_read(int ack) { | ||
| 97 | TWCR = (1<<TWINT) | (1<<TWEN) | (ack<<TWEA); | ||
| 98 | |||
| 99 | i2c_delay(); | ||
| 100 | return TWDR; | ||
| 101 | } | ||
| 102 | |||
| 103 | void i2c_reset_state(void) { | ||
| 104 | TWCR = 0; | ||
| 105 | } | ||
| 106 | |||
| 107 | void 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 | |||
| 116 | ISR(TWI_vect); | ||
| 117 | |||
| 118 | ISR(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/lily58/i2c.h b/keyboards/lily58/i2c.h deleted file mode 100755 index 710662c7a..000000000 --- a/keyboards/lily58/i2c.h +++ /dev/null | |||
| @@ -1,46 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <stdint.h> | ||
| 4 | |||
| 5 | #ifndef F_CPU | ||
| 6 | #define F_CPU 16000000UL | ||
| 7 | #endif | ||
| 8 | |||
| 9 | #define I2C_READ 1 | ||
| 10 | #define I2C_WRITE 0 | ||
| 11 | |||
| 12 | #define I2C_ACK 1 | ||
| 13 | #define I2C_NACK 0 | ||
| 14 | |||
| 15 | #define SLAVE_BUFFER_SIZE 0x10 | ||
| 16 | |||
| 17 | // i2c SCL clock frequency 400kHz | ||
| 18 | #define SCL_CLOCK 400000L | ||
| 19 | |||
| 20 | extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; | ||
| 21 | |||
| 22 | void i2c_master_init(void); | ||
| 23 | uint8_t i2c_master_start(uint8_t address); | ||
| 24 | void i2c_master_stop(void); | ||
| 25 | uint8_t i2c_master_write(uint8_t data); | ||
| 26 | uint8_t i2c_master_read(int); | ||
| 27 | void i2c_reset_state(void); | ||
| 28 | void i2c_slave_init(uint8_t address); | ||
| 29 | |||
| 30 | |||
| 31 | static inline unsigned char i2c_start_read(unsigned char addr) { | ||
| 32 | return i2c_master_start((addr << 1) | I2C_READ); | ||
| 33 | } | ||
| 34 | |||
| 35 | static inline unsigned char i2c_start_write(unsigned char addr) { | ||
| 36 | return i2c_master_start((addr << 1) | I2C_WRITE); | ||
| 37 | } | ||
| 38 | |||
| 39 | // from SSD1306 scrips | ||
| 40 | extern unsigned char i2c_rep_start(unsigned char addr); | ||
| 41 | extern void i2c_start_wait(unsigned char addr); | ||
| 42 | extern unsigned char i2c_readAck(void); | ||
| 43 | extern unsigned char i2c_readNak(void); | ||
| 44 | extern unsigned char i2c_read(unsigned char ack); | ||
| 45 | |||
| 46 | #define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); | ||
diff --git a/keyboards/lily58/keymaps/chuan/config.h b/keyboards/lily58/keymaps/chuan/config.h new file mode 100644 index 000000000..fa93060db --- /dev/null +++ b/keyboards/lily58/keymaps/chuan/config.h | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | /* | ||
| 2 | This is the c configuration file for the keymap | ||
| 3 | |||
| 4 | Copyright 2012 Jun Wako <wakojun@gmail.com> | ||
| 5 | Copyright 2015 Jack Humbert | ||
| 6 | |||
| 7 | This program is free software: you can redistribute it and/or modify | ||
| 8 | it under the terms of the GNU General Public License as published by | ||
| 9 | the Free Software Foundation, either version 2 of the License, or | ||
| 10 | (at your option) any later version. | ||
| 11 | |||
| 12 | This program 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 | ||
| 15 | GNU General Public License for more details. | ||
| 16 | |||
| 17 | You should have received a copy of the GNU General Public License | ||
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #pragma once | ||
| 22 | |||
| 23 | // #define USE_MATRIX_I2C | ||
| 24 | |||
| 25 | // #define USE_I2C | ||
| 26 | |||
| 27 | /* Select hand configuration */ | ||
| 28 | |||
| 29 | #define MASTER_LEFT | ||
| 30 | // #define MASTER_RIGHT | ||
| 31 | // #define EE_HANDS | ||
| 32 | |||
| 33 | // #define SSD1306OLED | ||
| 34 | |||
| 35 | #define USE_SERIAL_PD2 | ||
| 36 | |||
| 37 | #define TAPPING_FORCE_HOLD | ||
| 38 | |||
| 39 | /* define tapping term */ | ||
| 40 | #define TAPPING_TERM 200 | ||
| 41 | |||
| 42 | |||
| 43 | #undef RGBLED_NUM | ||
| 44 | #define RGBLIGHT_ANIMATIONS | ||
| 45 | #define RGBLED_NUM 27 | ||
| 46 | #define RGBLIGHT_LIMIT_VAL 120 | ||
| 47 | #define RGBLIGHT_HUE_STEP 10 | ||
| 48 | #define RGBLIGHT_SAT_STEP 17 | ||
| 49 | #define RGBLIGHT_VAL_STEP 17 | ||
| 50 | |||
| 51 | #define ENCODERS_PAD_A { F4 } | ||
| 52 | #define ENCODERS_PAD_B { F5 } | ||
| 53 | |||
| 54 | |||
| 55 | /* Set 0 if debouncing isn't needed */ | ||
| 56 | #define DEBOUNCE 5 | ||
| 57 | |||
| 58 | // Underglow | ||
| 59 | /* | ||
| 60 | #undef RGBLED_NUM | ||
| 61 | #define RGBLED_NUM 14 // Number of LEDs | ||
| 62 | #define RGBLIGHT_ANIMATIONS | ||
| 63 | #define RGBLIGHT_SLEEP | ||
| 64 | */ | ||
diff --git a/keyboards/lily58/keymaps/chuan/keymap.c b/keyboards/lily58/keymaps/chuan/keymap.c new file mode 100644 index 000000000..da49e67a0 --- /dev/null +++ b/keyboards/lily58/keymaps/chuan/keymap.c | |||
| @@ -0,0 +1,230 @@ | |||
| 1 | #include QMK_KEYBOARD_H | ||
| 2 | |||
| 3 | #ifdef RGBLIGHT_ENABLE | ||
| 4 | //Following line allows macro to read current RGB settings | ||
| 5 | extern rgblight_config_t rgblight_config; | ||
| 6 | #endif | ||
| 7 | |||
| 8 | extern uint8_t is_master; | ||
| 9 | |||
| 10 | #define _QWERTY 0 | ||
| 11 | #define _LOWER 1 | ||
| 12 | #define _RAISE 2 | ||
| 13 | #define _ADJUST 3 | ||
| 14 | |||
| 15 | enum custom_keycodes { | ||
| 16 | QWERTY = SAFE_RANGE, | ||
| 17 | LOWER, | ||
| 18 | RAISE, | ||
| 19 | ADJUST, | ||
| 20 | }; | ||
| 21 | |||
| 22 | |||
| 23 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
| 24 | |||
| 25 | /* QWERTY | ||
| 26 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 27 | * | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | ` | | ||
| 28 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 29 | * | Tab | Q | W | E | R | T | | Y | U | I | O | P | - | | ||
| 30 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 31 | * |HYPER | A | S | D | F | G |-------. ,-------| H | J | K | L | ; | ' | | ||
| 32 | * |------+------+------+------+------+------| - | | + |------+------+------+------+------+------| | ||
| 33 | * |LShift| Z | X | C | V | B |-------| |-------| N | M | , | . | / |RShift| | ||
| 34 | * `-----------------------------------------/ / \ \-----------------------------------------' | ||
| 35 | * | LCtl | LGUI |LALT | /Space / \Space \ |RAISE | [ | ] | | ||
| 36 | * | | | |/ LOWER / \ \ | ' | | | | ||
| 37 | * `----------------------------' '------''--------------------' | ||
| 38 | */ | ||
| 39 | |||
| 40 | [_QWERTY] = LAYOUT( | ||
| 41 | KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \ | ||
| 42 | KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS, \ | ||
| 43 | ALL_T(KC_GRV), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_ENTER, \ | ||
| 44 | KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_MINS, MEH_T(KC_EQL), KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, \ | ||
| 45 | KC_LCTRL, KC_LGUI, KC_LALT,LT(_LOWER, KC_SPC), KC_SPC, LT(2,KC_QUOT), KC_LBRC, KC_RBRC \ | ||
| 46 | ), | ||
| 47 | /* LOWER | ||
| 48 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 49 | * | | | | | | | | | | | | | | | ||
| 50 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 51 | * | F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | | ||
| 52 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 53 | * | ` | ! | @ | # | $ | % |-------. ,-------| ^ | & | * | ( | ) | - | | ||
| 54 | * |------+------+------+------+------+------| cmd spc| | |------+------+------+------+------+------| | ||
| 55 | * | | | |ctrl c| | |-------| |-------| | - | _ | [ | ] | | | | ||
| 56 | * `-----------------------------------------/ / \ \-----------------------------------------' | ||
| 57 | * | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE | { | } | | ||
| 58 | * | | | |/ / \ \ | | | | | ||
| 59 | * `----------------------------' '------''--------------------' | ||
| 60 | */ | ||
| 61 | [_LOWER] = LAYOUT( | ||
| 62 | KC_GRV, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_TILD, \ | ||
| 63 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \ | ||
| 64 | _______, _______, _______, _______, _______, _______, _______, _______, _______,_______, _______, _______,\ | ||
| 65 | _______, _______, _______, C(KC_C), _______, _______, LGUI(KC_SPC), _______, _______, KC_MINS, KC_UNDS , KC_LBRC, KC_RBRC, KC_PIPE, \ | ||
| 66 | _______, _______, _______, _______, _______, RAISE, KC_LCBR, KC_RCBR\ | ||
| 67 | ), | ||
| 68 | /* RAISE | ||
| 69 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 70 | * | | | | | | | | | | | | | | | ||
| 71 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 72 | * | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | | | ||
| 73 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 74 | * | F1 | F2 | F3 | F4 | F5 | F6 |-------. ,-------| | Left | Down | Up |Right | | | ||
| 75 | * |------+------+------+------+------+------| [ | | ] |------+------+------+------+------+------| | ||
| 76 | * | F7 | F8 | F9 | F10 | F11 | F12 |-------| |-------| + | - | = | [ | ] | \ | | ||
| 77 | * `-----------------------------------------/ / \ \-----------------------------------------' | ||
| 78 | * | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE |BackSP| RGUI | | ||
| 79 | * | | | |/ / \ \ | | | | | ||
| 80 | * `----------------------------' '------''--------------------' | ||
| 81 | */ | ||
| 82 | |||
| 83 | [_RAISE] = LAYOUT( | ||
| 84 | KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, _______, KC_MRWD, KC_MPLY, KC_MFFD, KC_DEL, _______, \ | ||
| 85 | KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_6, LCTL(LSFT(KC_TAB)),KC_UP,LCTL(KC_TAB), KC_0, _______, \ | ||
| 86 | _______, _______, _______, _______, _______, _______, XXXXXXX, KC_LEFT, KC_DOWN, KC_RIGHT, KC_RGHT, XXXXXXX, \ | ||
| 87 | _______, _______, _______, _______, _______, _______, _______, TG(_ADJUST),KC_PLUS, KC_MUTE ,KC_VOLD ,KC_VOLU, _______, _______, \ | ||
| 88 | _______, _______, _______, _______, _______, _______, _______, _______ \ | ||
| 89 | ), | ||
| 90 | /* ADJUST | ||
| 91 | * ,-----------------------------------------. ,-----------------------------------------. | ||
| 92 | * | | | | | | | | | 7 | 8 | 9 |RGB ON| HUE+ | | ||
| 93 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 94 | * | | | | | | | | | 4 | 5 | 6 | MODE | HUE- | | ||
| 95 | * |------+------+------+------+------+------| |------+------+------+------+------+------| | ||
| 96 | * | | | | | | |-------. ,-------| | 1 | 2 | 3 | SAT+ | VAL+ | | ||
| 97 | * |------+------+------+------+------+------| | |DEFAULT|------+------+------+------+------+------| | ||
| 98 | * | | | | | | |-------| |-------| | 0 | 0 | . | SAT- | VAL- | | ||
| 99 | * `-----------------------------------------/ / \ \-----------------------------------------' | ||
| 100 | * | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE |BackSP| RGUI | | ||
| 101 | * | | | |/ / \ \ | | | | | ||
| 102 | * `----------------------------' '------''--------------------' | ||
| 103 | */ | ||
| 104 | [_ADJUST] = LAYOUT( | ||
| 105 | XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_7 , KC_8 , KC_9 , RGB_TOG, RGB_HUI, \ | ||
| 106 | XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_4 , KC_5 , KC_6 , RGB_MOD, RGB_HUD, \ | ||
| 107 | XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_1 , KC_2 , KC_3 , RGB_SAI, RGB_VAI, \ | ||
| 108 | XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, TG(_ADJUST), XXXXXXX, KC_0 , KC_0 , KC_DOT, RGB_SAD, RGB_VAD,\ | ||
| 109 | _______, _______, _______, _______, _______, _______,KC_BSPC, _______ \ | ||
| 110 | ) | ||
| 111 | }; | ||
| 112 | |||
| 113 | int RGB_current_mode; | ||
| 114 | |||
| 115 | int counter = 0; | ||
| 116 | int lastIndex = 9; | ||
| 117 | |||
| 118 | // Setting ADJUST layer RGB back to default | ||
| 119 | void update_tri_layer_RGB(uint8_t layer1, uint8_t layer2, uint8_t layer3) { | ||
| 120 | if (IS_LAYER_ON(layer1) && IS_LAYER_ON(layer2)) { | ||
| 121 | layer_on(layer3); | ||
| 122 | } else { | ||
| 123 | layer_off(layer3); | ||
| 124 | } | ||
| 125 | } | ||
| 126 | |||
| 127 | void matrix_init_user(void) { | ||
| 128 | #ifdef RGBLIGHT_ENABLE | ||
| 129 | RGB_current_mode = rgblight_config.mode; | ||
| 130 | #endif | ||
| 131 | } | ||
| 132 | |||
| 133 | #ifdef OLED_DRIVER_ENABLE | ||
| 134 | |||
| 135 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { | ||
| 136 | if (!is_keyboard_master()) | ||
| 137 | return OLED_ROTATION_180; // flips the display 180 degrees if offhand | ||
| 138 | return rotation; | ||
| 139 | } | ||
| 140 | |||
| 141 | // When add source files to SRC in rules.mk, you can use functions. | ||
| 142 | const char *read_layer_state(void); | ||
| 143 | const char *read_logo(void); | ||
| 144 | void set_keylog(uint16_t keycode, keyrecord_t *record); | ||
| 145 | const char *read_keylog(void); | ||
| 146 | const char *read_keylogs(void); | ||
| 147 | |||
| 148 | const char *read_mode_icon(bool swap); | ||
| 149 | const char *read_host_led_state(void); | ||
| 150 | void set_timelog(void); | ||
| 151 | const char *read_timelog(void); | ||
| 152 | |||
| 153 | char encoder_debug[24]; | ||
| 154 | |||
| 155 | void oled_task_user(void) { | ||
| 156 | // Host Keyboard Layer Status | ||
| 157 | snprintf(encoder_debug, sizeof(encoder_debug), "%i %i", counter, lastIndex ); | ||
| 158 | if (is_keyboard_master()) { | ||
| 159 | // If you want to change the display of OLED, you need to change here | ||
| 160 | oled_write_ln(read_layer_state(), false); | ||
| 161 | // oled_write_ln(read_keylog(), false); | ||
| 162 | // oled_write_ln(read_keylogs(), false); | ||
| 163 | // oled_write_ln(read_mode_icon(keymap_config.swap_lalt_lgui), false); | ||
| 164 | oled_write_ln(read_host_led_state(), false); | ||
| 165 | oled_write_ln(encoder_debug, false); | ||
| 166 | // oled_write_ln(read_timelog(), false); | ||
| 167 | } else { | ||
| 168 | oled_write(read_logo(), false); | ||
| 169 | // oled_write_ln(encoder_debug, false); | ||
| 170 | } | ||
| 171 | } | ||
| 172 | #endif //OLED_DRIVER_ENABLE | ||
| 173 | |||
| 174 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
| 175 | if (record->event.pressed) { | ||
| 176 | #ifdef SSD1306OLED | ||
| 177 | // set_keylog(keycode, record); | ||
| 178 | #endif | ||
| 179 | // set_timelog(); | ||
| 180 | } | ||
| 181 | |||
| 182 | switch (keycode) { | ||
| 183 | case QWERTY: | ||
| 184 | if (record->event.pressed) { | ||
| 185 | set_single_persistent_default_layer(_QWERTY); | ||
| 186 | } | ||
| 187 | return false; | ||
| 188 | break; | ||
| 189 | case LOWER: | ||
| 190 | if (record->event.pressed) { | ||
| 191 | layer_on(_LOWER); | ||
| 192 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 193 | } else { | ||
| 194 | layer_off(_LOWER); | ||
| 195 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 196 | } | ||
| 197 | return false; | ||
| 198 | break; | ||
| 199 | case RAISE: | ||
| 200 | if (record->event.pressed) { | ||
| 201 | layer_on(_RAISE); | ||
| 202 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 203 | } else { | ||
| 204 | layer_off(_RAISE); | ||
| 205 | update_tri_layer_RGB(_LOWER, _RAISE, _ADJUST); | ||
| 206 | } | ||
| 207 | return false; | ||
| 208 | break; | ||
| 209 | case ADJUST: | ||
| 210 | if (record->event.pressed) { | ||
| 211 | layer_on(_ADJUST); | ||
| 212 | } else { | ||
| 213 | layer_off(_ADJUST); | ||
| 214 | } | ||
| 215 | return false; | ||
| 216 | break; | ||
| 217 | } | ||
| 218 | return true; | ||
| 219 | } | ||
| 220 | |||
| 221 | void encoder_update_user(uint8_t index, bool clockwise) { | ||
| 222 | lastIndex = index; | ||
| 223 | if (clockwise) { | ||
| 224 | counter++; | ||
| 225 | tap_code(KC_PGDN); | ||
| 226 | } else { | ||
| 227 | counter--; | ||
| 228 | tap_code(KC_PGUP); | ||
| 229 | } | ||
| 230 | } | ||
diff --git a/keyboards/lily58/keymaps/chuan/rules.mk b/keyboards/lily58/keymaps/chuan/rules.mk new file mode 100644 index 000000000..3e05cb7d9 --- /dev/null +++ b/keyboards/lily58/keymaps/chuan/rules.mk | |||
| @@ -0,0 +1,11 @@ | |||
| 1 | EXTRAKEY_ENABLE = yes | ||
| 2 | NKRO_ENABLE = yes | ||
| 3 | ENCODER_ENABLE = yes | ||
| 4 | # If you want to change the display of OLED, you need to change here | ||
| 5 | SRC += ./lib/rgb_state_reader.c \ | ||
| 6 | ./lib/layer_state_reader.c \ | ||
| 7 | ./lib/logo_reader.c \ | ||
| 8 | ./lib/mode_icon_reader.c \ | ||
| 9 | ./lib/host_led_state_reader.c \ | ||
| 10 | ./lib/timelogger.c \ | ||
| 11 | ./lib/keylogger.c \ | ||
diff --git a/keyboards/lily58/keymaps/default/config.h b/keyboards/lily58/keymaps/default/config.h index 58bbdc5e9..6b9e52c05 100644 --- a/keyboards/lily58/keymaps/default/config.h +++ b/keyboards/lily58/keymaps/default/config.h | |||
| @@ -28,8 +28,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 28 | // #define MASTER_RIGHT | 28 | // #define MASTER_RIGHT |
| 29 | // #define EE_HANDS | 29 | // #define EE_HANDS |
| 30 | 30 | ||
| 31 | #define SSD1306OLED | ||
| 32 | |||
| 33 | #define USE_SERIAL_PD2 | 31 | #define USE_SERIAL_PD2 |
| 34 | 32 | ||
| 35 | #define TAPPING_FORCE_HOLD | 33 | #define TAPPING_FORCE_HOLD |
| @@ -49,4 +47,4 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 49 | #define RGBLED_NUM 14 // Number of LEDs | 47 | #define RGBLED_NUM 14 // Number of LEDs |
| 50 | #define RGBLIGHT_ANIMATIONS | 48 | #define RGBLIGHT_ANIMATIONS |
| 51 | #define RGBLIGHT_SLEEP | 49 | #define RGBLIGHT_SLEEP |
| 52 | */ \ No newline at end of file | 50 | */ |
diff --git a/keyboards/lily58/keymaps/default/keymap.c b/keyboards/lily58/keymaps/default/keymap.c index f36248e12..f0fbaa8b0 100644 --- a/keyboards/lily58/keymaps/default/keymap.c +++ b/keyboards/lily58/keymaps/default/keymap.c | |||
| @@ -8,8 +8,6 @@ | |||
| 8 | #include "ssd1306.h" | 8 | #include "ssd1306.h" |
| 9 | #endif | 9 | #endif |
| 10 | 10 | ||
| 11 | |||
| 12 | |||
| 13 | #ifdef RGBLIGHT_ENABLE | 11 | #ifdef RGBLIGHT_ENABLE |
| 14 | //Following line allows macro to read current RGB settings | 12 | //Following line allows macro to read current RGB settings |
| 15 | extern rgblight_config_t rgblight_config; | 13 | extern rgblight_config_t rgblight_config; |
| @@ -135,16 +133,18 @@ void matrix_init_user(void) { | |||
| 135 | #ifdef RGBLIGHT_ENABLE | 133 | #ifdef RGBLIGHT_ENABLE |
| 136 | RGB_current_mode = rgblight_config.mode; | 134 | RGB_current_mode = rgblight_config.mode; |
| 137 | #endif | 135 | #endif |
| 138 | //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h | ||
| 139 | #ifdef SSD1306OLED | ||
| 140 | iota_gfx_init(!has_usb()); // turns on the display | ||
| 141 | #endif | ||
| 142 | } | 136 | } |
| 143 | 137 | ||
| 144 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | 138 | //SSD1306 OLED update loop, make sure to enable OLED_DRIVER_ENABLE=yes in rules.mk |
| 145 | #ifdef SSD1306OLED | 139 | #ifdef OLED_DRIVER_ENABLE |
| 146 | 140 | ||
| 147 | // When add source files to SRC in rules.mk, you can use functions. | 141 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { |
| 142 | if (!is_keyboard_master()) | ||
| 143 | return OLED_ROTATION_180; // flips the display 180 degrees if offhand | ||
| 144 | return rotation; | ||
| 145 | } | ||
| 146 | |||
| 147 | // When you add source files to SRC in rules.mk, you can use functions. | ||
| 148 | const char *read_layer_state(void); | 148 | const char *read_layer_state(void); |
| 149 | const char *read_logo(void); | 149 | const char *read_logo(void); |
| 150 | void set_keylog(uint16_t keycode, keyrecord_t *record); | 150 | void set_keylog(uint16_t keycode, keyrecord_t *record); |
| @@ -156,42 +156,24 @@ const char *read_keylogs(void); | |||
| 156 | // void set_timelog(void); | 156 | // void set_timelog(void); |
| 157 | // const char *read_timelog(void); | 157 | // const char *read_timelog(void); |
| 158 | 158 | ||
| 159 | void matrix_scan_user(void) { | 159 | void oled_task_user(void) { |
| 160 | iota_gfx_task(); | 160 | if (is_keyboard_master()) { |
| 161 | } | ||
| 162 | |||
| 163 | void matrix_render_user(struct CharacterMatrix *matrix) { | ||
| 164 | if (is_master) { | ||
| 165 | // If you want to change the display of OLED, you need to change here | 161 | // If you want to change the display of OLED, you need to change here |
| 166 | matrix_write_ln(matrix, read_layer_state()); | 162 | oled_write_ln(read_layer_state(), false); |
| 167 | matrix_write_ln(matrix, read_keylog()); | 163 | oled_write_ln(read_keylog(), false); |
| 168 | matrix_write_ln(matrix, read_keylogs()); | 164 | oled_write_ln(read_keylogs(), false); |
| 169 | //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui)); | 165 | //oled_write_ln(read_mode_icon(keymap_config.swap_lalt_lgui), false); |
| 170 | //matrix_write_ln(matrix, read_host_led_state()); | 166 | //oled_write_ln(read_host_led_state(), false); |
| 171 | //matrix_write_ln(matrix, read_timelog()); | 167 | //oled_write_ln(read_timelog(), false); |
| 172 | } else { | 168 | } else { |
| 173 | matrix_write(matrix, read_logo()); | 169 | oled_write(read_logo(), false); |
| 174 | } | ||
| 175 | } | ||
| 176 | |||
| 177 | void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) { | ||
| 178 | if (memcmp(dest->display, source->display, sizeof(dest->display))) { | ||
| 179 | memcpy(dest->display, source->display, sizeof(dest->display)); | ||
| 180 | dest->dirty = true; | ||
| 181 | } | 170 | } |
| 182 | } | 171 | } |
| 183 | 172 | #endif // OLED_DRIVER_ENABLE | |
| 184 | void iota_gfx_task_user(void) { | ||
| 185 | struct CharacterMatrix matrix; | ||
| 186 | matrix_clear(&matrix); | ||
| 187 | matrix_render_user(&matrix); | ||
| 188 | matrix_update(&display, &matrix); | ||
| 189 | } | ||
| 190 | #endif//SSD1306OLED | ||
| 191 | 173 | ||
| 192 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 174 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 193 | if (record->event.pressed) { | 175 | if (record->event.pressed) { |
| 194 | #ifdef SSD1306OLED | 176 | #ifdef OLED_DRIVER_ENABLE |
| 195 | set_keylog(keycode, record); | 177 | set_keylog(keycode, record); |
| 196 | #endif | 178 | #endif |
| 197 | // set_timelog(); | 179 | // set_timelog(); |
diff --git a/keyboards/lily58/keymaps/default/rules.mk b/keyboards/lily58/keymaps/default/rules.mk index b39305767..a5b6303a1 100644 --- a/keyboards/lily58/keymaps/default/rules.mk +++ b/keyboards/lily58/keymaps/default/rules.mk | |||
| @@ -15,13 +15,13 @@ UNICODE_ENABLE = no # Unicode | |||
| 15 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | 15 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 16 | RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. | 16 | RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. |
| 17 | SWAP_HANDS_ENABLE = no # Enable one-hand typing | 17 | SWAP_HANDS_ENABLE = no # Enable one-hand typing |
| 18 | OLED_DRIVER_ENABLE= yes # OLED display | ||
| 18 | 19 | ||
| 19 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 20 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 20 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 21 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 21 | 22 | ||
| 22 | # If you want to change the display of OLED, you need to change here | 23 | # If you want to change the display of OLED, you need to change here |
| 23 | SRC += ./lib/glcdfont.c \ | 24 | SRC += ./lib/rgb_state_reader.c \ |
| 24 | ./lib/rgb_state_reader.c \ | ||
| 25 | ./lib/layer_state_reader.c \ | 25 | ./lib/layer_state_reader.c \ |
| 26 | ./lib/logo_reader.c \ | 26 | ./lib/logo_reader.c \ |
| 27 | ./lib/keylogger.c \ | 27 | ./lib/keylogger.c \ |
diff --git a/keyboards/lily58/keymaps/yuchi/keymap.c b/keyboards/lily58/keymaps/yuchi/keymap.c index 13b6cb168..d258fbcbc 100644 --- a/keyboards/lily58/keymaps/yuchi/keymap.c +++ b/keyboards/lily58/keymaps/yuchi/keymap.c | |||
| @@ -112,7 +112,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 112 | * |LOWER | LGUI | Alt | /Space / \Enter \ |BackSP| RGUI |RAISE | | 112 | * |LOWER | LGUI | Alt | /Space / \Enter \ |BackSP| RGUI |RAISE | |
| 113 | * | | | |/ / \ \ | | | | | 113 | * | | | |/ / \ \ | | | | |
| 114 | * `----------------------------' '------''--------------------' | 114 | * `----------------------------' '------''--------------------' |
| 115 | */ | 115 | */ |
| 116 | [_ADJUST] = LAYOUT( \ | 116 | [_ADJUST] = LAYOUT( \ |
| 117 | XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ | 117 | XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ |
| 118 | XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ | 118 | XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, \ |
| @@ -137,14 +137,16 @@ void matrix_init_user(void) { | |||
| 137 | #ifdef RGBLIGHT_ENABLE | 137 | #ifdef RGBLIGHT_ENABLE |
| 138 | RGB_current_mode = rgblight_config.mode; | 138 | RGB_current_mode = rgblight_config.mode; |
| 139 | #endif | 139 | #endif |
| 140 | //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h | ||
| 141 | #ifdef SSD1306OLED | ||
| 142 | iota_gfx_init(!has_usb()); // turns on the display | ||
| 143 | #endif | ||
| 144 | } | 140 | } |
| 145 | 141 | ||
| 146 | //SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h | 142 | //SSD1306 OLED update loop, make sure to enable OLED_DRIVER_ENABLE=yes in rules.mk |
| 147 | #ifdef SSD1306OLED | 143 | #ifdef OLED_DRIVER_ENABLE |
| 144 | |||
| 145 | oled_rotation_t oled_init_user(oled_rotation_t rotation) { | ||
| 146 | if (!is_keyboard_master()) | ||
| 147 | return OLED_ROTATION_180; // flips the display 180 degrees if offhand | ||
| 148 | return rotation; | ||
| 149 | } | ||
| 148 | 150 | ||
| 149 | // When add source files to SRC in rules.mk, you can use functions. | 151 | // When add source files to SRC in rules.mk, you can use functions. |
| 150 | const char *read_layer_state(void); | 152 | const char *read_layer_state(void); |
| @@ -165,35 +167,22 @@ void matrix_scan_user(void) { | |||
| 165 | void matrix_render_user(struct CharacterMatrix *matrix) { | 167 | void matrix_render_user(struct CharacterMatrix *matrix) { |
| 166 | if (is_master) { | 168 | if (is_master) { |
| 167 | // If you want to change the display of OLED, you need to change here | 169 | // If you want to change the display of OLED, you need to change here |
| 168 | matrix_write_ln(matrix, read_layer_state()); | 170 | oled_write_ln(read_layer_state(), false); |
| 169 | matrix_write_ln(matrix, read_keylog()); | 171 | oled_write_ln(read_keylog(), false); |
| 170 | matrix_write_ln(matrix, read_keylogs()); | 172 | oled_write_ln(read_keylogs(), false); |
| 171 | //matrix_write_ln(matrix, read_mode_icon(keymap_config.swap_lalt_lgui)); | 173 | //oled_write_ln(read_mode_icon(keymap_config.swap_lalt_lgui), false); |
| 172 | //matrix_write_ln(matrix, read_host_led_state()); | 174 | //oled_write_ln(read_host_led_state(), false); |
| 173 | //matrix_write_ln(matrix, read_timelog()); | 175 | //oled_write_ln(read_timelog(), false); |
| 174 | } else { | 176 | } else { |
| 175 | matrix_write(matrix, read_logo()); | 177 | oled_write(read_logo(), false); |
| 176 | } | 178 | } |
| 177 | } | 179 | } |
| 178 | 180 | ||
| 179 | void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) { | ||
| 180 | if (memcmp(dest->display, source->display, sizeof(dest->display))) { | ||
| 181 | memcpy(dest->display, source->display, sizeof(dest->display)); | ||
| 182 | dest->dirty = true; | ||
| 183 | } | ||
| 184 | } | ||
| 185 | |||
| 186 | void iota_gfx_task_user(void) { | ||
| 187 | struct CharacterMatrix matrix; | ||
| 188 | matrix_clear(&matrix); | ||
| 189 | matrix_render_user(&matrix); | ||
| 190 | matrix_update(&display, &matrix); | ||
| 191 | } | ||
| 192 | #endif//SSD1306OLED | 181 | #endif//SSD1306OLED |
| 193 | 182 | ||
| 194 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | 183 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { |
| 195 | if (record->event.pressed) { | 184 | if (record->event.pressed) { |
| 196 | #ifdef SSD1306OLED | 185 | #ifdef OLED_DRIVER_ENABLE |
| 197 | set_keylog(keycode, record); | 186 | set_keylog(keycode, record); |
| 198 | #endif | 187 | #endif |
| 199 | // set_timelog(); | 188 | // set_timelog(); |
| @@ -236,4 +225,4 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 236 | break; | 225 | break; |
| 237 | } | 226 | } |
| 238 | return true; | 227 | return true; |
| 239 | } \ No newline at end of file | 228 | } |
diff --git a/keyboards/lily58/keymaps/yuchi/rules.mk b/keyboards/lily58/keymaps/yuchi/rules.mk index 922fac6b6..0db9ac50f 100644 --- a/keyboards/lily58/keymaps/yuchi/rules.mk +++ b/keyboards/lily58/keymaps/yuchi/rules.mk | |||
| @@ -13,15 +13,14 @@ MIDI_ENABLE = no # MIDI controls | |||
| 13 | AUDIO_ENABLE = no # Audio output on port C6 | 13 | AUDIO_ENABLE = no # Audio output on port C6 |
| 14 | UNICODE_ENABLE = no # Unicode | 14 | UNICODE_ENABLE = no # Unicode |
| 15 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | 15 | BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID |
| 16 | RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. | 16 | RGBLIGHT_ENABLE = yes # Enable WS2812 RGB underlight. |
| 17 | SWAP_HANDS_ENABLE = no # Enable one-hand typing | 17 | SWAP_HANDS_ENABLE = no # Enable one-hand typing |
| 18 | 18 | ||
| 19 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 19 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 20 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 20 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 21 | 21 | ||
| 22 | # If you want to change the display of OLED, you need to change here | 22 | # If you want to change the display of OLED, you need to change here |
| 23 | SRC += ./lib/glcdfont.c \ | 23 | SRC += ./lib/rgb_state_reader.c \ |
| 24 | ./lib/rgb_state_reader.c \ | ||
| 25 | ./lib/layer_state_reader.c \ | 24 | ./lib/layer_state_reader.c \ |
| 26 | ./lib/logo_reader.c \ | 25 | ./lib/logo_reader.c \ |
| 27 | ./lib/keylogger.c \ | 26 | ./lib/keylogger.c \ |
diff --git a/keyboards/lily58/lib/glcdfont.c b/keyboards/lily58/lib/glcdfont_lily.c index 94f026ba9..0aa69ea82 100644 --- a/keyboards/lily58/lib/glcdfont.c +++ b/keyboards/lily58/lib/glcdfont_lily.c | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | // This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. | 1 | // This is the 'classic' fixed-space bitmap font for Adafruit_GFX since 1.0. |
| 2 | // See gfxfont.h for newer custom bitmap font info. | 2 | // See gfxfont.h for newer custom bitmap font info. |
| 3 | 3 | ||
| 4 | // Modified to show the Lily58 logo instead of the qmk logo | ||
| 4 | #include "progmem.h" | 5 | #include "progmem.h" |
| 5 | 6 | ||
| 6 | // Standard ASCII 5x7 font | 7 | // Standard ASCII 5x7 font |
diff --git a/keyboards/lily58/lib/host_led_state_reader.c b/keyboards/lily58/lib/host_led_state_reader.c index 0e22173b1..589dd6152 100644 --- a/keyboards/lily58/lib/host_led_state_reader.c +++ b/keyboards/lily58/lib/host_led_state_reader.c | |||
| @@ -1,15 +1,16 @@ | |||
| 1 | #include <stdio.h> | 1 | #include <stdio.h> |
| 2 | #include "led.h" | ||
| 3 | #include "host.h" | ||
| 2 | #include "lily58.h" | 4 | #include "lily58.h" |
| 3 | 5 | ||
| 4 | char host_led_state_str[24]; | 6 | char host_led_state_str[24]; |
| 5 | 7 | ||
| 6 | const char *read_host_led_state(void) | 8 | const char *read_host_led_state(void) |
| 7 | { | 9 | { |
| 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 | 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 | (IS_HOST_LED_ON(USB_LED_NUM_LOCK)) ? "on" : "- ", |
| 11 | (leds & (1 << USB_LED_CAPS_LOCK)) ? "on" : "- ", | 12 | (IS_HOST_LED_ON(USB_LED_CAPS_LOCK)) ? "on" : "- ", |
| 12 | (leds & (1 << USB_LED_SCROLL_LOCK)) ? "on" : "- "); | 13 | (IS_HOST_LED_ON(USB_LED_SCROLL_LOCK)) ? "on" : "- "); |
| 13 | 14 | ||
| 14 | return host_led_state_str; | 15 | return host_led_state_str; |
| 15 | } | 16 | } |
diff --git a/keyboards/lily58/lib/keylogger.c b/keyboards/lily58/lib/keylogger.c index a1bd476d2..2fc3e663e 100644 --- a/keyboards/lily58/lib/keylogger.c +++ b/keyboards/lily58/lib/keylogger.c | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #include <stdio.h> | 1 | #include <stdio.h> |
| 2 | #include "action.h" | ||
| 2 | #include "lily58.h" | 3 | #include "lily58.h" |
| 3 | 4 | ||
| 4 | char keylog_str[24] = {}; | 5 | char keylog_str[24] = {}; |
diff --git a/keyboards/lily58/lib/layer_state_reader.c b/keyboards/lily58/lib/layer_state_reader.c index 48674b067..0e9dd7039 100644 --- a/keyboards/lily58/lib/layer_state_reader.c +++ b/keyboards/lily58/lib/layer_state_reader.c | |||
| @@ -4,10 +4,10 @@ | |||
| 4 | #include "lily58.h" | 4 | #include "lily58.h" |
| 5 | 5 | ||
| 6 | #define L_BASE 0 | 6 | #define L_BASE 0 |
| 7 | #define L_LOWER 2 | 7 | #define L_LOWER (1 << 1) |
| 8 | #define L_RAISE 4 | 8 | #define L_RAISE (1 << 2) |
| 9 | #define L_ADJUST 8 | 9 | #define L_ADJUST (1 << 3) |
| 10 | #define L_ADJUST_TRI 14 | 10 | #define L_ADJUST_TRI (L_ADJUST | L_RAISE | L_LOWER) |
| 11 | 11 | ||
| 12 | char layer_state_str[24]; | 12 | char layer_state_str[24]; |
| 13 | 13 | ||
diff --git a/keyboards/lily58/lib/mode_icon_reader.c b/keyboards/lily58/lib/mode_icon_reader.c index 2bce4a71b..27c6d92cd 100644 --- a/keyboards/lily58/lib/mode_icon_reader.c +++ b/keyboards/lily58/lib/mode_icon_reader.c | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #include <stdio.h> | 1 | #include <stdio.h> |
| 2 | #include <stdbool.h> | ||
| 2 | #include "lily58.h" | 3 | #include "lily58.h" |
| 3 | 4 | ||
| 4 | char mode_icon[24]; | 5 | char mode_icon[24]; |
diff --git a/keyboards/lily58/lib/timelogger.c b/keyboards/lily58/lib/timelogger.c index bfbfbe8a2..b00c13cb0 100644 --- a/keyboards/lily58/lib/timelogger.c +++ b/keyboards/lily58/lib/timelogger.c | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | #include <stdio.h> | 1 | #include <stdio.h> |
| 2 | #include "timer.h" | ||
| 2 | #include "lily58.h" | 3 | #include "lily58.h" |
| 3 | 4 | ||
| 4 | char timelog_str[24] = {}; | 5 | char timelog_str[24] = {}; |
diff --git a/keyboards/lily58/lily58.c b/keyboards/lily58/lily58.c index eacd90a82..03975057f 100644 --- a/keyboards/lily58/lily58.c +++ b/keyboards/lily58/lily58.c | |||
| @@ -1,10 +1,5 @@ | |||
| 1 | #include "lily58.h" | 1 | #include "lily58.h" |
| 2 | #include "ssd1306.h" | ||
| 3 | 2 | ||
| 4 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | 3 | bool 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); | 4 | return process_record_user(keycode, record); |
| 9 | #endif | 5 | } |
| 10 | } \ No newline at end of file | ||
diff --git a/keyboards/lily58/rev1/config.h b/keyboards/lily58/rev1/config.h index 4e8e3a7c9..adcf11b52 100644 --- a/keyboards/lily58/rev1/config.h +++ b/keyboards/lily58/rev1/config.h | |||
| @@ -36,8 +36,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 36 | #define MATRIX_ROW_PINS { C6, D7, E6, B4, B5 } | 36 | #define MATRIX_ROW_PINS { C6, D7, E6, B4, B5 } |
| 37 | #define MATRIX_COL_PINS { F6, F7, B1, B3, B2, B6 } | 37 | #define MATRIX_COL_PINS { F6, F7, B1, B3, B2, B6 } |
| 38 | 38 | ||
| 39 | /* define tapping term */ | ||
| 40 | #define TAPPING_TERM 100 | ||
| 41 | 39 | ||
| 42 | /* define if matrix has ghost */ | 40 | /* define if matrix has ghost */ |
| 43 | //#define MATRIX_HAS_GHOST | 41 | //#define MATRIX_HAS_GHOST |
diff --git a/keyboards/lily58/rev1/rules.mk b/keyboards/lily58/rev1/rules.mk index 6028b5a5b..e69de29bb 100644 --- a/keyboards/lily58/rev1/rules.mk +++ b/keyboards/lily58/rev1/rules.mk | |||
| @@ -1,3 +0,0 @@ | |||
| 1 | SRC += rev1/matrix.c | ||
| 2 | SRC += rev1/split_util.c | ||
| 3 | SRC += rev1/split_scomm.c | ||
diff --git a/keyboards/lily58/rev1/split_scomm.c b/keyboards/lily58/rev1/split_scomm.c deleted file mode 100755 index a1fe6ba5b..000000000 --- a/keyboards/lily58/rev1/split_scomm.c +++ /dev/null | |||
| @@ -1,91 +0,0 @@ | |||
| 1 | #ifdef USE_SERIAL | ||
| 2 | #ifdef SERIAL_USE_MULTI_TRANSACTION | ||
| 3 | /* --- USE flexible API (using multi-type transaction function) --- */ | ||
| 4 | |||
| 5 | #include <stdbool.h> | ||
| 6 | #include <stdint.h> | ||
| 7 | #include <stddef.h> | ||
| 8 | #include <split_scomm.h> | ||
| 9 | #include "serial.h" | ||
| 10 | #ifdef CONSOLE_ENABLE | ||
| 11 | #include <print.h> | ||
| 12 | #endif | ||
| 13 | |||
| 14 | uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; | ||
| 15 | uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; | ||
| 16 | uint8_t volatile status_com = 0; | ||
| 17 | uint8_t volatile status1 = 0; | ||
| 18 | uint8_t slave_buffer_change_count = 0; | ||
| 19 | uint8_t s_change_old = 0xff; | ||
| 20 | uint8_t s_change_new = 0xff; | ||
| 21 | |||
| 22 | SSTD_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 | |||
| 43 | void serial_master_init(void) | ||
| 44 | { | ||
| 45 | soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); | ||
| 46 | } | ||
| 47 | |||
| 48 | void 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 | ||
| 56 | int 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/lily58/rev1/split_scomm.h b/keyboards/lily58/rev1/split_scomm.h deleted file mode 100755 index 873d8939d..000000000 --- a/keyboards/lily58/rev1/split_scomm.h +++ /dev/null | |||
| @@ -1,24 +0,0 @@ | |||
| 1 | #ifndef SPLIT_COMM_H | ||
| 2 | #define SPLIT_COMM_H | ||
| 3 | |||
| 4 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
| 5 | /* --- USE Simple API (OLD API, compatible with let's split serial.c) --- */ | ||
| 6 | #include "serial.h" | ||
| 7 | |||
| 8 | #else | ||
| 9 | /* --- USE flexible API (using multi-type transaction function) --- */ | ||
| 10 | // Buffers for master - slave communication | ||
| 11 | #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 | ||
| 12 | #define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2 | ||
| 13 | |||
| 14 | extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; | ||
| 15 | extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; | ||
| 16 | extern uint8_t slave_buffer_change_count; | ||
| 17 | |||
| 18 | void serial_master_init(void); | ||
| 19 | void serial_slave_init(void); | ||
| 20 | int serial_update_buffers(int master_changed); | ||
| 21 | |||
| 22 | #endif | ||
| 23 | |||
| 24 | #endif /* SPLIT_COMM_H */ | ||
diff --git a/keyboards/lily58/rev1/split_util.h b/keyboards/lily58/rev1/split_util.h deleted file mode 100755 index 687ca19bd..000000000 --- a/keyboards/lily58/rev1/split_util.h +++ /dev/null | |||
| @@ -1,19 +0,0 @@ | |||
| 1 | #ifndef SPLIT_KEYBOARD_UTIL_H | ||
| 2 | #define SPLIT_KEYBOARD_UTIL_H | ||
| 3 | |||
| 4 | #include <stdbool.h> | ||
| 5 | #include "eeconfig.h" | ||
| 6 | |||
| 7 | #define SLAVE_I2C_ADDRESS 0x32 | ||
| 8 | |||
| 9 | extern volatile bool isLeftHand; | ||
| 10 | |||
| 11 | // slave version of matix scan, defined in matrix.c | ||
| 12 | void matrix_slave_scan(void); | ||
| 13 | |||
| 14 | void split_keyboard_setup(void); | ||
| 15 | bool has_usb(void); | ||
| 16 | |||
| 17 | void matrix_master_OLED_init (void); | ||
| 18 | |||
| 19 | #endif | ||
diff --git a/keyboards/lily58/rules.mk b/keyboards/lily58/rules.mk index d413510ba..34b512d59 100644 --- a/keyboards/lily58/rules.mk +++ b/keyboards/lily58/rules.mk | |||
| @@ -29,19 +29,7 @@ BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID | |||
| 29 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. | 29 | RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. |
| 30 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE | 30 | # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE |
| 31 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend | 31 | SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend |
| 32 | 32 | OLED_DRIVER_ENABLE = yes # OLED display | |
| 33 | CUSTOM_MATRIX = yes | 33 | SPLIT_KEYBOARD = yes |
| 34 | |||
| 35 | SRC += i2c.c | ||
| 36 | SRC += serial.c | ||
| 37 | SRC += ssd1306.c | ||
| 38 | |||
| 39 | # A workaround until #7089 is merged. | ||
| 40 | # serial.c must not be compiled with the -lto option. | ||
| 41 | # The current LIB_SRC has a side effect with the -fno-lto option, so use it. | ||
| 42 | LIB_SRC += serial.c | ||
| 43 | |||
| 44 | # if firmware size over limit, try this option | ||
| 45 | # CFLAGS += -flto | ||
| 46 | 34 | ||
| 47 | DEFAULT_FOLDER = lily58/rev1 | 35 | DEFAULT_FOLDER = lily58/rev1 |
diff --git a/keyboards/lily58/serial.h b/keyboards/lily58/serial.h deleted file mode 100755 index 7e0c0847a..000000000 --- a/keyboards/lily58/serial.h +++ /dev/null | |||
| @@ -1,84 +0,0 @@ | |||
| 1 | #ifndef SOFT_SERIAL_H | ||
| 2 | #define SOFT_SERIAL_H | ||
| 3 | |||
| 4 | #include <stdbool.h> | ||
| 5 | |||
| 6 | // ///////////////////////////////////////////////////////////////// | ||
| 7 | // Need Soft Serial defines in config.h | ||
| 8 | // ///////////////////////////////////////////////////////////////// | ||
| 9 | // ex. | ||
| 10 | // #define SOFT_SERIAL_PIN ?? // ?? = D0,D1,D2,D3,E6 | ||
| 11 | // OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5 | ||
| 12 | // // 1: about 137kbps (default) | ||
| 13 | // // 2: about 75kbps | ||
| 14 | // // 3: about 39kbps | ||
| 15 | // // 4: about 26kbps | ||
| 16 | // // 5: about 20kbps | ||
| 17 | // | ||
| 18 | // //// USE Simple API (OLD API, compatible with let's split serial.c) | ||
| 19 | // ex. | ||
| 20 | // #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 | ||
| 21 | // #define SERIAL_MASTER_BUFFER_LENGTH 1 | ||
| 22 | // | ||
| 23 | // //// USE flexible API (using multi-type transaction function) | ||
| 24 | // #define SERIAL_USE_MULTI_TRANSACTION | ||
| 25 | // | ||
| 26 | // ///////////////////////////////////////////////////////////////// | ||
| 27 | |||
| 28 | |||
| 29 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
| 30 | /* --- USE Simple API (OLD API, compatible with let's split serial.c) */ | ||
| 31 | #if SERIAL_SLAVE_BUFFER_LENGTH > 0 | ||
| 32 | extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; | ||
| 33 | #endif | ||
| 34 | #if SERIAL_MASTER_BUFFER_LENGTH > 0 | ||
| 35 | extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; | ||
| 36 | #endif | ||
| 37 | |||
| 38 | void serial_master_init(void); | ||
| 39 | void serial_slave_init(void); | ||
| 40 | int serial_update_buffers(void); | ||
| 41 | |||
| 42 | #endif // USE Simple API | ||
| 43 | |||
| 44 | // Soft Serial Transaction Descriptor | ||
| 45 | typedef 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 | ||
| 55 | void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size); | ||
| 56 | // target is interrupt accept side | ||
| 57 | void 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 | ||
| 65 | int soft_serial_transaction(void); | ||
| 66 | #else | ||
| 67 | int 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 | ||
| 81 | int soft_serial_get_and_clean_status(int sstd_index); | ||
| 82 | #endif | ||
| 83 | |||
| 84 | #endif /* SOFT_SERIAL_H */ | ||
diff --git a/keyboards/lily58/serial_config.h b/keyboards/lily58/serial_config.h deleted file mode 100644 index 4fab8e8dd..000000000 --- a/keyboards/lily58/serial_config.h +++ /dev/null | |||
| @@ -1,4 +0,0 @@ | |||
| 1 | #ifndef SOFT_SERIAL_PIN | ||
| 2 | #define SOFT_SERIAL_PIN D2 | ||
| 3 | #define SERIAL_USE_MULTI_TRANSACTION | ||
| 4 | #endif | ||
diff --git a/keyboards/lily58/ssd1306.c b/keyboards/lily58/ssd1306.c deleted file mode 100755 index 20c2738db..000000000 --- a/keyboards/lily58/ssd1306.c +++ /dev/null | |||
| @@ -1,344 +0,0 @@ | |||
| 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 | |||
| 16 | extern 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 60000 /* milliseconds */ | ||
| 31 | #if DEBUG_TO_SCREEN | ||
| 32 | static uint8_t displaying; | ||
| 33 | #endif | ||
| 34 | static uint16_t last_flush; | ||
| 35 | |||
| 36 | static bool force_dirty = true; | ||
| 37 | |||
| 38 | // Write command sequence. | ||
| 39 | // Returns true on success. | ||
| 40 | static 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; | ||
| 59 | done: | ||
| 60 | i2c_master_stop(); | ||
| 61 | return res; | ||
| 62 | } | ||
| 63 | |||
| 64 | // Write 2-byte command sequence. | ||
| 65 | // Returns true on success | ||
| 66 | static 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 | ||
| 75 | static 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 | |||
| 89 | static 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 | |||
| 112 | done: | ||
| 113 | i2c_master_stop(); | ||
| 114 | } | ||
| 115 | |||
| 116 | #if DEBUG_TO_SCREEN | ||
| 117 | #undef sendchar | ||
| 118 | static 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 | |||
| 129 | bool 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 | send_cmd2(SetComPins, 0x2); | ||
| 155 | send_cmd2(SetContrast, 0x8f); | ||
| 156 | send_cmd2(SetPreCharge, 0xf1); | ||
| 157 | send_cmd2(SetVComDetect, 0x40); | ||
| 158 | send_cmd1(DisplayAllOnResume); | ||
| 159 | send_cmd1(NormalDisplay); | ||
| 160 | send_cmd1(DeActivateScroll); | ||
| 161 | send_cmd1(DisplayOn); | ||
| 162 | |||
| 163 | send_cmd2(SetContrast, 0); // Dim | ||
| 164 | |||
| 165 | clear_display(); | ||
| 166 | |||
| 167 | success = true; | ||
| 168 | |||
| 169 | iota_gfx_flush(); | ||
| 170 | |||
| 171 | #if DEBUG_TO_SCREEN | ||
| 172 | print_set_sendchar(capture_sendchar); | ||
| 173 | #endif | ||
| 174 | |||
| 175 | done: | ||
| 176 | return success; | ||
| 177 | } | ||
| 178 | |||
| 179 | bool iota_gfx_off(void) { | ||
| 180 | bool success = false; | ||
| 181 | |||
| 182 | send_cmd1(DisplayOff); | ||
| 183 | success = true; | ||
| 184 | |||
| 185 | done: | ||
| 186 | return success; | ||
| 187 | } | ||
| 188 | |||
| 189 | bool iota_gfx_on(void) { | ||
| 190 | bool success = false; | ||
| 191 | |||
| 192 | send_cmd1(DisplayOn); | ||
| 193 | success = true; | ||
| 194 | |||
| 195 | done: | ||
| 196 | return success; | ||
| 197 | } | ||
| 198 | |||
| 199 | void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) { | ||
| 200 | *matrix->cursor = c; | ||
| 201 | ++matrix->cursor; | ||
| 202 | |||
| 203 | if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) { | ||
| 204 | // We went off the end; scroll the display upwards by one line | ||
| 205 | memmove(&matrix->display[0], &matrix->display[1], | ||
| 206 | MatrixCols * (MatrixRows - 1)); | ||
| 207 | matrix->cursor = &matrix->display[MatrixRows - 1][0]; | ||
| 208 | memset(matrix->cursor, ' ', MatrixCols); | ||
| 209 | } | ||
| 210 | } | ||
| 211 | |||
| 212 | void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { | ||
| 213 | matrix->dirty = true; | ||
| 214 | |||
| 215 | if (c == '\n') { | ||
| 216 | // Clear to end of line from the cursor and then move to the | ||
| 217 | // start of the next line | ||
| 218 | uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols; | ||
| 219 | |||
| 220 | while (cursor_col++ < MatrixCols) { | ||
| 221 | matrix_write_char_inner(matrix, ' '); | ||
| 222 | } | ||
| 223 | return; | ||
| 224 | } | ||
| 225 | |||
| 226 | matrix_write_char_inner(matrix, c); | ||
| 227 | } | ||
| 228 | |||
| 229 | void iota_gfx_write_char(uint8_t c) { | ||
| 230 | matrix_write_char(&display, c); | ||
| 231 | } | ||
| 232 | |||
| 233 | void matrix_write(struct CharacterMatrix *matrix, const char *data) { | ||
| 234 | const char *end = data + strlen(data); | ||
| 235 | while (data < end) { | ||
| 236 | matrix_write_char(matrix, *data); | ||
| 237 | ++data; | ||
| 238 | } | ||
| 239 | } | ||
| 240 | |||
| 241 | void matrix_write_ln(struct CharacterMatrix *matrix, const char *data) { | ||
| 242 | char data_ln[strlen(data)+2]; | ||
| 243 | snprintf(data_ln, sizeof(data_ln), "%s\n", data); | ||
| 244 | matrix_write(matrix, data_ln); | ||
| 245 | } | ||
| 246 | |||
| 247 | void iota_gfx_write(const char *data) { | ||
| 248 | matrix_write(&display, data); | ||
| 249 | } | ||
| 250 | |||
| 251 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { | ||
| 252 | while (true) { | ||
| 253 | uint8_t c = pgm_read_byte(data); | ||
| 254 | if (c == 0) { | ||
| 255 | return; | ||
| 256 | } | ||
| 257 | matrix_write_char(matrix, c); | ||
| 258 | ++data; | ||
| 259 | } | ||
| 260 | } | ||
| 261 | |||
| 262 | void iota_gfx_write_P(const char *data) { | ||
| 263 | matrix_write_P(&display, data); | ||
| 264 | } | ||
| 265 | |||
| 266 | void matrix_clear(struct CharacterMatrix *matrix) { | ||
| 267 | memset(matrix->display, ' ', sizeof(matrix->display)); | ||
| 268 | matrix->cursor = &matrix->display[0][0]; | ||
| 269 | matrix->dirty = true; | ||
| 270 | } | ||
| 271 | |||
| 272 | void iota_gfx_clear_screen(void) { | ||
| 273 | matrix_clear(&display); | ||
| 274 | } | ||
| 275 | |||
| 276 | void matrix_render(struct CharacterMatrix *matrix) { | ||
| 277 | last_flush = timer_read(); | ||
| 278 | iota_gfx_on(); | ||
| 279 | #if DEBUG_TO_SCREEN | ||
| 280 | ++displaying; | ||
| 281 | #endif | ||
| 282 | |||
| 283 | // Move to the home position | ||
| 284 | send_cmd3(PageAddr, 0, MatrixRows - 1); | ||
| 285 | send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); | ||
| 286 | |||
| 287 | if (i2c_start_write(SSD1306_ADDRESS)) { | ||
| 288 | goto done; | ||
| 289 | } | ||
| 290 | if (i2c_master_write(0x40)) { | ||
| 291 | // Data mode | ||
| 292 | goto done; | ||
| 293 | } | ||
| 294 | |||
| 295 | for (uint8_t row = 0; row < MatrixRows; ++row) { | ||
| 296 | for (uint8_t col = 0; col < MatrixCols; ++col) { | ||
| 297 | const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth); | ||
| 298 | |||
| 299 | for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) { | ||
| 300 | uint8_t colBits = pgm_read_byte(glyph + glyphCol); | ||
| 301 | i2c_master_write(colBits); | ||
| 302 | } | ||
| 303 | |||
| 304 | // 1 column of space between chars (it's not included in the glyph) | ||
| 305 | //i2c_master_write(0); | ||
| 306 | } | ||
| 307 | } | ||
| 308 | |||
| 309 | matrix->dirty = false; | ||
| 310 | |||
| 311 | done: | ||
| 312 | i2c_master_stop(); | ||
| 313 | #if DEBUG_TO_SCREEN | ||
| 314 | --displaying; | ||
| 315 | #endif | ||
| 316 | } | ||
| 317 | |||
| 318 | void iota_gfx_flush(void) { | ||
| 319 | matrix_render(&display); | ||
| 320 | } | ||
| 321 | |||
| 322 | __attribute__ ((weak)) | ||
| 323 | void iota_gfx_task_user(void) { | ||
| 324 | } | ||
| 325 | |||
| 326 | void iota_gfx_task(void) { | ||
| 327 | iota_gfx_task_user(); | ||
| 328 | |||
| 329 | if (display.dirty|| force_dirty) { | ||
| 330 | iota_gfx_flush(); | ||
| 331 | force_dirty = false; | ||
| 332 | } | ||
| 333 | |||
| 334 | if (timer_elapsed(last_flush) > ScreenOffInterval) { | ||
| 335 | iota_gfx_off(); | ||
| 336 | } | ||
| 337 | } | ||
| 338 | |||
| 339 | bool process_record_gfx(uint16_t keycode, keyrecord_t *record) { | ||
| 340 | force_dirty = true; | ||
| 341 | return true; | ||
| 342 | } | ||
| 343 | |||
| 344 | #endif | ||
diff --git a/keyboards/lily58/ssd1306.h b/keyboards/lily58/ssd1306.h deleted file mode 100755 index 0ca093093..000000000 --- a/keyboards/lily58/ssd1306.h +++ /dev/null | |||
| @@ -1,90 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <stdbool.h> | ||
| 4 | #include <stdio.h> | ||
| 5 | #include "action.h" | ||
| 6 | |||
| 7 | enum ssd1306_cmds { | ||
| 8 | DisplayOff = 0xAE, | ||
| 9 | DisplayOn = 0xAF, | ||
| 10 | |||
| 11 | SetContrast = 0x81, | ||
| 12 | DisplayAllOnResume = 0xA4, | ||
| 13 | |||
| 14 | DisplayAllOn = 0xA5, | ||
| 15 | NormalDisplay = 0xA6, | ||
| 16 | InvertDisplay = 0xA7, | ||
| 17 | SetDisplayOffset = 0xD3, | ||
| 18 | SetComPins = 0xda, | ||
| 19 | SetVComDetect = 0xdb, | ||
| 20 | SetDisplayClockDiv = 0xD5, | ||
| 21 | SetPreCharge = 0xd9, | ||
| 22 | SetMultiPlex = 0xa8, | ||
| 23 | SetLowColumn = 0x00, | ||
| 24 | SetHighColumn = 0x10, | ||
| 25 | SetStartLine = 0x40, | ||
| 26 | |||
| 27 | SetMemoryMode = 0x20, | ||
| 28 | ColumnAddr = 0x21, | ||
| 29 | PageAddr = 0x22, | ||
| 30 | |||
| 31 | ComScanInc = 0xc0, | ||
| 32 | ComScanDec = 0xc8, | ||
| 33 | SegRemap = 0xa0, | ||
| 34 | SetChargePump = 0x8d, | ||
| 35 | ExternalVcc = 0x01, | ||
| 36 | SwitchCapVcc = 0x02, | ||
| 37 | |||
| 38 | ActivateScroll = 0x2f, | ||
| 39 | DeActivateScroll = 0x2e, | ||
| 40 | SetVerticalScrollArea = 0xa3, | ||
| 41 | RightHorizontalScroll = 0x26, | ||
| 42 | LeftHorizontalScroll = 0x27, | ||
| 43 | VerticalAndRightHorizontalScroll = 0x29, | ||
| 44 | VerticalAndLeftHorizontalScroll = 0x2a, | ||
| 45 | }; | ||
| 46 | |||
| 47 | // Controls the SSD1306 128x32 OLED display via i2c | ||
| 48 | |||
| 49 | #ifndef SSD1306_ADDRESS | ||
| 50 | #define SSD1306_ADDRESS 0x3C | ||
| 51 | #endif | ||
| 52 | |||
| 53 | #define DisplayHeight 32 | ||
| 54 | #define DisplayWidth 128 | ||
| 55 | |||
| 56 | #define FontHeight 8 | ||
| 57 | #define FontWidth 6 | ||
| 58 | |||
| 59 | #define MatrixRows (DisplayHeight / FontHeight) | ||
| 60 | #define MatrixCols (DisplayWidth / FontWidth) | ||
| 61 | |||
| 62 | struct CharacterMatrix { | ||
| 63 | uint8_t display[MatrixRows][MatrixCols]; | ||
| 64 | uint8_t *cursor; | ||
| 65 | bool dirty; | ||
| 66 | }; | ||
| 67 | |||
| 68 | struct CharacterMatrix display; | ||
| 69 | |||
| 70 | bool iota_gfx_init(bool rotate); | ||
| 71 | void iota_gfx_task(void); | ||
| 72 | bool iota_gfx_off(void); | ||
| 73 | bool iota_gfx_on(void); | ||
| 74 | void iota_gfx_flush(void); | ||
| 75 | void iota_gfx_write_char(uint8_t c); | ||
| 76 | void iota_gfx_write(const char *data); | ||
| 77 | void iota_gfx_write_P(const char *data); | ||
| 78 | void iota_gfx_clear_screen(void); | ||
| 79 | |||
| 80 | void iota_gfx_task_user(void); | ||
| 81 | |||
| 82 | void matrix_clear(struct CharacterMatrix *matrix); | ||
| 83 | void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c); | ||
| 84 | void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c); | ||
| 85 | void matrix_write(struct CharacterMatrix *matrix, const char *data); | ||
| 86 | void matrix_write_ln(struct CharacterMatrix *matrix, const char *data); | ||
| 87 | void matrix_write_P(struct CharacterMatrix *matrix, const char *data); | ||
| 88 | void matrix_render(struct CharacterMatrix *matrix); | ||
| 89 | |||
| 90 | bool process_record_gfx(uint16_t keycode, keyrecord_t *record); | ||
