Skip to content

Commit

Permalink
fix split oled layer state and current input not sync
Browse files Browse the repository at this point in the history
  • Loading branch information
jiaxin96 committed Aug 21, 2021
1 parent a54bf3a commit 7888677
Show file tree
Hide file tree
Showing 13 changed files with 378 additions and 89 deletions.
2 changes: 1 addition & 1 deletion keyboards/crkbd/rev1/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define SOFT_SERIAL_PIN D2

/* ws2812 RGB LED */
#define RGB_DI_PIN D3
#define RGB_DI_PIN D3

#ifdef RGBLIGHT_ENABLE
# define RGBLED_NUM 12 // Number of LEDs
Expand Down
11 changes: 7 additions & 4 deletions keyboards/yandrstudio/hotdox76_V2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define PRODUCT_ID 0xAAA9
#define DEVICE_VER 0x0002
#define MANUFACTURER JasonRen biu
#define PRODUCT hotdox76_V2
#define PRODUCT hotdox76V2

/* key matrix size */
#define MATRIX_ROWS 6*2
Expand Down Expand Up @@ -86,12 +86,13 @@

# define RGBLIGHT_SPLIT
# define RGBLED_SPLIT {43, 43}

# define RGB_DI_PIN D3
# define RGBLED_NUM (43*2)
# define DRIVER_LED_TOTAL RGBLED_NUM
# define RGBLIGHT_LIMIT_VAL 150
# define RGBLIGHT_SLEEP
# define WS2812_TRST_US 100
# define RGBLIGHT_ANIMATIONS

// # define WS2812_BYTE_ORDER WS2812_BYTE_ORDER_RGB

Expand All @@ -106,6 +107,8 @@
# define SOFT_SERIAL_PIN D2

# define SPLIT_MODS_ENABLE
# define SPLIT_TRANSPORT_MIRROR


# define SPLIT_USB_DETECT

Expand All @@ -127,8 +130,8 @@
*/

/* disable action features */
#define NO_ACTION_LAYER
#define NO_ACTION_TAPPING
// #define NO_ACTION_LAYER
// #define NO_ACTION_TAPPING
#define NO_ACTION_ONESHOT

/* disable these deprecated features by default */
Expand Down
99 changes: 53 additions & 46 deletions keyboards/yandrstudio/hotdox76_V2/hotdox76_V2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@
#include "oled_font_lib/logo.h"
#include "oled_font_lib/ext_font.h"




bool is_keyboard_left(void) {

#ifdef I_AM_LEFT
return true;
#else
return false;
#endif

}


