Skip to content

Commit

Permalink
Louise: disable ACTION_ONESHOT and enable KEY_OVERRIDE
Browse files Browse the repository at this point in the history
  • Loading branch information
yangdigi committed Jan 6, 2025
1 parent 20554a6 commit 980cb8d
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 90 deletions.
8 changes: 4 additions & 4 deletions keyboards/ydkb/louise/backlight_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.


void backlight_init_ports(void) {
DDRC &= ~(1<<6);
PORTC |= (1<<6);
DDRC |= (1<<6);
//PORTC |= (1<<6);
}

void backlight_task(void) {
Expand All @@ -34,13 +34,13 @@ void backlight_task(void) {
void backlight_user_enable(void)
{

DDRC |= (1<<6);
//DDRC |= (1<<6);
PORTC &= ~(1<<6);
}

void backlight_user_disable(void)
{
DDRC &= ~(1<<6);
//DDRC &= ~(1<<6);
PORTC |= (1<<6);
}

Expand Down
16 changes: 9 additions & 7 deletions keyboards/ydkb/louise/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "config_common.h"

/* USB Device descriptor parameter */
#define FW_VER_DATE DO6A
#define FW_VER_DATE DP16
#define CONTACT(x,y) x##y
#define CONTACT2(x,y) CONTACT(x,y)
#define FW_VER CONTACT2(VIAL_, FW_VER_DATE)
Expand All @@ -17,10 +17,10 @@
#define MATRIX_ROWS 4 //595 num of each side.
#define MATRIX_COLS 16

#define DEFAULT_6KRO // macOS's Capslock switching between Chinese and English has compatibility issues with NKRO

#define BACKLIGHT_PIN C6
#define BACKLIGHT_LEVELS 6
#define BACKLIGHT_ON_STATE 0
#define BACKLIGHT_LEVELS 1
#define TAPPING_TOGGLE 3

/* key combination for command */
#define IS_COMMAND() ( \
Expand Down Expand Up @@ -72,12 +72,13 @@
#define BLE_NAME "Louise BLE"
#define BLE_BATTERY_SERVICE
#define BLE_LIGHT_ON (~PORTD & (1<<6)) //RGB Power IO
#define HARDWARE_BT_SWITCH

#define UPDATE_BATTERY_WHEN_CHARGING
#define BATTERY_CHARGING (~PINC & (1<<7))
#define CHARGING_FIX_VALUE 40
#define CHARGING_STATE_INIT() do { DDRC &= ~(1<<7); PORTC |= (1<<7);} while(0)
#define HARDWARE_BT_SWITCH


#define BLE51_NO_BATTERY_VOLTAGE
#define BLE51_NO_ULTRA_LOW_BATTERY
Expand All @@ -94,7 +95,8 @@
/* disable action features */
//#define NO_ACTION_LAYER
//#define NO_ACTION_TAPPING
//#define NO_ACTION_ONESHOT //930B
#define NO_ACTION_ONESHOT //930B
//#define NO_ACTION_MACRO
//#define NO_ACTION_FUNCTION
#define NO_DEFAULT_COMMAND
#define NO_DEFAULT_COMMAND
#define NO_RESET
2 changes: 1 addition & 1 deletion keyboards/ydkb/louise/keymaps/vial/config.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#define DYNAMIC_KEYMAP_LAYER_COUNT 5
#define DYNAMIC_KEYMAP_LAYER_COUNT 4
#define FLASH_KEYMAP8_COUNT 1 //set 0, save 112B
#define VIAL_KEYBOARD_UID {0x2E, 0xE6, 0x0E, 0x23, 0x34, 0xEF, 0x99, 0x37}
#define VIAL_COMBO_ENTRIES 16
2 changes: 1 addition & 1 deletion keyboards/ydkb/louise/keymaps/vial/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ VIAL_INSECURE = yes
QMK_SETTINGS = no
TAP_DANCE_ENABLE = yes
COMBO_ENABLE = yes
KEY_OVERRIDE_ENABLE = no
KEY_OVERRIDE_ENABLE = yes
46 changes: 22 additions & 24 deletions keyboards/ydkb/louise/keymaps/vial/vial.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{
"lighting": "qmk_backlight",
"matrix": {"rows": 4, "cols": 16},
"customKeycodes": [
{"name": "BT/USB", "title": "", "shortName": "BT/U"},
{"name": "RESET", "title": "", "shortName": "BLERST"},
{"name": "BT/USB", "title": "", "shortName": "BT/USB"},
{"name": "BLERST", "title": "", "shortName": "BLERST"},
{"name": "BAT%", "title": "", "shortName": "BAT%"},
{"name": "LkMode", "title": "", "shortName": "Lk.M"},
{"name": "RGB_TG", "title": "", "shortName": "R.TG"},
{"name": "RGB_M-", "title": "", "shortName": "R.M-"},
{"name": "RGB_M+", "title": "", "shortName": "R.M+"},
{"name": "LkMode", "title": "", "shortName": "LkMode"},
{"name": "RGB_TG", "title": "", "shortName": "RGB_TG"},
{"name": "RGB_M-", "title": "", "shortName": "RGB_M-"},
{"name": "RGB_M+", "title": "", "shortName": "RGB_M+"},
{"name": "HUE-", "title": "", "shortName": "HUE-"},
{"name": "HUE+", "title": "", "shortName": "HUE+"},
{"name": "SAT-", "title": "", "shortName": "SAT-"},
Expand All @@ -17,24 +16,23 @@
{"name": "LUM+", "title": "", "shortName": "LUM+"}
],
"layouts": {
"labels":[["Bottom Right", "1u+1u+1u", "1.25u+1.25u"]],
"labels":[["BR", "1u", "1.25u"]],
"keymap": [
[{"y":0.65,"x":11.97},"0,8","0,14","0,11"],
[{"y":-0.95,"x":1.03},"0,0","0,3"],
[{"y":-0.05,"x":12.34},"1,8",{"w":1.75},"1,11"],
[{"y":-0.95,"x":0.89,"w":1.25},"1,0","1,3"],
[{"y":-0.05,"x":11.97},"2,8","2,14",{"w":1.25},"2,11"],
[{"y":-0.95,"x":0.75,"w":1.75},"2,0","2,3"],
[{"y":-0.05,"x":11.98},"3,14\n\n\n0,0","3,8\n\n\n0,0","3,11\n\n\n0,0",{"x":0.27,"w":0.5,"d":true},"3,14\n\n\n0,1",{"w":1.25},"3,8\n\n\n0,1",{"w":1.25},"3,11\n\n\n0,1"],
[{"y":-0.95,"x":1,"w":1.25},"3,0",{"w":1.25},"3,3"],
[{"r":8,"y":-4.52,"x":3.22},"0,2","0,1","0,4","0,5"],
[{"x":3.47},"1,2","1,1",{"n":true},"1,4","1,5"],
[{"x":3.97},"2,2","2,1","2,4","2,5"],
[{"x":4.72,"w":1.25},"3,1",{"w":2},"3,5"],
[{"r":-8,"y":-1.88,"x":7.62},"0,9","0,10","0,12","0,13"],
[{"x":7.87},"1,10",{"n":true},"1,12","1,13","1,14"],
[{"x":7.37},"2,9","2,10","2,12","2,13"],
[{"x":7.37,"w":2.25},"3,10",{"w":1.25},"3,13"]
[{"y":0.75,"x":1},"0,0","0,3",{"x":8.85},"0,8","0,14","0,11"],
[{"x":12.25},"1,8",{"w":1.75},"1,11"],
[{"y":-1,"x":0.85,"w":1.25},"1,0","1,3"],
[{"x":12},"2,8","2,14",{"w":1.25},"2,11"],
[{"y":-1,"x":0.75,"w":1.75},"2,0","2,3"],
[{"x":12},"3,14\n\n\n0,0","3,8\n\n\n0,0","3,11\n\n\n0,0",{"x":0.25,"w":0.5,"d":true},"3,14\n\n\n0,1",{"w":1.25},"3,8\n\n\n0,1",{"w":1.25},"3,11\n\n\n0,1"],
[{"y":-1,"x":1,"w":1.25},"3,0",{"w":1.25},"3,3"],
[{"r":8,"y":-4.5,"x":3.25},"0,2","0,1","0,4","0,5"],
[{"x":3.5},"1,2","1,1",{"n":true},"1,4","1,5"],
[{"x":4},"2,2","2,1","2,4","2,5"],
[{"x":4.75,"w":1.25},"3,1",{"w":2},"3,5"],
[{"r":-8,"y":-1.85,"x":7.5},"0,9","0,10","0,12","0,13"],
[{"x":7.75},"1,10",{"n":true},"1,12","1,13","1,14"],
[{"x":7.25},"2,9","2,10","2,12","2,13"],
[{"x":7.25,"w":2.25},"3,10",{"w":1.25},"3,13"]
]
}
}
7 changes: 5 additions & 2 deletions keyboards/ydkb/louise/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ static void get_key_ready(void) {
_delay_us(6);
}

inline void select_key_ready(void) {
static inline void select_key_ready(void) {
DDRB |= (1<<3);
}

Expand Down Expand Up @@ -151,8 +151,11 @@ uint8_t matrix_scan(void)
}

if (matrix_keys_down) {
#if 0
if (BLE_LIGHT_ON == 0) kb_idle_times = 12;
else kb_idle_times = 0;
else
#endif
kb_idle_times = 0;
}

matrix_scan_quantum();
Expand Down
Binary file not shown.
84 changes: 58 additions & 26 deletions keyboards/ydkb/louise/rgblight.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,30 @@ struct cRGB *led = &rgbled[INDICATOR_NUM];
const uint8_t RGBLED_BREATHING_TABLE[64] PROGMEM= { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 3, 4, 5, 6, 8, 10, 12, 15, 17, 20, 24, 28, 32, 36, 41, 46, 51, 57, 63, 70, 76, 83, 91, 98, 106, 113, 121, 129, 138, 146, 154, 162, 170, 178, 185, 193, 200, 207, 213, 220, 225, 231, 235, 240, 244, 247, 250, 252, 253, 254, 255};


rgblight_config_t rgblight_config = {.enable = 0, .mode = 8,.hue = 640, .sat = 255, .val = 255};
rgblight_config_t rgblight_config = {.enable = 0, .mode = 8,.hue = 214, .sat = 255, .val = 255};

void sethsv(uint8_t hue, uint8_t saturation, uint8_t brightness, struct cRGB *led1)
{
/*
original code: https://blog.adafruit.com/2012/03/14/constant-brightness-hsb-to-rgb-algorithm/
use 8bit hue, hue16 = hue*3 to reach 0 to 767.
*/
uint8_t r, g, b;
uint8_t temp[5];
uint16_t hue16 = hue*3;

uint8_t n = hue16 >> 8;
uint8_t x = ((((hue16 & 255) * saturation) >> 8) * brightness) >> 8;
uint8_t s = ((256 - saturation) * brightness) >> 8;

//temp[n] g r b as struct cRGB of ws2812. save 18B
temp[0] = temp[3] = x + s;
temp[1] = temp[4] = brightness - x;
temp[2] = s;
memcpy(led1, &temp[n], 3);
}

#if 0 // my old code. the new way use 8bit hue saves about 134B
uint16_t hue_fix(uint16_t hue)
{
// hue needs to be 0x100 to 0x3ff
Expand All @@ -54,14 +75,22 @@ void sethsv(uint16_t hue, uint8_t saturation, uint8_t brightness, struct cRGB *l
if (n > 3) return; // 0 would be error. just leave it.
uint8_t x = ((((hue & 255) * saturation) >> 8) * brightness) >> 8;
uint8_t s = ((256 - saturation) * brightness) >> 8;
#if 0 //temp[n-1] b g r
temp[0] = temp[3] = s;
temp[1] = temp[4] = x + s;
temp[2] = brightness - x;
r = temp[n + 1];
g = temp[n];
b = temp[n - 1];
setrgb(r,g,b, led1);
#else //temp[n-1] g r b as struct cRGB of ws2812. save 18B
temp[0] = temp[3] = x + s;
temp[1] = temp[4] = brightness - x;
temp[2] = s;
memcpy(led1, &temp[n-1], 3);
#endif
}
#endif

void setrgb(uint8_t r, uint8_t g, uint8_t b, struct cRGB *led1)
{
Expand Down Expand Up @@ -127,13 +156,16 @@ void rgblight_mode(int8_t mode)
{
// rgb off, new way to save about 60B
if (!rgblight_config.enable) {
rgblight_clear();
rgblight_set();
//if (!indicator_state) rgblight_timer_disable();
//rgblight_clear();
//rgblight_set();
rgblight_timer_disable();
} else {
// rgb on
#if 0 //less than 0 can always be 0. save 8B
if (mode < 0) mode = RGBLIGHT_MODES - 1;
else if (mode >= RGBLIGHT_MODES) mode = 0;
else
#endif
if (mode >= RGBLIGHT_MODES) mode = 0;
rgblight_config.mode = mode;
dprintf("rgblight mode: %u\n", rgblight_config.mode);

Expand Down Expand Up @@ -161,7 +193,7 @@ void rgblight_action(uint8_t action)
5 sat- 6 sat+
7 val- 8 val+
*/
uint16_t hue = rgblight_config.hue;
uint8_t hue = rgblight_config.hue;
uint8_t sat = rgblight_config.sat;
uint8_t val = rgblight_config.val;
int8_t increament = 1;
Expand Down Expand Up @@ -195,20 +227,20 @@ void rgblight_action(uint8_t action)
if (action >= 3) rgblight_sethsv(hue, sat, val);
}

void rgblight_sethsv_noeeprom(uint16_t hue, uint8_t sat, uint8_t val)
void rgblight_sethsv_noeeprom(uint8_t hue, uint8_t sat, uint8_t val)
{
if (rgblight_config.enable) {
sethsv(hue, sat, val, &led[RGBLED_TEMP]);
for (uint8_t i=0; i< RGBLED_NUM; i++) {
led[i] = led[RGBLED_TEMP];
}
rgblight_set();
//rgblight_set();
}
}

void rgblight_sethsv(uint16_t hue, uint8_t sat, uint8_t val)
void rgblight_sethsv(uint8_t hue, uint8_t sat, uint8_t val)
{
hue = hue_fix(hue);
//hue = hue_fix(hue);
if (rgblight_config.enable) {
#if 0 // will do rgblight_sethsv_noeeprom() in rgblight_task
if (rgblight_config.mode == 1) {
Expand All @@ -232,7 +264,7 @@ void rgblight_setrgb(uint8_t r, uint8_t g, uint8_t b)
rgbled[i].g = g;
rgbled[i].b = b;
}
rgblight_set();
//rgblight_set();
}

void rgblight_clear(void)
Expand Down Expand Up @@ -276,6 +308,9 @@ void rgblight_task(void)
break;
#endif
}
rgblight_set();
} else {
rgblight_timer_disable();
}
}
}
Expand All @@ -293,26 +328,24 @@ void rgblight_effect_breathing(uint8_t interval)
}
}

