[Core] Split support for pointing devices. (#15304)

* Draft implementation

* formatting

* fix combined buttons

* remove pimoroni throttle

* sync pointing on a throttle loop with checksum

* no longer used

* doh

Co-authored-by: Drashna Jaelre <drashna@live.com>

* switch pimoroni to a cpi equivalent

* add cpi support

* allow user modification of seperate mouse reports

* a little tidy up

* add *_RIGHT defines.

* docs

* doxygen comments

* basic changelog

* clean up pimoroni

* small doc fixes

* Update docs/feature_pointing_device.md

Co-authored-by: Drashna Jaelre <drashna@live.com>

* performance tweak if side has usb

* Don't run init funtions on wrong side

* renamed some variables for consistency

* fix pimoroni typos

* Clamp instead of OR

* Promote combined values to uint16_t

* Update pointing_device.c

Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
This commit is contained in:
Dasky 2021-12-27 01:05:51 +00:00 committed by GitHub
parent 76a673233c
commit 7f7364c559
Failed to generate hash of commit
11 changed files with 625 additions and 65 deletions

View file

@ -33,8 +33,24 @@
static uint16_t precision = 128;
float pimoroni_trackball_get_precision(void) { return ((float)precision / 128); }
void pimoroni_trackball_set_precision(float floatprecision) { precision = (floatprecision * 128); }
uint16_t pimoroni_trackball_get_cpi(void) { return (precision * 125); }
/**
* @brief Sets the scaling value for pimoroni trackball
*
* Sets a scaling value for pimoroni trackball to allow runtime adjustment. This isn't used by the sensor and is an
* approximation so the functions are consistent across drivers.
*
* NOTE: This rounds down to the nearest number divisable by 125 that's a positive integer, values below 125 are clamped to 125.
*
* @param cpi uint16_t
*/
void pimoroni_trackball_set_cpi(uint16_t cpi) {
if (cpi < 249) {
precision = 1;
} else {
precision = (cpi - (cpi % 125)) / 125;
}
}
void pimoroni_trackball_set_rgbw(uint8_t r, uint8_t g, uint8_t b, uint8_t w) {
uint8_t data[4] = {r, g, b, w};
@ -60,7 +76,7 @@ i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data) {
return status;
}
__attribute__((weak)) void pimironi_trackball_device_init(void) {
__attribute__((weak)) void pimoroni_trackball_device_init(void) {
i2c_init();
pimoroni_trackball_set_rgbw(0x00, 0x00, 0x00, 0x00);
}