#ifdef RGB_MATRIX_ENABLE
led_config_t g_led_config = {
{
Expand Down Expand Up @@ -54,6 +68,7 @@ led_config_t g_led_config = {
#endif



#ifdef OLED_DRIVER_ENABLE

# define UNC (94+0x21)
Expand Down Expand Up @@ -81,85 +96,88 @@ void render_logo(void) {
for (i = 0; i < 4; ++i) {
for (j = 0; j < 32; ++j) {
# ifdef I_AM_LEFT
oled_write_raw_byte(logo_idobao[i*32+j], i*128+j);
oled_write_raw_byte(pgm_read_byte(&logo_idobao[i*32+j]), i*128+j);
# else
oled_write_raw_byte(logo_idobao[i*32+j], i*128+j+96);
oled_write_raw_byte(pgm_read_byte(&logo_idobao[i*32+j]), i*128+j+96);
# endif
}
}
}


void render_layer_helper_fun(uint8_t start_line, const char * data, uint8_t gap_w) {
uint8_t j = 0, k = 0, l = strlen(data);
void render_layer_helper_fun(uint8_t start_line, const char * data, uint8_t gap_w, uint8_t l) {
uint8_t j = 0, k = 0;
for (j = 0; j < l; ++j) { // font index
for (k = 0; k < 12; ++k) { // font byte index
// base + logo_w(32) + gap_w(12) +l*font_w(12)+current_byte_index
oled_write_raw_byte(ext_big_font[data[j]-0x21][k], start_line*2*128 + 32 + gap_w + j*12+k);
oled_write_raw_byte(ext_big_font[data[j]-0x21][k+12], start_line*2*128+128 + 32 + gap_w + j*12+k);
oled_write_raw_byte(pgm_read_byte(&ext_big_font[pgm_read_byte(&data[j])-0x21][k]), start_line*2*128 + 32 + gap_w + j*12+k);
oled_write_raw_byte(pgm_read_byte(&ext_big_font[pgm_read_byte(&data[j])-0x21][k+12]), start_line*2*128+128 + 32 + gap_w + j*12+k);
}
}
for (j = 0; j < gap_w; ++j) {
oled_write_raw_byte(blank_block, start_line*2*128 + 32 + j);
oled_write_raw_byte(blank_block, start_line*2*128 + 32 + gap_w + l*12 + j);
oled_write_raw_byte(pgm_read_byte(&blank_block), start_line*2*128 + 32 + j);
oled_write_raw_byte(pgm_read_byte(&blank_block), start_line*2*128 + 32 + gap_w + l*12 + j);

oled_write_raw_byte(blank_block, start_line*2*128+128 + 32 + j);
oled_write_raw_byte(blank_block, start_line*2*128+128 + 32 + gap_w + l*12 + j);
oled_write_raw_byte(pgm_read_byte(&blank_block), start_line*2*128+128 + 32 + j);
oled_write_raw_byte(pgm_read_byte(&blank_block), start_line*2*128+128 + 32 + gap_w + l*12 + j);

}
}
void render_layer(uint8_t layer) {
render_layer_helper_fun(0, PSTR("LAYER:"), 12);
switch (layer)
{
render_layer_helper_fun(0, PSTR("LAYER:"), 12, 6);
switch (layer) {
case 0:
render_layer_helper_fun(1, PSTR("1:HOME"), 12);
render_layer_helper_fun(1, PSTR("1:HOME"), 12, 6);
break;
case 1:
render_layer_helper_fun(1, PSTR("2:CODE"), 12);
render_layer_helper_fun(1, PSTR("2:CODE"), 12, 6);
break;
case 2:
render_layer_helper_fun(1, PSTR("3:OFFICE"), 0);
render_layer_helper_fun(1, PSTR("3:OFFICE"), 0, 8);
break;
case 3:
default:
render_layer_helper_fun(1, PSTR("OTHER"), 18);
render_layer_helper_fun(1, PSTR("4:OTHERS"), 0, 8);
break;
}
}

void render_cur_input_helper_fun(uint8_t start_line, const char * data, uint8_t gap_w) {
uint8_t j = 0, k = 0, l = strlen(data);
void render_cur_input_helper_fun(uint8_t start_line, const char * data, uint8_t gap_w, uint8_t l) {
uint8_t j = 0, k = 0;
for (j = 0; j < l; ++j) { // font index
for (k = 0; k < 12; ++k) { // font byte index
// base + logo_w(0) + gap_w(12) +l*font_w(12)+current_byte_index
oled_write_raw_byte(ext_big_font[data[j]-0x21][k], start_line*2*128 + gap_w + j*12+k);
oled_write_raw_byte(ext_big_font[data[j]-0x21][12+k], start_line*2*128+128 + gap_w + j*12+k);
oled_write_raw_byte(pgm_read_byte(&ext_big_font[data[j]-0x21][k]), start_line*2*128 + gap_w + j*12+k);
oled_write_raw_byte(pgm_read_byte(&ext_big_font[data[j]-0x21][12+k]), start_line*2*128+128 + gap_w + j*12+k);
}
}
for (j = 0; j < gap_w; ++j) {
oled_write_raw_byte(blank_block, start_line*2*128 + j);
oled_write_raw_byte(blank_block, start_line*2*128 + gap_w + l*12 + j);
oled_write_raw_byte(pgm_read_byte(&blank_block), start_line*2*128 + j);
oled_write_raw_byte(pgm_read_byte(&blank_block), start_line*2*128 + gap_w + l*12 + j);

oled_write_raw_byte(blank_block, start_line*2*128+128 + j);
oled_write_raw_byte(blank_block, start_line*2*128+128 + gap_w + l*12 + j);
oled_write_raw_byte(pgm_read_byte(&blank_block), start_line*2*128+128 + j);
oled_write_raw_byte(pgm_read_byte(&blank_block), start_line*2*128+128 + gap_w + l*12 + j);
}
}

void render_cur_input(void) {
render_cur_input_helper_fun(0, PSTR("INPUTS:"), 6);
render_cur_input_helper_fun(1, (const char *)(current_alp), 12);
render_cur_input_helper_fun(0, "INPUTS:", 6, 7);
render_cur_input_helper_fun(1, (const char *)(current_alp), 12, 6);
return;
}


void oled_task_user(void) {
render_logo();
# ifdef I_AM_LEFT
render_layer(biton32(layer_state));
# else
render_cur_input();
# endif
if (is_keyboard_left()) {
render_layer(biton32(layer_state));
} else {
render_cur_input();
}
// # ifdef I_AM_LEFT
// render_layer(biton32(layer_state));
// # else
// render_cur_input();
// # endif
}


Expand Down Expand Up @@ -192,18 +210,17 @@ void get_cur_alp_hook(uint16_t keycode) {
keycode = 0xF0;
}
if (cur_alp_index < 4) {
current_alp[cur_alp_index] = code_to_name[keycode];
current_alp[cur_alp_index] = pgm_read_byte(&code_to_name[keycode]);
cur_alp_index++;
} else {
for (uint8_t i = 2; i <= 4; ++i) {
current_alp[i-1] = current_alp[i];
}
current_alp[cur_alp_index] = code_to_name[keycode];
current_alp[cur_alp_index] = pgm_read_byte(&code_to_name[keycode]);
}
}

bool process_record_kb(uint16_t keycode, keyrecord_t *record) {

get_cur_alp_hook(keycode);
return true;

Expand All @@ -215,19 +232,9 @@ void matrix_scan_kb(void) {
cur_alp_index = 1;
}
}


#endif

bool is_keyboard_left(void) {

#ifdef I_AM_LEFT
return true;
#else
return false;
#endif

}


// void keyboard_post_init_kb(void) {
Expand Down
3 changes: 3 additions & 0 deletions keyboards/yandrstudio/hotdox76_V2/hotdox76_V2.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,6 @@
{ R110, R111, R112, R113, R114, R115, R116 } \
}

extern volatile char current_alp[7];
extern volatile uint8_t cur_alp_index;

4 changes: 2 additions & 2 deletions keyboards/yandrstudio/hotdox76_V2/keymaps/default/rules.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RGB_MATRIX_ENABLE = yes
RGB_MATRIX_DRIVER = WS2812
# RGB_MATRIX_ENABLE = yes
# RGB_MATRIX_DRIVER = WS2812
# RGBLIGHT_ENABLE = yes
# RGBLIGHT_DRIVER = WS2812
46 changes: 23 additions & 23 deletions keyboards/yandrstudio/hotdox76_V2/keymaps/via/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,29 +16,29 @@
#pragma once

/* RGN Matrix */
#ifdef RGB_MATRIX_ENABLE
// #ifdef RGB_MATRIX_ENABLE

#define DISABLE_RGB_MATRIX_ALPHAS_MODS
#define DISABLE_RGB_MATRIX_BAND_SAT
#define DISABLE_RGB_MATRIX_BAND_VAL
#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
#define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
#define DISABLE_RGB_MATRIX_CYCLE_ALL
// #define DISABLE_RGB_MATRIX_ALPHAS_MODS
// #define DISABLE_RGB_MATRIX_BAND_SAT
// #define DISABLE_RGB_MATRIX_BAND_VAL
// #define DISABLE_RGB_MATRIX_BAND_PINWHEEL_SAT
// #define DISABLE_RGB_MATRIX_BAND_PINWHEEL_VAL
// #define DISABLE_RGB_MATRIX_CYCLE_ALL

#define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
#define DISABLE_RGB_MATRIX_SOLID_REACTIVE
#define DISABLE_RGB_MATRIX_HUE_BREATHING
#define DISABLE_RGB_MATRIX_DIGITAL_RAIN
#define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
#define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
#define DISABLE_RGB_MATRIX_CYCLE_SPIRAL
#define DISABLE_RGB_MATRIX_SPLASH
#define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
#define DISABLE_RGB_MATRIX_SOLID_SPLASH
#define DISABLE_RGB_MATRIX_DUAL_BEACON
#define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
#define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
#define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS
// #define DISABLE_RGB_MATRIX_BAND_SPIRAL_VAL
// #define DISABLE_RGB_MATRIX_SOLID_REACTIVE_SIMPLE
// #define DISABLE_RGB_MATRIX_SOLID_REACTIVE
// #define DISABLE_RGB_MATRIX_HUE_BREATHING
// #define DISABLE_RGB_MATRIX_DIGITAL_RAIN
// #define DISABLE_RGB_MATRIX_GRADIENT_UP_DOWN
// #define DISABLE_RGB_MATRIX_CYCLE_OUT_IN_DUAL
// #define DISABLE_RGB_MATRIX_CYCLE_SPIRAL
// #define DISABLE_RGB_MATRIX_SPLASH
// #define DISABLE_RGB_MATRIX_SOLID_MULTISPLASH
// #define DISABLE_RGB_MATRIX_SOLID_SPLASH
// #define DISABLE_RGB_MATRIX_DUAL_BEACON
// #define DISABLE_RGB_MATRIX_RAINBOW_MOVING_CHEVRON
// #define DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT
// #define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS

#endif
// #endif
2 changes: 1 addition & 1 deletion keyboards/yandrstudio/hotdox76_V2/keymaps/via/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
LAYOUT(
// left hand
KC_EQL, RGB_TOG, KC_2, KC_3, KC_4, KC_5, KC_LEFT,
KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT,
KC_DEL, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(1),
KC_BSPC, KC_A, KC_S, KC_D, KC_F, KC_G,
KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO),
Expand Down
4 changes: 2 additions & 2 deletions keyboards/yandrstudio/hotdox76_V2/keymaps/via/rules.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VIA_ENABLE = yes
RGBLIGHT_ENABLE = yes
RGBLIGHT_DRIVER = WS2812
# RGBLIGHT_ENABLE = yes
# RGBLIGHT_DRIVER = WS2812
# RGB_MATRIX_ENABLE = yes
# RGB_MATRIX_DRIVER = WS2812
8 changes: 6 additions & 2 deletions keyboards/yandrstudio/hotdox76_V2/oled_font_lib/ext_font.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#include "progmem.h"

/*
!(0) "(1) #(2) $(3) %(4) &(5) '(6) ((7)
)(8) *(9) +(10) ,(11) -(12) .(13) /(14) 0(15)
Expand All @@ -26,9 +29,10 @@
a(64) b(65) c(66) d(67) e(68) f(69) g(70) h(71)
i(72) j(73) k(74) l(75) m(76) n(77) o(78) p(79)
q(80) r(81) s(82) t(83) u(84) v(85) w(86) x(87)
y(88) z(89) {(90) |(91) }(92) ~(93)
y(88) z(89) {(90) |(91) }(92) ~(93) (94)
*/
static const unsigned char ext_big_font[][24] = {

static const unsigned char ext_big_font[95][24] PROGMEM = {
{0x00,0x00,0x00,0x00,0xFC,0xFC,0xFC,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x1B,0x1B,0x1B,0x00,0x00,0x00,0x00},/*"!",0*/
{0x00,0x00,0x00,0x18,0xF8,0x18,0x00,0x18,0xF8,0x18,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},/*""",1*/
{0x00,0x00,0x60,0x60,0xFE,0xFE,0x60,0xFE,0xFE,0x60,0x00,0x00,0x00,0x00,0x06,0x7F,0x7F,0x06,0x7F,0x7F,0x06,0x06,0x00,0x00},/*"#",2*/
Expand Down
4 changes: 3 additions & 1 deletion keyboards/yandrstudio/hotdox76_V2/oled_font_lib/logo.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
*/
#pragma once

static const unsigned char logo_idobao[] = {
#include "progmem.h"

static const unsigned char logo_idobao[] PROGMEM = {
0x00, 0x00, 0x00, 0x80, 0xC0, 0xC0, 0xE0, 0xE0,
0xF0, 0xF0, 0x70, 0x60, 0x04, 0x0E, 0x0E, 0x1E,
0x8E, 0x8E, 0xC4, 0xC0, 0xE0, 0xF0, 0xF0, 0xF0,
Expand Down
18 changes: 11 additions & 7 deletions keyboards/yandrstudio/hotdox76_V2/rules.mk
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
# MCU name
MCU = atmega32u4

BOOTLOADER = atmel-dfu
F_CPU = 16000000

ARCH = AVR8

F_USB = $(F_CPU)

# Bootloader selection
BOOTLOADER = caterina

# Build Options
# comment out to disable the options.
Expand All @@ -19,8 +15,16 @@ 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 = yes # USB Nkey Rollover - if this doesn't work, see here: https://github.com/tmk/tmk_keyboard/wiki/FAQ#nkro-doesnt-work
OLED_DRIVER_ENABLE = yes # Enable Support for SSD1306 or SH1106 OLED Displays; Communicating over I2C

SPLIT_KEYBOARD = yes
OLED_DRIVER_ENABLE = yes # Enable Support for SSD1306 or SH1106 OLED Displays; Communicating over I2C

LTO_ENABLE = yes

RGBLIGHT_ENABLE = yes
RGBLIGHT_DRIVER = WS2812
# RGB_MATRIX_ENABLE = yes
# RGB_MATRIX_DRIVER = WS2812
SPLIT_KEYBOARD = yes
SPLIT_TRANSPORT = custom
QUANTUM_LIB_SRC += serial.c \
transport_lib/transport.c
Loading

0 comments on commit 7888677

Please sign in to comment.