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.

60 lines
1.6 KiB

  1. /*
  2. Copyright 2017 Balz Guenat
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include "fc660c.h"
  15. #ifdef ACTUATION_DEPTH_ADJUSTMENT
  16. void matrix_init_kb(void) {
  17. adjust_actuation_point(ACTUATION_DEPTH_ADJUSTMENT);
  18. matrix_init_user();
  19. }
  20. void actuation_point_up(void) {
  21. // write RDAC register: lower value makes actuation point shallow
  22. uint8_t rdac = ad5258_read_rdac();
  23. if (rdac == 0) {
  24. ad5258_write_rdac(0);
  25. } else {
  26. ad5258_write_rdac(rdac - 1);
  27. }
  28. }
  29. void actuation_point_down(void) {
  30. // write RDAC register: higher value makes actuation point deep
  31. uint8_t rdac = ad5258_read_rdac();
  32. if (rdac == 63) {
  33. ad5258_write_rdac(63);
  34. } else {
  35. ad5258_write_rdac(rdac + 1);
  36. }
  37. }
  38. void adjust_actuation_point(int offset) {
  39. ad5258_init();
  40. uint8_t rdac = ad5258_read_eeprom() + offset;
  41. if (rdac > 63) { // protects from under and overflows
  42. if (offset > 0) {
  43. ad5258_write_rdac(63);
  44. } else {
  45. ad5258_write_rdac(0);
  46. }
  47. } else {
  48. ad5258_write_rdac(rdac);
  49. }
  50. }
  51. #endif