summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/main.c b/main.c
index 313bb7c..c87fa93 100644
--- a/main.c
+++ b/main.c
@@ -19,6 +19,9 @@
#include "math.h"
#include "color.h"
+extern void usb_serial_poll(void);
+extern void usb_serial_init(void);
+
static struct hsvf g_color_s = {0.0f, 0.0f, 0.0f};
struct hsvf *g_color = &g_color_s;
volatile uint64_t g_time_ms = 0;
@@ -44,6 +47,9 @@ uint32_t pcg32_random_r() {
}
int main(void){
+ /* This also sets the clocks */
+ usb_serial_init();
+
/* We're starting out from HSI@8MHz */
SystemCoreClockUpdate();
SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */
@@ -89,18 +95,19 @@ int main(void){
uint64_t ts = g_time_ms;
uint64_t led_ts = 0;
for (;;) {
- g_color->h = fmodf(g_color->h + 0.0005, 1.0f);
- //g_color->h = 0.0;
- g_color->s = 0.8;
- g_color->v = 1.0;
-
- struct rgbf rgb;
- hsv_to_rgb(g_color, &rgb);
- update_timers(&rgb);
+ if (check_interval(&ts, 5)) {
+ g_color->h = fmodf(g_color->h + 0.0005, 1.0f);
+ //g_color->h = 0.0;
+ g_color->s = 0.8;
+ g_color->v = 1.0;
- ts = wait_until(ts + 5);
+ struct rgbf rgb;
+ hsv_to_rgb(g_color, &rgb);
+ update_timers(&rgb);
+ }
blink_led(&led_ts, 100, 200, GPIOC, 13);
+ usb_serial_poll();
}
}