qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

fc980c.c (1670B)


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