pimoroni_trackball.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_INTERVAL_MS
  25. # define PIMORONI_TRACKBALL_INTERVAL_MS 8
  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. #ifndef PIMORONI_TRACKBALL_TIMEOUT
  37. # define PIMORONI_TRACKBALL_TIMEOUT 100
  38. #endif
  39. #ifndef PIMORONI_TRACKBALL_DEBUG_INTERVAL
  40. # define PIMORONI_TRACKBALL_DEBUG_INTERVAL 100
  41. #endif
  42. typedef struct {
  43. uint8_t left;
  44. uint8_t right;
  45. uint8_t up;
  46. uint8_t down;
  47. uint8_t click;
  48. } pimoroni_data_t;
  49. void pimironi_trackball_device_init(void);
  50. void pimoroni_trackball_set_rgbw(uint8_t red, uint8_t green, uint8_t blue, uint8_t white);
  51. int16_t pimoroni_trackball_get_offsets(uint8_t negative_dir, uint8_t positive_dir, uint8_t scale);
  52. void pimoroni_trackball_adapt_values(int8_t* mouse, int16_t* offset);
  53. float pimoroni_trackball_get_precision(void);
  54. void pimoroni_trackball_set_precision(float precision);
  55. i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data);