diff --git a/keyboards/massdrop/alt/keymaps/drugo/config.h b/keyboards/massdrop/alt/keymaps/drugo/config.h index 4cf242313a4b..b67ffa4b8fb3 100644 --- a/keyboards/massdrop/alt/keymaps/drugo/config.h +++ b/keyboards/massdrop/alt/keymaps/drugo/config.h @@ -8,5 +8,5 @@ #define SERIAL_NUM "FRT001" -#define UNICODE_SELECTED_MODES UC_LNX, UC_WINC +#define UNICODE_SELECTED_MODES UC_LNX, UC_WINC, UC_MAC #define UCIS_MAX_CODE_POINTS 32 \ No newline at end of file diff --git a/keyboards/massdrop/alt/keymaps/drugo/config_led.h b/keyboards/massdrop/alt/keymaps/drugo/config_led.h index d30c4b8cee6e..9e0e4a62fa87 100644 --- a/keyboards/massdrop/alt/keymaps/drugo/config_led.h +++ b/keyboards/massdrop/alt/keymaps/drugo/config_led.h @@ -18,6 +18,12 @@ #define DISABLE_RGB_MATRIX_RAINBOW_PINWHEELS #define DISABLE_RGB_MATRIX_DUAL_BEACON #define DISABLE_RGB_MATRIX_BREATHING +#define DISABLE_RGB_MATRIX_HUE_BREATHING +#define DISABLE_RGB_MATRIX_HUE_PENDULUM +#define DISABLE_RGB_MATRIX_HUE_WAVE + +#define RGB_MATRIX_FRAMEBUFFER_EFFECTS +#define RGB_MATRIX_TYPING_HEATMAP_DECREASE_DELAY 50 // Set default RGB effect #define RGB_MATRIX_STARTUP_MODE RGB_MATRIX_ALPHAS_MODS diff --git a/keyboards/massdrop/alt/keymaps/drugo/keymap.c b/keyboards/massdrop/alt/keymaps/drugo/keymap.c index 4fb3f53ac8fe..c9a5822ffad0 100644 --- a/keyboards/massdrop/alt/keymaps/drugo/keymap.c +++ b/keyboards/massdrop/alt/keymaps/drugo/keymap.c @@ -25,6 +25,22 @@ enum { TD_LOCK, //ESC/GUI+L }; +enum alt_rgb_mode { + RGB_MODE_ALL, + RGB_MODE_KEYLIGHT, + RGB_MODE_UNDERGLOW, + RGB_MODE_NONE, +}; + +typedef union { + uint32_t raw; + struct { + uint8_t rgb_mode :8; + }; +} alt_config_t; + +alt_config_t alt_config; + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { // DEFAULT [0] = LAYOUT_65_ansi_blocker( @@ -38,8 +54,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [1] = LAYOUT_65_ansi_blocker( KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, KC_MUTE, \ _______, RGB_SPD, RGB_VAI, RGB_SPI, RGB_HUI, RGB_SAI, _______,U_T_AUTO,U_T_AGCR, _______, KC_PSCR, KC_SLCK, KC_PAUS, _______, KC_HOME, \ - _______,RGB_RMOD, RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______, KC_BRIU, \ - _______, RGB_TOG, RGB_FRZ, _______, _______, MD_BOOT, NK_TOGG, DBG_TOG, DBG_KBD,DBG_MTRX, _______, _______, KC_VOLU, KC_BRID, \ + UC_M_MA,RGB_RMOD, RGB_VAD, RGB_MOD, RGB_HUD, RGB_SAD, _______, _______, _______, _______, _______, _______, _______, KC_BRIU, \ + _______, RGB_TOG, RGB_FRZ, _______, EEP_RST, MD_BOOT, NK_TOGG, DBG_TOG, DBG_KBD,DBG_MTRX, _______, _______, KC_VOLU, KC_BRID, \ UNI_ON , UC_M_WC, UC_M_LN, KC_MPLY, MO(2) , _______, KC_MPRV, KC_VOLD, KC_MNXT \ ), // MACRO @@ -110,6 +126,15 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } } return false; + case EEP_RST: + if (record->event.pressed) { + key_timer = timer_read32(); + } else { + if (timer_elapsed32(key_timer) >= 500) { + eeconfig_init(); + } + } + return false; #ifdef UCIS_ENABLE case UNI_ON: if (record->event.pressed) { @@ -196,24 +221,29 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case LED_FLAG_ALL: { rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); rgb_matrix_set_color_all(0, 0, 0); + alt_config.rgb_mode = RGB_MODE_KEYLIGHT; } break; case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): { rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); rgb_matrix_set_color_all(0, 0, 0); + alt_config.rgb_mode = RGB_MODE_UNDERGLOW; } break; case LED_FLAG_UNDERGLOW: { rgb_matrix_set_flags(LED_FLAG_NONE); rgb_matrix_disable_noeeprom(); + alt_config.rgb_mode = RGB_MODE_NONE; } break; default: { rgb_matrix_set_flags(LED_FLAG_ALL); rgb_matrix_enable_noeeprom(); + alt_config.rgb_mode = RGB_MODE_ALL; } break; } + eeconfig_update_user(alt_config.raw); } return false; case RGB_FRZ: @@ -235,6 +265,28 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } } +void keyboard_post_init_kb(void) { + alt_config.raw = eeconfig_read_user(); + switch (alt_config.rgb_mode) { + case RGB_MODE_ALL: + rgb_matrix_set_flags(LED_FLAG_ALL); + rgb_matrix_enable_noeeprom(); + break; + case RGB_MODE_KEYLIGHT: + rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); + rgb_matrix_set_color_all(0, 0, 0); + break; + case RGB_MODE_UNDERGLOW: + rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); + rgb_matrix_set_color_all(0, 0, 0); + break; + case RGB_MODE_NONE: + rgb_matrix_set_flags(LED_FLAG_NONE); + rgb_matrix_disable_noeeprom(); + break; + } +} + #ifdef TAP_DANCE_ENABLE void lock_esc(qk_tap_dance_state_t *state, void *user_data){ if (state->count == 1) { diff --git a/tmk_core/common/arm_atsam/eeprom.c b/tmk_core/common/arm_atsam/eeprom.c index ccd5d15a5478..082553c31817 100644 --- a/tmk_core/common/arm_atsam/eeprom.c +++ b/tmk_core/common/arm_atsam/eeprom.c @@ -13,8 +13,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ - +#include "samd51j18a.h" #include "eeprom.h" +#include "core_cm4.h" +#include "component/nvmctrl.h" #ifndef EEPROM_SIZE # include "eeconfig.h" @@ -22,15 +24,40 @@ #endif __attribute__((aligned(4))) static uint8_t buffer[EEPROM_SIZE]; +volatile uint8_t *SmartEEPROM8 = (uint8_t *) SEEPROM_ADDR; uint8_t eeprom_read_byte(const uint8_t *addr) { uintptr_t offset = (uintptr_t)addr; - return buffer[offset]; + if (offset >= EEPROM_SIZE) + return 0x0; + + if (NVMCTRL->SEESTAT.bit.PSZ == 0 || NVMCTRL->SEESTAT.bit.SBLK == 0) + return buffer[offset]; + + int timeout = 10000; + while (NVMCTRL->SEESTAT.bit.BUSY && timeout-- > 0) + ; + if (!NVMCTRL->SEESTAT.bit.BUSY) + return SmartEEPROM8[offset]; + + return 0; } void eeprom_write_byte(uint8_t *addr, uint8_t value) { uintptr_t offset = (uintptr_t)addr; - buffer[offset] = value; + if (offset >= EEPROM_SIZE) + return; + + if (NVMCTRL->SEESTAT.bit.PSZ == 0 || NVMCTRL->SEESTAT.bit.SBLK == 0) { + buffer[offset] = value; + return; + } + + int timeout = 10000; + while (NVMCTRL->SEESTAT.bit.BUSY && timeout-- > 0) + ; + if (!NVMCTRL->SEESTAT.bit.BUSY) + SmartEEPROM8[offset] = value; } uint16_t eeprom_read_word(const uint16_t *addr) { diff --git a/util/applet-mdflash.bin b/util/applet-flash-samd51j18a.bin similarity index 100% rename from util/applet-mdflash.bin rename to util/applet-flash-samd51j18a.bin diff --git a/util/mdloader b/util/mdloader new file mode 100755 index 000000000000..6f51f3d508e5 Binary files /dev/null and b/util/mdloader differ diff --git a/util/mdloader_linux b/util/old_mdloder/mdloader_linux similarity index 100% rename from util/mdloader_linux rename to util/old_mdloder/mdloader_linux diff --git a/util/old_mdloder/mdloader_mac b/util/old_mdloder/mdloader_mac new file mode 100755 index 000000000000..943d16648a64 Binary files /dev/null and b/util/old_mdloder/mdloader_mac differ