|
@@ -310,32 +310,59 @@ static void pmw_motion_irq(void) {
|
310
|
310
|
}
|
311
|
311
|
}
|
312
|
312
|
|
|
313
|
+static void pmw_irq_start(void) {
|
|
314
|
+ gpio_set_irq_enabled(PMW_MOTION_PIN, GPIO_IRQ_LEVEL_LOW, true);
|
|
315
|
+}
|
|
316
|
+
|
|
317
|
+static void pmw_irq_stop(void) {
|
|
318
|
+ gpio_set_irq_enabled(PMW_MOTION_PIN, GPIO_IRQ_LEVEL_LOW, false);
|
|
319
|
+}
|
|
320
|
+
|
313
|
321
|
void pmw_set_sensitivity(uint8_t sens) {
|
314
|
322
|
if (sens > 0x77) {
|
315
|
323
|
debug("invalid sense, clamping (0x%X > 0x77)", sens);
|
316
|
324
|
sens = 0x77;
|
317
|
325
|
}
|
318
|
326
|
|
|
327
|
+ pmw_irq_stop();
|
|
328
|
+
|
319
|
329
|
pmw_write_register(REG_CONFIG1, sens);
|
320
|
330
|
pmw_write_register(REG_CONFIG5, sens);
|
|
331
|
+
|
|
332
|
+ pmw_irq_start();
|
321
|
333
|
}
|
322
|
334
|
|
323
|
335
|
uint8_t pmw_get_sensitivity(void) {
|
|
336
|
+ pmw_irq_stop();
|
|
337
|
+
|
324
|
338
|
uint8_t sense_y = pmw_read_register(REG_CONFIG1);
|
325
|
339
|
uint8_t sense_x = pmw_read_register(REG_CONFIG5);
|
326
|
340
|
if (sense_y != sense_x) {
|
327
|
341
|
debug("sensitivity differs for x (0x%02X) and y (0x%02X). resetting.", sense_x, sense_y);
|
328
|
342
|
pmw_write_register(REG_CONFIG5, sense_y);
|
329
|
343
|
}
|
|
344
|
+
|
|
345
|
+ pmw_irq_start();
|
330
|
346
|
return sense_y;
|
331
|
347
|
}
|
332
|
348
|
|
333
|
|
-static void pmw_irq_start(void) {
|
334
|
|
- gpio_set_irq_enabled(PMW_MOTION_PIN, GPIO_IRQ_LEVEL_LOW, true);
|
|
349
|
+void pmw_set_angle(int8_t angle) {
|
|
350
|
+ pmw_irq_stop();
|
|
351
|
+
|
|
352
|
+ uint8_t tmp = *((uint8_t *)(&angle));
|
|
353
|
+ pmw_write_register(REG_ANGLE_TUNE, tmp);
|
|
354
|
+
|
|
355
|
+ pmw_irq_start();
|
335
|
356
|
}
|
336
|
357
|
|
337
|
|
-static void pmw_irq_stop(void) {
|
338
|
|
- gpio_set_irq_enabled(PMW_MOTION_PIN, GPIO_IRQ_LEVEL_LOW, false);
|
|
358
|
+int8_t pmw_get_angle(void) {
|
|
359
|
+ pmw_irq_stop();
|
|
360
|
+
|
|
361
|
+ uint8_t tmp = pmw_read_register(REG_ANGLE_TUNE);
|
|
362
|
+ int8_t angle = *((int8_t *)(&tmp));
|
|
363
|
+
|
|
364
|
+ pmw_irq_start();
|
|
365
|
+ return angle;
|
339
|
366
|
}
|
340
|
367
|
|
341
|
368
|
static void pmw_irq_init(void) {
|
|
@@ -528,6 +555,8 @@ int pmw_init(void) {
|
528
|
555
|
// Set lift-detection threshold to 3mm (max)
|
529
|
556
|
pmw_write_register(REG_LIFT_CONFIG, 0x03);
|
530
|
557
|
|
|
558
|
+ pmw_set_angle(DEFAULT_MOUSE_ANGLE);
|
|
559
|
+
|
531
|
560
|
pmw_irq_init();
|
532
|
561
|
|
533
|
562
|
return 0;
|