extern "C" int main() { pinMode(LED_BUILTIN, OUTPUT); leds.begin(); // Announce firmware version serial_begin(BAUD2DIV(115200)); serial_print("Fadecandy v" DEVICE_VER_STRING "\r\n"); // Application main loop while (usb_dfu_state == DFU_appIDLE) { watchdog_refresh(); buffers.handleUSB(); updateDrawBuffer(calculateInterpCoefficient()); leds.show(); // Optionally disable dithering by clearing our residual buffer every frame. if (buffers.flags & CFLAG_NO_DITHERING) { for (unsigned i = 0; i < CHANNELS_TOTAL; ++i) residual[i] = 0; } } // Reboot into DFU bootloader dfu_reboot(); }
extern "C" int main() { pinMode(LED_BUILTIN, OUTPUT); leds.begin(); // Announce firmware version serial_begin(BAUD2DIV(115200)); serial_print("Fadecandy v" DEVICE_VER_STRING "\r\n"); // Application main loop while (usb_dfu_state == DFU_appIDLE) { watchdog_refresh(); buffers.handleUSB(); // Select a different drawing loop based on our firmware config flags switch (buffers.flags & (CFLAG_NO_INTERPOLATION | CFLAG_NO_DITHERING)) { case 0: default: updateDrawBuffer_I1_D1(calculateInterpCoefficient()); break; case CFLAG_NO_INTERPOLATION: updateDrawBuffer_I0_D1(0x10000); break; case CFLAG_NO_DITHERING: updateDrawBuffer_I1_D0(calculateInterpCoefficient()); break; case CFLAG_NO_INTERPOLATION | CFLAG_NO_DITHERING: updateDrawBuffer_I0_D0(0x10000); break; } // Start sending the next frame over DMA leds.show(); // Performance counter, for monitoring frame rate externally perf_frameCounter++; } // Reboot into DFU bootloader dfu_reboot(); }
extern "C" int usb_rx_handler(usb_packet_t *packet) { // USB packet interrupt handler. Invoked by the ISR dispatch code in usb_dev.c return buffers.handleUSB(packet); }