From 881f27b461189e6a02ecbaee0b5bcb3d85fc2b76 Mon Sep 17 00:00:00 2001 From: MakotoKurauchi Date: Thu, 17 Oct 2019 03:01:49 +0900 Subject: [Keyboard] Cleanup helix rules options (#6952) * add temporary test shell-spript * Use LINK_TIME_OPTIMIZATION_ENABLE instead of Link_Time_Optimization No change in build result. * Helix config.h use '#pragma once' No change in build result. * Helix helix.h,rev?/rev?.h,pico/pico.h use '#pragma once' No change in build result. * Use drivers/avr/pro_micro.h instead of keyboards/helix/pro_micro.h No change in build result. * remove keyboards/helix/{rev2|pico}/serial_config.h No change in build result. * 'HELIX_ROWS' macro is now referenced only in rev1/config.h and rev2/config.h. No change in build result. * The contents of helix/rules.mk were distributed to subdirectories. This is a preparation to create a new subdirectory for helix code using split_common. No change in build result. remove 'USE_I2C = yes', 'SUBPROJECT_rev1 = no' from keyboards/helix/rules.mk. follow code move from keyboards/helix/rules.mk to keyboards/helix/{rev1,rev2,pico}/rules.mk. ---- SRC += i2c.c SRC += serial.c SRC += ssd1306.c CUSTOM_MATRIX = yes --- * helix/{i2c.[ch], serial.[ch], ssd1306.[ch]} move into helix/local_drivers/ No change in build result. * Simplified 'helix/pico/keymap/*/rules.mk' using KEYBOARD_LOCAL_FEATURES_MK. No change in build result. * add keyboards/helix/pico/local_features.mk * add 'KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))local_features.mk' into keyboards/helix/pico/rules.mk * remove HELIX_CUSTOMISE_MSG from keyboards/helix/pico/keymaps/*/rules.mk * remove HELIX= process from keyboards/helix/pico/keymaps/*/rules.mk * remove convert code(helix to standaerd) from keyboards/helix/pico/keymaps/*/rules.mk * add 'include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))' into keyboards/helix/pico/keymaps/*/rules.mk * Simplified 'helix/rev2/keymap/*/rules.mk' using KEYBOARD_LOCAL_FEATURES_MK. No change in build result. * add keyboards/helix/rev2/local_features.mk * add 'KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))local_features.mk' into keyboards/helix/rev2/rules.mk * remove HELIX_CUSTOMISE_MSG from keyboards/helix/rev2/keymaps/*/rules.mk * remove HELIX= process from keyboards/helix/rev2/keymaps/*/rules.mk * remove convert code(helix to standaerd) from keyboards/helix/rev2/keymaps/*/rules.mk * add 'include $(strip $(KEYBOARD_LOCAL_FEATURES_MK))' into keyboards/helix/rev2/keymaps/*/rules.mk * Added helix keyboard build NEW method. No change in build result. ## Helix build $ make helix:default ## no oled, no backlight, no underglow $ make helix/rev2/back:default ## no oled, with backlight, no underglow $ make helix/rev2/under:default ## no oled, no backlight, with underglow $ make helix/rev2/oled:default ## with oled, no backlight, not underglow $ make helix/rev2/oled/back:default ## with oled, with backlight, no underglow $ make helix/rev2/back/oled:default ## with oled, with backlight, no underglow $ make helix/rev2/oled/under:default ## with oled, no backlight, with underglow $ make helix/rev2/under/oled:default ## with oled, no backlight, with underglow ## Helix pico build $ make helix/pico:default ## no oled, no backlight, no underglow $ make helix/pico/back:default ## no oled, with backlight, no underglow $ make helix/pico/under:default ## no oled, no backlight, with underglow $ make helix/pico/oled:default ## with oled, no backlight, not underglow * add temporary test shell-spript * test end remove test script. Revert "add temporary test shell-spript" This reverts commit 5dac20cd0f8b4bc192edb2313652c1635f829657. * test end remove test script. Revert "add temporary test shell-spript" This reverts commit ec49f63b2dc0f2b3fe8c1c36ffa615cee2f7e3ed. * Extended the 'HELIX=' option. add keyword 'verbose', 'no_ani'. No change in build result. * update keyboards/helix/{rev2,pico}/keymaps/default/readme.md * rename KEYBOARD_TOP_DIR to HELIX_TOP_DIR in rules.mk * update keyboards/helix/{rev2,pico}/keymaps/default/readme_jp.md * rm keyboards/helix/pico/oled/rules.mk * update helix's readmes. All the ':avrdude' was replaced with ':flash'. * remove F_CPU, ARCH, F_USB, INTERRUPT_CONTROL_ENDPOINT from helix/rules.mk No change in build result. --- keyboards/helix/config.h | 16 +- keyboards/helix/helix.h | 5 +- keyboards/helix/i2c.c | 162 ------ keyboards/helix/i2c.h | 49 -- keyboards/helix/local_drivers/i2c.c | 162 ++++++ keyboards/helix/local_drivers/i2c.h | 49 ++ keyboards/helix/local_drivers/serial.c | 590 +++++++++++++++++++++ keyboards/helix/local_drivers/serial.h | 89 ++++ keyboards/helix/local_drivers/ssd1306.c | 342 ++++++++++++ keyboards/helix/local_drivers/ssd1306.h | 93 ++++ keyboards/helix/pico/back/rules.mk | 1 + keyboards/helix/pico/config.h | 10 +- keyboards/helix/pico/keymaps/biacco/rules.mk | 139 +---- keyboards/helix/pico/keymaps/default/readme.md | 28 +- keyboards/helix/pico/keymaps/default/readme_jp.md | 81 +-- keyboards/helix/pico/keymaps/default/rules.mk | 141 +---- keyboards/helix/pico/keymaps/mtei/rules.mk | 141 +---- keyboards/helix/pico/local_features.mk | 100 ++++ keyboards/helix/pico/pico.h | 6 +- keyboards/helix/pico/rules.mk | 17 + keyboards/helix/pico/serial_config.h | 9 - keyboards/helix/pico/under/rules.mk | 1 + keyboards/helix/pro_micro.h | 362 ------------- keyboards/helix/rev1/config.h | 11 +- keyboards/helix/rev1/keymaps/OLED_sample/keymap.c | 4 +- keyboards/helix/rev1/keymaps/default/keymap.c | 4 +- keyboards/helix/rev1/rev1.h | 14 +- keyboards/helix/rev1/rules.mk | 7 + keyboards/helix/rev2/back/oled/rules.mk | 1 + keyboards/helix/rev2/back/rules.mk | 1 + keyboards/helix/rev2/config.h | 14 +- keyboards/helix/rev2/keymaps/default/keymap.c | 4 +- keyboards/helix/rev2/keymaps/default/readme.md | 36 +- keyboards/helix/rev2/keymaps/default/readme_jp.md | 98 ++-- keyboards/helix/rev2/keymaps/default/rules.mk | 141 +---- keyboards/helix/rev2/keymaps/edvorakjp/rules.mk | 130 +---- keyboards/helix/rev2/keymaps/five_rows/keymap.c | 2 +- keyboards/helix/rev2/keymaps/five_rows/rules.mk | 144 +---- .../helix/rev2/keymaps/five_rows_jis/keymap.c | 2 +- .../helix/rev2/keymaps/five_rows_jis/rules.mk | 137 +---- keyboards/helix/rev2/keymaps/froggy/keymap.c | 2 +- keyboards/helix/rev2/keymaps/froggy/rules.mk | 131 +---- keyboards/helix/rev2/keymaps/led_test/README.md | 2 +- keyboards/helix/rev2/keymaps/led_test/rules.mk | 131 +---- keyboards/helix/rev2/keymaps/yshrsmz/keymap.c | 4 +- keyboards/helix/rev2/keymaps/yshrsmz/rules.mk | 129 +---- keyboards/helix/rev2/local_features.mk | 98 ++++ keyboards/helix/rev2/oled/back/rules.mk | 1 + keyboards/helix/rev2/oled/rules.mk | 1 + keyboards/helix/rev2/oled/under/rules.mk | 1 + keyboards/helix/rev2/rev2.h | 9 +- keyboards/helix/rev2/rules.mk | 18 + keyboards/helix/rev2/serial_config.h | 8 - keyboards/helix/rev2/under/oled/rules.mk | 1 + keyboards/helix/rev2/under/rules.mk | 1 + keyboards/helix/rules.mk | 76 +-- keyboards/helix/serial.c | 590 --------------------- keyboards/helix/serial.h | 89 ---- keyboards/helix/ssd1306.c | 342 ------------ keyboards/helix/ssd1306.h | 93 ---- 60 files changed, 1971 insertions(+), 3099 deletions(-) delete mode 100644 keyboards/helix/i2c.c delete mode 100644 keyboards/helix/i2c.h create mode 100644 keyboards/helix/local_drivers/i2c.c create mode 100644 keyboards/helix/local_drivers/i2c.h create mode 100644 keyboards/helix/local_drivers/serial.c create mode 100644 keyboards/helix/local_drivers/serial.h create mode 100644 keyboards/helix/local_drivers/ssd1306.c create mode 100644 keyboards/helix/local_drivers/ssd1306.h create mode 100644 keyboards/helix/pico/back/rules.mk create mode 100644 keyboards/helix/pico/local_features.mk delete mode 100644 keyboards/helix/pico/serial_config.h create mode 100644 keyboards/helix/pico/under/rules.mk delete mode 100644 keyboards/helix/pro_micro.h create mode 100644 keyboards/helix/rev2/back/oled/rules.mk create mode 100644 keyboards/helix/rev2/back/rules.mk create mode 100644 keyboards/helix/rev2/local_features.mk create mode 100644 keyboards/helix/rev2/oled/back/rules.mk create mode 100644 keyboards/helix/rev2/oled/rules.mk create mode 100644 keyboards/helix/rev2/oled/under/rules.mk delete mode 100644 keyboards/helix/rev2/serial_config.h create mode 100644 keyboards/helix/rev2/under/oled/rules.mk create mode 100644 keyboards/helix/rev2/under/rules.mk delete mode 100644 keyboards/helix/serial.c delete mode 100644 keyboards/helix/serial.h delete mode 100644 keyboards/helix/ssd1306.c delete mode 100644 keyboards/helix/ssd1306.h diff --git a/keyboards/helix/config.h b/keyboards/helix/config.h index fbfbd32804..875312f0c3 100644 --- a/keyboards/helix/config.h +++ b/keyboards/helix/config.h @@ -16,8 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef CONFIG_H -#define CONFIG_H +#pragma once #include "config_common.h" @@ -27,8 +26,6 @@ along with this program. If not, see . // -include keyboards/helix/rev?/keymaps/MAPNAME/config.h // XXXX.c -#include - // GCC include search path in qmk_firmare/keyboards/helix/ // #include "..." search starts here: // #include <...> search starts here: @@ -38,14 +35,3 @@ along with this program. If not, see . // . // ./tmk_core // ...... - -#ifdef USE_Link_Time_Optimization - // LTO has issues with macros (action_get_macro) and "functions" (fn_actions), - // so just disable them - #define NO_ACTION_MACRO - #define NO_ACTION_FUNCTION - - #define DISABLE_LEADER -#endif // USE_Link_Time_Optimization - -#endif /* CONFIG_H */ diff --git a/keyboards/helix/helix.h b/keyboards/helix/helix.h index d73feb6bbf..7dac2455de 100644 --- a/keyboards/helix/helix.h +++ b/keyboards/helix/helix.h @@ -1,5 +1,4 @@ -#ifndef HELIX_H -#define HELIX_H +#pragma once #ifdef KEYBOARD_helix_rev1 #include "rev1.h" @@ -12,5 +11,3 @@ #endif #include "quantum.h" - -#endif diff --git a/keyboards/helix/i2c.c b/keyboards/helix/i2c.c deleted file mode 100644 index 4bee5c6398..0000000000 --- a/keyboards/helix/i2c.c +++ /dev/null @@ -1,162 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include "i2c.h" - -#ifdef USE_I2C - -// Limits the amount of we wait for any one i2c transaction. -// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is -// 9 bits, a single transaction will take around 90μs to complete. -// -// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit -// poll loop takes at least 8 clock cycles to execute -#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8 - -#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE) - -volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; - -static volatile uint8_t slave_buffer_pos; -static volatile bool slave_has_register_set = false; - -// Wait for an i2c operation to finish -inline static -void i2c_delay(void) { - uint16_t lim = 0; - while(!(TWCR & (1<10. - // Check datasheets for more info. - TWBR = ((F_CPU/SCL_CLOCK)-16)/2; -} - -// Start a transaction with the given i2c slave address. The direction of the -// transfer is set with I2C_READ and I2C_WRITE. -// returns: 0 => success -// 1 => error -uint8_t i2c_master_start(uint8_t address) { - TWCR = (1< slave ACK -// 1 => slave NACK -uint8_t i2c_master_write(uint8_t data) { - TWDR = data; - TWCR = (1<= SLAVE_BUFFER_SIZE ) { - ack = 0; - slave_buffer_pos = 0; - } - slave_has_register_set = true; - } else { - i2c_slave_buffer[slave_buffer_pos] = TWDR; - BUFFER_POS_INC(); - } - break; - - case TW_ST_SLA_ACK: - case TW_ST_DATA_ACK: - // master has addressed this device as a slave transmitter and is - // requesting data. - TWDR = i2c_slave_buffer[slave_buffer_pos]; - BUFFER_POS_INC(); - break; - - case TW_BUS_ERROR: // something went wrong, reset twi state - TWCR = 0; - default: - break; - } - // Reset everything, so we are ready for the next TWI interrupt - TWCR |= (1< - -#ifndef F_CPU -#define F_CPU 16000000UL -#endif - -#define I2C_READ 1 -#define I2C_WRITE 0 - -#define I2C_ACK 1 -#define I2C_NACK 0 - -#define SLAVE_BUFFER_SIZE 0x10 - -// i2c SCL clock frequency 400kHz -#define SCL_CLOCK 400000L - -extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; - -void i2c_master_init(void); -uint8_t i2c_master_start(uint8_t address); -void i2c_master_stop(void); -uint8_t i2c_master_write(uint8_t data); -uint8_t i2c_master_read(int); -void i2c_reset_state(void); -void i2c_slave_init(uint8_t address); - - -static inline unsigned char i2c_start_read(unsigned char addr) { - return i2c_master_start((addr << 1) | I2C_READ); -} - -static inline unsigned char i2c_start_write(unsigned char addr) { - return i2c_master_start((addr << 1) | I2C_WRITE); -} - -// from SSD1306 scrips -extern unsigned char i2c_rep_start(unsigned char addr); -extern void i2c_start_wait(unsigned char addr); -extern unsigned char i2c_readAck(void); -extern unsigned char i2c_readNak(void); -extern unsigned char i2c_read(unsigned char ack); - -#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); - -#endif diff --git a/keyboards/helix/local_drivers/i2c.c b/keyboards/helix/local_drivers/i2c.c new file mode 100644 index 0000000000..4bee5c6398 --- /dev/null +++ b/keyboards/helix/local_drivers/i2c.c @@ -0,0 +1,162 @@ +#include +#include +#include +#include +#include +#include +#include "i2c.h" + +#ifdef USE_I2C + +// Limits the amount of we wait for any one i2c transaction. +// Since were running SCL line 100kHz (=> 10μs/bit), and each transactions is +// 9 bits, a single transaction will take around 90μs to complete. +// +// (F_CPU/SCL_CLOCK) => # of μC cycles to transfer a bit +// poll loop takes at least 8 clock cycles to execute +#define I2C_LOOP_TIMEOUT (9+1)*(F_CPU/SCL_CLOCK)/8 + +#define BUFFER_POS_INC() (slave_buffer_pos = (slave_buffer_pos+1)%SLAVE_BUFFER_SIZE) + +volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; + +static volatile uint8_t slave_buffer_pos; +static volatile bool slave_has_register_set = false; + +// Wait for an i2c operation to finish +inline static +void i2c_delay(void) { + uint16_t lim = 0; + while(!(TWCR & (1<10. + // Check datasheets for more info. + TWBR = ((F_CPU/SCL_CLOCK)-16)/2; +} + +// Start a transaction with the given i2c slave address. The direction of the +// transfer is set with I2C_READ and I2C_WRITE. +// returns: 0 => success +// 1 => error +uint8_t i2c_master_start(uint8_t address) { + TWCR = (1< slave ACK +// 1 => slave NACK +uint8_t i2c_master_write(uint8_t data) { + TWDR = data; + TWCR = (1<= SLAVE_BUFFER_SIZE ) { + ack = 0; + slave_buffer_pos = 0; + } + slave_has_register_set = true; + } else { + i2c_slave_buffer[slave_buffer_pos] = TWDR; + BUFFER_POS_INC(); + } + break; + + case TW_ST_SLA_ACK: + case TW_ST_DATA_ACK: + // master has addressed this device as a slave transmitter and is + // requesting data. + TWDR = i2c_slave_buffer[slave_buffer_pos]; + BUFFER_POS_INC(); + break; + + case TW_BUS_ERROR: // something went wrong, reset twi state + TWCR = 0; + default: + break; + } + // Reset everything, so we are ready for the next TWI interrupt + TWCR |= (1< + +#ifndef F_CPU +#define F_CPU 16000000UL +#endif + +#define I2C_READ 1 +#define I2C_WRITE 0 + +#define I2C_ACK 1 +#define I2C_NACK 0 + +#define SLAVE_BUFFER_SIZE 0x10 + +// i2c SCL clock frequency 400kHz +#define SCL_CLOCK 400000L + +extern volatile uint8_t i2c_slave_buffer[SLAVE_BUFFER_SIZE]; + +void i2c_master_init(void); +uint8_t i2c_master_start(uint8_t address); +void i2c_master_stop(void); +uint8_t i2c_master_write(uint8_t data); +uint8_t i2c_master_read(int); +void i2c_reset_state(void); +void i2c_slave_init(uint8_t address); + + +static inline unsigned char i2c_start_read(unsigned char addr) { + return i2c_master_start((addr << 1) | I2C_READ); +} + +static inline unsigned char i2c_start_write(unsigned char addr) { + return i2c_master_start((addr << 1) | I2C_WRITE); +} + +// from SSD1306 scrips +extern unsigned char i2c_rep_start(unsigned char addr); +extern void i2c_start_wait(unsigned char addr); +extern unsigned char i2c_readAck(void); +extern unsigned char i2c_readNak(void); +extern unsigned char i2c_read(unsigned char ack); + +#define i2c_read(ack) (ack) ? i2c_readAck() : i2c_readNak(); + +#endif diff --git a/keyboards/helix/local_drivers/serial.c b/keyboards/helix/local_drivers/serial.c new file mode 100644 index 0000000000..6006ebf1bd --- /dev/null +++ b/keyboards/helix/local_drivers/serial.c @@ -0,0 +1,590 @@ +/* + * WARNING: be careful changing this code, it is very timing dependent + * + * 2018-10-28 checked + * avr-gcc 4.9.2 + * avr-gcc 5.4.0 + * avr-gcc 7.3.0 + */ + +#ifndef F_CPU +#define F_CPU 16000000 +#endif + +#include +#include +#include +#include +#include +#include "serial.h" +//#include + +#ifdef SOFT_SERIAL_PIN + +#ifdef __AVR_ATmega32U4__ + // if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial. + #ifdef USE_I2C + #if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1 + #error Using ATmega32U4 I2C, so can not use PD0, PD1 + #endif + #endif + + #if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3 + #define SERIAL_PIN_DDR DDRD + #define SERIAL_PIN_PORT PORTD + #define SERIAL_PIN_INPUT PIND + #if SOFT_SERIAL_PIN == D0 + #define SERIAL_PIN_MASK _BV(PD0) + #define EIMSK_BIT _BV(INT0) + #define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01))) + #define SERIAL_PIN_INTERRUPT INT0_vect + #elif SOFT_SERIAL_PIN == D1 + #define SERIAL_PIN_MASK _BV(PD1) + #define EIMSK_BIT _BV(INT1) + #define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11))) + #define SERIAL_PIN_INTERRUPT INT1_vect + #elif SOFT_SERIAL_PIN == D2 + #define SERIAL_PIN_MASK _BV(PD2) + #define EIMSK_BIT _BV(INT2) + #define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21))) + #define SERIAL_PIN_INTERRUPT INT2_vect + #elif SOFT_SERIAL_PIN == D3 + #define SERIAL_PIN_MASK _BV(PD3) + #define EIMSK_BIT _BV(INT3) + #define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31))) + #define SERIAL_PIN_INTERRUPT INT3_vect + #endif + #elif SOFT_SERIAL_PIN == E6 + #define SERIAL_PIN_DDR DDRE + #define SERIAL_PIN_PORT PORTE + #define SERIAL_PIN_INPUT PINE + #define SERIAL_PIN_MASK _BV(PE6) + #define EIMSK_BIT _BV(INT6) + #define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61))) + #define SERIAL_PIN_INTERRUPT INT6_vect + #else + #error invalid SOFT_SERIAL_PIN value + #endif + +#else + #error serial.c now support ATmega32U4 only +#endif + +//////////////// for backward compatibility //////////////////////////////// +#if !defined(SERIAL_USE_SINGLE_TRANSACTION) && !defined(SERIAL_USE_MULTI_TRANSACTION) +/* --- USE OLD API (compatible with let's split serial.c) */ + #if SERIAL_SLAVE_BUFFER_LENGTH > 0 + uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; + #endif + #if SERIAL_MASTER_BUFFER_LENGTH > 0 + uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; + #endif + uint8_t volatile status0 = 0; + +SSTD_t transactions[] = { + { (uint8_t *)&status0, + #if SERIAL_MASTER_BUFFER_LENGTH > 0 + sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer, + #else + 0, (uint8_t *)NULL, + #endif + #if SERIAL_SLAVE_BUFFER_LENGTH > 0 + sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer + #else + 0, (uint8_t *)NULL, + #endif + } +}; + +void serial_master_init(void) +{ soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); } + +void serial_slave_init(void) +{ soft_serial_target_init(transactions, TID_LIMIT(transactions)); } + +// 0 => no error +// 1 => slave did not respond +// 2 => checksum error +int serial_update_buffers() +{ + int result; + result = soft_serial_transaction(); + return result; +} + +#endif // end of OLD API (compatible with let's split serial.c) +//////////////////////////////////////////////////////////////////////////// + +#define ALWAYS_INLINE __attribute__((always_inline)) +#define NO_INLINE __attribute__((noinline)) +#define _delay_sub_us(x) __builtin_avr_delay_cycles(x) + +// parity check +#define ODD_PARITY 1 +#define EVEN_PARITY 0 +#define PARITY EVEN_PARITY + +#ifdef SERIAL_DELAY + // custom setup in config.h + // #define TID_SEND_ADJUST 2 + // #define SERIAL_DELAY 6 // micro sec + // #define READ_WRITE_START_ADJUST 30 // cycles + // #define READ_WRITE_WIDTH_ADJUST 8 // cycles +#else +// ============ Standard setups ============ + +#ifndef SELECT_SOFT_SERIAL_SPEED +#define SELECT_SOFT_SERIAL_SPEED 1 +// 0: about 189kbps +// 1: about 137kbps (default) +// 2: about 75kbps +// 3: about 39kbps +// 4: about 26kbps +// 5: about 20kbps +#endif + +#if __GNUC__ < 6 + #define TID_SEND_ADJUST 14 +#else + #define TID_SEND_ADJUST 2 +#endif + +#if SELECT_SOFT_SERIAL_SPEED == 0 + // Very High speed + #define SERIAL_DELAY 4 // micro sec + #if __GNUC__ < 6 + #define READ_WRITE_START_ADJUST 33 // cycles + #define READ_WRITE_WIDTH_ADJUST 3 // cycles + #else + #define READ_WRITE_START_ADJUST 34 // cycles + #define READ_WRITE_WIDTH_ADJUST 7 // cycles + #endif +#elif SELECT_SOFT_SERIAL_SPEED == 1 + // High speed + #define SERIAL_DELAY 6 // micro sec + #if __GNUC__ < 6 + #define READ_WRITE_START_ADJUST 30 // cycles + #define READ_WRITE_WIDTH_ADJUST 3 // cycles + #else + #define READ_WRITE_START_ADJUST 33 // cycles + #define READ_WRITE_WIDTH_ADJUST 7 // cycles + #endif +#elif SELECT_SOFT_SERIAL_SPEED == 2 + // Middle speed + #define SERIAL_DELAY 12 // micro sec + #define READ_WRITE_START_ADJUST 30 // cycles + #if __GNUC__ < 6 + #define READ_WRITE_WIDTH_ADJUST 3 // cycles + #else + #define READ_WRITE_WIDTH_ADJUST 7 // cycles + #endif +#elif SELECT_SOFT_SERIAL_SPEED == 3 + // Low speed + #define SERIAL_DELAY 24 // micro sec + #define READ_WRITE_START_ADJUST 30 // cycles + #if __GNUC__ < 6 + #define READ_WRITE_WIDTH_ADJUST 3 // cycles + #else + #define READ_WRITE_WIDTH_ADJUST 7 // cycles + #endif +#elif SELECT_SOFT_SERIAL_SPEED == 4 + // Very Low speed + #define SERIAL_DELAY 36 // micro sec + #define READ_WRITE_START_ADJUST 30 // cycles + #if __GNUC__ < 6 + #define READ_WRITE_WIDTH_ADJUST 3 // cycles + #else + #define READ_WRITE_WIDTH_ADJUST 7 // cycles + #endif +#elif SELECT_SOFT_SERIAL_SPEED == 5 + // Ultra Low speed + #define SERIAL_DELAY 48 // micro sec + #define READ_WRITE_START_ADJUST 30 // cycles + #if __GNUC__ < 6 + #define READ_WRITE_WIDTH_ADJUST 3 // cycles + #else + #define READ_WRITE_WIDTH_ADJUST 7 // cycles + #endif +#else +#error invalid SELECT_SOFT_SERIAL_SPEED value +#endif /* SELECT_SOFT_SERIAL_SPEED */ +#endif /* SERIAL_DELAY */ + +#define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2) +#define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2) + +#define SLAVE_INT_WIDTH_US 1 +#ifndef SERIAL_USE_MULTI_TRANSACTION + #define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY +#else + #define SLAVE_INT_ACK_WIDTH_UNIT 2 + #define SLAVE_INT_ACK_WIDTH 4 +#endif + +static SSTD_t *Transaction_table = NULL; +static uint8_t Transaction_table_size = 0; + +inline static void serial_delay(void) ALWAYS_INLINE; +inline static +void serial_delay(void) { + _delay_us(SERIAL_DELAY); +} + +inline static void serial_delay_half1(void) ALWAYS_INLINE; +inline static +void serial_delay_half1(void) { + _delay_us(SERIAL_DELAY_HALF1); +} + +inline static void serial_delay_half2(void) ALWAYS_INLINE; +inline static +void serial_delay_half2(void) { + _delay_us(SERIAL_DELAY_HALF2); +} + +inline static void serial_output(void) ALWAYS_INLINE; +inline static +void serial_output(void) { + SERIAL_PIN_DDR |= SERIAL_PIN_MASK; +} + +// make the serial pin an input with pull-up resistor +inline static void serial_input_with_pullup(void) ALWAYS_INLINE; +inline static +void serial_input_with_pullup(void) { + SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK; + SERIAL_PIN_PORT |= SERIAL_PIN_MASK; +} + +inline static uint8_t serial_read_pin(void) ALWAYS_INLINE; +inline static +uint8_t serial_read_pin(void) { + return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK); +} + +inline static void serial_low(void) ALWAYS_INLINE; +inline static +void serial_low(void) { + SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; +} + +inline static void serial_high(void) ALWAYS_INLINE; +inline static +void serial_high(void) { + SERIAL_PIN_PORT |= SERIAL_PIN_MASK; +} + +void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size) +{ + Transaction_table = sstd_table; + Transaction_table_size = (uint8_t)sstd_table_size; + serial_output(); + serial_high(); +} + +void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size) +{ + Transaction_table = sstd_table; + Transaction_table_size = (uint8_t)sstd_table_size; + serial_input_with_pullup(); + + // Enable INT0-INT3,INT6 + EIMSK |= EIMSK_BIT; +#if SERIAL_PIN_MASK == _BV(PE6) + // Trigger on falling edge of INT6 + EICRB &= EICRx_BIT; +#else + // Trigger on falling edge of INT0-INT3 + EICRA &= EICRx_BIT; +#endif +} + +// Used by the sender to synchronize timing with the reciver. +static void sync_recv(void) NO_INLINE; +static +void sync_recv(void) { + for (uint8_t i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) { + } + // This shouldn't hang if the target disconnects because the + // serial line will float to high if the target does disconnect. + while (!serial_read_pin()); +} + +// Used by the reciver to send a synchronization signal to the sender. +static void sync_send(void) NO_INLINE; +static +void sync_send(void) { + serial_low(); + serial_delay(); + serial_high(); +} + +// Reads a byte from the serial line +static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) NO_INLINE; +static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) { + uint8_t byte, i, p, pb; + + _delay_sub_us(READ_WRITE_START_ADJUST); + for( i = 0, byte = 0, p = PARITY; i < bit; i++ ) { + serial_delay_half1(); // read the middle of pulses + if( serial_read_pin() ) { + byte = (byte << 1) | 1; p ^= 1; + } else { + byte = (byte << 1) | 0; p ^= 0; + } + _delay_sub_us(READ_WRITE_WIDTH_ADJUST); + serial_delay_half2(); + } + /* recive parity bit */ + serial_delay_half1(); // read the middle of pulses + pb = serial_read_pin(); + _delay_sub_us(READ_WRITE_WIDTH_ADJUST); + serial_delay_half2(); + + *pterrcount += (p != pb)? 1 : 0; + + return byte; +} + +// Sends a byte with MSB ordering +void serial_write_chunk(uint8_t data, uint8_t bit) NO_INLINE; +void serial_write_chunk(uint8_t data, uint8_t bit) { + uint8_t b, p; + for( p = PARITY, b = 1<<(bit-1); b ; b >>= 1) { + if(data & b) { + serial_high(); p ^= 1; + } else { + serial_low(); p ^= 0; + } + serial_delay(); + } + /* send parity bit */ + if(p & 1) { serial_high(); } + else { serial_low(); } + serial_delay(); + + serial_low(); // sync_send() / senc_recv() need raise edge +} + +static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE; +static +void serial_send_packet(uint8_t *buffer, uint8_t size) { + for (uint8_t i = 0; i < size; ++i) { + uint8_t data; + data = buffer[i]; + sync_send(); + serial_write_chunk(data,8); + } +} + +static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) NO_INLINE; +static +uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) { + uint8_t pecount = 0; + for (uint8_t i = 0; i < size; ++i) { + uint8_t data; + sync_recv(); + data = serial_read_chunk(&pecount, 8); + buffer[i] = data; + } + return pecount == 0; +} + +inline static +void change_sender2reciver(void) { + sync_send(); //0 + serial_delay_half1(); //1 + serial_low(); //2 + serial_input_with_pullup(); //2 + serial_delay_half1(); //3 +} + +inline static +void change_reciver2sender(void) { + sync_recv(); //0 + serial_delay(); //1 + serial_low(); //3 + serial_output(); //3 + serial_delay_half1(); //4 +} + +static inline uint8_t nibble_bits_count(uint8_t bits) +{ + bits = (bits & 0x5) + (bits >> 1 & 0x5); + bits = (bits & 0x3) + (bits >> 2 & 0x3); + return bits; +} + +// interrupt handle to be used by the target device +ISR(SERIAL_PIN_INTERRUPT) { + +#ifndef SERIAL_USE_MULTI_TRANSACTION + serial_low(); + serial_output(); + SSTD_t *trans = Transaction_table; +#else + // recive transaction table index + uint8_t tid, bits; + uint8_t pecount = 0; + sync_recv(); + bits = serial_read_chunk(&pecount,7); + tid = bits>>3; + bits = (bits&7) != nibble_bits_count(tid); + if( bits || pecount> 0 || tid > Transaction_table_size ) { + return; + } + serial_delay_half1(); + + serial_high(); // response step1 low->high + serial_output(); + _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT*SLAVE_INT_ACK_WIDTH); + SSTD_t *trans = &Transaction_table[tid]; + serial_low(); // response step2 ack high->low +#endif + + // target send phase + if( trans->target2initiator_buffer_size > 0 ) + serial_send_packet((uint8_t *)trans->target2initiator_buffer, + trans->target2initiator_buffer_size); + // target switch to input + change_sender2reciver(); + + // target recive phase + if( trans->initiator2target_buffer_size > 0 ) { + if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer, + trans->initiator2target_buffer_size) ) { + *trans->status = TRANSACTION_ACCEPTED; + } else { + *trans->status = TRANSACTION_DATA_ERROR; + } + } else { + *trans->status = TRANSACTION_ACCEPTED; + } + + sync_recv(); //weit initiator output to high +} + +///////// +// start transaction by initiator +// +// int soft_serial_transaction(int sstd_index) +// +// Returns: +// TRANSACTION_END +// TRANSACTION_NO_RESPONSE +// TRANSACTION_DATA_ERROR +// this code is very time dependent, so we need to disable interrupts +#ifndef SERIAL_USE_MULTI_TRANSACTION +int soft_serial_transaction(void) { + SSTD_t *trans = Transaction_table; +#else +int soft_serial_transaction(int sstd_index) { + if( sstd_index > Transaction_table_size ) + return TRANSACTION_TYPE_ERROR; + SSTD_t *trans = &Transaction_table[sstd_index]; +#endif + cli(); + + // signal to the target that we want to start a transaction + serial_output(); + serial_low(); + _delay_us(SLAVE_INT_WIDTH_US); + +#ifndef SERIAL_USE_MULTI_TRANSACTION + // wait for the target response + serial_input_with_pullup(); + _delay_us(SLAVE_INT_RESPONSE_TIME); + + // check if the target is present + if (serial_read_pin()) { + // target failed to pull the line low, assume not present + serial_output(); + serial_high(); + *trans->status = TRANSACTION_NO_RESPONSE; + sei(); + return TRANSACTION_NO_RESPONSE; + } + +#else + // send transaction table index + int tid = (sstd_index<<3) | (7 & nibble_bits_count(sstd_index)); + sync_send(); + _delay_sub_us(TID_SEND_ADJUST); + serial_write_chunk(tid, 7); + serial_delay_half1(); + + // wait for the target response (step1 low->high) + serial_input_with_pullup(); + while( !serial_read_pin() ) { + _delay_sub_us(2); + } + + // check if the target is present (step2 high->low) + for( int i = 0; serial_read_pin(); i++ ) { + if (i > SLAVE_INT_ACK_WIDTH + 1) { + // slave failed to pull the line low, assume not present + serial_output(); + serial_high(); + *trans->status = TRANSACTION_NO_RESPONSE; + sei(); + return TRANSACTION_NO_RESPONSE; + } + _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT); + } +#endif + + // initiator recive phase + // if the target is present syncronize with it + if( trans->target2initiator_buffer_size > 0 ) { + if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer, + trans->target2initiator_buffer_size) ) { + serial_output(); + serial_high(); + *trans->status = TRANSACTION_DATA_ERROR; + sei(); + return TRANSACTION_DATA_ERROR; + } + } + + // initiator switch to output + change_reciver2sender(); + + // initiator send phase + if( trans->initiator2target_buffer_size > 0 ) { + serial_send_packet((uint8_t *)trans->initiator2target_buffer, + trans->initiator2target_buffer_size); + } + + // always, release the line when not in use + sync_send(); + + *trans->status = TRANSACTION_END; + sei(); + return TRANSACTION_END; +} + +#ifdef SERIAL_USE_MULTI_TRANSACTION +int soft_serial_get_and_clean_status(int sstd_index) { + SSTD_t *trans = &Transaction_table[sstd_index]; + cli(); + int retval = *trans->status; + *trans->status = 0;; + sei(); + return retval; +} +#endif + +#endif + +// Helix serial.c history +// 2018-1-29 fork from let's split and add PD2, modify sync_recv() (#2308, bceffdefc) +// 2018-6-28 bug fix master to slave comm and speed up (#3255, 1038bbef4) +// (adjusted with avr-gcc 4.9.2) +// 2018-7-13 remove USE_SERIAL_PD2 macro (#3374, f30d6dd78) +// (adjusted with avr-gcc 4.9.2) +// 2018-8-11 add support multi-type transaction (#3608, feb5e4aae) +// (adjusted with avr-gcc 4.9.2) +// 2018-10-21 fix serial and RGB animation conflict (#4191, 4665e4fff) +// (adjusted with avr-gcc 7.3.0) +// 2018-10-28 re-adjust compiler depend value of delay (#4269, 8517f8a66) +// (adjusted with avr-gcc 5.4.0, 7.3.0) diff --git a/keyboards/helix/local_drivers/serial.h b/keyboards/helix/local_drivers/serial.h new file mode 100644 index 0000000000..2e53928df2 --- /dev/null +++ b/keyboards/helix/local_drivers/serial.h @@ -0,0 +1,89 @@ +#ifndef SOFT_SERIAL_H +#define SOFT_SERIAL_H + +#include + +// ///////////////////////////////////////////////////////////////// +// Need Soft Serial defines in config.h +// ///////////////////////////////////////////////////////////////// +// ex. +// #define SOFT_SERIAL_PIN ?? // ?? = D0,D1,D2,D3,E6 +// OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5 +// // 1: about 137kbps (default) +// // 2: about 75kbps +// // 3: about 39kbps +// // 4: about 26kbps +// // 5: about 20kbps +// +// //// USE OLD API (compatible with let's split serial.c) +// ex. +// #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 +// #define SERIAL_MASTER_BUFFER_LENGTH 1 +// +// //// USE NEW API +// //// USE simple API (using signle-type transaction function) +// #define SERIAL_USE_SINGLE_TRANSACTION +// //// USE flexible API (using multi-type transaction function) +// #define SERIAL_USE_MULTI_TRANSACTION +// +// ///////////////////////////////////////////////////////////////// + + +//////////////// for backward compatibility //////////////////////////////// +#if !defined(SERIAL_USE_SINGLE_TRANSACTION) && !defined(SERIAL_USE_MULTI_TRANSACTION) +/* --- USE OLD API (compatible with let's split serial.c) */ + #if SERIAL_SLAVE_BUFFER_LENGTH > 0 + extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; + #endif + #if SERIAL_MASTER_BUFFER_LENGTH > 0 + extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; + #endif + + void serial_master_init(void); + void serial_slave_init(void); + int serial_update_buffers(void); + +#endif // end of USE OLD API +//////////////////////////////////////////////////////////////////////////// + +// Soft Serial Transaction Descriptor +typedef struct _SSTD_t { + uint8_t *status; + uint8_t initiator2target_buffer_size; + uint8_t *initiator2target_buffer; + uint8_t target2initiator_buffer_size; + uint8_t *target2initiator_buffer; +} SSTD_t; +#define TID_LIMIT( table ) (sizeof(table) / sizeof(SSTD_t)) + +// initiator is transaction start side +void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size); +// target is interrupt accept side +void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size); + +// initiator resullt +#define TRANSACTION_END 0 +#define TRANSACTION_NO_RESPONSE 0x1 +#define TRANSACTION_DATA_ERROR 0x2 +#define TRANSACTION_TYPE_ERROR 0x4 +#ifndef SERIAL_USE_MULTI_TRANSACTION +int soft_serial_transaction(void); +#else +int soft_serial_transaction(int sstd_index); +#endif + +// target status +// *SSTD_t.status has +// initiator: +// TRANSACTION_END +// or TRANSACTION_NO_RESPONSE +// or TRANSACTION_DATA_ERROR +// target: +// TRANSACTION_DATA_ERROR +// or TRANSACTION_ACCEPTED +#define TRANSACTION_ACCEPTED 0x8 +#ifdef SERIAL_USE_MULTI_TRANSACTION +int soft_serial_get_and_clean_status(int sstd_index); +#endif + +#endif /* SOFT_SERIAL_H */ diff --git a/keyboards/helix/local_drivers/ssd1306.c b/keyboards/helix/local_drivers/ssd1306.c new file mode 100644 index 0000000000..dd3290ba0c --- /dev/null +++ b/keyboards/helix/local_drivers/ssd1306.c @@ -0,0 +1,342 @@ + +#ifdef SSD1306OLED + +#include "ssd1306.h" +#include "i2c.h" +#include +#include "print.h" +#ifndef LOCAL_GLCDFONT +#include "common/glcdfont.c" +#else +#include +#endif +#ifdef ADAFRUIT_BLE_ENABLE +#include "adafruit_ble.h" +#endif +#ifdef PROTOCOL_LUFA +#include "lufa.h" +#endif +#include "sendchar.h" +#include "timer.h" + +// Set this to 1 to help diagnose early startup problems +// when testing power-on with ble. Turn it off otherwise, +// as the latency of printing most of the debug info messes +// with the matrix scan, causing keys to drop. +#define DEBUG_TO_SCREEN 0 + +//static uint16_t last_battery_update; +//static uint32_t vbat; +//#define BatteryUpdateInterval 10000 /* milliseconds */ + +// 'last_flush' is declared as uint16_t, +// so this must be less than 65535 +#define ScreenOffInterval 60000 /* milliseconds */ +#if DEBUG_TO_SCREEN +static uint8_t displaying; +#endif +static uint16_t last_flush; + +static bool force_dirty = true; + +// Write command sequence. +// Returns true on success. +static inline bool _send_cmd1(uint8_t cmd) { + bool res = false; + + if (i2c_start_write(SSD1306_ADDRESS)) { + xprintf("failed to start write to %d\n", SSD1306_ADDRESS); + goto done; + } + + if (i2c_master_write(0x0 /* command byte follows */)) { + print("failed to write control byte\n"); + + goto done; + } + + if (i2c_master_write(cmd)) { + xprintf("failed to write command %d\n", cmd); + goto done; + } + res = true; +done: + i2c_master_stop(); + return res; +} + +// Write 2-byte command sequence. +// Returns true on success +static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) { + if (!_send_cmd1(cmd)) { + return false; + } + return _send_cmd1(opr); +} + +// Write 3-byte command sequence. +// Returns true on success +static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { + if (!_send_cmd1(cmd)) { + return false; + } + if (!_send_cmd1(opr1)) { + return false; + } + return _send_cmd1(opr2); +} + +#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;} +#define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;} +#define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;} + +static void clear_display(void) { + matrix_clear(&display); + + // Clear all of the display bits (there can be random noise + // in the RAM on startup) + send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1); + send_cmd3(ColumnAddr, 0, DisplayWidth - 1); + + if (i2c_start_write(SSD1306_ADDRESS)) { + goto done; + } + if (i2c_master_write(0x40)) { + // Data mode + goto done; + } + for (uint8_t row = 0; row < MatrixRows; ++row) { + for (uint8_t col = 0; col < DisplayWidth; ++col) { + i2c_master_write(0); + } + } + + display.dirty = false; + +done: + i2c_master_stop(); +} + +#if DEBUG_TO_SCREEN +#undef sendchar +static int8_t capture_sendchar(uint8_t c) { + sendchar(c); + iota_gfx_write_char(c); + + if (!displaying) { + iota_gfx_flush(); + } + return 0; +} +#endif + +bool iota_gfx_init(bool rotate) { + bool success = false; + + i2c_master_init(); + send_cmd1(DisplayOff); + send_cmd2(SetDisplayClockDiv, 0x80); + send_cmd2(SetMultiPlex, DisplayHeight - 1); + + send_cmd2(SetDisplayOffset, 0); + + + send_cmd1(SetStartLine | 0x0); + send_cmd2(SetChargePump, 0x14 /* Enable */); + send_cmd2(SetMemoryMode, 0 /* horizontal addressing */); + + if(rotate){ + // the following Flip the display orientation 180 degrees + send_cmd1(SegRemap); + send_cmd1(ComScanInc); + }else{ + // Flips the display orientation 0 degrees + send_cmd1(SegRemap | 0x1); + send_cmd1(ComScanDec); + } + + send_cmd2(SetComPins, 0x2); + send_cmd2(SetContrast, 0x8f); + send_cmd2(SetPreCharge, 0xf1); + send_cmd2(SetVComDetect, 0x40); + send_cmd1(DisplayAllOnResume); + send_cmd1(NormalDisplay); + send_cmd1(DeActivateScroll); + send_cmd1(DisplayOn); + + send_cmd2(SetContrast, 0); // Dim + + clear_display(); + + success = true; + + iota_gfx_flush(); + +#if DEBUG_TO_SCREEN + print_set_sendchar(capture_sendchar); +#endif + +done: + return success; +} + +bool iota_gfx_off(void) { + bool success = false; + + send_cmd1(DisplayOff); + success = true; + +done: + return success; +} + +bool iota_gfx_on(void) { + bool success = false; + + send_cmd1(DisplayOn); + success = true; + +done: + return success; +} + +void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) { + *matrix->cursor = c; + ++matrix->cursor; + + if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) { + // We went off the end; scroll the display upwards by one line + memmove(&matrix->display[0], &matrix->display[1], + MatrixCols * (MatrixRows - 1)); + matrix->cursor = &matrix->display[MatrixRows - 1][0]; + memset(matrix->cursor, ' ', MatrixCols); + } +} + +void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { + matrix->dirty = true; + + if (c == '\n') { + // Clear to end of line from the cursor and then move to the + // start of the next line + uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols; + + while (cursor_col++ < MatrixCols) { + matrix_write_char_inner(matrix, ' '); + } + return; + } + + matrix_write_char_inner(matrix, c); +} + +void iota_gfx_write_char(uint8_t c) { + matrix_write_char(&display, c); +} + +void matrix_write(struct CharacterMatrix *matrix, const char *data) { + const char *end = data + strlen(data); + while (data < end) { + matrix_write_char(matrix, *data); + ++data; + } +} + +void iota_gfx_write(const char *data) { + matrix_write(&display, data); +} + +void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { + while (true) { + uint8_t c = pgm_read_byte(data); + if (c == 0) { + return; + } + matrix_write_char(matrix, c); + ++data; + } +} + +void iota_gfx_write_P(const char *data) { + matrix_write_P(&display, data); +} + +void matrix_clear(struct CharacterMatrix *matrix) { + memset(matrix->display, ' ', sizeof(matrix->display)); + matrix->cursor = &matrix->display[0][0]; + matrix->dirty = true; +} + +void iota_gfx_clear_screen(void) { + matrix_clear(&display); +} + +void matrix_render(struct CharacterMatrix *matrix) { + last_flush = timer_read(); + iota_gfx_on(); +#if DEBUG_TO_SCREEN + ++displaying; +#endif + + // Move to the home position + send_cmd3(PageAddr, 0, MatrixRows - 1); + send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); + + if (i2c_start_write(SSD1306_ADDRESS)) { + goto done; + } + if (i2c_master_write(0x40)) { + // Data mode + goto done; + } + + for (uint8_t row = 0; row < MatrixRows; ++row) { + for (uint8_t col = 0; col < MatrixCols; ++col) { + const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth); + + for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) { + uint8_t colBits = pgm_read_byte(glyph + glyphCol); + i2c_master_write(colBits); + } + + // 1 column of space between chars (it's not included in the glyph) + //i2c_master_write(0); + } + } + + matrix->dirty = false; + +done: + i2c_master_stop(); +#if DEBUG_TO_SCREEN + --displaying; +#endif +} + +void iota_gfx_flush(void) { + matrix_render(&display); +} + +__attribute__ ((weak)) +void iota_gfx_task_user(void) { +} + +void iota_gfx_task(void) { + iota_gfx_task_user(); + + if (display.dirty|| force_dirty) { + iota_gfx_flush(); + force_dirty = false; + } + + if (timer_elapsed(last_flush) > ScreenOffInterval) { + iota_gfx_off(); + } +} + +bool process_record_gfx(uint16_t keycode, keyrecord_t *record) { + force_dirty = true; + return true; +} + +#endif diff --git a/keyboards/helix/local_drivers/ssd1306.h b/keyboards/helix/local_drivers/ssd1306.h new file mode 100644 index 0000000000..9cf6983b7e --- /dev/null +++ b/keyboards/helix/local_drivers/ssd1306.h @@ -0,0 +1,93 @@ +#ifndef SSD1306_H +#define SSD1306_H + +#include +#include +#include "pincontrol.h" +#include "action.h" + +enum ssd1306_cmds { + DisplayOff = 0xAE, + DisplayOn = 0xAF, + + SetContrast = 0x81, + DisplayAllOnResume = 0xA4, + + DisplayAllOn = 0xA5, + NormalDisplay = 0xA6, + InvertDisplay = 0xA7, + SetDisplayOffset = 0xD3, + SetComPins = 0xda, + SetVComDetect = 0xdb, + SetDisplayClockDiv = 0xD5, + SetPreCharge = 0xd9, + SetMultiPlex = 0xa8, + SetLowColumn = 0x00, + SetHighColumn = 0x10, + SetStartLine = 0x40, + + SetMemoryMode = 0x20, + ColumnAddr = 0x21, + PageAddr = 0x22, + + ComScanInc = 0xc0, + ComScanDec = 0xc8, + SegRemap = 0xa0, + SetChargePump = 0x8d, + ExternalVcc = 0x01, + SwitchCapVcc = 0x02, + + ActivateScroll = 0x2f, + DeActivateScroll = 0x2e, + SetVerticalScrollArea = 0xa3, + RightHorizontalScroll = 0x26, + LeftHorizontalScroll = 0x27, + VerticalAndRightHorizontalScroll = 0x29, + VerticalAndLeftHorizontalScroll = 0x2a, +}; + +// Controls the SSD1306 128x32 OLED display via i2c + +#ifndef SSD1306_ADDRESS +#define SSD1306_ADDRESS 0x3C +#endif + +#define DisplayHeight 32 +#define DisplayWidth 128 + +#define FontHeight 8 +#define FontWidth 6 + +#define MatrixRows (DisplayHeight / FontHeight) +#define MatrixCols (DisplayWidth / FontWidth) + +struct CharacterMatrix { + uint8_t display[MatrixRows][MatrixCols]; + uint8_t *cursor; + bool dirty; +}; + +struct CharacterMatrix display; + +bool iota_gfx_init(bool rotate); +void iota_gfx_task(void); +bool iota_gfx_off(void); +bool iota_gfx_on(void); +void iota_gfx_flush(void); +void iota_gfx_write_char(uint8_t c); +void iota_gfx_write(const char *data); +void iota_gfx_write_P(const char *data); +void iota_gfx_clear_screen(void); + +void iota_gfx_task_user(void); + +void matrix_clear(struct CharacterMatrix *matrix); +void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c); +void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c); +void matrix_write(struct CharacterMatrix *matrix, const char *data); +void matrix_write_P(struct CharacterMatrix *matrix, const char *data); +void matrix_render(struct CharacterMatrix *matrix); + +bool process_record_gfx(uint16_t keycode, keyrecord_t *record); + +#endif diff --git a/keyboards/helix/pico/back/rules.mk b/keyboards/helix/pico/back/rules.mk new file mode 100644 index 0000000000..066fffb74a --- /dev/null +++ b/keyboards/helix/pico/back/rules.mk @@ -0,0 +1 @@ +LED_BACK_ENABLE = yes diff --git a/keyboards/helix/pico/config.h b/keyboards/helix/pico/config.h index b377332efa..260560f556 100644 --- a/keyboards/helix/pico/config.h +++ b/keyboards/helix/pico/config.h @@ -16,8 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef PICO_CONFIG_H -#define PICO_CONFIG_H +#pragma once /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED @@ -35,6 +34,11 @@ along with this program. If not, see . #define USE_SERIAL //#define USE_MATRIX_I2C +/* Soft Serial defines */ +#define SOFT_SERIAL_PIN D2 +#define SERIAL_SLAVE_BUFFER_LENGTH ((MATRIX_ROWS)/2) +#define SERIAL_MASTER_BUFFER_LENGTH ((MATRIX_ROWS)/2) + /* Select hand configuration */ #define MASTER_LEFT // #define MASTER_RIGHT @@ -138,5 +142,3 @@ along with this program. If not, see . //#define NO_ACTION_ONESHOT //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION - -#endif diff --git a/keyboards/helix/pico/keymaps/biacco/rules.mk b/keyboards/helix/pico/keymaps/biacco/rules.mk index d6b36580e1..0c60c40f64 100644 --- a/keyboards/helix/pico/keymaps/biacco/rules.mk +++ b/keyboards/helix/pico/keymaps/biacco/rules.mk @@ -1,125 +1,24 @@ - -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls AUDIO_ENABLE = yes # Audio output on port B5 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing - -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef - -# Helix keyboard customize -# you can edit follows 6 Variables -# jp: 以下の6つの変数を必要に応じて編集します。 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = no # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -Link_Time_Optimization = no # if firmware size over limit, try this option - -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'default' keymap: convenient command line option -## make HELIX= helix:defualt -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:defualt -## make HELIX=oled,back helix:defualt -## make HELIX=oled,under helix:defualt -## make HELIX=oled,back,na helix:defualt -## make HELIX=oled,back,ios helix:defualt -## -ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) -endif - -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) - -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS -endif - -ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE -endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -ifeq ($(strip $(AUDIO_ENABLE)),yes) - ifeq ($(strip $(RGBLIGHT_ENABLE)),yes) - Link_Time_Optimization = yes - endif - ifeq ($(strip $(OLED_ENABLE)),yes) - Link_Time_Optimization = yes - endif -endif - -ifeq ($(strip $(Link_Time_Optimization)),yes) - EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization -endif - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option + +# Helix Spacific Build Options +# you can uncomment and edit follows 6 Variables +# jp: 以下の6つの変数を必要に応じて編集し、コメントアウトをはずします。 +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +LED_ANIMATIONS = no # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) + +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) diff --git a/keyboards/helix/pico/keymaps/default/readme.md b/keyboards/helix/pico/keymaps/default/readme.md index 13948cf620..9013e31287 100644 --- a/keyboards/helix/pico/keymaps/default/readme.md +++ b/keyboards/helix/pico/keymaps/default/readme.md @@ -95,16 +95,15 @@ see `qmk_firmware/keyboards/helix/pico/keymaps/default/rules.mk` ``` -# Helix keyboard customize -# you can edit follows 6 Variables -# jp: 以下の6つの変数を必要に応じて編集します。 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) - +# Helix Spacific Build Options +# you can uncomment and edit follows 6 Variables +# jp: 以下の6つの変数を必要に応じて編集し、コメントアウトをはずします。 +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) ``` ## Compile @@ -116,11 +115,18 @@ $ cd qmk_firmware build ``` $ make helix/pico:default +$ make helix/pico/back:default # with backlight +$ make HELIX=no_ani helix/pico/back:default # with backlight without animation +$ make helix/pico/under:default # with underglow ``` flash to keyboard ``` -$ make helix/pico:default:avrdude +$ make helix/pico:default:flash +$ make helix/pico/back:default:flash # with backlight +$ make HELIX=no_ani helix/pico/back:default:flash # with backlight without animation +$ make helix/pico/under:default:flash # with underglow + ``` ## Link diff --git a/keyboards/helix/pico/keymaps/default/readme_jp.md b/keyboards/helix/pico/keymaps/default/readme_jp.md index 1e272f9e6a..28594dafcb 100644 --- a/keyboards/helix/pico/keymaps/default/readme_jp.md +++ b/keyboards/helix/pico/keymaps/default/readme_jp.md @@ -56,31 +56,6 @@ 他の配列(Colemak,Dvorak)は、[readme.md](readme.md) を参照 -## コンパイルの仕方 - -コンパイルは、qmk_firmware のトップディレクトリで行います。 - -``` -$ cd qmk_firmware -``` -qmk_firmwareでは各キーボードのコンパイルは、`<キーボード名>:<キーマップ名>`という指定で行います。 - -``` -$ make helix/pico:default -``` - -キーボードへの書き込みまで同時に行うには下記のように`:avrdude`を付けます。 - -``` -$ make helix/pico:default:avrdude -``` - -コンパイル結果と中間生成物を消去したい場合は以下のようにします。 - -``` -$ make helix/pico:default:clean -``` - ## カスタマイズ オプションの OLED をつけたり、 @@ -88,16 +63,15 @@ RGB バックライトまたは、RGB Underglow をつけた場合は、 `qmk_firmware/keyboards/helix/pico/keymaps/default/rules.mk` の以下の部分を編集して機能を有効化してください。 ``` -# Helix keyboard customize -# you can edit follows 6 Variables -# jp: 以下の6つの変数を必要に応じて編集します。 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) - +# Helix Spacific Build Options +# you can uncomment and edit follows 6 Variables +# jp: 以下の6つの変数を必要に応じて編集し、コメントアウトをはずします。 +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) ``` ## RGB バックライトを有効にする @@ -131,6 +105,43 @@ RBG Underglow や RGBバックライトの輝度を抑えて、iPad, iPhone に IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) ``` +## コンパイルの仕方 + +コンパイルは、qmk_firmware のトップディレクトリで行います。 + +``` +$ cd qmk_firmware +``` +qmk_firmwareでは各キーボードのコンパイルは、`<キーボード名>:<キーマップ名>`という指定で行います。 + +``` +$ make helix/pico:default +``` + +キーボードへの書き込みまで同時に行うには下記のように`:flash`を付けます。 + +``` +$ make helix/pico:default:flash +``` + +コンパイル結果と中間生成物を消去したい場合は以下のようにします。 + +``` +$ make helix/pico:default:clean +``` + +上記の、rules.mk によるカスタマイズ項目の一部は下記のようにコマンド上で直接指定することも可能です。 + +RGB バックライトを有効にしてコンパイルしてキーボードへ書き込む。 +``` +$ make helix/pico/back:default:flash +``` + +RGB Underglow を有効にしてコンパイルしてキーボードへ書き込む。 +``` +$ make helix/pico/under:default:flash +``` + ## リンク * さらに詳細は、[こちら helix/Doc/firmware_jp.md](https://github.com/MakotoKurauchi/helix/blob/master/Doc/firmware_jp.md)をご覧ください。 diff --git a/keyboards/helix/pico/keymaps/default/rules.mk b/keyboards/helix/pico/keymaps/default/rules.mk index 3b518ff881..764b073007 100644 --- a/keyboards/helix/pico/keymaps/default/rules.mk +++ b/keyboards/helix/pico/keymaps/default/rules.mk @@ -1,125 +1,24 @@ - -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = yes # Audio output on port B5 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing - -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef - -# Helix keyboard customize -# you can edit follows 6 Variables -# jp: 以下の6つの変数を必要に応じて編集します。 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -Link_Time_Optimization = no # if firmware size over limit, try this option - -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'default' keymap: convenient command line option -## make HELIX= helix:defualt -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:defualt -## make HELIX=oled,back helix:defualt -## make HELIX=oled,under helix:defualt -## make HELIX=oled,back,na helix:defualt -## make HELIX=oled,back,ios helix:defualt -## -ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) -endif - -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) - -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS -endif - -ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE -endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -ifeq ($(strip $(AUDIO_ENABLE)),yes) - ifeq ($(strip $(RGBLIGHT_ENABLE)),yes) - Link_Time_Optimization = yes - endif - ifeq ($(strip $(OLED_ENABLE)),yes) - Link_Time_Optimization = yes - endif -endif - -ifeq ($(strip $(Link_Time_Optimization)),yes) - EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization -endif - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) +AUDIO_ENABLE = yes # Audio output on port B5 +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option + +# Helix Spacific Build Options +# you can uncomment and edit follows 6 Variables +# jp: 以下の6つの変数を必要に応じて編集し、コメントアウトをはずします。 +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) + +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) diff --git a/keyboards/helix/pico/keymaps/mtei/rules.mk b/keyboards/helix/pico/keymaps/mtei/rules.mk index 3b518ff881..764b073007 100644 --- a/keyboards/helix/pico/keymaps/mtei/rules.mk +++ b/keyboards/helix/pico/keymaps/mtei/rules.mk @@ -1,125 +1,24 @@ - -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# EXTRAKEY_ENABLE = yes # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = yes # Audio output on port B5 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing - -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef - -# Helix keyboard customize -# you can edit follows 6 Variables -# jp: 以下の6つの変数を必要に応じて編集します。 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -Link_Time_Optimization = no # if firmware size over limit, try this option - -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'default' keymap: convenient command line option -## make HELIX= helix:defualt -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:defualt -## make HELIX=oled,back helix:defualt -## make HELIX=oled,under helix:defualt -## make HELIX=oled,back,na helix:defualt -## make HELIX=oled,back,ios helix:defualt -## -ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) -endif - -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) - -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS -endif - -ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE -endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -ifeq ($(strip $(AUDIO_ENABLE)),yes) - ifeq ($(strip $(RGBLIGHT_ENABLE)),yes) - Link_Time_Optimization = yes - endif - ifeq ($(strip $(OLED_ENABLE)),yes) - Link_Time_Optimization = yes - endif -endif - -ifeq ($(strip $(Link_Time_Optimization)),yes) - EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization -endif - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) +AUDIO_ENABLE = yes # Audio output on port B5 +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option + +# Helix Spacific Build Options +# you can uncomment and edit follows 6 Variables +# jp: 以下の6つの変数を必要に応じて編集し、コメントアウトをはずします。 +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) + +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) diff --git a/keyboards/helix/pico/local_features.mk b/keyboards/helix/pico/local_features.mk new file mode 100644 index 0000000000..47b928647b --- /dev/null +++ b/keyboards/helix/pico/local_features.mk @@ -0,0 +1,100 @@ +# +# local_features.mk contains post-processing rules for the Helix keyboard. +# +# Post-processing rules convert keyboard-specific shortcuts (that represent +# combinations of standard options) into QMK standard options. +# + +define HELIX_CUSTOMISE_MSG + $(info Helix Spacific Build Options) + $(info - OLED_ENABLE = $(OLED_ENABLE)) + $(info - LED_BACK_ENABLE = $(LED_BACK_ENABLE)) + $(info - LED_UNDERGLOW_ENABLE = $(LED_UNDERGLOW_ENABLE)) + $(info - LED_ANIMATION = $(LED_ANIMATIONS)) + $(info - IOS_DEVICE_ENABLE = $(IOS_DEVICE_ENABLE)) + $(info ) +endef + + ifneq ($(strip $(HELIX)),) + ### Helix keyboard keymap: convenient command line option + ## make HELIX= helix/pico: + ## option= oled | back | under | no_ani | na | ios | verbose + ## ex. + ## make HELIX=oled helix/pico: + ## make HELIX=oled,back helix/pico: + ## make HELIX=oled,under helix/pico: + ## make HELIX=oled,back,na helix/pico: + ## make HELIX=oled,back,ios helix/pico: + ## + ifeq ($(findstring oled,$(HELIX)), oled) + OLED_ENABLE = yes + endif + ifeq ($(findstring back,$(HELIX)), back) + LED_BACK_ENABLE = yes + else ifeq ($(findstring under,$(HELIX)), under) + LED_UNDERGLOW_ENABLE = yes + endif + ifeq ($(findstring na,$(HELIX)), na) + LED_ANIMATIONS = no + endif + ifeq ($(findstring no_ani,$(HELIX)), no_ani) + LED_ANIMATIONS = no + endif + ifeq ($(findstring ios,$(HELIX)), ios) + IOS_DEVICE_ENABLE = yes + endif + ifeq ($(findstring verbose,$(HELIX)), verbose) + SHOW_VERBOSE_INFO = yes + endif + SHOW_HELIX_OPTIONS = yes + endif + +######## +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. + +ifeq ($(strip $(LED_BACK_ENABLE)), yes) + RGBLIGHT_ENABLE = yes + OPT_DEFS += -DRGBLED_BACK + ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) + $(eval $(call HELIX_CUSTOMISE_MSG)) + $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') + endif +else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) + RGBLIGHT_ENABLE = yes +endif + +ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) + OPT_DEFS += -DIOS_DEVICE_ENABLE +endif + +ifeq ($(strip $(LED_ANIMATIONS)), yes) + OPT_DEFS += -DLED_ANIMATIONS +endif + +ifeq ($(strip $(OLED_ENABLE)), yes) + OPT_DEFS += -DOLED_ENABLE +endif + +ifeq ($(strip $(LOCAL_GLCDFONT)), yes) + OPT_DEFS += -DLOCAL_GLCDFONT +endif + +ifeq ($(strip $(AUDIO_ENABLE)),yes) + ifeq ($(strip $(RGBLIGHT_ENABLE)),yes) + LINK_TIME_OPTIMIZATION_ENABLE = yes + endif + ifeq ($(strip $(OLED_ENABLE)),yes) + LINK_TIME_OPTIMIZATION_ENABLE = yes + endif +endif + +ifneq ($(strip $(SHOW_HELIX_OPTIONS)),) + $(eval $(call HELIX_CUSTOMISE_MSG)) + ifneq ($(strip $(SHOW_VERBOSE_INFO)),) + $(info -- RGBLIGHT_ENABLE = $(RGBLIGHT_ENABLE)) + $(info -- OPT_DEFS = $(OPT_DEFS)) + $(info -- LINK_TIME_OPTIMIZATION_ENABLE = $(LINK_TIME_OPTIMIZATION_ENABLE)) + $(info ) + endif +endif diff --git a/keyboards/helix/pico/pico.h b/keyboards/helix/pico/pico.h index d9c57206c6..4360be2a9c 100644 --- a/keyboards/helix/pico/pico.h +++ b/keyboards/helix/pico/pico.h @@ -1,5 +1,4 @@ -#ifndef PICO_H -#define PICO_CONFIG_H +#pragma once #include "../helix.h" @@ -70,6 +69,3 @@ KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25, \ KC_##L30, KC_##L31, KC_##L32, KC_##L33, KC_##L34, KC_##L35, KC_##L36, KC_##R36, KC_##R30, KC_##R31, KC_##R32, KC_##R33, KC_##R34, KC_##R35 \ ) - - -#endif diff --git a/keyboards/helix/pico/rules.mk b/keyboards/helix/pico/rules.mk index 75bf0a5ef8..e916f25f45 100644 --- a/keyboards/helix/pico/rules.mk +++ b/keyboards/helix/pico/rules.mk @@ -1,2 +1,19 @@ +KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))local_features.mk + +SRC += local_drivers/i2c.c +SRC += local_drivers/serial.c +SRC += local_drivers/ssd1306.c +KEYBOARD_PATHS += $(HELIX_TOP_DIR)/local_drivers + +CUSTOM_MATRIX = yes + SRC += pico/matrix.c SRC += pico/split_util.c + +# Helix Spacific Build Options default values +OLED_ENABLE = no # OLED_ENABLE +LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +LED_ANIMATIONS = yes # LED animations +IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) diff --git a/keyboards/helix/pico/serial_config.h b/keyboards/helix/pico/serial_config.h deleted file mode 100644 index fc8736d472..0000000000 --- a/keyboards/helix/pico/serial_config.h +++ /dev/null @@ -1,9 +0,0 @@ -//// #error rev2 serial config - -#ifndef SOFT_SERIAL_PIN -/* Soft Serial defines */ -#define SOFT_SERIAL_PIN D2 - -#define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 -#define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2 -#endif diff --git a/keyboards/helix/pico/under/rules.mk b/keyboards/helix/pico/under/rules.mk new file mode 100644 index 0000000000..a37aa6fab3 --- /dev/null +++ b/keyboards/helix/pico/under/rules.mk @@ -0,0 +1 @@ +LED_UNDERGLOW_ENABLE = yes diff --git a/keyboards/helix/pro_micro.h b/keyboards/helix/pro_micro.h deleted file mode 100644 index f9e7ed75d9..0000000000 --- a/keyboards/helix/pro_micro.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - pins_arduino.h - Pin definition functions for Arduino - Part of Arduino - http://www.arduino.cc/ - - Copyright (c) 2007 David A. Mellis - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA - - $Id: wiring.h 249 2007-02-03 16:52:51Z mellis $ -*/ - -#ifndef Pins_Arduino_h -#define Pins_Arduino_h - -#include - -// Workaround for wrong definitions in "iom32u4.h". -// This should be fixed in the AVR toolchain. -#undef UHCON -#undef UHINT -#undef UHIEN -#undef UHADDR -#undef UHFNUM -#undef UHFNUML -#undef UHFNUMH -#undef UHFLEN -#undef UPINRQX -#undef UPINTX -#undef UPNUM -#undef UPRST -#undef UPCONX -#undef UPCFG0X -#undef UPCFG1X -#undef UPSTAX -#undef UPCFG2X -#undef UPIENX -#undef UPDATX -#undef TCCR2A -#undef WGM20 -#undef WGM21 -#undef COM2B0 -#undef COM2B1 -#undef COM2A0 -#undef COM2A1 -#undef TCCR2B -#undef CS20 -#undef CS21 -#undef CS22 -#undef WGM22 -#undef FOC2B -#undef FOC2A -#undef TCNT2 -#undef TCNT2_0 -#undef TCNT2_1 -#undef TCNT2_2 -#undef TCNT2_3 -#undef TCNT2_4 -#undef TCNT2_5 -#undef TCNT2_6 -#undef TCNT2_7 -#undef OCR2A -#undef OCR2_0 -#undef OCR2_1 -#undef OCR2_2 -#undef OCR2_3 -#undef OCR2_4 -#undef OCR2_5 -#undef OCR2_6 -#undef OCR2_7 -#undef OCR2B -#undef OCR2_0 -#undef OCR2_1 -#undef OCR2_2 -#undef OCR2_3 -#undef OCR2_4 -#undef OCR2_5 -#undef OCR2_6 -#undef OCR2_7 - -#define NUM_DIGITAL_PINS 30 -#define NUM_ANALOG_INPUTS 12 - -#define TX_RX_LED_INIT DDRD |= (1<<5), DDRB |= (1<<0) -#define TXLED0 PORTD |= (1<<5) -#define TXLED1 PORTD &= ~(1<<5) -#define RXLED0 PORTB |= (1<<0) -#define RXLED1 PORTB &= ~(1<<0) - -static const uint8_t SDA = 2; -static const uint8_t SCL = 3; -#define LED_BUILTIN 13 - -// Map SPI port to 'new' pins D14..D17 -static const uint8_t SS = 17; -static const uint8_t MOSI = 16; -static const uint8_t MISO = 14; -static const uint8_t SCK = 15; - -// Mapping of analog pins as digital I/O -// A6-A11 share with digital pins -static const uint8_t ADC0 = 18; -static const uint8_t ADC1 = 19; -static const uint8_t ADC2 = 20; -static const uint8_t ADC3 = 21; -static const uint8_t ADC4 = 22; -static const uint8_t ADC5 = 23; -static const uint8_t ADC6 = 24; // D4 -static const uint8_t ADC7 = 25; // D6 -static const uint8_t ADC8 = 26; // D8 -static const uint8_t ADC9 = 27; // D9 -static const uint8_t ADC10 = 28; // D10 -static const uint8_t ADC11 = 29; // D12 - -#define digitalPinToPCICR(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCICR) : ((uint8_t *)0)) -#define digitalPinToPCICRbit(p) 0 -#define digitalPinToPCMSK(p) ((((p) >= 8 && (p) <= 11) || ((p) >= 14 && (p) <= 17) || ((p) >= A8 && (p) <= A10)) ? (&PCMSK0) : ((uint8_t *)0)) -#define digitalPinToPCMSKbit(p) ( ((p) >= 8 && (p) <= 11) ? (p) - 4 : ((p) == 14 ? 3 : ((p) == 15 ? 1 : ((p) == 16 ? 2 : ((p) == 17 ? 0 : (p - A8 + 4)))))) - -// __AVR_ATmega32U4__ has an unusual mapping of pins to channels -extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; -#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) - -#define digitalPinToInterrupt(p) ((p) == 0 ? 2 : ((p) == 1 ? 3 : ((p) == 2 ? 1 : ((p) == 3 ? 0 : ((p) == 7 ? 4 : NOT_AN_INTERRUPT))))) - -#ifdef ARDUINO_MAIN - -// On the Arduino board, digital pins are also used -// for the analog output (software PWM). Analog input -// pins are a separate set. - -// ATMEL ATMEGA32U4 / ARDUINO LEONARDO -// -// D0 PD2 RXD1/INT2 -// D1 PD3 TXD1/INT3 -// D2 PD1 SDA SDA/INT1 -// D3# PD0 PWM8/SCL OC0B/SCL/INT0 -// D4 A6 PD4 ADC8 -// D5# PC6 ??? OC3A/#OC4A -// D6# A7 PD7 FastPWM #OC4D/ADC10 -// D7 PE6 INT6/AIN0 -// -// D8 A8 PB4 ADC11/PCINT4 -// D9# A9 PB5 PWM16 OC1A/#OC4B/ADC12/PCINT5 -// D10# A10 PB6 PWM16 OC1B/0c4B/ADC13/PCINT6 -// D11# PB7 PWM8/16 0C0A/OC1C/#RTS/PCINT7 -// D12 A11 PD6 T1/#OC4D/ADC9 -// D13# PC7 PWM10 CLK0/OC4A -// -// A0 D18 PF7 ADC7 -// A1 D19 PF6 ADC6 -// A2 D20 PF5 ADC5 -// A3 D21 PF4 ADC4 -// A4 D22 PF1 ADC1 -// A5 D23 PF0 ADC0 -// -// New pins D14..D17 to map SPI port to digital pins -// -// MISO D14 PB3 MISO,PCINT3 -// SCK D15 PB1 SCK,PCINT1 -// MOSI D16 PB2 MOSI,PCINT2 -// SS D17 PB0 RXLED,SS/PCINT0 -// -// Connected LEDs on board for TX and RX -// TXLED D24 PD5 XCK1 -// RXLED D17 PB0 -// HWB PE2 HWB - -// these arrays map port names (e.g. port B) to the -// appropriate addresses for various functions (e.g. reading -// and writing) -const uint16_t PROGMEM port_to_mode_PGM[] = { - NOT_A_PORT, - NOT_A_PORT, - (uint16_t) &DDRB, - (uint16_t) &DDRC, - (uint16_t) &DDRD, - (uint16_t) &DDRE, - (uint16_t) &DDRF, -}; - -const uint16_t PROGMEM port_to_output_PGM[] = { - NOT_A_PORT, - NOT_A_PORT, - (uint16_t) &PORTB, - (uint16_t) &PORTC, - (uint16_t) &PORTD, - (uint16_t) &PORTE, - (uint16_t) &PORTF, -}; - -const uint16_t PROGMEM port_to_input_PGM[] = { - NOT_A_PORT, - NOT_A_PORT, - (uint16_t) &PINB, - (uint16_t) &PINC, - (uint16_t) &PIND, - (uint16_t) &PINE, - (uint16_t) &PINF, -}; - -const uint8_t PROGMEM digital_pin_to_port_PGM[] = { - PD, // D0 - PD2 - PD, // D1 - PD3 - PD, // D2 - PD1 - PD, // D3 - PD0 - PD, // D4 - PD4 - PC, // D5 - PC6 - PD, // D6 - PD7 - PE, // D7 - PE6 - - PB, // D8 - PB4 - PB, // D9 - PB5 - PB, // D10 - PB6 - PB, // D11 - PB7 - PD, // D12 - PD6 - PC, // D13 - PC7 - - PB, // D14 - MISO - PB3 - PB, // D15 - SCK - PB1 - PB, // D16 - MOSI - PB2 - PB, // D17 - SS - PB0 - - PF, // D18 - A0 - PF7 - PF, // D19 - A1 - PF6 - PF, // D20 - A2 - PF5 - PF, // D21 - A3 - PF4 - PF, // D22 - A4 - PF1 - PF, // D23 - A5 - PF0 - - PD, // D24 - PD5 - PD, // D25 / D6 - A7 - PD7 - PB, // D26 / D8 - A8 - PB4 - PB, // D27 / D9 - A9 - PB5 - PB, // D28 / D10 - A10 - PB6 - PD, // D29 / D12 - A11 - PD6 -}; - -const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = { - _BV(2), // D0 - PD2 - _BV(3), // D1 - PD3 - _BV(1), // D2 - PD1 - _BV(0), // D3 - PD0 - _BV(4), // D4 - PD4 - _BV(6), // D5 - PC6 - _BV(7), // D6 - PD7 - _BV(6), // D7 - PE6 - - _BV(4), // D8 - PB4 - _BV(5), // D9 - PB5 - _BV(6), // D10 - PB6 - _BV(7), // D11 - PB7 - _BV(6), // D12 - PD6 - _BV(7), // D13 - PC7 - - _BV(3), // D14 - MISO - PB3 - _BV(1), // D15 - SCK - PB1 - _BV(2), // D16 - MOSI - PB2 - _BV(0), // D17 - SS - PB0 - - _BV(7), // D18 - A0 - PF7 - _BV(6), // D19 - A1 - PF6 - _BV(5), // D20 - A2 - PF5 - _BV(4), // D21 - A3 - PF4 - _BV(1), // D22 - A4 - PF1 - _BV(0), // D23 - A5 - PF0 - - _BV(5), // D24 - PD5 - _BV(7), // D25 / D6 - A7 - PD7 - _BV(4), // D26 / D8 - A8 - PB4 - _BV(5), // D27 / D9 - A9 - PB5 - _BV(6), // D28 / D10 - A10 - PB6 - _BV(6), // D29 / D12 - A11 - PD6 -}; - -const uint8_t PROGMEM digital_pin_to_timer_PGM[] = { - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - TIMER0B, /* 3 */ - NOT_ON_TIMER, - TIMER3A, /* 5 */ - TIMER4D, /* 6 */ - NOT_ON_TIMER, - - NOT_ON_TIMER, - TIMER1A, /* 9 */ - TIMER1B, /* 10 */ - TIMER0A, /* 11 */ - - NOT_ON_TIMER, - TIMER4A, /* 13 */ - - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, - NOT_ON_TIMER, -}; - -const uint8_t PROGMEM analog_pin_to_channel_PGM[] = { - 7, // A0 PF7 ADC7 - 6, // A1 PF6 ADC6 - 5, // A2 PF5 ADC5 - 4, // A3 PF4 ADC4 - 1, // A4 PF1 ADC1 - 0, // A5 PF0 ADC0 - 8, // A6 D4 PD4 ADC8 - 10, // A7 D6 PD7 ADC10 - 11, // A8 D8 PB4 ADC11 - 12, // A9 D9 PB5 ADC12 - 13, // A10 D10 PB6 ADC13 - 9 // A11 D12 PD6 ADC9 -}; - -#endif /* ARDUINO_MAIN */ - -// These serial port names are intended to allow libraries and architecture-neutral -// sketches to automatically default to the correct port name for a particular type -// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, -// the first hardware serial port whose RX/TX pins are not dedicated to another use. -// -// SERIAL_PORT_MONITOR Port which normally prints to the Arduino Serial Monitor -// -// SERIAL_PORT_USBVIRTUAL Port which is USB virtual serial -// -// SERIAL_PORT_LINUXBRIDGE Port which connects to a Linux system via Bridge library -// -// SERIAL_PORT_HARDWARE Hardware serial port, physical RX & TX pins. -// -// SERIAL_PORT_HARDWARE_OPEN Hardware serial ports which are open for use. Their RX & TX -// pins are NOT connected to anything by default. -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_USBVIRTUAL Serial -#define SERIAL_PORT_HARDWARE Serial1 -#define SERIAL_PORT_HARDWARE_OPEN Serial1 - -#endif /* Pins_Arduino_h */ diff --git a/keyboards/helix/rev1/config.h b/keyboards/helix/rev1/config.h index 61fe744728..1a5a266641 100644 --- a/keyboards/helix/rev1/config.h +++ b/keyboards/helix/rev1/config.h @@ -16,8 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef REV1_CONFIG_H -#define REV1_CONFIG_H +#pragma once /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED @@ -27,25 +26,25 @@ along with this program. If not, see . #define PRODUCT Helix Alpha #define DESCRIPTION A split keyboard for the cheap makers +#include + #define HELIX_ROWS 5 /* key matrix size */ // Rows are doubled-up #if HELIX_ROWS == 3 #define MATRIX_ROWS 6 - #define MATRIX_COLS 6 #define MATRIX_ROW_PINS { D7, E6, B4 } #elif HELIX_ROWS == 4 #define MATRIX_ROWS 8 - #define MATRIX_COLS 6 #define MATRIX_ROW_PINS { D7, E6, B4, B5 } #elif HELIX_ROWS == 5 #define MATRIX_ROWS 10 - #define MATRIX_COLS 6 #define MATRIX_ROW_PINS { D7, E6, B4, B5, D4 } #else #error "expected HELIX_ROWS 3 or 4 or 5" #endif +#define MATRIX_COLS 6 // wiring of each half #define MATRIX_COL_PINS { F6, F7, B1, B3, B2, B6 } @@ -86,5 +85,3 @@ along with this program. If not, see . //#define NO_ACTION_ONESHOT //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION - -#endif diff --git a/keyboards/helix/rev1/keymaps/OLED_sample/keymap.c b/keyboards/helix/rev1/keymaps/OLED_sample/keymap.c index 6bee91786c..cc73e36fb6 100644 --- a/keyboards/helix/rev1/keymaps/OLED_sample/keymap.c +++ b/keyboards/helix/rev1/keymaps/OLED_sample/keymap.c @@ -44,7 +44,7 @@ enum custom_keycodes { M_SAMPLE }; -#if HELIX_ROWS == 5 +#if MATRIX_ROWS == 10 // HELIX_ROWS == 5 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Qwerty @@ -174,7 +174,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ) }; -#elif HELIX_ROWS == 4 +#elif MATRIX_ROWS == 8 // HELIX_ROWS == 4 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { diff --git a/keyboards/helix/rev1/keymaps/default/keymap.c b/keyboards/helix/rev1/keymaps/default/keymap.c index 43928a4185..299840e3db 100644 --- a/keyboards/helix/rev1/keymaps/default/keymap.c +++ b/keyboards/helix/rev1/keymaps/default/keymap.c @@ -22,7 +22,7 @@ enum custom_keycodes { ADJUST, }; -#if HELIX_ROWS == 5 +#if MATRIX_ROWS == 10 // HELIX_ROWS == 5 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Qwerty @@ -152,7 +152,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ) }; -#elif HELIX_ROWS == 4 +#elif MATRIX_ROWS == 8 // HELIX_ROWS == 4 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { diff --git a/keyboards/helix/rev1/rev1.h b/keyboards/helix/rev1/rev1.h index a8d6ff0507..b505845ada 100644 --- a/keyboards/helix/rev1/rev1.h +++ b/keyboards/helix/rev1/rev1.h @@ -1,5 +1,4 @@ -#ifndef REV1_H -#define REV1_CONFIG_H +#pragma once #include "../helix.h" @@ -13,7 +12,7 @@ #endif #endif -#if HELIX_ROWS == 3 +#if MATRIX_ROWS == 6 // HELIX_ROWS == 3 #ifndef FLIP_HALF // Standard Keymap // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left) @@ -47,7 +46,7 @@ { R20, R21, R22, R23, R24, R25 }, \ } #endif -#elif HELIX_ROWS == 4 +#elif MATRIX_ROWS == 8 // HELIX_ROWS == 4 #ifndef FLIP_HALF // Standard Keymap // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left) @@ -87,7 +86,7 @@ { R30, R31, R32, R33, R34, R35 } \ } #endif -#elif HELIX_ROWS == 5 +#elif MATRIX_ROWS == 10 // HELIX_ROWS == 5 #ifndef FLIP_HALF // Standard Keymap // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left) @@ -138,7 +137,7 @@ #endif // Used to create a keymap using only KC_ prefixed keys -#if HELIX_ROWS == 3 +#if MATRIX_ROWS == 6 // HELIX_ROWS == 3 #define LAYOUT_kc( \ L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ @@ -149,7 +148,7 @@ KC_##L10, KC_##L11, KC_##L12, KC_##L13, KC_##L14, KC_##L15, KC_##R10, KC_##R11, KC_##R12, KC_##R13, KC_##R14, KC_##R15, \ KC_##L20, KC_##L21, KC_##L22, KC_##L23, KC_##L24, KC_##L25, KC_##R20, KC_##R21, KC_##R22, KC_##R23, KC_##R24, KC_##R25 \ ) -#elif HELIX_ROWS == 4 +#elif MATRIX_ROWS == 8 // HELIX_ROWS == 4 #define LAYOUT_kc( \ L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ @@ -179,4 +178,3 @@ ) #endif -#endif diff --git a/keyboards/helix/rev1/rules.mk b/keyboards/helix/rev1/rules.mk index 13834f5da1..1418f01786 100644 --- a/keyboards/helix/rev1/rules.mk +++ b/keyboards/helix/rev1/rules.mk @@ -1,3 +1,10 @@ +SRC += local_drivers/i2c.c +SRC += local_drivers/serial.c +SRC += local_drivers/ssd1306.c +KEYBOARD_PATHS += $(HELIX_TOP_DIR)/local_drivers + +CUSTOM_MATRIX = yes + SRC += rev1/matrix.c SRC += rev1/split_util.c diff --git a/keyboards/helix/rev2/back/oled/rules.mk b/keyboards/helix/rev2/back/oled/rules.mk new file mode 100644 index 0000000000..dd68e9d3b0 --- /dev/null +++ b/keyboards/helix/rev2/back/oled/rules.mk @@ -0,0 +1 @@ +OLED_ENABLE = yes diff --git a/keyboards/helix/rev2/back/rules.mk b/keyboards/helix/rev2/back/rules.mk new file mode 100644 index 0000000000..066fffb74a --- /dev/null +++ b/keyboards/helix/rev2/back/rules.mk @@ -0,0 +1 @@ +LED_BACK_ENABLE = yes diff --git a/keyboards/helix/rev2/config.h b/keyboards/helix/rev2/config.h index ec74458594..fe82ce140f 100644 --- a/keyboards/helix/rev2/config.h +++ b/keyboards/helix/rev2/config.h @@ -16,8 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ -#ifndef REV2_CONFIG_H -#define REV2_CONFIG_H +#pragma once /* USB Device descriptor parameter */ #define VENDOR_ID 0xFEED @@ -35,6 +34,10 @@ along with this program. If not, see . #define USE_SERIAL //#define USE_MATRIX_I2C +/* Soft Serial defines */ +#define SOFT_SERIAL_PIN D2 +#define SERIAL_USE_MULTI_TRANSACTION + /* Select hand configuration */ #define MASTER_LEFT // #define MASTER_RIGHT @@ -88,7 +91,7 @@ along with this program. If not, see . //#define RGBLIGHT_ANIMATIONS : see ./rules.mk: LED_ANIMATIONS = yes or no // see ./rules.mk: LED_BACK_ENABLE or LED_UNDERGLOW_ENABLE set yes #ifdef RGBLED_BACK - #if HELIX_ROWS == 4 + #if MATRIX_ROWS == 8 // HELIX_ROWS == 4 #define RGBLED_NUM 25 #else #define RGBLED_NUM 32 @@ -101,7 +104,7 @@ along with this program. If not, see . #if RGBLED_NUM <= 6 #define RGBLIGHT_LIMIT_VAL 255 #else - #if HELIX_ROWS == 4 + #if MATRIX_ROWS == 8 // HELIX_ROWS == 4 #define RGBLIGHT_LIMIT_VAL 130 #else #define RGBLIGHT_LIMIT_VAL 120 @@ -112,7 +115,7 @@ along with this program. If not, see . #if RGBLED_NUM <= 6 #define RGBLIGHT_LIMIT_VAL 90 #else - #if HELIX_ROWS == 4 + #if MATRIX_ROWS == 8 // HELIX_ROWS == 4 #define RGBLIGHT_LIMIT_VAL 45 #else #define RGBLIGHT_LIMIT_VAL 35 @@ -155,4 +158,3 @@ along with this program. If not, see . //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION -#endif diff --git a/keyboards/helix/rev2/keymaps/default/keymap.c b/keyboards/helix/rev2/keymaps/default/keymap.c index a64eed3e72..2f4736add8 100644 --- a/keyboards/helix/rev2/keymaps/default/keymap.c +++ b/keyboards/helix/rev2/keymaps/default/keymap.c @@ -53,7 +53,7 @@ enum macro_keycodes { //Macros #define M_SAMPLE M(KC_SAMPLEMACRO) -#if HELIX_ROWS == 5 +#if MATRIX_ROWS == 10 // HELIX_ROWS == 5 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Qwerty @@ -183,7 +183,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ) }; -#elif HELIX_ROWS == 4 +#elif MATRIX_ROWS == 8 // HELIX_ROWS == 4 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { diff --git a/keyboards/helix/rev2/keymaps/default/readme.md b/keyboards/helix/rev2/keymaps/default/readme.md index 2cdc5506ca..c618c47525 100644 --- a/keyboards/helix/rev2/keymaps/default/readme.md +++ b/keyboards/helix/rev2/keymaps/default/readme.md @@ -108,17 +108,16 @@ see `qmk_firmware/keyboards/helix/rev2/keymaps/default/rules.mk` ``` -# Helix keyboard customize -# you can edit follows 7 Variables -# jp: 以下の7つの変数を必要に応じて編集します。 -HELIX_ROWS = 5 # Helix Rows is 4 or 5 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) - +# Helix Spacific Build Options +# you can uncomment and edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集し、コメントアウトをはずします。 +# HELIX_ROWS = 5 # Helix Rows is 4 or 5 +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) ``` ## Compile @@ -130,11 +129,24 @@ $ cd qmk_firmware build ``` $ make helix:default +$ make helix/rev2/back:default # with backlight +$ make HELIX=no_ani helix/rev2/back:default # with backlight without animation +$ make helix/rev2/under:default # with underglow +$ make helix/rev2/oled:default # with oled +$ make helix/rev2/oled/back:default # with oled and backlight +$ make helix/rev2/oled/under:default # with oled and underglow ``` flash to keyboard ``` -$ make helix:default:avrdude +$ make helix:default:flash +$ make helix/rev2/back:default:flash # with backlight +$ make HELIX=no_ani helix/rev2/back:default:flash # with backlight without animation +$ make helix/rev2/under:default:flash # with underglow +$ make helix/rev2/oled:default:flash # with oled +$ make helix/rev2/oled/back:default:flash # with oled and backlight +$ make helix/rev2/oled/under:default:flash # with oled and underglow + ``` ## Link diff --git a/keyboards/helix/rev2/keymaps/default/readme_jp.md b/keyboards/helix/rev2/keymaps/default/readme_jp.md index 3eaeab48ec..2dfab351b0 100644 --- a/keyboards/helix/rev2/keymaps/default/readme_jp.md +++ b/keyboards/helix/rev2/keymaps/default/readme_jp.md @@ -19,31 +19,6 @@ 他の配列(Colemak,Dvorak)は、[readme.md](readme.md) を参照 -## コンパイルの仕方 - -コンパイルは、qmk_firmware のトップディレクトリで行います。 - -``` -$ cd qmk_firmware -``` -qmk_firmwareでは各キーボードのコンパイルは、`<キーボード名>:<キーマップ名>`という指定で行います。 - -``` -$ make helix:default -``` - -キーボードへの書き込みまで同時に行うには下記のように`:avrdude`を付けます。 - -``` -$ make helix:default:avrdude -``` - -コンパイル結果と中間生成物を消去したい場合は以下のようにします。 - -``` -$ make helix:default:clean -``` - ## カスタマイズ Helix キーボードを4行版として製作したり、オプションの OLED をつけたり、 @@ -51,17 +26,16 @@ RGB バックライトまたは、RGB Underglow をつけた場合は、 `qmk_firmware/keyboards/helix/rev2/keymaps/default/rules.mk` の以下の部分を編集して機能を有効化してください。 ``` -# Helix keyboard customize -# you can edit follows 7 Variables -# jp: 以下の7つの変数を必要に応じて編集します。 -HELIX_ROWS = 5 # Helix Rows is 4 or 5 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) - +# Helix Spacific Build Options +# you can uncomment and edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集し、コメントアウトをはずします。 +# HELIX_ROWS = 5 # Helix Rows is 4 or 5 +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) ``` ## 4行版Helix に対応する @@ -103,6 +77,58 @@ RBG Underglow や RGBバックライトの輝度を抑えて、iPad, iPhone に IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) ``` +## コンパイルの仕方 + +コンパイルは、qmk_firmware のトップディレクトリで行います。 + +``` +$ cd qmk_firmware +``` +qmk_firmwareでは各キーボードのコンパイルは、`<キーボード名>:<キーマップ名>`という指定で行います。 + +``` +$ make helix:default +``` + +キーボードへの書き込みまで同時に行うには下記のように`:flash`を付けます。 + +``` +$ make helix:default:flash +``` + +コンパイル結果と中間生成物を消去したい場合は以下のようにします。 + +``` +$ make helix:default:clean +``` + +上記の、rules.mk によるカスタマイズ項目の一部は下記のようにコマンド上で直接指定することも可能です。 + +OLED を有効にしてコンパイルしてキーボードへの書き込む。 +``` +$ make helix/rev2/oled:default:flash +``` + +RGB バックライトを有効にしてコンパイルしてキーボードへ書き込む。 +``` +$ make helix/rev2/back:default:flash +``` + +RGB Underglow を有効にしてコンパイルしてキーボードへ書き込む。 +``` +$ make helix/rev2/under:default:flash +``` + +OLED とRGB バックライトを有効にしてコンパイルしてキーボードへ書き込む。 +``` +$ make helix/rev2/oled/back:default:flash +``` + +OLED とRGB Underglowを有効にしてコンパイルしてキーボードへ書き込む。 +``` +$ make helix/rev2/oled/under:default:flash +``` + ## リンク * さらに詳細は、[こちら helix/Doc/firmware_jp.md](https://github.com/MakotoKurauchi/helix/blob/master/Doc/firmware_jp.md)をご覧ください。 diff --git a/keyboards/helix/rev2/keymaps/default/rules.mk b/keyboards/helix/rev2/keymaps/default/rules.mk index 37ef8632de..6a42fcf73f 100644 --- a/keyboards/helix/rev2/keymaps/default/rules.mk +++ b/keyboards/helix/rev2/keymaps/default/rules.mk @@ -1,124 +1,23 @@ - -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing - -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef - -# Helix keyboard customize -# you can edit follows 7 Variables -# jp: 以下の7つの変数を必要に応じて編集します。 -HELIX_ROWS = 5 # Helix Rows is 4 or 5 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -Link_Time_Optimization = no # if firmware size over limit, try this option - -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'default' keymap: convenient command line option -## make HELIX= helix:defualt -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:defualt -## make HELIX=oled,back helix:defualt -## make HELIX=oled,under helix:defualt -## make HELIX=oled,back,na helix:defualt -## make HELIX=oled,back,ios helix:defualt -## -ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) -endif - -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) - -ifneq ($(strip $(HELIX_ROWS)), 4) - ifneq ($(strip $(HELIX_ROWS)), 5) - $(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value) - endif -endif -OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS)) - -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS -endif - -ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE -endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -ifeq ($(strip $(Link_Time_Optimization)),yes) - EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization -endif - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option + +# Helix Spacific Build Options +# you can uncomment and edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集し、コメントアウトをはずします。 +# HELIX_ROWS = 5 # Helix Rows is 4 or 5 +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) + +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) diff --git a/keyboards/helix/rev2/keymaps/edvorakjp/rules.mk b/keyboards/helix/rev2/keymaps/edvorakjp/rules.mk index 4a96517eb9..e30690029b 100644 --- a/keyboards/helix/rev2/keymaps/edvorakjp/rules.mk +++ b/keyboards/helix/rev2/keymaps/edvorakjp/rules.mk @@ -1,128 +1,38 @@ -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option TAP_DANCE_ENABLE = yes -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef - -# Helix keyboard customize -# you can edit follows 7 Variables -# jp: 以下の7つの変数を必要に応じて編集します。 -HELIX_ROWS = 5 # Helix Rows is 4 or 5 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" instead of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -Link_Time_Optimization = no # if firmware size over limit, try this option - -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'edvorakjp' keymap: convenient command line option -## make HELIX= helix:edvorakjp -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:edvorakjp -## make HELIX=oled,back helix:edvorakjp -## make HELIX=oled,under helix:edvorakjp -## make HELIX=oled,back,na helix:edvorakjp -## make HELIX=oled,back,ios helix:edvorakjp -## -ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) -endif - -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) +# Helix Spacific Build Options +# you can uncomment and edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集し、コメントアウトをはずします。 +# HELIX_ROWS = 5 # Helix Rows is 4 or 5 +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" instead of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) + +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) ifeq ($(strip $(HELIX_ROWS)), 4) SRC += keymap_4rows.c else ifeq ($(strip $(HELIX_ROWS)), 5) SRC += keymap_5rows.c -else - $(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value) endif -OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS)) -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes +ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) OPT_DEFS += -DRGBLED_BACK -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS endif ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE SRC += oled.c endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -ifeq ($(strip $(Link_Time_Optimization)),yes) - EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization -endif - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) diff --git a/keyboards/helix/rev2/keymaps/five_rows/keymap.c b/keyboards/helix/rev2/keymaps/five_rows/keymap.c index 7b7d573d6a..eb73881c6b 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/keymap.c +++ b/keyboards/helix/rev2/keymaps/five_rows/keymap.c @@ -67,7 +67,7 @@ enum custom_keycodes { #define KC_LSLB LSFT(KC_LBRC) #define ___ _______ -#if HELIX_ROWS == 5 +#if MATRIX_ROWS == 10 // HELIX_ROWS == 5 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Qwerty diff --git a/keyboards/helix/rev2/keymaps/five_rows/rules.mk b/keyboards/helix/rev2/keymaps/five_rows/rules.mk index a0bf21917b..fb564b6e04 100644 --- a/keyboards/helix/rev2/keymaps/five_rows/rules.mk +++ b/keyboards/helix/rev2/keymaps/five_rows/rules.mk @@ -1,131 +1,35 @@ - -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug -COMMAND_ENABLE = no # Commands for debug and configuration -# CONSOLE_ENABLE and COMMAND_ENABLE -# yes, no +1500 -# yes, yes +3200 -# no, yes +400 -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing - -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef - -# Helix keyboard customize -# you can edit follows 7 Variables -# jp: 以下の7つの変数を必要に応じて編集します。 +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# + CONSOLE_ENABLE = no # Console for debug + COMMAND_ENABLE = no # Commands for debug and configuration + # CONSOLE_ENABLE and COMMAND_ENABLE + # yes, no +1500 + # yes, yes +3200 + # no, yes +400 +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option + +# Helix Spacific Build Options +# you can uncomment and edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集し、コメントアウトをはずします。 HELIX_ROWS = 5 # Helix Rows is 4 or 5 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -Link_Time_Optimization = no # if firmware size over limit, try this option +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'five_rows' keymap: convenient command line option -## make HELIX= helix:five_rows -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:five_rows -## make HELIX=oled,back helix:five_rows -## make HELIX=oled,under helix:five_rows -## make HELIX=oled,back,na helix:five_rows -## make HELIX=oled,back,ios helix:five_rows -## ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif ifeq ($(findstring console,$(HELIX)), console) CONSOLE_ENABLE = yes endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) endif -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) - -ifneq ($(strip $(HELIX_ROWS)), 4) -ifneq ($(strip $(HELIX_ROWS)), 5) -$(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value) -endif -endif -OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS)) - -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS -endif - -ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE -endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -ifeq ($(strip $(Link_Time_Optimization)),yes) - EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization -endif - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) diff --git a/keyboards/helix/rev2/keymaps/five_rows_jis/keymap.c b/keyboards/helix/rev2/keymaps/five_rows_jis/keymap.c index be76dffbe4..0dae2524d8 100644 --- a/keyboards/helix/rev2/keymaps/five_rows_jis/keymap.c +++ b/keyboards/helix/rev2/keymaps/five_rows_jis/keymap.c @@ -55,7 +55,7 @@ enum custom_keycodes { #define ML_RAIE MO(_RAI_E) #define ML_ADJ MO(_ADJUST) -#if HELIX_ROWS == 5 +#if MATRIX_ROWS == 10 // HELIX_ROWS == 5 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Qwerty JIS Normal * ,-----------------------------------------. ,-----------------------------------------. diff --git a/keyboards/helix/rev2/keymaps/five_rows_jis/rules.mk b/keyboards/helix/rev2/keymaps/five_rows_jis/rules.mk index 37ef8632de..6c2057cfd6 100644 --- a/keyboards/helix/rev2/keymaps/five_rows_jis/rules.mk +++ b/keyboards/helix/rev2/keymaps/five_rows_jis/rules.mk @@ -1,124 +1,23 @@ - -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing - -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option -# Helix keyboard customize -# you can edit follows 7 Variables -# jp: 以下の7つの変数を必要に応じて編集します。 +# Helix Spacific Build Options +# you can uncomment and edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集し、コメントアウトをはずします。 HELIX_ROWS = 5 # Helix Rows is 4 or 5 -OLED_ENABLE = no # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) -LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -Link_Time_Optimization = no # if firmware size over limit, try this option - -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'default' keymap: convenient command line option -## make HELIX= helix:defualt -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:defualt -## make HELIX=oled,back helix:defualt -## make HELIX=oled,under helix:defualt -## make HELIX=oled,back,na helix:defualt -## make HELIX=oled,back,ios helix:defualt -## -ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) -endif - -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) - -ifneq ($(strip $(HELIX_ROWS)), 4) - ifneq ($(strip $(HELIX_ROWS)), 5) - $(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value) - endif -endif -OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS)) - -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS -endif - -ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE -endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -ifeq ($(strip $(Link_Time_Optimization)),yes) - EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization -endif - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) +# OLED_ENABLE = no # OLED_ENABLE +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_ANIMATIONS = yes # LED animations +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) + +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) diff --git a/keyboards/helix/rev2/keymaps/froggy/keymap.c b/keyboards/helix/rev2/keymaps/froggy/keymap.c index c27c1320c4..15fe1afb0c 100644 --- a/keyboards/helix/rev2/keymaps/froggy/keymap.c +++ b/keyboards/helix/rev2/keymaps/froggy/keymap.c @@ -64,7 +64,7 @@ enum macro_keycodes { //Macros #define M_SAMPLE M(KC_SAMPLEMACRO) -#if HELIX_ROWS == 5 +#if MATRIX_ROWS == 10 // HELIX_ROWS == 5 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Base diff --git a/keyboards/helix/rev2/keymaps/froggy/rules.mk b/keyboards/helix/rev2/keymaps/froggy/rules.mk index 8cd0efdd4d..bea059ca16 100644 --- a/keyboards/helix/rev2/keymaps/froggy/rules.mk +++ b/keyboards/helix/rev2/keymaps/froggy/rules.mk @@ -1,124 +1,23 @@ - -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing - -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option -# Helix keyboard customize -# you can edit follows 7 Variables -# jp: 以下の7つの変数を必要に応じて編集します。 +# Helix Spacific Build Options +# you can uncomment and edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集し、コメントアウトをはずします。 HELIX_ROWS = 5 # Helix Rows is 4 or 5 -OLED_ENABLE = yes # OLED_ENABLE -LOCAL_GLCDFONT = yes # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = yes # LED backlight (Enable WS2812 RGB underlight.) +OLED_ENABLE = yes # OLED_ENABLE +LOCAL_GLCDFONT = yes # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +LED_BACK_ENABLE = yes # LED backlight (Enable WS2812 RGB underlight.) LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -Link_Time_Optimization = no # if firmware size over limit, try this option - -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'default' keymap: convenient command line option -## make HELIX= helix:defualt -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:defualt -## make HELIX=oled,back helix:defualt -## make HELIX=oled,under helix:defualt -## make HELIX=oled,back,na helix:defualt -## make HELIX=oled,back,ios helix:defualt -## -ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) -endif - -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) - -ifneq ($(strip $(HELIX_ROWS)), 4) - ifneq ($(strip $(HELIX_ROWS)), 5) - $(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value) - endif -endif -OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS)) - -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS -endif - -ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE -endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -ifeq ($(strip $(Link_Time_Optimization)),yes) - EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization -endif - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) diff --git a/keyboards/helix/rev2/keymaps/led_test/README.md b/keyboards/helix/rev2/keymaps/led_test/README.md index a25f3f36fe..2fe6706452 100644 --- a/keyboards/helix/rev2/keymaps/led_test/README.md +++ b/keyboards/helix/rev2/keymaps/led_test/README.md @@ -23,5 +23,5 @@ $ make helix:led_test Execute the 'make' command and press the reset switch on the keyboard. ``` -$ make helix:led_test:avrdude +$ make helix:led_test:flash ``` diff --git a/keyboards/helix/rev2/keymaps/led_test/rules.mk b/keyboards/helix/rev2/keymaps/led_test/rules.mk index 2062d348d1..fb0b5a5476 100644 --- a/keyboards/helix/rev2/keymaps/led_test/rules.mk +++ b/keyboards/helix/rev2/keymaps/led_test/rules.mk @@ -1,126 +1,25 @@ - -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing - -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option -# Helix keyboard customize -# you can edit follows 7 Variables -# jp: 以下の7つの変数を必要に応じて編集します。 -HELIX_ROWS = 5 # Helix Rows is 4 or 5 +# Helix Spacific Build Options +# you can uncomment and edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集し、コメントアウトをはずします。 +# HELIX_ROWS = 5 # Helix Rows is 4 or 5 OLED_ENABLE = yes # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" LED_BACK_ENABLE = yes # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) LED_ANIMATIONS = yes # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -Link_Time_Optimization = no # if firmware size over limit, try this option - -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'default' keymap: convenient command line option -## make HELIX= helix:defualt -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:defualt -## make HELIX=oled,back helix:defualt -## make HELIX=oled,under helix:defualt -## make HELIX=oled,back,na helix:defualt -## make HELIX=oled,back,ios helix:defualt -## -ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) -endif - -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) - -ifneq ($(strip $(HELIX_ROWS)), 4) - ifneq ($(strip $(HELIX_ROWS)), 5) - $(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value) - endif -endif -OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS)) - -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS -endif - -ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE -endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -ifeq ($(strip $(Link_Time_Optimization)),yes) - EXTRAFLAGS += -flto -DUSE_Link_Time_Optimization -endif +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) SRC += led_test_init.c -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) diff --git a/keyboards/helix/rev2/keymaps/yshrsmz/keymap.c b/keyboards/helix/rev2/keymaps/yshrsmz/keymap.c index 5240ac800c..e5b5f57d97 100644 --- a/keyboards/helix/rev2/keymaps/yshrsmz/keymap.c +++ b/keyboards/helix/rev2/keymaps/yshrsmz/keymap.c @@ -49,7 +49,7 @@ enum macro_keycodes { //Macros #define M_SAMPLE M(KC_SAMPLEMACRO) -#if HELIX_ROWS == 5 +#if MATRIX_ROWS == 10 // HELIX_ROWS == 5 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Qwerty @@ -158,7 +158,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ) }; -#elif HELIX_ROWS == 4 +#elif MATRIX_ROWS == 8 // HELIX_ROWS == 4 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { diff --git a/keyboards/helix/rev2/keymaps/yshrsmz/rules.mk b/keyboards/helix/rev2/keymaps/yshrsmz/rules.mk index 3f390b48f8..bc823e5e12 100644 --- a/keyboards/helix/rev2/keymaps/yshrsmz/rules.mk +++ b/keyboards/helix/rev2/keymaps/yshrsmz/rules.mk @@ -1,121 +1,24 @@ - -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SWAP_HANDS_ENABLE = no # Enable one-hand typing - -define HELIX_CUSTOMISE_MSG - $(info Helix customize) - $(info - OLED_ENABLE=$(OLED_ENABLE)) - $(info - LED_BACK_ENABLE=$(LED_BACK_ENABLE)) - $(info - LED_UNDERGLOW_ENABLE=$(LED_UNDERGLOW_ENABLE)) - $(info - LED_ANIMATION=$(LED_ANIMATIONS)) - $(info - IOS_DEVICE_ENABLE=$(IOS_DEVICE_ENABLE)) -endef +# See TOP/keyboards/helix/rules.mk for a list of options that can be set. +# See TOP/docs/config_options.md for more information. +# +LINK_TIME_OPTIMIZATION_ENABLE = no # if firmware size over limit, try this option +AUTO_SHIFT_ENABLE = yes -# Helix keyboard customize -# you can edit follows 7 Variables -# jp: 以下の7つの変数を必要に応じて編集します。 +# Helix Spacific Build Options +# you can uncomment and edit follows 7 Variables +# jp: 以下の7つの変数を必要に応じて編集し、コメントアウトをはずします。 HELIX_ROWS = 4 # Helix Rows is 4 or 5 OLED_ENABLE = yes # OLED_ENABLE -LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" -LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) -LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +# LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +# LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +# LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) LED_ANIMATIONS = no # LED animations -IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) - -#### LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE. -#### Do not enable these with audio at the same time. - -### Helix keyboard 'default' keymap: convenient command line option -## make HELIX= helix:defualt -## option= oled | back | under | na | ios -## ex. -## make HELIX=oled helix:defualt -## make HELIX=oled,back helix:defualt -## make HELIX=oled,under helix:defualt -## make HELIX=oled,back,na helix:defualt -## make HELIX=oled,back,ios helix:defualt -## -ifneq ($(strip $(HELIX)),) - ifeq ($(findstring oled,$(HELIX)), oled) - OLED_ENABLE = yes - endif - ifeq ($(findstring back,$(HELIX)), back) - LED_BACK_ENABLE = yes - else ifeq ($(findstring under,$(HELIX)), under) - LED_UNDERGLOW_ENABLE = yes - endif - ifeq ($(findstring na,$(HELIX)), na) - LED_ANIMATIONS = no - endif - ifeq ($(findstring ios,$(HELIX)), ios) - IOS_DEVICE_ENABLE = yes - endif - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(info ) -endif - -# Uncomment these for checking -# jp: コンパイル時にカスタマイズの状態を表示したい時はコメントをはずします。 -# $(eval $(call HELIX_CUSTOMISE_MSG)) -# $(info ) - -ifneq ($(strip $(HELIX_ROWS)), 4) - ifneq ($(strip $(HELIX_ROWS)), 5) - $(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value) - endif -endif -OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS)) - -ifeq ($(strip $(LED_BACK_ENABLE)), yes) - RGBLIGHT_ENABLE = yes - OPT_DEFS += -DRGBLED_BACK - ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - $(eval $(call HELIX_CUSTOMISE_MSG)) - $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') - endif -else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) - RGBLIGHT_ENABLE = yes -else - RGBLIGHT_ENABLE = no -endif - -ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) - OPT_DEFS += -DIOS_DEVICE_ENABLE -endif - -ifeq ($(strip $(LED_ANIMATIONS)), yes) - OPT_DEFS += -DLED_ANIMATIONS -endif - -ifeq ($(strip $(OLED_ENABLE)), yes) - OPT_DEFS += -DOLED_ENABLE -endif - -ifeq ($(strip $(LOCAL_GLCDFONT)), yes) - OPT_DEFS += -DLOCAL_GLCDFONT -endif - -# Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -AUTO_SHIFT_ENABLE = yes +# IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) -# Uncomment these for debugging -# $(info -- RGBLIGHT_ENABLE=$(RGBLIGHT_ENABLE)) -# $(info -- OPT_DEFS=$(OPT_DEFS)) -# $(info ) +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. +include $(strip $(KEYBOARD_LOCAL_FEATURES_MK)) diff --git a/keyboards/helix/rev2/local_features.mk b/keyboards/helix/rev2/local_features.mk new file mode 100644 index 0000000000..0f4285eea9 --- /dev/null +++ b/keyboards/helix/rev2/local_features.mk @@ -0,0 +1,98 @@ +# +# local_features.mk contains post-processing rules for the Helix keyboard. +# +# Post-processing rules convert keyboard-specific shortcuts (that represent +# combinations of standard options) into QMK standard options. +# + +define HELIX_CUSTOMISE_MSG + $(info Helix Spacific Build Options) + $(info - OLED_ENABLE = $(OLED_ENABLE)) + $(info - LED_BACK_ENABLE = $(LED_BACK_ENABLE)) + $(info - LED_UNDERGLOW_ENABLE = $(LED_UNDERGLOW_ENABLE)) + $(info - LED_ANIMATION = $(LED_ANIMATIONS)) + $(info - IOS_DEVICE_ENABLE = $(IOS_DEVICE_ENABLE)) + $(info ) +endef + + ifneq ($(strip $(HELIX)),) + ### Helix keyboard keymap: convenient command line option + ## make HELIX= helix: + ## option= oled | back | under | na | ios + ## ex. + ## make HELIX=oled helix: + ## make HELIX=oled,back helix: + ## make HELIX=oled,under helix: + ## make HELIX=oled,back,na helix: + ## make HELIX=oled,back,ios helix: + ## + ifeq ($(findstring oled,$(HELIX)), oled) + OLED_ENABLE = yes + endif + ifeq ($(findstring back,$(HELIX)), back) + LED_BACK_ENABLE = yes + else ifeq ($(findstring under,$(HELIX)), under) + LED_UNDERGLOW_ENABLE = yes + endif + ifeq ($(findstring na,$(HELIX)), na) + LED_ANIMATIONS = no + endif + ifeq ($(findstring no_ani,$(HELIX)), no_ani) + LED_ANIMATIONS = no + endif + ifeq ($(findstring ios,$(HELIX)), ios) + IOS_DEVICE_ENABLE = yes + endif + ifeq ($(findstring verbose,$(HELIX)), verbose) + SHOW_VERBOSE_INFO = yes + endif + SHOW_HELIX_OPTIONS = yes + endif + +######## +# convert Helix-specific options (that represent combinations of standard options) +# into QMK standard options. + +ifneq ($(strip $(HELIX_ROWS)), 4) + ifneq ($(strip $(HELIX_ROWS)), 5) + $(error HELIX_ROWS = $(strip $(HELIX_ROWS)) is unexpected value) + endif +endif +OPT_DEFS += -DHELIX_ROWS=$(strip $(HELIX_ROWS)) + +ifeq ($(strip $(LED_BACK_ENABLE)), yes) + RGBLIGHT_ENABLE = yes + OPT_DEFS += -DRGBLED_BACK + ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) + $(eval $(call HELIX_CUSTOMISE_MSG)) + $(error LED_BACK_ENABLE and LED_UNDERGLOW_ENABLE both 'yes') + endif +else ifeq ($(strip $(LED_UNDERGLOW_ENABLE)), yes) + RGBLIGHT_ENABLE = yes +endif + +ifeq ($(strip $(IOS_DEVICE_ENABLE)), yes) + OPT_DEFS += -DIOS_DEVICE_ENABLE +endif + +ifeq ($(strip $(LED_ANIMATIONS)), yes) + OPT_DEFS += -DLED_ANIMATIONS +endif + +ifeq ($(strip $(OLED_ENABLE)), yes) + OPT_DEFS += -DOLED_ENABLE +endif + +ifeq ($(strip $(LOCAL_GLCDFONT)), yes) + OPT_DEFS += -DLOCAL_GLCDFONT +endif + +ifneq ($(strip $(SHOW_HELIX_OPTIONS)),) + $(eval $(call HELIX_CUSTOMISE_MSG)) + ifneq ($(strip $(SHOW_VERBOSE_INFO)),) + $(info -- RGBLIGHT_ENABLE = $(RGBLIGHT_ENABLE)) + $(info -- OPT_DEFS = $(OPT_DEFS)) + $(info -- LINK_TIME_OPTIMIZATION_ENABLE = $(LINK_TIME_OPTIMIZATION_ENABLE)) + $(info ) + endif +endif diff --git a/keyboards/helix/rev2/oled/back/rules.mk b/keyboards/helix/rev2/oled/back/rules.mk new file mode 100644 index 0000000000..066fffb74a --- /dev/null +++ b/keyboards/helix/rev2/oled/back/rules.mk @@ -0,0 +1 @@ +LED_BACK_ENABLE = yes diff --git a/keyboards/helix/rev2/oled/rules.mk b/keyboards/helix/rev2/oled/rules.mk new file mode 100644 index 0000000000..dd68e9d3b0 --- /dev/null +++ b/keyboards/helix/rev2/oled/rules.mk @@ -0,0 +1 @@ +OLED_ENABLE = yes diff --git a/keyboards/helix/rev2/oled/under/rules.mk b/keyboards/helix/rev2/oled/under/rules.mk new file mode 100644 index 0000000000..a37aa6fab3 --- /dev/null +++ b/keyboards/helix/rev2/oled/under/rules.mk @@ -0,0 +1 @@ +LED_UNDERGLOW_ENABLE = yes diff --git a/keyboards/helix/rev2/rev2.h b/keyboards/helix/rev2/rev2.h index f492999838..4e69daef50 100644 --- a/keyboards/helix/rev2/rev2.h +++ b/keyboards/helix/rev2/rev2.h @@ -1,5 +1,4 @@ -#ifndef REV2_H -#define REV2_CONFIG_H +#pragma once #include "../helix.h" @@ -18,7 +17,7 @@ #endif #endif -#if HELIX_ROWS == 4 +#if MATRIX_ROWS == 8 // HELIX_ROWS == 4 #ifndef FLIP_HALF // Standard Keymap // (TRRS jack on the left half is to the right, TRRS jack on the right half is to the left) @@ -107,7 +106,7 @@ #endif // Used to create a keymap using only KC_ prefixed keys -#if HELIX_ROWS == 4 +#if MATRIX_ROWS == 8 // HELIX_ROWS == 4 #define LAYOUT_kc( \ L00, L01, L02, L03, L04, L05, R00, R01, R02, R03, R04, R05, \ L10, L11, L12, L13, L14, L15, R10, R11, R12, R13, R14, R15, \ @@ -136,5 +135,3 @@ KC_##L40, KC_##L41, KC_##L42, KC_##L43, KC_##L44, KC_##L45, KC_##L46, KC_##R46, KC_##R40, KC_##R41, KC_##R42, KC_##R43, KC_##R44, KC_##R45 \ ) #endif - -#endif diff --git a/keyboards/helix/rev2/rules.mk b/keyboards/helix/rev2/rules.mk index 5582a0f9c4..4db8f7da94 100644 --- a/keyboards/helix/rev2/rules.mk +++ b/keyboards/helix/rev2/rules.mk @@ -1,3 +1,21 @@ +KEYBOARD_LOCAL_FEATURES_MK := $(dir $(lastword $(MAKEFILE_LIST)))local_features.mk + +SRC += local_drivers/i2c.c +SRC += local_drivers/serial.c +SRC += local_drivers/ssd1306.c +KEYBOARD_PATHS += $(HELIX_TOP_DIR)/local_drivers + +CUSTOM_MATRIX = yes + SRC += rev2/matrix.c SRC += rev2/split_util.c SRC += rev2/split_scomm.c + +# Helix Spacific Build Options default values +HELIX_ROWS = 5 # Helix Rows is 4 or 5 +OLED_ENABLE = no # OLED_ENABLE +LOCAL_GLCDFONT = no # use each keymaps "helixfont.h" insted of "common/glcdfont.c" +LED_BACK_ENABLE = no # LED backlight (Enable WS2812 RGB underlight.) +LED_UNDERGLOW_ENABLE = no # LED underglow (Enable WS2812 RGB underlight.) +LED_ANIMATIONS = yes # LED animations +IOS_DEVICE_ENABLE = no # connect to IOS device (iPad,iPhone) diff --git a/keyboards/helix/rev2/serial_config.h b/keyboards/helix/rev2/serial_config.h deleted file mode 100644 index 37135213d5..0000000000 --- a/keyboards/helix/rev2/serial_config.h +++ /dev/null @@ -1,8 +0,0 @@ -//// #error rev2 serial config - -#ifndef SOFT_SERIAL_PIN -/* Soft Serial defines */ -#define SOFT_SERIAL_PIN D2 - -#define SERIAL_USE_MULTI_TRANSACTION -#endif diff --git a/keyboards/helix/rev2/under/oled/rules.mk b/keyboards/helix/rev2/under/oled/rules.mk new file mode 100644 index 0000000000..dd68e9d3b0 --- /dev/null +++ b/keyboards/helix/rev2/under/oled/rules.mk @@ -0,0 +1 @@ +OLED_ENABLE = yes diff --git a/keyboards/helix/rev2/under/rules.mk b/keyboards/helix/rev2/under/rules.mk new file mode 100644 index 0000000000..a37aa6fab3 --- /dev/null +++ b/keyboards/helix/rev2/under/rules.mk @@ -0,0 +1 @@ +LED_UNDERGLOW_ENABLE = yes diff --git a/keyboards/helix/rules.mk b/keyboards/helix/rules.mk index 245bff70fa..cf23434d80 100644 --- a/keyboards/helix/rules.mk +++ b/keyboards/helix/rules.mk @@ -1,75 +1,37 @@ -SRC += i2c.c -SRC += serial.c -SRC += ssd1306.c - # MCU name MCU = atmega32u4 -# Processor frequency. -# This will define a symbol, F_CPU, in all source code files equal to the -# processor frequency in Hz. You can then use this symbol in your source code to -# calculate timings. Do NOT tack on a 'UL' at the end, this will be done -# automatically to create a 32-bit value in your source code. -# -# This will be an integer division of F_USB below, as it is sourced by -# F_USB after it has run through any CPU prescalers. Note that this value -# does not *change* the processor frequency - it should merely be updated to -# reflect the processor speed set externally so that the code can use accurate -# software delays. -F_CPU = 16000000 - -# -# LUFA specific -# -# Target architecture (see library "Board Types" documentation). -ARCH = AVR8 - -# Input clock frequency. -# This will define a symbol, F_USB, in all source code files equal to the -# input clock frequency (before any prescaling is performed) in Hz. This value may -# differ from F_CPU if prescaling is used on the latter, and is required as the -# raw input clock is fed directly to the PLL sections of the AVR for high speed -# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL' -# at the end, this will be done automatically to create a 32-bit value in your -# source code. -# -# If no clock division is performed on the input clock inside the AVR (via the -# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. -F_USB = $(F_CPU) - # Bootloader selection # Teensy halfkay # Pro Micro caterina # Atmel DFU atmel-dfu # LUFA DFU lufa-dfu # QMK DFU qmk-dfu -# atmega32a bootloadHID +# ATmega32A bootloadHID +# ATmega328P USBasp BOOTLOADER = caterina -# Interrupt driven control endpoint task(+60) -OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT +HELIX_TOP_DIR := $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST)))) -# Build Options +# QMK Standard Build Options # change to "no" to disable the options, or define them in the Makefile in # the appropriate keymap folder that will get included automatically # -BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) -MOUSEKEY_ENABLE = no # Mouse keys(+4700) -EXTRAKEY_ENABLE = no # Audio control and System control(+450) -CONSOLE_ENABLE = no # Console for debug(+400) -COMMAND_ENABLE = no # Commands for debug and configuration -NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work -BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality -MIDI_ENABLE = no # MIDI controls -AUDIO_ENABLE = no # Audio output on port C6 -UNICODE_ENABLE = no # Unicode -BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID -RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. -SUBPROJECT_rev1 = no -USE_I2C = yes +# See TOP/docs/config_options.md for more information. +# +BOOTMAGIC_ENABLE = no # Virtual DIP switch configuration(+1000) +MOUSEKEY_ENABLE = no # Mouse keys(+4700) +EXTRAKEY_ENABLE = no # Audio control and System control(+450) +CONSOLE_ENABLE = no # Console for debug(+400) +COMMAND_ENABLE = no # Commands for debug and configuration +NKRO_ENABLE = no # Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work +BACKLIGHT_ENABLE = no # Enable keyboard backlight functionality +MIDI_ENABLE = no # MIDI controls +AUDIO_ENABLE = no # Audio output on port C6 +UNICODE_ENABLE = no # Unicode +BLUETOOTH_ENABLE = no # Enable Bluetooth with the Adafruit EZ-Key HID +RGBLIGHT_ENABLE = no # Enable WS2812 RGB underlight. # Do not enable SLEEP_LED_ENABLE. it uses the same timer as BACKLIGHT_ENABLE -SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend - -CUSTOM_MATRIX = yes +SLEEP_LED_ENABLE = no # Breathing sleep LED during USB suspend DEFAULT_FOLDER = helix/rev2 diff --git a/keyboards/helix/serial.c b/keyboards/helix/serial.c deleted file mode 100644 index 6006ebf1bd..0000000000 --- a/keyboards/helix/serial.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - * WARNING: be careful changing this code, it is very timing dependent - * - * 2018-10-28 checked - * avr-gcc 4.9.2 - * avr-gcc 5.4.0 - * avr-gcc 7.3.0 - */ - -#ifndef F_CPU -#define F_CPU 16000000 -#endif - -#include -#include -#include -#include -#include -#include "serial.h" -//#include - -#ifdef SOFT_SERIAL_PIN - -#ifdef __AVR_ATmega32U4__ - // if using ATmega32U4 I2C, can not use PD0 and PD1 in soft serial. - #ifdef USE_I2C - #if SOFT_SERIAL_PIN == D0 || SOFT_SERIAL_PIN == D1 - #error Using ATmega32U4 I2C, so can not use PD0, PD1 - #endif - #endif - - #if SOFT_SERIAL_PIN >= D0 && SOFT_SERIAL_PIN <= D3 - #define SERIAL_PIN_DDR DDRD - #define SERIAL_PIN_PORT PORTD - #define SERIAL_PIN_INPUT PIND - #if SOFT_SERIAL_PIN == D0 - #define SERIAL_PIN_MASK _BV(PD0) - #define EIMSK_BIT _BV(INT0) - #define EICRx_BIT (~(_BV(ISC00) | _BV(ISC01))) - #define SERIAL_PIN_INTERRUPT INT0_vect - #elif SOFT_SERIAL_PIN == D1 - #define SERIAL_PIN_MASK _BV(PD1) - #define EIMSK_BIT _BV(INT1) - #define EICRx_BIT (~(_BV(ISC10) | _BV(ISC11))) - #define SERIAL_PIN_INTERRUPT INT1_vect - #elif SOFT_SERIAL_PIN == D2 - #define SERIAL_PIN_MASK _BV(PD2) - #define EIMSK_BIT _BV(INT2) - #define EICRx_BIT (~(_BV(ISC20) | _BV(ISC21))) - #define SERIAL_PIN_INTERRUPT INT2_vect - #elif SOFT_SERIAL_PIN == D3 - #define SERIAL_PIN_MASK _BV(PD3) - #define EIMSK_BIT _BV(INT3) - #define EICRx_BIT (~(_BV(ISC30) | _BV(ISC31))) - #define SERIAL_PIN_INTERRUPT INT3_vect - #endif - #elif SOFT_SERIAL_PIN == E6 - #define SERIAL_PIN_DDR DDRE - #define SERIAL_PIN_PORT PORTE - #define SERIAL_PIN_INPUT PINE - #define SERIAL_PIN_MASK _BV(PE6) - #define EIMSK_BIT _BV(INT6) - #define EICRx_BIT (~(_BV(ISC60) | _BV(ISC61))) - #define SERIAL_PIN_INTERRUPT INT6_vect - #else - #error invalid SOFT_SERIAL_PIN value - #endif - -#else - #error serial.c now support ATmega32U4 only -#endif - -//////////////// for backward compatibility //////////////////////////////// -#if !defined(SERIAL_USE_SINGLE_TRANSACTION) && !defined(SERIAL_USE_MULTI_TRANSACTION) -/* --- USE OLD API (compatible with let's split serial.c) */ - #if SERIAL_SLAVE_BUFFER_LENGTH > 0 - uint8_t volatile serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH] = {0}; - #endif - #if SERIAL_MASTER_BUFFER_LENGTH > 0 - uint8_t volatile serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH] = {0}; - #endif - uint8_t volatile status0 = 0; - -SSTD_t transactions[] = { - { (uint8_t *)&status0, - #if SERIAL_MASTER_BUFFER_LENGTH > 0 - sizeof(serial_master_buffer), (uint8_t *)serial_master_buffer, - #else - 0, (uint8_t *)NULL, - #endif - #if SERIAL_SLAVE_BUFFER_LENGTH > 0 - sizeof(serial_slave_buffer), (uint8_t *)serial_slave_buffer - #else - 0, (uint8_t *)NULL, - #endif - } -}; - -void serial_master_init(void) -{ soft_serial_initiator_init(transactions, TID_LIMIT(transactions)); } - -void serial_slave_init(void) -{ soft_serial_target_init(transactions, TID_LIMIT(transactions)); } - -// 0 => no error -// 1 => slave did not respond -// 2 => checksum error -int serial_update_buffers() -{ - int result; - result = soft_serial_transaction(); - return result; -} - -#endif // end of OLD API (compatible with let's split serial.c) -//////////////////////////////////////////////////////////////////////////// - -#define ALWAYS_INLINE __attribute__((always_inline)) -#define NO_INLINE __attribute__((noinline)) -#define _delay_sub_us(x) __builtin_avr_delay_cycles(x) - -// parity check -#define ODD_PARITY 1 -#define EVEN_PARITY 0 -#define PARITY EVEN_PARITY - -#ifdef SERIAL_DELAY - // custom setup in config.h - // #define TID_SEND_ADJUST 2 - // #define SERIAL_DELAY 6 // micro sec - // #define READ_WRITE_START_ADJUST 30 // cycles - // #define READ_WRITE_WIDTH_ADJUST 8 // cycles -#else -// ============ Standard setups ============ - -#ifndef SELECT_SOFT_SERIAL_SPEED -#define SELECT_SOFT_SERIAL_SPEED 1 -// 0: about 189kbps -// 1: about 137kbps (default) -// 2: about 75kbps -// 3: about 39kbps -// 4: about 26kbps -// 5: about 20kbps -#endif - -#if __GNUC__ < 6 - #define TID_SEND_ADJUST 14 -#else - #define TID_SEND_ADJUST 2 -#endif - -#if SELECT_SOFT_SERIAL_SPEED == 0 - // Very High speed - #define SERIAL_DELAY 4 // micro sec - #if __GNUC__ < 6 - #define READ_WRITE_START_ADJUST 33 // cycles - #define READ_WRITE_WIDTH_ADJUST 3 // cycles - #else - #define READ_WRITE_START_ADJUST 34 // cycles - #define READ_WRITE_WIDTH_ADJUST 7 // cycles - #endif -#elif SELECT_SOFT_SERIAL_SPEED == 1 - // High speed - #define SERIAL_DELAY 6 // micro sec - #if __GNUC__ < 6 - #define READ_WRITE_START_ADJUST 30 // cycles - #define READ_WRITE_WIDTH_ADJUST 3 // cycles - #else - #define READ_WRITE_START_ADJUST 33 // cycles - #define READ_WRITE_WIDTH_ADJUST 7 // cycles - #endif -#elif SELECT_SOFT_SERIAL_SPEED == 2 - // Middle speed - #define SERIAL_DELAY 12 // micro sec - #define READ_WRITE_START_ADJUST 30 // cycles - #if __GNUC__ < 6 - #define READ_WRITE_WIDTH_ADJUST 3 // cycles - #else - #define READ_WRITE_WIDTH_ADJUST 7 // cycles - #endif -#elif SELECT_SOFT_SERIAL_SPEED == 3 - // Low speed - #define SERIAL_DELAY 24 // micro sec - #define READ_WRITE_START_ADJUST 30 // cycles - #if __GNUC__ < 6 - #define READ_WRITE_WIDTH_ADJUST 3 // cycles - #else - #define READ_WRITE_WIDTH_ADJUST 7 // cycles - #endif -#elif SELECT_SOFT_SERIAL_SPEED == 4 - // Very Low speed - #define SERIAL_DELAY 36 // micro sec - #define READ_WRITE_START_ADJUST 30 // cycles - #if __GNUC__ < 6 - #define READ_WRITE_WIDTH_ADJUST 3 // cycles - #else - #define READ_WRITE_WIDTH_ADJUST 7 // cycles - #endif -#elif SELECT_SOFT_SERIAL_SPEED == 5 - // Ultra Low speed - #define SERIAL_DELAY 48 // micro sec - #define READ_WRITE_START_ADJUST 30 // cycles - #if __GNUC__ < 6 - #define READ_WRITE_WIDTH_ADJUST 3 // cycles - #else - #define READ_WRITE_WIDTH_ADJUST 7 // cycles - #endif -#else -#error invalid SELECT_SOFT_SERIAL_SPEED value -#endif /* SELECT_SOFT_SERIAL_SPEED */ -#endif /* SERIAL_DELAY */ - -#define SERIAL_DELAY_HALF1 (SERIAL_DELAY/2) -#define SERIAL_DELAY_HALF2 (SERIAL_DELAY - SERIAL_DELAY/2) - -#define SLAVE_INT_WIDTH_US 1 -#ifndef SERIAL_USE_MULTI_TRANSACTION - #define SLAVE_INT_RESPONSE_TIME SERIAL_DELAY -#else - #define SLAVE_INT_ACK_WIDTH_UNIT 2 - #define SLAVE_INT_ACK_WIDTH 4 -#endif - -static SSTD_t *Transaction_table = NULL; -static uint8_t Transaction_table_size = 0; - -inline static void serial_delay(void) ALWAYS_INLINE; -inline static -void serial_delay(void) { - _delay_us(SERIAL_DELAY); -} - -inline static void serial_delay_half1(void) ALWAYS_INLINE; -inline static -void serial_delay_half1(void) { - _delay_us(SERIAL_DELAY_HALF1); -} - -inline static void serial_delay_half2(void) ALWAYS_INLINE; -inline static -void serial_delay_half2(void) { - _delay_us(SERIAL_DELAY_HALF2); -} - -inline static void serial_output(void) ALWAYS_INLINE; -inline static -void serial_output(void) { - SERIAL_PIN_DDR |= SERIAL_PIN_MASK; -} - -// make the serial pin an input with pull-up resistor -inline static void serial_input_with_pullup(void) ALWAYS_INLINE; -inline static -void serial_input_with_pullup(void) { - SERIAL_PIN_DDR &= ~SERIAL_PIN_MASK; - SERIAL_PIN_PORT |= SERIAL_PIN_MASK; -} - -inline static uint8_t serial_read_pin(void) ALWAYS_INLINE; -inline static -uint8_t serial_read_pin(void) { - return !!(SERIAL_PIN_INPUT & SERIAL_PIN_MASK); -} - -inline static void serial_low(void) ALWAYS_INLINE; -inline static -void serial_low(void) { - SERIAL_PIN_PORT &= ~SERIAL_PIN_MASK; -} - -inline static void serial_high(void) ALWAYS_INLINE; -inline static -void serial_high(void) { - SERIAL_PIN_PORT |= SERIAL_PIN_MASK; -} - -void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size) -{ - Transaction_table = sstd_table; - Transaction_table_size = (uint8_t)sstd_table_size; - serial_output(); - serial_high(); -} - -void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size) -{ - Transaction_table = sstd_table; - Transaction_table_size = (uint8_t)sstd_table_size; - serial_input_with_pullup(); - - // Enable INT0-INT3,INT6 - EIMSK |= EIMSK_BIT; -#if SERIAL_PIN_MASK == _BV(PE6) - // Trigger on falling edge of INT6 - EICRB &= EICRx_BIT; -#else - // Trigger on falling edge of INT0-INT3 - EICRA &= EICRx_BIT; -#endif -} - -// Used by the sender to synchronize timing with the reciver. -static void sync_recv(void) NO_INLINE; -static -void sync_recv(void) { - for (uint8_t i = 0; i < SERIAL_DELAY*5 && serial_read_pin(); i++ ) { - } - // This shouldn't hang if the target disconnects because the - // serial line will float to high if the target does disconnect. - while (!serial_read_pin()); -} - -// Used by the reciver to send a synchronization signal to the sender. -static void sync_send(void) NO_INLINE; -static -void sync_send(void) { - serial_low(); - serial_delay(); - serial_high(); -} - -// Reads a byte from the serial line -static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) NO_INLINE; -static uint8_t serial_read_chunk(uint8_t *pterrcount, uint8_t bit) { - uint8_t byte, i, p, pb; - - _delay_sub_us(READ_WRITE_START_ADJUST); - for( i = 0, byte = 0, p = PARITY; i < bit; i++ ) { - serial_delay_half1(); // read the middle of pulses - if( serial_read_pin() ) { - byte = (byte << 1) | 1; p ^= 1; - } else { - byte = (byte << 1) | 0; p ^= 0; - } - _delay_sub_us(READ_WRITE_WIDTH_ADJUST); - serial_delay_half2(); - } - /* recive parity bit */ - serial_delay_half1(); // read the middle of pulses - pb = serial_read_pin(); - _delay_sub_us(READ_WRITE_WIDTH_ADJUST); - serial_delay_half2(); - - *pterrcount += (p != pb)? 1 : 0; - - return byte; -} - -// Sends a byte with MSB ordering -void serial_write_chunk(uint8_t data, uint8_t bit) NO_INLINE; -void serial_write_chunk(uint8_t data, uint8_t bit) { - uint8_t b, p; - for( p = PARITY, b = 1<<(bit-1); b ; b >>= 1) { - if(data & b) { - serial_high(); p ^= 1; - } else { - serial_low(); p ^= 0; - } - serial_delay(); - } - /* send parity bit */ - if(p & 1) { serial_high(); } - else { serial_low(); } - serial_delay(); - - serial_low(); // sync_send() / senc_recv() need raise edge -} - -static void serial_send_packet(uint8_t *buffer, uint8_t size) NO_INLINE; -static -void serial_send_packet(uint8_t *buffer, uint8_t size) { - for (uint8_t i = 0; i < size; ++i) { - uint8_t data; - data = buffer[i]; - sync_send(); - serial_write_chunk(data,8); - } -} - -static uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) NO_INLINE; -static -uint8_t serial_recive_packet(uint8_t *buffer, uint8_t size) { - uint8_t pecount = 0; - for (uint8_t i = 0; i < size; ++i) { - uint8_t data; - sync_recv(); - data = serial_read_chunk(&pecount, 8); - buffer[i] = data; - } - return pecount == 0; -} - -inline static -void change_sender2reciver(void) { - sync_send(); //0 - serial_delay_half1(); //1 - serial_low(); //2 - serial_input_with_pullup(); //2 - serial_delay_half1(); //3 -} - -inline static -void change_reciver2sender(void) { - sync_recv(); //0 - serial_delay(); //1 - serial_low(); //3 - serial_output(); //3 - serial_delay_half1(); //4 -} - -static inline uint8_t nibble_bits_count(uint8_t bits) -{ - bits = (bits & 0x5) + (bits >> 1 & 0x5); - bits = (bits & 0x3) + (bits >> 2 & 0x3); - return bits; -} - -// interrupt handle to be used by the target device -ISR(SERIAL_PIN_INTERRUPT) { - -#ifndef SERIAL_USE_MULTI_TRANSACTION - serial_low(); - serial_output(); - SSTD_t *trans = Transaction_table; -#else - // recive transaction table index - uint8_t tid, bits; - uint8_t pecount = 0; - sync_recv(); - bits = serial_read_chunk(&pecount,7); - tid = bits>>3; - bits = (bits&7) != nibble_bits_count(tid); - if( bits || pecount> 0 || tid > Transaction_table_size ) { - return; - } - serial_delay_half1(); - - serial_high(); // response step1 low->high - serial_output(); - _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT*SLAVE_INT_ACK_WIDTH); - SSTD_t *trans = &Transaction_table[tid]; - serial_low(); // response step2 ack high->low -#endif - - // target send phase - if( trans->target2initiator_buffer_size > 0 ) - serial_send_packet((uint8_t *)trans->target2initiator_buffer, - trans->target2initiator_buffer_size); - // target switch to input - change_sender2reciver(); - - // target recive phase - if( trans->initiator2target_buffer_size > 0 ) { - if (serial_recive_packet((uint8_t *)trans->initiator2target_buffer, - trans->initiator2target_buffer_size) ) { - *trans->status = TRANSACTION_ACCEPTED; - } else { - *trans->status = TRANSACTION_DATA_ERROR; - } - } else { - *trans->status = TRANSACTION_ACCEPTED; - } - - sync_recv(); //weit initiator output to high -} - -///////// -// start transaction by initiator -// -// int soft_serial_transaction(int sstd_index) -// -// Returns: -// TRANSACTION_END -// TRANSACTION_NO_RESPONSE -// TRANSACTION_DATA_ERROR -// this code is very time dependent, so we need to disable interrupts -#ifndef SERIAL_USE_MULTI_TRANSACTION -int soft_serial_transaction(void) { - SSTD_t *trans = Transaction_table; -#else -int soft_serial_transaction(int sstd_index) { - if( sstd_index > Transaction_table_size ) - return TRANSACTION_TYPE_ERROR; - SSTD_t *trans = &Transaction_table[sstd_index]; -#endif - cli(); - - // signal to the target that we want to start a transaction - serial_output(); - serial_low(); - _delay_us(SLAVE_INT_WIDTH_US); - -#ifndef SERIAL_USE_MULTI_TRANSACTION - // wait for the target response - serial_input_with_pullup(); - _delay_us(SLAVE_INT_RESPONSE_TIME); - - // check if the target is present - if (serial_read_pin()) { - // target failed to pull the line low, assume not present - serial_output(); - serial_high(); - *trans->status = TRANSACTION_NO_RESPONSE; - sei(); - return TRANSACTION_NO_RESPONSE; - } - -#else - // send transaction table index - int tid = (sstd_index<<3) | (7 & nibble_bits_count(sstd_index)); - sync_send(); - _delay_sub_us(TID_SEND_ADJUST); - serial_write_chunk(tid, 7); - serial_delay_half1(); - - // wait for the target response (step1 low->high) - serial_input_with_pullup(); - while( !serial_read_pin() ) { - _delay_sub_us(2); - } - - // check if the target is present (step2 high->low) - for( int i = 0; serial_read_pin(); i++ ) { - if (i > SLAVE_INT_ACK_WIDTH + 1) { - // slave failed to pull the line low, assume not present - serial_output(); - serial_high(); - *trans->status = TRANSACTION_NO_RESPONSE; - sei(); - return TRANSACTION_NO_RESPONSE; - } - _delay_sub_us(SLAVE_INT_ACK_WIDTH_UNIT); - } -#endif - - // initiator recive phase - // if the target is present syncronize with it - if( trans->target2initiator_buffer_size > 0 ) { - if (!serial_recive_packet((uint8_t *)trans->target2initiator_buffer, - trans->target2initiator_buffer_size) ) { - serial_output(); - serial_high(); - *trans->status = TRANSACTION_DATA_ERROR; - sei(); - return TRANSACTION_DATA_ERROR; - } - } - - // initiator switch to output - change_reciver2sender(); - - // initiator send phase - if( trans->initiator2target_buffer_size > 0 ) { - serial_send_packet((uint8_t *)trans->initiator2target_buffer, - trans->initiator2target_buffer_size); - } - - // always, release the line when not in use - sync_send(); - - *trans->status = TRANSACTION_END; - sei(); - return TRANSACTION_END; -} - -#ifdef SERIAL_USE_MULTI_TRANSACTION -int soft_serial_get_and_clean_status(int sstd_index) { - SSTD_t *trans = &Transaction_table[sstd_index]; - cli(); - int retval = *trans->status; - *trans->status = 0;; - sei(); - return retval; -} -#endif - -#endif - -// Helix serial.c history -// 2018-1-29 fork from let's split and add PD2, modify sync_recv() (#2308, bceffdefc) -// 2018-6-28 bug fix master to slave comm and speed up (#3255, 1038bbef4) -// (adjusted with avr-gcc 4.9.2) -// 2018-7-13 remove USE_SERIAL_PD2 macro (#3374, f30d6dd78) -// (adjusted with avr-gcc 4.9.2) -// 2018-8-11 add support multi-type transaction (#3608, feb5e4aae) -// (adjusted with avr-gcc 4.9.2) -// 2018-10-21 fix serial and RGB animation conflict (#4191, 4665e4fff) -// (adjusted with avr-gcc 7.3.0) -// 2018-10-28 re-adjust compiler depend value of delay (#4269, 8517f8a66) -// (adjusted with avr-gcc 5.4.0, 7.3.0) diff --git a/keyboards/helix/serial.h b/keyboards/helix/serial.h deleted file mode 100644 index 2e53928df2..0000000000 --- a/keyboards/helix/serial.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef SOFT_SERIAL_H -#define SOFT_SERIAL_H - -#include - -// ///////////////////////////////////////////////////////////////// -// Need Soft Serial defines in config.h -// ///////////////////////////////////////////////////////////////// -// ex. -// #define SOFT_SERIAL_PIN ?? // ?? = D0,D1,D2,D3,E6 -// OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5 -// // 1: about 137kbps (default) -// // 2: about 75kbps -// // 3: about 39kbps -// // 4: about 26kbps -// // 5: about 20kbps -// -// //// USE OLD API (compatible with let's split serial.c) -// ex. -// #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 -// #define SERIAL_MASTER_BUFFER_LENGTH 1 -// -// //// USE NEW API -// //// USE simple API (using signle-type transaction function) -// #define SERIAL_USE_SINGLE_TRANSACTION -// //// USE flexible API (using multi-type transaction function) -// #define SERIAL_USE_MULTI_TRANSACTION -// -// ///////////////////////////////////////////////////////////////// - - -//////////////// for backward compatibility //////////////////////////////// -#if !defined(SERIAL_USE_SINGLE_TRANSACTION) && !defined(SERIAL_USE_MULTI_TRANSACTION) -/* --- USE OLD API (compatible with let's split serial.c) */ - #if SERIAL_SLAVE_BUFFER_LENGTH > 0 - extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; - #endif - #if SERIAL_MASTER_BUFFER_LENGTH > 0 - extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; - #endif - - void serial_master_init(void); - void serial_slave_init(void); - int serial_update_buffers(void); - -#endif // end of USE OLD API -//////////////////////////////////////////////////////////////////////////// - -// Soft Serial Transaction Descriptor -typedef struct _SSTD_t { - uint8_t *status; - uint8_t initiator2target_buffer_size; - uint8_t *initiator2target_buffer; - uint8_t target2initiator_buffer_size; - uint8_t *target2initiator_buffer; -} SSTD_t; -#define TID_LIMIT( table ) (sizeof(table) / sizeof(SSTD_t)) - -// initiator is transaction start side -void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size); -// target is interrupt accept side -void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size); - -// initiator resullt -#define TRANSACTION_END 0 -#define TRANSACTION_NO_RESPONSE 0x1 -#define TRANSACTION_DATA_ERROR 0x2 -#define TRANSACTION_TYPE_ERROR 0x4 -#ifndef SERIAL_USE_MULTI_TRANSACTION -int soft_serial_transaction(void); -#else -int soft_serial_transaction(int sstd_index); -#endif - -// target status -// *SSTD_t.status has -// initiator: -// TRANSACTION_END -// or TRANSACTION_NO_RESPONSE -// or TRANSACTION_DATA_ERROR -// target: -// TRANSACTION_DATA_ERROR -// or TRANSACTION_ACCEPTED -#define TRANSACTION_ACCEPTED 0x8 -#ifdef SERIAL_USE_MULTI_TRANSACTION -int soft_serial_get_and_clean_status(int sstd_index); -#endif - -#endif /* SOFT_SERIAL_H */ diff --git a/keyboards/helix/ssd1306.c b/keyboards/helix/ssd1306.c deleted file mode 100644 index dd3290ba0c..0000000000 --- a/keyboards/helix/ssd1306.c +++ /dev/null @@ -1,342 +0,0 @@ - -#ifdef SSD1306OLED - -#include "ssd1306.h" -#include "i2c.h" -#include -#include "print.h" -#ifndef LOCAL_GLCDFONT -#include "common/glcdfont.c" -#else -#include -#endif -#ifdef ADAFRUIT_BLE_ENABLE -#include "adafruit_ble.h" -#endif -#ifdef PROTOCOL_LUFA -#include "lufa.h" -#endif -#include "sendchar.h" -#include "timer.h" - -// Set this to 1 to help diagnose early startup problems -// when testing power-on with ble. Turn it off otherwise, -// as the latency of printing most of the debug info messes -// with the matrix scan, causing keys to drop. -#define DEBUG_TO_SCREEN 0 - -//static uint16_t last_battery_update; -//static uint32_t vbat; -//#define BatteryUpdateInterval 10000 /* milliseconds */ - -// 'last_flush' is declared as uint16_t, -// so this must be less than 65535 -#define ScreenOffInterval 60000 /* milliseconds */ -#if DEBUG_TO_SCREEN -static uint8_t displaying; -#endif -static uint16_t last_flush; - -static bool force_dirty = true; - -// Write command sequence. -// Returns true on success. -static inline bool _send_cmd1(uint8_t cmd) { - bool res = false; - - if (i2c_start_write(SSD1306_ADDRESS)) { - xprintf("failed to start write to %d\n", SSD1306_ADDRESS); - goto done; - } - - if (i2c_master_write(0x0 /* command byte follows */)) { - print("failed to write control byte\n"); - - goto done; - } - - if (i2c_master_write(cmd)) { - xprintf("failed to write command %d\n", cmd); - goto done; - } - res = true; -done: - i2c_master_stop(); - return res; -} - -// Write 2-byte command sequence. -// Returns true on success -static inline bool _send_cmd2(uint8_t cmd, uint8_t opr) { - if (!_send_cmd1(cmd)) { - return false; - } - return _send_cmd1(opr); -} - -// Write 3-byte command sequence. -// Returns true on success -static inline bool _send_cmd3(uint8_t cmd, uint8_t opr1, uint8_t opr2) { - if (!_send_cmd1(cmd)) { - return false; - } - if (!_send_cmd1(opr1)) { - return false; - } - return _send_cmd1(opr2); -} - -#define send_cmd1(c) if (!_send_cmd1(c)) {goto done;} -#define send_cmd2(c,o) if (!_send_cmd2(c,o)) {goto done;} -#define send_cmd3(c,o1,o2) if (!_send_cmd3(c,o1,o2)) {goto done;} - -static void clear_display(void) { - matrix_clear(&display); - - // Clear all of the display bits (there can be random noise - // in the RAM on startup) - send_cmd3(PageAddr, 0, (DisplayHeight / 8) - 1); - send_cmd3(ColumnAddr, 0, DisplayWidth - 1); - - if (i2c_start_write(SSD1306_ADDRESS)) { - goto done; - } - if (i2c_master_write(0x40)) { - // Data mode - goto done; - } - for (uint8_t row = 0; row < MatrixRows; ++row) { - for (uint8_t col = 0; col < DisplayWidth; ++col) { - i2c_master_write(0); - } - } - - display.dirty = false; - -done: - i2c_master_stop(); -} - -#if DEBUG_TO_SCREEN -#undef sendchar -static int8_t capture_sendchar(uint8_t c) { - sendchar(c); - iota_gfx_write_char(c); - - if (!displaying) { - iota_gfx_flush(); - } - return 0; -} -#endif - -bool iota_gfx_init(bool rotate) { - bool success = false; - - i2c_master_init(); - send_cmd1(DisplayOff); - send_cmd2(SetDisplayClockDiv, 0x80); - send_cmd2(SetMultiPlex, DisplayHeight - 1); - - send_cmd2(SetDisplayOffset, 0); - - - send_cmd1(SetStartLine | 0x0); - send_cmd2(SetChargePump, 0x14 /* Enable */); - send_cmd2(SetMemoryMode, 0 /* horizontal addressing */); - - if(rotate){ - // the following Flip the display orientation 180 degrees - send_cmd1(SegRemap); - send_cmd1(ComScanInc); - }else{ - // Flips the display orientation 0 degrees - send_cmd1(SegRemap | 0x1); - send_cmd1(ComScanDec); - } - - send_cmd2(SetComPins, 0x2); - send_cmd2(SetContrast, 0x8f); - send_cmd2(SetPreCharge, 0xf1); - send_cmd2(SetVComDetect, 0x40); - send_cmd1(DisplayAllOnResume); - send_cmd1(NormalDisplay); - send_cmd1(DeActivateScroll); - send_cmd1(DisplayOn); - - send_cmd2(SetContrast, 0); // Dim - - clear_display(); - - success = true; - - iota_gfx_flush(); - -#if DEBUG_TO_SCREEN - print_set_sendchar(capture_sendchar); -#endif - -done: - return success; -} - -bool iota_gfx_off(void) { - bool success = false; - - send_cmd1(DisplayOff); - success = true; - -done: - return success; -} - -bool iota_gfx_on(void) { - bool success = false; - - send_cmd1(DisplayOn); - success = true; - -done: - return success; -} - -void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c) { - *matrix->cursor = c; - ++matrix->cursor; - - if (matrix->cursor - &matrix->display[0][0] == sizeof(matrix->display)) { - // We went off the end; scroll the display upwards by one line - memmove(&matrix->display[0], &matrix->display[1], - MatrixCols * (MatrixRows - 1)); - matrix->cursor = &matrix->display[MatrixRows - 1][0]; - memset(matrix->cursor, ' ', MatrixCols); - } -} - -void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c) { - matrix->dirty = true; - - if (c == '\n') { - // Clear to end of line from the cursor and then move to the - // start of the next line - uint8_t cursor_col = (matrix->cursor - &matrix->display[0][0]) % MatrixCols; - - while (cursor_col++ < MatrixCols) { - matrix_write_char_inner(matrix, ' '); - } - return; - } - - matrix_write_char_inner(matrix, c); -} - -void iota_gfx_write_char(uint8_t c) { - matrix_write_char(&display, c); -} - -void matrix_write(struct CharacterMatrix *matrix, const char *data) { - const char *end = data + strlen(data); - while (data < end) { - matrix_write_char(matrix, *data); - ++data; - } -} - -void iota_gfx_write(const char *data) { - matrix_write(&display, data); -} - -void matrix_write_P(struct CharacterMatrix *matrix, const char *data) { - while (true) { - uint8_t c = pgm_read_byte(data); - if (c == 0) { - return; - } - matrix_write_char(matrix, c); - ++data; - } -} - -void iota_gfx_write_P(const char *data) { - matrix_write_P(&display, data); -} - -void matrix_clear(struct CharacterMatrix *matrix) { - memset(matrix->display, ' ', sizeof(matrix->display)); - matrix->cursor = &matrix->display[0][0]; - matrix->dirty = true; -} - -void iota_gfx_clear_screen(void) { - matrix_clear(&display); -} - -void matrix_render(struct CharacterMatrix *matrix) { - last_flush = timer_read(); - iota_gfx_on(); -#if DEBUG_TO_SCREEN - ++displaying; -#endif - - // Move to the home position - send_cmd3(PageAddr, 0, MatrixRows - 1); - send_cmd3(ColumnAddr, 0, (MatrixCols * FontWidth) - 1); - - if (i2c_start_write(SSD1306_ADDRESS)) { - goto done; - } - if (i2c_master_write(0x40)) { - // Data mode - goto done; - } - - for (uint8_t row = 0; row < MatrixRows; ++row) { - for (uint8_t col = 0; col < MatrixCols; ++col) { - const uint8_t *glyph = font + (matrix->display[row][col] * FontWidth); - - for (uint8_t glyphCol = 0; glyphCol < FontWidth; ++glyphCol) { - uint8_t colBits = pgm_read_byte(glyph + glyphCol); - i2c_master_write(colBits); - } - - // 1 column of space between chars (it's not included in the glyph) - //i2c_master_write(0); - } - } - - matrix->dirty = false; - -done: - i2c_master_stop(); -#if DEBUG_TO_SCREEN - --displaying; -#endif -} - -void iota_gfx_flush(void) { - matrix_render(&display); -} - -__attribute__ ((weak)) -void iota_gfx_task_user(void) { -} - -void iota_gfx_task(void) { - iota_gfx_task_user(); - - if (display.dirty|| force_dirty) { - iota_gfx_flush(); - force_dirty = false; - } - - if (timer_elapsed(last_flush) > ScreenOffInterval) { - iota_gfx_off(); - } -} - -bool process_record_gfx(uint16_t keycode, keyrecord_t *record) { - force_dirty = true; - return true; -} - -#endif diff --git a/keyboards/helix/ssd1306.h b/keyboards/helix/ssd1306.h deleted file mode 100644 index 9cf6983b7e..0000000000 --- a/keyboards/helix/ssd1306.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef SSD1306_H -#define SSD1306_H - -#include -#include -#include "pincontrol.h" -#include "action.h" - -enum ssd1306_cmds { - DisplayOff = 0xAE, - DisplayOn = 0xAF, - - SetContrast = 0x81, - DisplayAllOnResume = 0xA4, - - DisplayAllOn = 0xA5, - NormalDisplay = 0xA6, - InvertDisplay = 0xA7, - SetDisplayOffset = 0xD3, - SetComPins = 0xda, - SetVComDetect = 0xdb, - SetDisplayClockDiv = 0xD5, - SetPreCharge = 0xd9, - SetMultiPlex = 0xa8, - SetLowColumn = 0x00, - SetHighColumn = 0x10, - SetStartLine = 0x40, - - SetMemoryMode = 0x20, - ColumnAddr = 0x21, - PageAddr = 0x22, - - ComScanInc = 0xc0, - ComScanDec = 0xc8, - SegRemap = 0xa0, - SetChargePump = 0x8d, - ExternalVcc = 0x01, - SwitchCapVcc = 0x02, - - ActivateScroll = 0x2f, - DeActivateScroll = 0x2e, - SetVerticalScrollArea = 0xa3, - RightHorizontalScroll = 0x26, - LeftHorizontalScroll = 0x27, - VerticalAndRightHorizontalScroll = 0x29, - VerticalAndLeftHorizontalScroll = 0x2a, -}; - -// Controls the SSD1306 128x32 OLED display via i2c - -#ifndef SSD1306_ADDRESS -#define SSD1306_ADDRESS 0x3C -#endif - -#define DisplayHeight 32 -#define DisplayWidth 128 - -#define FontHeight 8 -#define FontWidth 6 - -#define MatrixRows (DisplayHeight / FontHeight) -#define MatrixCols (DisplayWidth / FontWidth) - -struct CharacterMatrix { - uint8_t display[MatrixRows][MatrixCols]; - uint8_t *cursor; - bool dirty; -}; - -struct CharacterMatrix display; - -bool iota_gfx_init(bool rotate); -void iota_gfx_task(void); -bool iota_gfx_off(void); -bool iota_gfx_on(void); -void iota_gfx_flush(void); -void iota_gfx_write_char(uint8_t c); -void iota_gfx_write(const char *data); -void iota_gfx_write_P(const char *data); -void iota_gfx_clear_screen(void); - -void iota_gfx_task_user(void); - -void matrix_clear(struct CharacterMatrix *matrix); -void matrix_write_char_inner(struct CharacterMatrix *matrix, uint8_t c); -void matrix_write_char(struct CharacterMatrix *matrix, uint8_t c); -void matrix_write(struct CharacterMatrix *matrix, const char *data); -void matrix_write_P(struct CharacterMatrix *matrix, const char *data); -void matrix_render(struct CharacterMatrix *matrix); - -bool process_record_gfx(uint16_t keycode, keyrecord_t *record); - -#endif -- cgit v1.2.3