static uint8_t current_hue = 0;

void rgblight_effect_rainbow_mood(uint8_t interval)
{
static uint16_t current_hue = 0;
rgblight_sethsv_noeeprom(current_hue, rgblight_config.sat, rgblight_config.val);
current_hue = hue_fix(current_hue + interval * 3);
current_hue += interval;
}

void rgblight_effect_rainbow_swirl(uint8_t interval)
{
static uint16_t current_hue=0;
uint16_t hue;
uint8_t i;
uint8_t interval2 = interval/2;
if (interval & 1) interval2 *= -1;
for (i=0; i<RGBLED_NUM; i++) {
hue = 768/16*i+current_hue;
//uint8_t interval2 = interval/2;
if (interval & 1) interval *= -1;
for (uint8_t i=0; i<RGBLED_NUM; i++) {
uint8_t hue = 256/16*i+current_hue;
sethsv(hue, rgblight_config.sat, rgblight_config.val, &led[i]);
}
rgblight_set();
current_hue = hue_fix(current_hue - interval2*16);
//rgblight_set();
current_hue = current_hue - interval*2;
}

#if RGBLIGHT_MODES > 15
Expand All @@ -331,12 +364,12 @@ void rgblight_effect_snake(uint8_t interval)
int8_t target_led = pos+i*increament;
if (target_led < 0) target_led += RGBLED_NUM;
else if (target_led >= RGBLED_NUM) target_led -= RGBLED_NUM;
sethsv(rgblight_config.hue+i*50, rgblight_config.sat, rgblight_config.val, &led[target_led]);
sethsv(rgblight_config.hue+i*16, rgblight_config.sat, rgblight_config.val, &led[target_led]);
}
pos += increament;
if (pos > RGBLED_NUM) pos = 0;
else if (pos < 0 ) pos = RGBLED_NUM;
rgblight_set();
//rgblight_set();
}
}
#endif
Expand All @@ -346,7 +379,6 @@ void rgblight_effect_knight(uint8_t interval)
{
static int8_t pos = RGBLED_NUM - 1;
static uint8_t sled_step = 0;
static uint16_t current_hue=0;
uint8_t i;
static int8_t increament = 1;
if (++sled_step > interval) {
Expand All @@ -364,7 +396,7 @@ void rgblight_effect_knight(uint8_t interval)
pos += increament;
if (pos <= 0 - RGBLIGHT_EFFECT_KNIGHT_LENGTH || pos >= RGBLED_NUM) {
increament *= -1;
current_hue = hue_fix(current_hue + 40);
current_hue = current_hue + 16;
sethsv(current_hue, rgblight_config.sat, rgblight_config.val, &led[RGBLED_TEMP]);
}
}
Expand Down
Loading

0 comments on commit 980cb8d

Please sign in to comment.