ninjonas.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* Copyright 2019 @ninjonas
  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 "ninjonas.h"
  17. layer_state_t layer_state_set_user (layer_state_t state) {
  18. return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
  19. }
  20. // BEGIN: SSD1306OLED
  21. // SSD1306 OLED update loop, make sure to add #define SSD1306OLED in config.h
  22. #if defined(KEYBOARD_lily58_rev1) & defined(PROTOCOL_LUFA)
  23. extern uint8_t is_master;
  24. void matrix_init_user(void) {
  25. //SSD1306 OLED init, make sure to add #define SSD1306OLED in config.h
  26. iota_gfx_init(!has_usb()); // turns on the display
  27. }
  28. // When add source files to SRC in rules.mk, you can use functions.
  29. const char *read_layer_state(void);
  30. const char *read_logo(void);
  31. //void set_keylog(uint16_t keycode, keyrecord_t *record); // Moved to process_records.h
  32. const char *read_keylog(void);
  33. const char *read_keylogs(void);
  34. void matrix_scan_user(void) {
  35. iota_gfx_task();
  36. }
  37. void matrix_render_user(struct CharacterMatrix *matrix) {
  38. if (is_master) {
  39. // If you want to change the display of OLED, you need to change here
  40. matrix_write_ln(matrix, read_layer_state());
  41. matrix_write_ln(matrix, read_keylog());
  42. matrix_write_ln(matrix, read_keylogs());
  43. } else {
  44. matrix_write(matrix, read_logo());
  45. }
  46. }
  47. void matrix_update(struct CharacterMatrix *dest, const struct CharacterMatrix *source) {
  48. if (memcmp(dest->display, source->display, sizeof(dest->display))) {
  49. memcpy(dest->display, source->display, sizeof(dest->display));
  50. dest->dirty = true;
  51. }
  52. }
  53. void iota_gfx_task_user(void) {
  54. struct CharacterMatrix matrix;
  55. matrix_clear(&matrix);
  56. matrix_render_user(&matrix);
  57. matrix_update(&display, &matrix);
  58. }
  59. #endif
  60. // END: SSD1306OLED