@@ -261,7 +261,7 @@ void initialiseHardware(void)
261261 Serial_CreateStream (NULL );
262262
263263 // Output some debug header information to the serial console
264- puts_P (PSTR (ESC_FG_YELLOW "SmallyMouse2 - Serial debug console\r\n" ESC_FG_WHITE ));
264+ puts_P (PSTR (ESC_FG_YELLOW "SmallyMouse2 V1.3 - Serial debug console\r\n" ESC_FG_WHITE ));
265265 puts_P (PSTR (ESC_FG_YELLOW "(c)2017-2020 Simon Inns\r\n" ESC_FG_WHITE ));
266266 puts_P (PSTR (ESC_FG_YELLOW "http://www.waitingforfriday.com\r\n" ESC_FG_WHITE ));
267267
@@ -375,18 +375,20 @@ void processMouse(void)
375375 //
376376 // X and Y have a range of -127 to +127
377377
378- // If the mouse movement changes direction then disregard any remaining
379- // movement units in the previous direction.
378+ // If the mouse movement changes X direction then disregard any remaining movement
380379 if (MouseReport .X > 0 && mouseDirectionX == 0 ) {
381380 mouseDistanceX = 0 ;
382381 mouseDirectionX = 1 ;
383382 } else if (MouseReport .X < 0 && mouseDirectionX == 1 ) {
384383 mouseDistanceX = 0 ;
385384 mouseDirectionX = 0 ;
386- } else if (MouseReport .Y > 0 && mouseDirectionY == 0 ) {
385+ }
386+
387+ // If the mouse movement changes Y direction then disregard any remaining movement
388+ if (MouseReport .Y > 0 && mouseDirectionY == 0 ) {
387389 mouseDistanceY = 0 ;
388390 mouseDirectionY = 1 ;
389- } else if (MouseReport .Y < 0 && mouseDirectionY == 1 ) {
391+ } else if (MouseReport .Y < 0 && mouseDirectionY == 1 ) {
390392 mouseDistanceY = 0 ;
391393 mouseDirectionY = 0 ;
392394 }
@@ -516,8 +518,9 @@ uint8_t processMouseMovement(int8_t movementUnits, uint8_t axis, bool limitRate,
516518 // timerTopValue = timerTopValue / 64;
517519 // timerTopValue = timerTopValue - 1;
518520
519- timerTopValue = ((10000 / timerTopValue ) / 64 ) - 1 ;
520-
521+ if (timerTopValue > 0 ) timerTopValue = ((10000 / timerTopValue ) / 64 ) - 1 ;
522+ else timerTopValue = 0 ; // Avoid divide by zero
523+
521524 // If the 'Slow' configuration jumper is shorted; apply the quadrature rate limit
522525 if (limitRate ) {
523526 // Rate limit is on
0 commit comments