@@ -210,7 +210,7 @@ class CodepointSender
210
210
{
211
211
// Start sending keys if it's not running yet
212
212
if (m_send_timer.alarm_id == 0 ) {
213
- add_repeating_timer_ms (5 , key_send_callback, this , &m_send_timer);
213
+ add_repeating_timer_ms (1 , key_send_callback, this , &m_send_timer);
214
214
update ();
215
215
}
216
216
}
@@ -273,6 +273,10 @@ int main()
273
273
usb_init ();
274
274
stdio_usb_init ();
275
275
276
+ // Run USB polling from an interrupt as the main loop slows down when rendering
277
+ static struct repeating_timer usb_timer;
278
+ add_repeating_timer_ms (5 , background_usb_poll, NULL , &usb_timer);
279
+
276
280
printf (" \n\n Device has reset\n " );
277
281
278
282
// GPIOs 0-11 as inputs with pull-up
@@ -332,16 +336,8 @@ int main()
332
336
// Scroll so 0,0 in memory is actually rendered in the top-left corner
333
337
st7789_vertical_scroll (300 );
334
338
335
- // Start the application
336
- // Temporarily polls usb from an interrupt as app.load() blocks for a while
337
- {
338
- struct repeating_timer timer;
339
- add_repeating_timer_ms (5 , background_usb_poll, NULL , &timer);
340
-
341
- app.load (" fonts" );
342
-
343
- cancel_repeating_timer (&timer);
344
- }
339
+ // Start the application (blocking until loaded)
340
+ app.load (" fonts" );
345
341
346
342
// Turn on data input LEDs (inverted as this drives a P-channel mosfet)
347
343
{
@@ -366,8 +362,6 @@ int main()
366
362
UserInput send_switch (PIN_SWITCH_SEND);
367
363
368
364
while (true ) {
369
- usb_poll ();
370
-
371
365
if (needs_render) {
372
366
needs_render = false ;
373
367
0 commit comments