Skip to content

Commit d0d037b

Browse files
author
Erik Tylek Kettenburg
committed
Merge pull request digistump#7 from jorgerivera/master
Separate the USB init process from the object initialization
2 parents 98d4f0e + dbf841f commit d0d037b

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

libraries/DigisparkMouse/DigiMouse.h

+8-15
Original file line numberDiff line numberDiff line change
@@ -145,25 +145,18 @@ void clearMove() {
145145
class DigiMouseDevice {
146146
public:
147147
DigiMouseDevice () {
148-
// this timer stuff doesn't even make sense - it seems like someone got some code for Timer1
149-
// and haphazardly changed the 1's in the register names to 0's, but the two timers don't work
150-
// the same way, so this code doesn't do what it says at all. Is it even useful to have?
151-
/* configure timer 0 for a rate of 16M5/(1024 * 256) = 62.94 Hz (~16ms) */
152-
//TCCR0A = 5; /* timer 0 prescaler: 1024 */
153-
154-
155-
156-
//TIMSK &= !(1<TOIE0);//interrupt off
157-
cli();
158-
usbDeviceDisconnect();
159-
_delay_ms(250);
160-
usbDeviceConnect();
161-
148+
162149
rt_usbHidReportDescriptor = mouse_usbHidReportDescriptor;
163150
rt_usbHidReportDescriptorSize = sizeof(mouse_usbHidReportDescriptor);
164151
rt_usbDeviceDescriptor = usbDescrDevice;
165152
rt_usbDeviceDescriptorSize = sizeof(usbDescrDevice);
166-
153+
}
154+
155+
void init() {
156+
cli();
157+
usbDeviceDisconnect();
158+
_delay_ms(200);
159+
usbDeviceConnect();
167160

168161
usbInit();
169162

libraries/DigisparkMouse/examples/Mouse/Mouse.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "DigiMouse.h"
66

77
void setup() {
8-
// Do nothing? It seems as if the USB hardware is ready to go on reset
8+
DigiMouse.init(); // call init to enumerate
99
}
1010

1111
void loop() {

0 commit comments

Comments
 (0)