logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

paw3204.h (2438B)


  1. /* Copyright 2021 Gompa (@Gompa)
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #pragma once
  17. #include <stdint.h>
  18. #include <stdbool.h>
  19. #include "pointing_device.h"
  20. #ifndef PAW3204_SCLK_PIN
  21. # ifdef POINTING_DEVICE_SCLK_PIN
  22. # define PAW3204_SCLK_PIN POINTING_DEVICE_SCLK_PIN
  23. # else
  24. # error "No clock pin defined -- missing POINTING_DEVICE_SCLK_PIN or PAW3204_SCLK_PIN"
  25. # endif
  26. #endif
  27. #ifndef PAW3204_SDIO_PIN
  28. # ifdef POINTING_DEVICE_SDIO_PIN
  29. # define PAW3204_SDIO_PIN POINTING_DEVICE_SDIO_PIN
  30. # else
  31. # error "No data pin defined -- missing POINTING_DEVICE_SDIO_PIN or PAW3204_SDIO_PIN"
  32. # endif
  33. #endif
  34. typedef struct {
  35. int16_t x;
  36. int16_t y;
  37. bool isMotion;
  38. } report_paw3204_t;
  39. const pointing_device_driver_t paw3204_pointing_device_driver;
  40. /**
  41. * @brief Initializes the sensor so it is in a working state and ready to
  42. * be polled for data.
  43. *
  44. * @return true Initialization was a success
  45. * @return false Initialization failed, do not proceed operation
  46. */
  47. void paw3204_init(void);
  48. /**
  49. * @brief Reads and clears the current delta, and motion register values on the
  50. * given sensor.
  51. *
  52. * @return pmw33xx_report_t Current values of the sensor, if errors occurred all
  53. * fields are set to zero
  54. */
  55. report_paw3204_t paw3204_read(void);
  56. /**
  57. * @brief Sets the given CPI value the sensor. CPI is often refereed to
  58. * as the sensors sensitivity. Values outside of the allowed range are
  59. * constrained into legal values.
  60. *
  61. * @param cpi CPI value to set
  62. */
  63. void paw3204_set_cpi(uint16_t cpi);
  64. /**
  65. * @brief Gets the currently set CPI value from the sensor. CPI is often
  66. * refereed to as the sensors sensitivity.
  67. *
  68. * @return uint16_t Current CPI value of the sensor
  69. */
  70. uint16_t paw3204_get_cpi(void);
  71. report_mouse_t paw3204_get_report(report_mouse_t mouse_report);