pimoroni_trackball.h (2145B)
1 /* Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com> 2 * Copyright 2021 Dasky (@daskygit) 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 #pragma once 18 19 #include <stdint.h> 20 #include "report.h" 21 #include "i2c_master.h" 22 #include "pointing_device.h" 23 24 #ifndef PIMORONI_TRACKBALL_ADDRESS 25 # define PIMORONI_TRACKBALL_ADDRESS 0x0A 26 #endif 27 #ifndef PIMORONI_TRACKBALL_SCALE 28 # define PIMORONI_TRACKBALL_SCALE 5 29 #endif 30 #ifndef PIMORONI_TRACKBALL_DEBOUNCE_CYCLES 31 # define PIMORONI_TRACKBALL_DEBOUNCE_CYCLES 20 32 #endif 33 #ifndef PIMORONI_TRACKBALL_ERROR_COUNT 34 # define PIMORONI_TRACKBALL_ERROR_COUNT 10 35 #endif 36 37 #ifndef PIMORONI_TRACKBALL_TIMEOUT 38 # define PIMORONI_TRACKBALL_TIMEOUT 100 39 #endif 40 41 #ifndef PIMORONI_TRACKBALL_DEBUG_INTERVAL 42 # define PIMORONI_TRACKBALL_DEBUG_INTERVAL 100 43 #endif 44 45 typedef struct { 46 uint8_t left; 47 uint8_t right; 48 uint8_t up; 49 uint8_t down; 50 uint8_t click; 51 } pimoroni_data_t; 52 53 extern const pointing_device_driver_t pimoroni_trackball_pointing_device_driver; 54 55 bool pimoroni_trackball_device_init(void); 56 void pimoroni_trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white); 57 int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_dir, uint8_t scale); 58 uint16_t pimoroni_trackball_get_cpi(void); 59 void pimoroni_trackball_set_cpi(uint16_t cpi); 60 i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data); 61 report_mouse_t pimoroni_trackball_get_report(report_mouse_t mouse_report);