rubi.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* Copyright 2021 gregorio
  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. #pragma once
  17. #include "quantum.h"
  18. #define CALC_DIGITS 12
  19. enum rubi_keycodes {
  20. ENC_PRESS = SAFE_RANGE,
  21. CL_PLUS,
  22. CL_STAR,
  23. CL_TYPE,
  24. NEW_SAFE_RANGE
  25. };
  26. enum oled_modes {
  27. OLED_MODE_DEFAULT,
  28. OLED_MODE_CALC,
  29. OLED_MODE_OFF,
  30. _NUM_OLED_MODES
  31. };
  32. enum encoder_modes {
  33. ENC_MODE_VOLUME,
  34. ENC_MODE_MEDIA,
  35. ENC_MODE_BRIGHTNESS,
  36. _NUM_ENCODER_MODES
  37. };
  38. extern uint8_t current_layer;
  39. extern uint8_t oled_mode;
  40. extern uint8_t encoder_mode;
  41. extern char calc_result_display[CALC_DIGITS+1];
  42. extern char calc_operator_display;
  43. extern char calc_status_display[CALC_DIGITS+1];
  44. extern uint8_t calc_display_lines;
  45. bool process_record_user_oled(uint16_t keycode, keyrecord_t *record);
  46. void change_oled_mode(void);
  47. void change_encoder_mode(bool reverse);
  48. uint16_t handle_encoder_cw(void);
  49. uint16_t handle_encoder_ccw(void);
  50. uint16_t handle_encoder_press(void);
  51. void calcUpdate(void);
  52. void calcInput(char input);
  53. void calcOperands(void);
  54. /* This is a shortcut to help you visually see your layout.
  55. *
  56. * The first section contains all of the arguments representing the physical
  57. * layout of the board and position of the keys.
  58. *
  59. * The second converts the arguments into a two-dimensional array which
  60. * represents the switch matrix.
  61. */
  62. /* Rubi matrix layout
  63. * ,---------------.
  64. * | 23|
  65. * |---------------|
  66. * | 00| 01| 02| 03|
  67. * |---------------|
  68. * | 10| 11| 12| |
  69. * |-----------| 13|
  70. * | 20| 21| 22| |
  71. * |---------------|
  72. * | 30| 31| 32| |
  73. * |-----------| 33|
  74. * | 41 | 42| |
  75. * `---------------'
  76. */
  77. #define LAYOUT( \
  78. k23, \
  79. k00, k01, k02, k03, \
  80. k10, k11, k12, k13, \
  81. k20, k21, k22, \
  82. k30, k31, k32, k33, \
  83. k41, k42 \
  84. ) { \
  85. { k00, k01, k02, k03 }, \
  86. { k10, k11, k12, k13 }, \
  87. { k20, k21, k22, k23 }, \
  88. { k30, k31, k32, k33 }, \
  89. { KC_NO, k41, k42, KC_NO } \
  90. }