Skip to content

Commit

Permalink
partial storage of led settings
Browse files Browse the repository at this point in the history
  • Loading branch information
zvecr committed Oct 4, 2021
1 parent b3b6ab1 commit 18ee1f5
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 12 deletions.
14 changes: 13 additions & 1 deletion keyboards/massdrop/alt/keymaps/default_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ enum alt_keycodes {

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT(
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL, \
L_T_MD, L_BRD, L_BRI, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_DEL, \
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_HOME, \
KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, \
KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, \
Expand Down Expand Up @@ -60,60 +60,70 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (LED_GCR_STEP > LED_GCR_MAX - gcr_desired) gcr_desired = LED_GCR_MAX;
else gcr_desired += LED_GCR_STEP;
if (led_animation_breathing) gcr_breathe = gcr_desired;
//md_led_changed();
}
return false;
case L_BRD:
if (record->event.pressed) {
if (LED_GCR_STEP > gcr_desired) gcr_desired = 0;
else gcr_desired -= LED_GCR_STEP;
if (led_animation_breathing) gcr_breathe = gcr_desired;
//md_led_changed();
}
return false;
case L_PTN:
if (record->event.pressed) {
if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
else led_animation_id++;
md_led_changed();
}
return false;
case L_PTP:
if (record->event.pressed) {
if (led_animation_id == 0) led_animation_id = led_setups_count - 1;
else led_animation_id--;
md_led_changed();
}
return false;
case L_PSI:
if (record->event.pressed) {
led_animation_speed += ANIMATION_SPEED_STEP;
md_led_changed();
}
return false;
case L_PSD:
if (record->event.pressed) {
led_animation_speed -= ANIMATION_SPEED_STEP;
if (led_animation_speed < 0) led_animation_speed = 0;
md_led_changed();
}
return false;
case L_T_MD:
if (record->event.pressed) {
led_lighting_mode++;
if (led_lighting_mode > LED_MODE_MAX_INDEX) led_lighting_mode = LED_MODE_NORMAL;
md_led_changed();
}
return false;
case L_T_ONF:
if (record->event.pressed) {
led_enabled = !led_enabled;
I2C3733_Control_Set(led_enabled);
md_led_changed();
}
return false;
case L_ON:
if (record->event.pressed) {
led_enabled = 1;
I2C3733_Control_Set(led_enabled);
md_led_changed();
}
return false;
case L_OFF:
if (record->event.pressed) {
led_enabled = 0;
I2C3733_Control_Set(led_enabled);
md_led_changed();
}
return false;
case L_T_BR:
Expand All @@ -124,11 +134,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
led_animation_breathe_cur = BREATHE_MIN_STEP;
breathe_dir = 1;
}
md_led_changed();
}
return false;
case L_T_PTD:
if (record->event.pressed) {
led_animation_direction = !led_animation_direction;
md_led_changed();
}
return false;
case U_T_AGCR:
Expand Down
41 changes: 30 additions & 11 deletions tmk_core/protocol/arm_atsam/md_rgb_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,33 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# ifdef USE_MASSDROP_CONFIGURATOR

// TODO?: wire these up to keymap.c
md_led_config_t md_led_config = {
.animation_orientation = 0,
.animation_direction = 0,
.animation_breathing = 0,
.animation_id = 0,
.animation_speed = 4.0f,
.lighting_mode = LED_MODE_NORMAL,
.enabled = 1,
.animation_breathe_cur = BREATHE_MIN_STEP,
.animation_breathe_dir = 1
};
md_led_config_t md_led_config = {0};
EECONFIG_DEBOUNCE_HELPER(md_led, ((uint8_t *)(EECONFIG_SIZE + 64)), md_led_config);

void eeconfig_update_md_led_default(void) {
md_led_config.ver = 1;
md_led_config.animation_orientation = 0;
md_led_config.animation_direction = 0;
md_led_config.animation_breathing = 0;
md_led_config.animation_id = 0;
md_led_config.animation_speed = 4.0f;
md_led_config.lighting_mode = LED_MODE_NORMAL;
md_led_config.enabled = 1;
md_led_config.animation_breathe_cur = BREATHE_MIN_STEP;
md_led_config.animation_breathe_dir = 1;

eeconfig_flush_md_led(true);
}

void md_led_changed(void) {
eeconfig_flag_md_led(true);
}

//todo: use real task rather than this bodge
void housekeeping_task_kb(void) {
eeconfig_flush_md_led_task();
}

__attribute__((weak)) led_instruction_t led_instructions[] = {{.end = 1}};
static void md_rgb_matrix_config_override(int i);
# endif // USE_MASSDROP_CONFIGURATOR
Expand Down Expand Up @@ -233,6 +247,11 @@ static void led_set_all(uint8_t r, uint8_t g, uint8_t b) {
static void init(void) {
DBGC(DC_LED_MATRIX_INIT_BEGIN);

eeconfig_init_md_led();
if (md_led_config.ver != 1) {
eeconfig_update_md_led_default();
}

issi3733_prepare_arrays();

md_rgb_matrix_prepare();
Expand Down
3 changes: 3 additions & 0 deletions tmk_core/protocol/arm_atsam/md_rgb_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ typedef struct led_instruction_s {
extern led_instruction_t led_instructions[];

typedef struct led_config_s {
uint8_t ver; // assumed to be zero on eeprom reset
uint8_t animation_orientation;
uint8_t animation_breathing;
uint8_t animation_id;
Expand All @@ -152,6 +153,8 @@ typedef struct led_config_s {

extern md_led_config_t md_led_config;

void md_led_changed(void);

# define led_animation_breathing md_led_config.animation_breathing
# define led_animation_id md_led_config.animation_id
# define led_animation_speed md_led_config.animation_speed
Expand Down

0 comments on commit 18ee1f5

Please sign in to comment.