pimoroni_trackball.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #include <stdint.h>
  19. #include "report.h"
  20. #include "i2c_master.h"
  21. #ifndef PIMORONI_TRACKBALL_ADDRESS
  22. # define PIMORONI_TRACKBALL_ADDRESS 0x0A
  23. #endif
  24. #ifndef PIMORONI_TRACKBALL_SCALE
  25. # define PIMORONI_TRACKBALL_SCALE 5
  26. #endif
  27. #ifndef PIMORONI_TRACKBALL_DEBOUNCE_CYCLES
  28. # define PIMORONI_TRACKBALL_DEBOUNCE_CYCLES 20
  29. #endif
  30. #ifndef PIMORONI_TRACKBALL_ERROR_COUNT
  31. # define PIMORONI_TRACKBALL_ERROR_COUNT 10
  32. #endif
  33. #ifndef PIMORONI_TRACKBALL_TIMEOUT
  34. # define PIMORONI_TRACKBALL_TIMEOUT 100
  35. #endif
  36. #ifndef PIMORONI_TRACKBALL_DEBUG_INTERVAL
  37. # define PIMORONI_TRACKBALL_DEBUG_INTERVAL 100
  38. #endif
  39. typedef struct {
  40. uint8_t left;
  41. uint8_t right;
  42. uint8_t up;
  43. uint8_t down;
  44. uint8_t click;
  45. } pimoroni_data_t;
  46. void pimoroni_trackball_device_init(void);
  47. void pimoroni_trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white);
  48. int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_dir, uint8_t scale);
  49. void pimoroni_trackball_adapt_values(int8_t* mouse, int16_t* offset);
  50. uint16_t pimoroni_trackball_get_cpi(void);
  51. void pimoroni_trackball_set_cpi(uint16_t cpi);
  52. i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data);