Sin descripción
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.

pmw3360.h 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * pmw3360.h
  3. *
  4. * Copyright (c) 2022 - 2023 Thomas Buck (thomas@xythobuz.de)
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * See <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __PMW3360_H__
  19. #define __PMW3360_H__
  20. #include <sys/types.h>
  21. struct pmw_motion {
  22. bool motion;
  23. int32_t delta_x;
  24. int32_t delta_y;
  25. };
  26. int pmw_init(void);
  27. void pmw_run(void);
  28. bool pmw_is_alive(void);
  29. struct pmw_motion pmw_get(void);
  30. /*
  31. * 0x00: 100 cpi (minimum cpi)
  32. * 0x01: 200 cpi
  33. * 0x02: 300 cpi
  34. * ...
  35. * 0x31: 5000 cpi (default cpi)
  36. * ...
  37. * 0x77: 12000 cpi (maximum cpi)
  38. */
  39. void pmw_set_sensitivity(uint8_t sens);
  40. uint8_t pmw_get_sensitivity(void);
  41. #define PMW_SENSE_TO_CPI(sense) (100 + (sense * 100))
  42. #define PMW_CPI_TO_SENSE(cpi) ((cpi / 100) - 1)
  43. void pmw_set_angle(int8_t angle);
  44. int8_t pmw_get_angle(void);
  45. void pmw_print_status(char *buff, size_t len);
  46. void pmw_dump_data(bool serial);
  47. ssize_t pmw_frame_capture(uint8_t *buff, size_t buffsize);
  48. #define PMW_FRAME_CAPTURE_LEN 1296
  49. #endif // __PMW3360_H__