diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/bluetooth/bluefruit_le.cpp | 8 | ||||
-rw-r--r-- | drivers/bluetooth/bluefruit_le.h | 2 | ||||
-rw-r--r-- | drivers/haptic/solenoid.c | 5 | ||||
-rw-r--r-- | drivers/sensors/cirque_pinnacle.c | 8 | ||||
-rw-r--r-- | drivers/sensors/cirque_pinnacle.h | 1 | ||||
-rw-r--r-- | drivers/sensors/cirque_pinnacle_i2c.c | 10 | ||||
-rw-r--r-- | drivers/sensors/cirque_pinnacle_spi.c | 10 | ||||
-rw-r--r-- | drivers/sensors/pimoroni_trackball.c | 21 | ||||
-rw-r--r-- | drivers/sensors/pmw33xx_common.c | 19 |
9 files changed, 28 insertions, 56 deletions
diff --git a/drivers/bluetooth/bluefruit_le.cpp b/drivers/bluetooth/bluefruit_le.cpp index 19310767cf..50170b83fe 100644 --- a/drivers/bluetooth/bluefruit_le.cpp +++ b/drivers/bluetooth/bluefruit_le.cpp @@ -79,9 +79,7 @@ struct sdep_msg { enum queue_type { QTKeyReport, // 1-byte modifier + 6-byte key report QTConsumer, // 16-bit key code -#ifdef MOUSE_ENABLE QTMouseMove, // 4-byte mouse report -#endif }; struct queue_item { @@ -442,7 +440,7 @@ bool bluefruit_le_enable_keyboard(void) { // Disable command echo static const char kEcho[] PROGMEM = "ATE=0"; // Make the advertised name match the keyboard - static const char kGapDevName[] PROGMEM = "AT+GAPDEVNAME=" STR(PRODUCT); + static const char kGapDevName[] PROGMEM = "AT+GAPDEVNAME=" PRODUCT; // Turn on keyboard support static const char kHidEnOn[] PROGMEM = "AT+BLEHIDEN=1"; @@ -581,10 +579,12 @@ static bool process_queue_item(struct queue_item *item, uint16_t timeout) { snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->key.modifier, item->key.keys[0], item->key.keys[1], item->key.keys[2], item->key.keys[3], item->key.keys[4], item->key.keys[5]); return at_command(cmdbuf, NULL, 0, true, timeout); +#ifdef EXTRAKEY_ENABLE case QTConsumer: strcpy_P(fmtbuf, PSTR("AT+BLEHIDCONTROLKEY=0x%04x")); snprintf(cmdbuf, sizeof(cmdbuf), fmtbuf, item->consumer); return at_command(cmdbuf, NULL, 0, true, timeout); +#endif #ifdef MOUSE_ENABLE case QTMouseMove: @@ -658,7 +658,6 @@ void bluefruit_le_send_consumer_key(uint16_t usage) { } } -#ifdef MOUSE_ENABLE void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons) { struct queue_item item; @@ -673,7 +672,6 @@ void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, send_buf_send_one(); } } -#endif uint32_t bluefruit_le_read_battery_voltage(void) { return state.vbat; diff --git a/drivers/bluetooth/bluefruit_le.h b/drivers/bluetooth/bluefruit_le.h index de301c6167..731ba2e370 100644 --- a/drivers/bluetooth/bluefruit_le.h +++ b/drivers/bluetooth/bluefruit_le.h @@ -40,12 +40,10 @@ extern void bluefruit_le_send_keys(uint8_t hid_modifier_mask, uint8_t *keys, uin * (milliseconds) */ extern void bluefruit_le_send_consumer_key(uint16_t usage); -#ifdef MOUSE_ENABLE /* Send a mouse/wheel movement report. * The parameters are signed and indicate positive or negative direction * change. */ extern void bluefruit_le_send_mouse_move(int8_t x, int8_t y, int8_t scroll, int8_t pan, uint8_t buttons); -#endif /* Compute battery voltage by reading an analog pin. * Returns the integer number of millivolts */ diff --git a/drivers/haptic/solenoid.c b/drivers/haptic/solenoid.c index 637a77da3d..4e43903255 100644 --- a/drivers/haptic/solenoid.c +++ b/drivers/haptic/solenoid.c @@ -20,11 +20,12 @@ #include "haptic.h" #include "gpio.h" #include "usb_device_state.h" +#include "util.h" #include <stdlib.h> uint8_t solenoid_dwell = SOLENOID_DEFAULT_DWELL; static pin_t solenoid_pads[] = SOLENOID_PINS; -#define NUMBER_OF_SOLENOIDS (sizeof(solenoid_pads) / sizeof(pin_t)) +#define NUMBER_OF_SOLENOIDS ARRAY_SIZE(solenoid_pads) bool solenoid_on[NUMBER_OF_SOLENOIDS] = {false}; bool solenoid_buzzing[NUMBER_OF_SOLENOIDS] = {false}; uint16_t solenoid_start[NUMBER_OF_SOLENOIDS] = {0}; @@ -147,7 +148,7 @@ void solenoid_check(void) { void solenoid_setup(void) { #ifdef SOLENOID_PINS_ACTIVE_STATE bool state_temp[] = SOLENOID_PINS_ACTIVE_STATE; - uint8_t bound_check = (sizeof(state_temp) / sizeof(bool)); + uint8_t bound_check = ARRAY_SIZE(state_temp); #endif for (uint8_t i = 0; i < NUMBER_OF_SOLENOIDS; i++) { diff --git a/drivers/sensors/cirque_pinnacle.c b/drivers/sensors/cirque_pinnacle.c index 8bd4eb736e..4aed5fe67a 100644 --- a/drivers/sensors/cirque_pinnacle.c +++ b/drivers/sensors/cirque_pinnacle.c @@ -4,8 +4,6 @@ // refer to documentation: Gen2 and Gen3 (Pinnacle ASIC) at https://www.cirque.com/documentation #include "cirque_pinnacle.h" -#include "print.h" -#include "debug.h" #include "wait.h" #include "timer.h" @@ -27,12 +25,6 @@ void cirque_pinnacle_enable_feed(bool feedEnable); void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count); void RAP_Write(uint8_t address, uint8_t data); -#ifdef CONSOLE_ENABLE -void print_byte(uint8_t byte) { - xprintf("%c%c%c%c%c%c%c%c|", (byte & 0x80 ? '1' : '0'), (byte & 0x40 ? '1' : '0'), (byte & 0x20 ? '1' : '0'), (byte & 0x10 ? '1' : '0'), (byte & 0x08 ? '1' : '0'), (byte & 0x04 ? '1' : '0'), (byte & 0x02 ? '1' : '0'), (byte & 0x01 ? '1' : '0')); -} -#endif - #if CIRQUE_PINNACLE_POSITION_MODE /* Logical Scaling Functions */ // Clips raw coordinates to "reachable" window of sensor diff --git a/drivers/sensors/cirque_pinnacle.h b/drivers/sensors/cirque_pinnacle.h index fa06e047f2..8717b32991 100644 --- a/drivers/sensors/cirque_pinnacle.h +++ b/drivers/sensors/cirque_pinnacle.h @@ -5,6 +5,7 @@ #include "cirque_pinnacle_regdefs.h" #include <stdint.h> #include <stdbool.h> +#include "pointing_device_internal.h" #ifndef CIRQUE_PINNACLE_TIMEOUT # define CIRQUE_PINNACLE_TIMEOUT 20 // I2C timeout in milliseconds diff --git a/drivers/sensors/cirque_pinnacle_i2c.c b/drivers/sensors/cirque_pinnacle_i2c.c index b328dd9a7a..3c11e5f079 100644 --- a/drivers/sensors/cirque_pinnacle_i2c.c +++ b/drivers/sensors/cirque_pinnacle_i2c.c @@ -1,8 +1,6 @@ // Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license #include "cirque_pinnacle.h" #include "i2c_master.h" -#include "print.h" -#include "debug.h" #include "stdio.h" // Masks for Cirque Register Access Protocol (RAP) @@ -18,9 +16,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { if (touchpad_init) { i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, NULL, 0, CIRQUE_PINNACLE_TIMEOUT); if (i2c_readReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, data, count, CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { -#ifdef CONSOLE_ENABLE - dprintf("error cirque_pinnacle i2c_readReg\n"); -#endif + pd_dprintf("error cirque_pinnacle i2c_readReg\n"); touchpad_init = false; } i2c_stop(); @@ -33,9 +29,7 @@ void RAP_Write(uint8_t address, uint8_t data) { if (touchpad_init) { if (i2c_writeReg(CIRQUE_PINNACLE_ADDR << 1, cmdByte, &data, sizeof(data), CIRQUE_PINNACLE_TIMEOUT) != I2C_STATUS_SUCCESS) { -#ifdef CONSOLE_ENABLE - dprintf("error cirque_pinnacle i2c_writeReg\n"); -#endif + pd_dprintf("error cirque_pinnacle i2c_writeReg\n"); touchpad_init = false; } i2c_stop(); diff --git a/drivers/sensors/cirque_pinnacle_spi.c b/drivers/sensors/cirque_pinnacle_spi.c index bd980fc863..5cb39aebb0 100644 --- a/drivers/sensors/cirque_pinnacle_spi.c +++ b/drivers/sensors/cirque_pinnacle_spi.c @@ -1,8 +1,6 @@ // Copyright (c) 2018 Cirque Corp. Restrictions apply. See: www.cirque.com/sw-license #include "cirque_pinnacle.h" #include "spi_master.h" -#include "print.h" -#include "debug.h" // Masks for Cirque Register Access Protocol (RAP) #define WRITE_MASK 0x80 @@ -24,9 +22,7 @@ void RAP_ReadBytes(uint8_t address, uint8_t* data, uint8_t count) { data[i] = spi_write(FILLER_BYTE); // write filler, receive data on the third filler send } } else { -#ifdef CONSOLE_ENABLE - dprintf("error cirque_pinnacle spi_start read\n"); -#endif + pd_dprintf("error cirque_pinnacle spi_start read\n"); touchpad_init = false; } spi_stop(); @@ -42,9 +38,7 @@ void RAP_Write(uint8_t address, uint8_t data) { spi_write(cmdByte); spi_write(data); } else { -#ifdef CONSOLE_ENABLE - dprintf("error cirque_pinnacle spi_start write\n"); -#endif + pd_dprintf("error cirque_pinnacle spi_start write\n"); touchpad_init = false; } spi_stop(); diff --git a/drivers/sensors/pimoroni_trackball.c b/drivers/sensors/pimoroni_trackball.c index 88a351316b..326e59744f 100644 --- a/drivers/sensors/pimoroni_trackball.c +++ b/drivers/sensors/pimoroni_trackball.c @@ -14,10 +14,10 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ + +#include "pointing_device_internal.h" #include "pimoroni_trackball.h" #include "i2c_master.h" -#include "print.h" -#include "debug.h" #include "timer.h" // clang-format off @@ -58,20 +58,17 @@ 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}; __attribute__((unused)) i2c_status_t status = i2c_writeReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LED_RED, data, sizeof(data), PIMORONI_TRACKBALL_TIMEOUT); -#ifdef CONSOLE_ENABLE - if (debug_mouse) dprintf("Trackball RGBW i2c_status_t: %d\n", status); -#endif + pd_dprintf("Trackball RGBW i2c_status_t: %d\n", status); } i2c_status_t read_pimoroni_trackball(pimoroni_data_t* data) { i2c_status_t status = i2c_readReg(PIMORONI_TRACKBALL_ADDRESS << 1, PIMORONI_TRACKBALL_REG_LEFT, (uint8_t*)data, sizeof(*data), PIMORONI_TRACKBALL_TIMEOUT); -#ifdef CONSOLE_ENABLE - if (debug_mouse) { - static uint16_t d_timer; - if (timer_elapsed(d_timer) > PIMORONI_TRACKBALL_DEBUG_INTERVAL) { - dprintf("Trackball READ i2c_status_t: %d L: %d R: %d Up: %d D: %d SW: %d\n", status, data->left, data->right, data->up, data->down, data->click); - d_timer = timer_read(); - } + +#ifdef POINTING_DEVICE_DEBUG + static uint16_t d_timer; + if (timer_elapsed(d_timer) > PIMORONI_TRACKBALL_DEBUG_INTERVAL) { + pd_dprintf("Trackball READ i2c_status_t: %d L: %d R: %d Up: %d D: %d SW: %d\n", status, data->left, data->right, data->up, data->down, data->click); + d_timer = timer_read(); } #endif diff --git a/drivers/sensors/pmw33xx_common.c b/drivers/sensors/pmw33xx_common.c index 13164cb150..b8d4e532ca 100644 --- a/drivers/sensors/pmw33xx_common.c +++ b/drivers/sensors/pmw33xx_common.c @@ -7,9 +7,8 @@ // Copyright 2020 Ploopy Corporation // SPDX-License-Identifier: GPL-2.0-or-later -#include "debug.h" +#include "pointing_device_internal.h" #include "pmw33xx_common.h" -#include "print.h" #include "string.h" #include "wait.h" #include "spi_master.h" @@ -18,10 +17,10 @@ extern const uint8_t pmw33xx_firmware_data[PMW33XX_FIRMWARE_LENGTH] PROGMEM; extern const uint8_t pmw33xx_firmware_signature[3] PROGMEM; -static const pin_t cs_pins[] = PMW33XX_CS_PINS; -static bool in_burst[sizeof(cs_pins) / sizeof(pin_t)] = {0}; +static const pin_t cs_pins[] = PMW33XX_CS_PINS; +static bool in_burst[ARRAY_SIZE(cs_pins)] = {0}; -const size_t pmw33xx_number_of_sensors = sizeof(cs_pins) / sizeof(pin_t); +const size_t pmw33xx_number_of_sensors = ARRAY_SIZE(cs_pins); bool __attribute__((cold)) pmw33xx_upload_firmware(uint8_t sensor); bool __attribute__((cold)) pmw33xx_check_signature(uint8_t sensor); @@ -154,7 +153,7 @@ bool pmw33xx_init(uint8_t sensor) { pmw33xx_read(sensor, REG_Delta_Y_H); if (!pmw33xx_upload_firmware(sensor)) { - dprintf("PMW33XX (%d): firmware upload failed!\n", sensor); + pd_dprintf("PMW33XX (%d): firmware upload failed!\n", sensor); return false; } @@ -170,7 +169,7 @@ bool pmw33xx_init(uint8_t sensor) { pmw33xx_write(sensor, REG_Lift_Config, PMW33XX_LIFTOFF_DISTANCE); if (!pmw33xx_check_signature(sensor)) { - dprintf("PMW33XX (%d): firmware signature verification failed!\n", sensor); + pd_dprintf("PMW33XX (%d): firmware signature verification failed!\n", sensor); return false; } @@ -185,7 +184,7 @@ pmw33xx_report_t pmw33xx_read_burst(uint8_t sensor) { } if (!in_burst[sensor]) { - dprintf("PMW33XX (%d): burst\n", sensor); + pd_dprintf("PMW33XX (%d): burst\n", sensor); if (!pmw33xx_write(sensor, REG_Motion_Burst, 0x00)) { return report; } @@ -208,9 +207,7 @@ pmw33xx_report_t pmw33xx_read_burst(uint8_t sensor) { spi_stop(); - if (debug_config.mouse) { - dprintf("PMW33XX (%d): motion: 0x%x dx: %i dy: %i\n", sensor, report.motion.w, report.delta_x, report.delta_y); - } + pd_dprintf("PMW33XX (%d): motion: 0x%x dx: %i dy: %i\n", sensor, report.motion.w, report.delta_x, report.delta_y); report.delta_x *= -1; report.delta_y *= -1; |