logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

kb83.c (20540B)


  1. /* Copyright (C) 2022 jonylee@hfd
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "quantum.h"
  17. // clang-format off
  18. #ifdef RGB_MATRIX_ENABLE
  19. const snled27351_led_t PROGMEM g_snled27351_leds[SNLED27351_LED_COUNT] = {
  20. /* Refer to SNLED27351 manual for these locations
  21. * driver
  22. * | R location
  23. * | | G location
  24. * | | | B location
  25. * | | | | */
  26. {1, CB1_CA1, CB2_CA1, CB3_CA1},
  27. {1, CB1_CA2, CB2_CA2, CB3_CA2},
  28. {1, CB1_CA3, CB2_CA3, CB3_CA3},
  29. {1, CB1_CA4, CB2_CA4, CB3_CA4},
  30. {1, CB1_CA5, CB2_CA5, CB3_CA5},
  31. {1, CB1_CA6, CB2_CA6, CB3_CA6},
  32. {1, CB1_CA7, CB2_CA7, CB3_CA7},
  33. {1, CB1_CA8, CB2_CA8, CB3_CA8},
  34. {1, CB1_CA9, CB2_CA9, CB3_CA9},
  35. {1, CB1_CA10, CB2_CA10, CB3_CA10},
  36. {1, CB1_CA11, CB2_CA11, CB3_CA11},
  37. {1, CB1_CA12, CB2_CA12, CB3_CA12},
  38. {1, CB1_CA13, CB2_CA13, CB3_CA13},
  39. {1, CB1_CA14, CB2_CA14, CB3_CA14},
  40. {0, CB1_CA1, CB2_CA1, CB3_CA1},
  41. {0, CB1_CA2, CB2_CA2, CB3_CA2},
  42. {0, CB1_CA3, CB2_CA3, CB3_CA3},
  43. {0, CB1_CA4, CB2_CA4, CB3_CA4},
  44. {0, CB1_CA5, CB2_CA5, CB3_CA5},
  45. {0, CB1_CA6, CB2_CA6, CB3_CA6},
  46. {0, CB1_CA7, CB2_CA7, CB3_CA7},
  47. {0, CB1_CA8, CB2_CA8, CB3_CA8},
  48. {0, CB1_CA9, CB2_CA9, CB3_CA9},
  49. {0, CB1_CA10, CB2_CA10, CB3_CA10},
  50. {0, CB1_CA11, CB2_CA11, CB3_CA11},
  51. {0, CB1_CA12, CB2_CA12, CB3_CA12},
  52. {0, CB1_CA13, CB2_CA13, CB3_CA13},
  53. {0, CB1_CA14, CB2_CA14, CB3_CA14},
  54. {1, CB4_CA1, CB5_CA1, CB6_CA1},
  55. {0, CB4_CA1, CB5_CA1, CB6_CA1},
  56. {0, CB4_CA2, CB5_CA2, CB6_CA2},
  57. {0, CB4_CA3, CB5_CA3, CB6_CA3},
  58. {0, CB4_CA4, CB5_CA4, CB6_CA4},
  59. {0, CB4_CA5, CB5_CA5, CB6_CA5},
  60. {0, CB4_CA6, CB5_CA6, CB6_CA6},
  61. {0, CB4_CA7, CB5_CA7, CB6_CA7},
  62. {0, CB4_CA8, CB5_CA8, CB6_CA8},
  63. {0, CB4_CA9, CB5_CA9, CB6_CA9},
  64. {0, CB4_CA10, CB5_CA10, CB6_CA10},
  65. {0, CB4_CA11, CB5_CA11, CB6_CA11},
  66. {0, CB4_CA12, CB5_CA12, CB6_CA12},
  67. {0, CB4_CA13, CB5_CA13, CB6_CA13},
  68. {0, CB4_CA14, CB5_CA14, CB6_CA14},
  69. {1, CB4_CA2, CB5_CA2, CB6_CA2},
  70. {0, CB7_CA1, CB8_CA1, CB9_CA1},
  71. {0, CB7_CA2, CB8_CA2, CB9_CA2},
  72. {0, CB7_CA3, CB8_CA3, CB9_CA3},
  73. {0, CB7_CA4, CB8_CA4, CB9_CA4},
  74. {0, CB7_CA5, CB8_CA5, CB9_CA5},
  75. {0, CB7_CA6, CB8_CA6, CB9_CA6},
  76. {0, CB7_CA7, CB8_CA7, CB9_CA7},
  77. {0, CB7_CA8, CB8_CA8, CB9_CA8},
  78. {0, CB7_CA9, CB8_CA9, CB9_CA9},
  79. {0, CB7_CA10, CB8_CA10, CB9_CA10},
  80. {0, CB7_CA11, CB8_CA11, CB9_CA11},
  81. {0, CB7_CA12, CB8_CA12, CB9_CA12},
  82. {0, CB7_CA13, CB8_CA13, CB9_CA13},
  83. {1, CB4_CA3, CB5_CA3, CB6_CA3},
  84. {0, CB10_CA1, CB11_CA1, CB12_CA1},
  85. {0, CB10_CA2, CB11_CA2, CB12_CA2},
  86. {0, CB10_CA3, CB11_CA3, CB12_CA3},
  87. {0, CB10_CA4, CB11_CA4, CB12_CA4},
  88. {0, CB10_CA5, CB11_CA5, CB12_CA5},
  89. {0, CB10_CA6, CB11_CA6, CB12_CA6},
  90. {0, CB10_CA7, CB11_CA7, CB12_CA7},
  91. {0, CB10_CA8, CB11_CA8, CB12_CA8},
  92. {0, CB10_CA9, CB11_CA9, CB12_CA9},
  93. {0, CB10_CA10, CB11_CA10, CB12_CA10},
  94. {0, CB10_CA11, CB11_CA11, CB12_CA11},
  95. {0, CB10_CA12, CB11_CA12, CB12_CA12},
  96. {1, CB4_CA7, CB5_CA7, CB6_CA7},
  97. {1, CB4_CA4, CB5_CA4, CB6_CA4},
  98. {0, CB10_CA13, CB11_CA13, CB12_CA13},
  99. {0, CB10_CA14, CB11_CA14, CB12_CA14},
  100. {0, CB10_CA15, CB11_CA15, CB12_CA15},
  101. {0, CB10_CA16, CB11_CA16, CB12_CA16},
  102. {0, CB7_CA14, CB8_CA14, CB9_CA14},
  103. {0, CB7_CA15, CB8_CA15, CB9_CA15},
  104. {0, CB7_CA16, CB8_CA16, CB9_CA16},
  105. {0, CB4_CA15, CB5_CA15, CB6_CA15},
  106. {1, CB4_CA6, CB5_CA6, CB6_CA6},
  107. {1, CB4_CA5, CB5_CA5, CB6_CA5},
  108. {1, CB7_CA1, CB8_CA1, CB9_CA1},
  109. {1, CB7_CA2, CB8_CA2, CB9_CA2},
  110. {1, CB7_CA3, CB8_CA3, CB9_CA3},
  111. {1, CB7_CA4, CB8_CA4, CB9_CA4},
  112. {1, CB7_CA5, CB8_CA5, CB9_CA5},
  113. {1, CB10_CA1, CB11_CA1, CB12_CA1},
  114. {1, CB10_CA2, CB11_CA2, CB12_CA2},
  115. {1, CB10_CA3, CB11_CA3, CB12_CA3},
  116. {1, CB10_CA4, CB11_CA4, CB12_CA4},
  117. {1, CB10_CA5, CB11_CA5, CB12_CA5},
  118. };
  119. led_config_t g_led_config = {
  120. {
  121. { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, NO_LED, NO_LED},
  122. { 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, NO_LED, 28},
  123. { 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, NO_LED, 43},
  124. { 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, NO_LED, 56, NO_LED, 57},
  125. { 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, NO_LED, NO_LED, 69, 70, 71},
  126. { 72, 73, 74, NO_LED, NO_LED, 75, NO_LED, NO_LED, NO_LED, 76, 77, 78, NO_LED, 79, 80, 81}
  127. },
  128. {
  129. { 0, 0}, // 0
  130. { 14, 0}, // 1
  131. { 29, 0}, // 2
  132. { 44, 0}, // 3
  133. { 59, 0}, // 4
  134. { 74, 0}, // 5
  135. { 89, 0}, // 6
  136. {104, 0}, // 7
  137. {119, 0}, // 8
  138. {134, 0}, // 9
  139. {149, 0}, // 10
  140. {164, 0}, // 11
  141. {179, 0}, // 12
  142. {194, 0}, // 13
  143. { 0, 12}, // 14
  144. { 14, 12}, // 15
  145. { 28, 12}, // 16
  146. { 42, 12}, // 17
  147. { 56, 12}, // 18
  148. { 70, 12}, // 19
  149. { 84, 12}, // 20
  150. { 98, 12}, // 21
  151. {112, 12}, // 22
  152. {126, 12}, // 23
  153. {140, 12}, // 24
  154. {154, 12}, // 25
  155. {168, 12}, // 26
  156. {182, 12}, // 27
  157. {224, 12}, // 28
  158. { 0, 25}, // 29
  159. { 14, 25}, // 30
  160. { 28, 25}, // 31
  161. { 42, 25}, // 32
  162. { 56, 25}, // 33
  163. { 70, 25}, // 34
  164. { 84, 25}, // 35
  165. { 98, 25}, // 36
  166. {112, 25}, // 37
  167. {126, 25}, // 38
  168. {140, 25}, // 39
  169. {154, 25}, // 40
  170. {168, 25}, // 41
  171. {182, 25}, // 42
  172. {224, 25}, // 43
  173. { 0, 38}, // 44
  174. { 28, 38}, // 45
  175. { 42, 38}, // 46
  176. { 56, 38}, // 47
  177. { 70, 38}, // 48
  178. { 84, 38}, // 49
  179. { 98, 38}, // 50
  180. {112, 38}, // 51
  181. {126, 38}, // 52
  182. {140, 38}, // 53
  183. {154, 38}, // 54
  184. {168, 38}, // 55
  185. {182, 38}, // 56
  186. {224, 38}, // 57
  187. { 0, 51}, // 58
  188. { 18, 51}, // 59
  189. { 37, 51}, // 60
  190. { 56, 51}, // 61
  191. { 74, 51}, // 62
  192. { 93, 51}, // 63
  193. {112, 51}, // 64
  194. {130, 51}, // 65
  195. {149, 51}, // 66
  196. {168, 51}, // 67
  197. {186, 51}, // 68
  198. {200, 51}, // 69
  199. {214, 51}, // 70
  200. {224, 51}, // 71
  201. { 0, 64}, // 72
  202. { 18, 64}, // 73
  203. { 37, 64}, // 74
  204. { 92, 64}, // 75
  205. {140, 64}, // 76
  206. {154, 64}, // 77
  207. {168, 64}, // 78
  208. {196, 64}, // 80
  209. {210, 64}, // 81
  210. {224, 64}, // 82
  211. {0, 0}, // 68 LED 1
  212. {0, 16}, // 69 LED 2
  213. {0, 32}, // 70 LED 3
  214. {0, 48}, // 71 LED 4
  215. {0, 64}, // 72 LED 5
  216. {224, 0 }, // 78 LED 12
  217. {224, 16}, // 79 LED 13
  218. {224, 32}, // 80 LED 14
  219. {224, 48}, // 81 LED 15
  220. {224, 64}, // 82 LED 16
  221. },
  222. {
  223. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  224. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  225. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  226. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  227. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  228. 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
  229. 2, 2, 2, 2, 2,
  230. 2, 2, 2, 2, 2,
  231. }
  232. };
  233. bool rgb_matrix_indicators_advanced_kb(uint8_t led_min, uint8_t led_max) {
  234. if (!rgb_matrix_indicators_advanced_user(led_min, led_max)) {
  235. return false;
  236. }
  237. // caps lock red
  238. if (host_keyboard_led_state().caps_lock) {
  239. RGB_MATRIX_INDICATOR_SET_COLOR(44, 255, 0, 0);
  240. } else {
  241. if (!rgb_matrix_get_flags()) {
  242. RGB_MATRIX_INDICATOR_SET_COLOR(44, 0, 0, 0);
  243. }
  244. }
  245. // GUI lock red
  246. if (keymap_config.no_gui) {
  247. RGB_MATRIX_INDICATOR_SET_COLOR(73, 255, 0, 0);
  248. } else {
  249. if (!rgb_matrix_get_flags()) {
  250. RGB_MATRIX_INDICATOR_SET_COLOR(73, 0, 0, 0);
  251. }
  252. }
  253. return true;
  254. }
  255. #endif
  256. enum __layers {
  257. WIN_B,
  258. WIN_FN,
  259. MAC_B,
  260. MAC_FN
  261. };
  262. enum colors {
  263. WHITE,
  264. RED,
  265. GREEN,
  266. BLUE
  267. };
  268. enum colors led_color_status = WHITE;
  269. // clang-format on
  270. static bool fn_make_flag = false;
  271. static bool Lkey_flag = false;
  272. static bool reset_glint_flag = false;
  273. static bool while_test_flag = false;
  274. static bool alarm_flag = false;
  275. static uint16_t current_time = 0;
  276. static uint8_t glint_cnt = 0;
  277. static uint16_t scancode = 0;
  278. static uint8_t alarm_cnt = 0;
  279. static uint8_t RGB_HSV_level;
  280. hsv_t hsv;
  281. void led_test(uint8_t color);
  282. void clear_eeprom(void);
  283. void rgb_hsv_updata_user(void);
  284. bool dip_switch_update_kb(uint8_t index, bool active) {
  285. if (!dip_switch_update_user(index, active)) {
  286. return false;
  287. }
  288. if (index == 0) {
  289. default_layer_set(1UL << (active ? MAC_B : WIN_B));
  290. }
  291. return true;
  292. }
  293. bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
  294. if (!process_record_user(keycode, record)) {
  295. return false;
  296. }
  297. switch (keycode) {
  298. case MO(WIN_FN):
  299. case MO(MAC_FN):
  300. fn_make_flag = record->event.pressed;
  301. return true;
  302. case KC_ESC:
  303. if (fn_make_flag && record->event.pressed) {
  304. Lkey_flag = true;
  305. current_time = timer_read();
  306. scancode = KC_ESC;
  307. return false;
  308. } else {
  309. Lkey_flag = 0;
  310. }
  311. return true;
  312. case KC_END:
  313. if (fn_make_flag && record->event.pressed) {
  314. if (while_test_flag) {
  315. while_test_flag = false;
  316. rgb_matrix_init();
  317. } else {
  318. Lkey_flag = true;
  319. current_time = timer_read();
  320. scancode = KC_END;
  321. }
  322. return false;
  323. } else {
  324. Lkey_flag = 0;
  325. }
  326. return true;
  327. case KC_LEFT:
  328. if (while_test_flag == true) {
  329. if (record->event.pressed) {
  330. if (glint_cnt == 0)
  331. glint_cnt = 3;
  332. else
  333. glint_cnt--;
  334. if ((glint_cnt % 4) == 0) {
  335. rgb_matrix_sethsv_noeeprom(HSV_WHITE);
  336. } else if ((glint_cnt % 4) == 1) {
  337. rgb_matrix_sethsv_noeeprom(HSV_RED);
  338. } else if ((glint_cnt % 4) == 2) {
  339. rgb_matrix_sethsv_noeeprom(HSV_GREEN);
  340. } else if ((glint_cnt % 4) == 3) {
  341. rgb_matrix_sethsv_noeeprom(HSV_BLUE);
  342. }
  343. }
  344. return false;
  345. }
  346. return true;
  347. case KC_RGHT:
  348. if (while_test_flag == true) {
  349. if (record->event.pressed) {
  350. glint_cnt++;
  351. if (glint_cnt >= 4) glint_cnt = 0;
  352. if ((glint_cnt % 4) == 0) {
  353. rgb_matrix_sethsv_noeeprom(HSV_WHITE);
  354. } else if ((glint_cnt % 4) == 1) {
  355. rgb_matrix_sethsv_noeeprom(HSV_RED);
  356. } else if ((glint_cnt % 4) == 2) {
  357. rgb_matrix_sethsv_noeeprom(HSV_GREEN);
  358. } else if ((glint_cnt % 4) == 3) {
  359. rgb_matrix_sethsv_noeeprom(HSV_BLUE);
  360. }
  361. }
  362. return false;
  363. }
  364. return true;
  365. case DF(WIN_B):
  366. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  367. alarm_flag = true;
  368. rgb_matrix_toggle_noeeprom();
  369. current_time = timer_read();
  370. set_single_persistent_default_layer(WIN_B);
  371. return false;
  372. }
  373. return true;
  374. case DF(MAC_B):
  375. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  376. alarm_flag = true;
  377. rgb_matrix_toggle_noeeprom();
  378. current_time = timer_read();
  379. set_single_persistent_default_layer(MAC_B);
  380. return false;
  381. }
  382. return true;
  383. case QK_RGB_MATRIX_VALUE_UP:
  384. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  385. if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_val() / (RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4)) < 4) {
  386. RGB_HSV_level++;
  387. rgb_matrix_config.hsv.v = (uint8_t)(RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4) * RGB_HSV_level;
  388. }
  389. rgb_hsv_updata_user();
  390. }
  391. return false;
  392. case QK_RGB_MATRIX_VALUE_DOWN:
  393. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  394. if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_val() / (RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4)) > 0) {
  395. RGB_HSV_level--;
  396. rgb_matrix_config.hsv.v = (uint8_t)(RGB_MATRIX_MAXIMUM_BRIGHTNESS / 4) * RGB_HSV_level;
  397. }
  398. rgb_hsv_updata_user();
  399. }
  400. return false;
  401. case QK_RGB_MATRIX_SATURATION_UP:
  402. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  403. if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_sat() / (UINT8_MAX / 4)) < 4) {
  404. RGB_HSV_level++;
  405. rgb_matrix_config.hsv.s = (uint8_t)(UINT8_MAX / 4) * RGB_HSV_level;
  406. }
  407. rgb_hsv_updata_user();
  408. }
  409. return false;
  410. case QK_RGB_MATRIX_SATURATION_DOWN:
  411. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  412. if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_sat() / (UINT8_MAX / 4)) > 0) {
  413. RGB_HSV_level--;
  414. rgb_matrix_config.hsv.s = (uint8_t)(UINT8_MAX / 4) * RGB_HSV_level;
  415. }
  416. rgb_hsv_updata_user();
  417. }
  418. return false;
  419. case QK_RGB_MATRIX_HUE_UP:
  420. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  421. if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_hue() / (UINT8_MAX / 6)) < 6) {
  422. RGB_HSV_level++;
  423. rgb_matrix_config.hsv.h = (uint8_t)(UINT8_MAX / 6) * RGB_HSV_level;
  424. }
  425. rgb_hsv_updata_user();
  426. }
  427. return false;
  428. case QK_RGB_MATRIX_HUE_DOWN:
  429. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  430. if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_hue() / (UINT8_MAX / 6)) > 0) {
  431. RGB_HSV_level--;
  432. rgb_matrix_config.hsv.h = (uint8_t)(UINT8_MAX / 6) * RGB_HSV_level;
  433. }
  434. rgb_hsv_updata_user();
  435. }
  436. return false;
  437. case QK_RGB_MATRIX_SPEED_UP:
  438. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  439. if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_speed() / (UINT8_MAX / 4)) < 4) {
  440. RGB_HSV_level++;
  441. rgb_matrix_set_speed((uint8_t)(UINT8_MAX / 4) * RGB_HSV_level);
  442. }
  443. }
  444. return false;
  445. case QK_RGB_MATRIX_SPEED_DOWN:
  446. if ((fn_make_flag && record->event.pressed) && (alarm_flag == 0)) {
  447. if ((RGB_HSV_level = (uint8_t)rgb_matrix_get_speed() / (UINT8_MAX / 4)) > 0) {
  448. RGB_HSV_level--;
  449. rgb_matrix_set_speed((uint8_t)(UINT8_MAX / 4) * RGB_HSV_level);
  450. }
  451. }
  452. return false;
  453. case QK_RGB_MATRIX_TOGGLE:
  454. if (record->event.pressed) {
  455. switch (rgb_matrix_get_flags()) {
  456. case LED_FLAG_ALL: {
  457. rgb_matrix_set_flags(LED_FLAG_NONE);
  458. rgb_matrix_set_color_all(0, 0, 0);
  459. } break;
  460. default: {
  461. rgb_matrix_set_flags(LED_FLAG_ALL);
  462. } break;
  463. }
  464. }
  465. if (!rgb_matrix_is_enabled()) {
  466. rgb_matrix_set_flags(LED_FLAG_ALL);
  467. rgb_matrix_enable();
  468. }
  469. return false;
  470. default:
  471. return process_record_user(keycode, record);
  472. }
  473. }
  474. void housekeeping_task_kb(void) {
  475. if (Lkey_flag) {
  476. if (scancode == KC_ESC) {
  477. if (timer_elapsed(current_time) >= 3000) {
  478. Lkey_flag = false;
  479. clear_eeprom();
  480. current_time = timer_read();
  481. reset_glint_flag = true;
  482. glint_cnt = 0;
  483. rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
  484. rgb_matrix_sethsv_noeeprom(HSV_OFF);
  485. }
  486. } else if (scancode == KC_END) {
  487. if (timer_elapsed(current_time) >= 3000) {
  488. Lkey_flag = false;
  489. clear_eeprom();
  490. while_test_flag = true;
  491. glint_cnt = 0;
  492. rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
  493. rgb_matrix_sethsv_noeeprom(HSV_WHITE);
  494. }
  495. }
  496. } else if (reset_glint_flag) {
  497. if ((timer_elapsed(current_time)) >= 300) {
  498. current_time = timer_read();
  499. if (((glint_cnt++) & 0x01) == 0) {
  500. rgb_matrix_sethsv_noeeprom(HSV_RED);
  501. } else {
  502. rgb_matrix_sethsv_noeeprom(HSV_OFF);
  503. }
  504. if (glint_cnt >= 7) {
  505. glint_cnt = 0;
  506. reset_glint_flag = false;
  507. rgb_matrix_init();
  508. }
  509. }
  510. } else if (alarm_cnt != 0) {
  511. alarm_cnt--;
  512. if (alarm_cnt == 0) {
  513. alarm_flag = true;
  514. rgb_matrix_toggle_noeeprom();
  515. current_time = timer_read();
  516. }
  517. } else if (alarm_flag) {
  518. if ((timer_elapsed(current_time)) >= 200) {
  519. rgb_matrix_toggle_noeeprom();
  520. alarm_flag = 0;
  521. }
  522. }
  523. }
  524. void led_test(uint8_t color) {
  525. rgb_matrix_mode_noeeprom(RGB_MATRIX_SOLID_COLOR);
  526. switch (color) {
  527. case WHITE:
  528. rgb_matrix_sethsv_noeeprom(HSV_WHITE);
  529. break;
  530. case RED:
  531. rgb_matrix_sethsv_noeeprom(HSV_RED);
  532. break;
  533. case GREEN:
  534. rgb_matrix_sethsv_noeeprom(HSV_GREEN);
  535. break;
  536. case BLUE:
  537. rgb_matrix_sethsv_noeeprom(HSV_BLUE);
  538. break;
  539. }
  540. }
  541. void clear_eeprom(void) {
  542. layer_state_t default_layer_temp = default_layer_state;
  543. eeconfig_init();
  544. default_layer_set(default_layer_temp);
  545. #ifdef VIA_ENABLE
  546. // This resets the layout options
  547. via_set_layout_options(VIA_EEPROM_LAYOUT_OPTIONS_DEFAULT);
  548. // This resets the keymaps in EEPROM to what is in flash.
  549. dynamic_keymap_reset();
  550. // This resets the macros in EEPROM to nothing.
  551. dynamic_keymap_macro_reset();
  552. #endif
  553. rgb_matrix_enable_noeeprom();
  554. }
  555. void rgb_hsv_updata_user(void) {
  556. rgb_matrix_sethsv(rgb_matrix_config.hsv.h, rgb_matrix_config.hsv.s, rgb_matrix_config.hsv.v);
  557. }