You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
5.8 KiB

Add a new keyboard "Unicorne" (#12993) * Add keyboards/yanghu/unicorne initial files. * add default keymap to yanghu/unicorne * use slow i2c and enable internal pullup resistor * add oled to default keymaps * fix unicorne default keymap * fix encoder pad direction * fix marauder * add led matrix configs. * add encoder code to default keymap. * fix encoder direction * add readme, info.json and update copyright for c files. * fix build error by clean up include in unicorne.c * fix images in readme files * Fix various issues in PR #12993 feedback. * Added copyright in glcdfont, fix include in that file. * Removed `_kc` layout and renamed layout with generic style. * Moved capslock oled update to oled.c inside `oled_task_user()`. * Update keyboards/yanghu/unicorne/keymaps/default/rules.mk Always include oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Wrap `oled.c` with ifdef. Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * move oled code to unicorne.c, and set weakly. * Update keyboards/yanghu/unicorne/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/unicorne.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/f411/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * remove oled.h * remove include of oled.h after the file is deleted. * Apply suggestions from code review: remove redundant macros and reformat. Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> * Apply suggestions from code review: change OLED driver macro. Use `OLED_ENABLE` instead of `OLED_DRIVER_ENABLE`. Co-authored-by: Jonathan Rascher <jon@bcat.name> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Jonathan Rascher <jon@bcat.name>
2 years ago
Add a new keyboard "Unicorne" (#12993) * Add keyboards/yanghu/unicorne initial files. * add default keymap to yanghu/unicorne * use slow i2c and enable internal pullup resistor * add oled to default keymaps * fix unicorne default keymap * fix encoder pad direction * fix marauder * add led matrix configs. * add encoder code to default keymap. * fix encoder direction * add readme, info.json and update copyright for c files. * fix build error by clean up include in unicorne.c * fix images in readme files * Fix various issues in PR #12993 feedback. * Added copyright in glcdfont, fix include in that file. * Removed `_kc` layout and renamed layout with generic style. * Moved capslock oled update to oled.c inside `oled_task_user()`. * Update keyboards/yanghu/unicorne/keymaps/default/rules.mk Always include oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Wrap `oled.c` with ifdef. Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * move oled code to unicorne.c, and set weakly. * Update keyboards/yanghu/unicorne/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/unicorne.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/f411/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * remove oled.h * remove include of oled.h after the file is deleted. * Apply suggestions from code review: remove redundant macros and reformat. Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> * Apply suggestions from code review: change OLED driver macro. Use `OLED_ENABLE` instead of `OLED_DRIVER_ENABLE`. Co-authored-by: Jonathan Rascher <jon@bcat.name> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Jonathan Rascher <jon@bcat.name>
2 years ago
Add a new keyboard "Unicorne" (#12993) * Add keyboards/yanghu/unicorne initial files. * add default keymap to yanghu/unicorne * use slow i2c and enable internal pullup resistor * add oled to default keymaps * fix unicorne default keymap * fix encoder pad direction * fix marauder * add led matrix configs. * add encoder code to default keymap. * fix encoder direction * add readme, info.json and update copyright for c files. * fix build error by clean up include in unicorne.c * fix images in readme files * Fix various issues in PR #12993 feedback. * Added copyright in glcdfont, fix include in that file. * Removed `_kc` layout and renamed layout with generic style. * Moved capslock oled update to oled.c inside `oled_task_user()`. * Update keyboards/yanghu/unicorne/keymaps/default/rules.mk Always include oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Wrap `oled.c` with ifdef. Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * move oled code to unicorne.c, and set weakly. * Update keyboards/yanghu/unicorne/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/unicorne.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/f411/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * remove oled.h * remove include of oled.h after the file is deleted. * Apply suggestions from code review: remove redundant macros and reformat. Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> * Apply suggestions from code review: change OLED driver macro. Use `OLED_ENABLE` instead of `OLED_DRIVER_ENABLE`. Co-authored-by: Jonathan Rascher <jon@bcat.name> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Jonathan Rascher <jon@bcat.name>
2 years ago
Add a new keyboard "Unicorne" (#12993) * Add keyboards/yanghu/unicorne initial files. * add default keymap to yanghu/unicorne * use slow i2c and enable internal pullup resistor * add oled to default keymaps * fix unicorne default keymap * fix encoder pad direction * fix marauder * add led matrix configs. * add encoder code to default keymap. * fix encoder direction * add readme, info.json and update copyright for c files. * fix build error by clean up include in unicorne.c * fix images in readme files * Fix various issues in PR #12993 feedback. * Added copyright in glcdfont, fix include in that file. * Removed `_kc` layout and renamed layout with generic style. * Moved capslock oled update to oled.c inside `oled_task_user()`. * Update keyboards/yanghu/unicorne/keymaps/default/rules.mk Always include oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Wrap `oled.c` with ifdef. Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * move oled code to unicorne.c, and set weakly. * Update keyboards/yanghu/unicorne/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/unicorne.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/f411/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * remove oled.h * remove include of oled.h after the file is deleted. * Apply suggestions from code review: remove redundant macros and reformat. Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> * Apply suggestions from code review: change OLED driver macro. Use `OLED_ENABLE` instead of `OLED_DRIVER_ENABLE`. Co-authored-by: Jonathan Rascher <jon@bcat.name> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Jonathan Rascher <jon@bcat.name>
2 years ago
Add a new keyboard "Unicorne" (#12993) * Add keyboards/yanghu/unicorne initial files. * add default keymap to yanghu/unicorne * use slow i2c and enable internal pullup resistor * add oled to default keymaps * fix unicorne default keymap * fix encoder pad direction * fix marauder * add led matrix configs. * add encoder code to default keymap. * fix encoder direction * add readme, info.json and update copyright for c files. * fix build error by clean up include in unicorne.c * fix images in readme files * Fix various issues in PR #12993 feedback. * Added copyright in glcdfont, fix include in that file. * Removed `_kc` layout and renamed layout with generic style. * Moved capslock oled update to oled.c inside `oled_task_user()`. * Update keyboards/yanghu/unicorne/keymaps/default/rules.mk Always include oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Wrap `oled.c` with ifdef. Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * move oled code to unicorne.c, and set weakly. * Update keyboards/yanghu/unicorne/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/unicorne.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/f411/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * remove oled.h * remove include of oled.h after the file is deleted. * Apply suggestions from code review: remove redundant macros and reformat. Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> * Apply suggestions from code review: change OLED driver macro. Use `OLED_ENABLE` instead of `OLED_DRIVER_ENABLE`. Co-authored-by: Jonathan Rascher <jon@bcat.name> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Jonathan Rascher <jon@bcat.name>
2 years ago
Add a new keyboard "Unicorne" (#12993) * Add keyboards/yanghu/unicorne initial files. * add default keymap to yanghu/unicorne * use slow i2c and enable internal pullup resistor * add oled to default keymaps * fix unicorne default keymap * fix encoder pad direction * fix marauder * add led matrix configs. * add encoder code to default keymap. * fix encoder direction * add readme, info.json and update copyright for c files. * fix build error by clean up include in unicorne.c * fix images in readme files * Fix various issues in PR #12993 feedback. * Added copyright in glcdfont, fix include in that file. * Removed `_kc` layout and renamed layout with generic style. * Moved capslock oled update to oled.c inside `oled_task_user()`. * Update keyboards/yanghu/unicorne/keymaps/default/rules.mk Always include oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Wrap `oled.c` with ifdef. Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * move oled code to unicorne.c, and set weakly. * Update keyboards/yanghu/unicorne/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/unicorne.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/f411/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * remove oled.h * remove include of oled.h after the file is deleted. * Apply suggestions from code review: remove redundant macros and reformat. Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> * Apply suggestions from code review: change OLED driver macro. Use `OLED_ENABLE` instead of `OLED_DRIVER_ENABLE`. Co-authored-by: Jonathan Rascher <jon@bcat.name> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Jonathan Rascher <jon@bcat.name>
2 years ago
Add a new keyboard "Unicorne" (#12993) * Add keyboards/yanghu/unicorne initial files. * add default keymap to yanghu/unicorne * use slow i2c and enable internal pullup resistor * add oled to default keymaps * fix unicorne default keymap * fix encoder pad direction * fix marauder * add led matrix configs. * add encoder code to default keymap. * fix encoder direction * add readme, info.json and update copyright for c files. * fix build error by clean up include in unicorne.c * fix images in readme files * Fix various issues in PR #12993 feedback. * Added copyright in glcdfont, fix include in that file. * Removed `_kc` layout and renamed layout with generic style. * Moved capslock oled update to oled.c inside `oled_task_user()`. * Update keyboards/yanghu/unicorne/keymaps/default/rules.mk Always include oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Wrap `oled.c` with ifdef. Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Drashna Jaelre <drashna@live.com> * move oled code to unicorne.c, and set weakly. * Update keyboards/yanghu/unicorne/config.h Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/keymaps/default/keymap.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/unicorne.c Co-authored-by: Drashna Jaelre <drashna@live.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/readme.md Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/keymaps/default/oled.c Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/f411/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * Update keyboards/yanghu/unicorne/rules.mk Co-authored-by: Ryan <fauxpark@gmail.com> * remove oled.h * remove include of oled.h after the file is deleted. * Apply suggestions from code review: remove redundant macros and reformat. Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> * Apply suggestions from code review: change OLED driver macro. Use `OLED_ENABLE` instead of `OLED_DRIVER_ENABLE`. Co-authored-by: Jonathan Rascher <jon@bcat.name> Co-authored-by: Drashna Jaelre <drashna@live.com> Co-authored-by: Ryan <fauxpark@gmail.com> Co-authored-by: Jonathan Rascher <jon@bcat.name>
2 years ago
  1. /* Copyright 2021 Yang Hu
  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 "unicorne.h"
  17. #include "i2c_master.h"
  18. // Custom i2c init to enable internal pull up resistor for i2c.
  19. void i2c_init(void) {
  20. static bool is_initialised = false;
  21. if (!is_initialised) {
  22. is_initialised = true;
  23. // Try releasing special pins for a short time
  24. palSetLineMode(I2C1_SCL_PIN, PAL_MODE_INPUT);
  25. palSetLineMode(I2C1_SDA_PIN, PAL_MODE_INPUT);
  26. chThdSleepMilliseconds(10);
  27. // Use internal pull up since we do not have pull up on i2c pins in v1 design.
  28. palSetLineMode(I2C1_SCL_PIN, PAL_MODE_ALTERNATE(I2C1_SCL_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
  29. palSetLineMode(I2C1_SDA_PIN, PAL_MODE_ALTERNATE(I2C1_SDA_PAL_MODE) | PAL_OUTPUT_TYPE_OPENDRAIN | PAL_STM32_PUPDR_PULLUP);
  30. }
  31. }
  32. // LED matrix
  33. // physical location
  34. // 2 3 4 5
  35. //
  36. // 1 6
  37. // 0 7
  38. #ifdef RGB_MATRIX_ENABLE
  39. // clang-format off
  40. led_config_t g_led_config = {{
  41. // Key Matrix to LED Index
  42. // Since we only have 8 LEDs, map the keys near them to the same LED.
  43. {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5},
  44. {2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5},
  45. {1, 1, 1, 0, 0, 0, 7, 7, 7, 6, 6, 6},
  46. {NO_LED, NO_LED, NO_LED, 0, 0, 0, 7, 7, 7, NO_LED, NO_LED, NO_LED},
  47. }, {// LED Index to Physical Position
  48. {94, 60},
  49. {18, 44},
  50. {8, 10},
  51. {94, 10},
  52. {130,10},
  53. {216, 10},
  54. {208, 44},
  55. {130, 60}
  56. }, {// LED Index to Flag
  57. LED_FLAG_ALL, LED_FLAG_ALL, LED_FLAG_ALL, LED_FLAG_ALL, LED_FLAG_ALL,
  58. LED_FLAG_ALL, LED_FLAG_ALL, LED_FLAG_ALL
  59. }};
  60. // clang-format on
  61. #endif
  62. #ifdef OLED_ENABLE
  63. // OLED shared code
  64. // The oled is vertical. Need to rotate 270 degrees.
  65. __attribute__((weak)) oled_rotation_t oled_init_user(oled_rotation_t rotation) { return OLED_ROTATION_270; }
  66. // Render layer status on OLED. To be re-implemented by keymaps since layers are
  67. // defined there.
  68. __attribute__((weak)) void oled_render_layer(void) { return; }
  69. // Oneshot mods status
  70. uint8_t osmods;
  71. __attribute__((weak)) void oled_render_mods(void) {
  72. static const char PROGMEM ctrl[] = {0xb6, 0xb7, 10, 0xd6, 0xd7, 10, 0x20, 0x20, 10, 0};
  73. static const char PROGMEM shift[] = {0x87, 0x88, 0x89, 10, 0xa7, 0xa8, 0xa9, 10, 0xc7, 0xc8, 0xc9, 10, 0};
  74. static const char PROGMEM alt[] = {0x84, 0x85, 0x86, 10, 0xa4, 0xa5, 0xa6, 10, 0xc4, 0xc5, 0xc6, 10, 0};
  75. static const char PROGMEM ctrl_alt[] = {0xb6, 0xb7, 0x84, 0x85, 0x86, 0xd6, 0xd7, 0xa4, 0xa5, 0xa6, 0x20, 0x20, 0xc4, 0xc5, 0xc6, 0};
  76. static const char PROGMEM ctrl_shift[] = {0xb6, 0xb7, 0x87, 0x88, 0x89, 0xd6, 0xd7, 0xa7, 0xa8, 0xa9, 0x20, 0x20, 0xc7, 0xc8, 0xc9, 0};
  77. static const char PROGMEM c_a_shift[] = {0xb6, 0xb7, 0x84, 0x85, 0x86, 0xd6, 0xd7, 0xa4, 0xa5, 0xa6, 0x20, 0x20, 0xc4, 0xc5, 0xc6, 0x87, 0x88, 0x89, 10, 0xa7, 0xa8, 0xa9, 10, 0xc7, 0xc8, 0xc9, 10, 0};
  78. // Now check mod status and render.
  79. static uint8_t mods;
  80. mods = get_mods() | osmods;
  81. if ((mods & MOD_MASK_CTRL) && (mods & MOD_MASK_ALT) && (mods & MOD_MASK_SHIFT)) {
  82. oled_write_P(c_a_shift, false);
  83. } else if ((mods & MOD_MASK_CTRL) && (mods & MOD_MASK_ALT)) {
  84. oled_write_P(ctrl_alt, false);
  85. } else if ((mods & MOD_MASK_CTRL) && (mods & MOD_MASK_SHIFT)) {
  86. oled_write_P(ctrl_shift, false);
  87. } else if ((mods & MOD_MASK_SHIFT) && (mods & MOD_MASK_ALT)) {
  88. oled_write_P(alt, false);
  89. oled_write_P(shift, false);
  90. } else if (mods & MOD_MASK_CTRL) {
  91. oled_write_P(ctrl, false);
  92. } else if (mods & MOD_MASK_ALT) {
  93. oled_write_P(alt, false);
  94. } else if (mods & MOD_MASK_SHIFT) {
  95. oled_write_P(shift, false);
  96. } else {
  97. for (int i = 0; i < 6; ++i) {
  98. oled_write_ln(" ", false);
  99. }
  100. }
  101. return;
  102. }
  103. void oneshot_mods_changed_user(uint8_t mods) { osmods = mods; }
  104. // Call this from "led_update_user" and use `led_state.caps_lock` to check
  105. // the status of capslock.
  106. __attribute__((weak)) void oled_render_capslock(bool caps_on) {
  107. static const char PROGMEM capslock_logo[] = {0x9c, 0x9d, 0x9e, 0x9f, 10, 0xbc, 0xbd, 0xbe, 0xbf, 10, 0xdc, 0xdd, 0xde, 0xdf, 10, 0};
  108. if (caps_on) {
  109. oled_write_P(capslock_logo, false);
  110. } else {
  111. for (int i = 0; i < 3; ++i) {
  112. oled_write_ln(" ", false);
  113. }
  114. }
  115. }
  116. char keylog_str[24] = {};
  117. const char code_to_name[60] = {' ', ' ', ' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\', '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
  118. void set_keylog(uint16_t keycode, keyrecord_t *record) {
  119. if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
  120. keycode = keycode & 0xFF;
  121. }
  122. }
  123. __attribute__((weak)) void oled_render_keylog(void) { oled_write(keylog_str, false); }
  124. // Keymaps can override this function
  125. __attribute__((weak)) bool oled_task_kb(void) {
  126. if (!oled_task_user()) { return false; }
  127. /* oled_render_keylog(); */
  128. oled_render_layer();
  129. oled_render_mods();
  130. led_t led_state = host_keyboard_led_state();
  131. oled_render_capslock(led_state.caps_lock);
  132. return true;
  133. }
  134. #endif