Skip to content

Commit a739a0b

Browse files
committed
take the USB initialization out of the constructor, to allow a wait before enumerating
1 parent 6e722be commit a739a0b

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
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

0 commit comments

Comments
 (0)