"dune/tectonic/spatial-solving/fixedpointiterator.cc" did not exist on "174bdf7e512ba074b45e588bec7c52635f17e337"
Newer
Older
// Copyright (c) Charles Lohr
// All rights reserved
#include <mdk.h>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// On the ESP32C3 dev boards, the WS2812 LED is connected to GPIO 8
static int ws_2812_pin = 8;
// Simple hue function for generation of smooth rainbow.
static uint8_t hueval(int value) {
value = value % 1536;
if (value < 256) {
return (uint8_t) value;
} else if (value < 768) {
return 255;
} else if (value < 1024) {
return (uint8_t) (1023 - value);
} else {
return 0;
}
}
static void blink(int count, unsigned long delay_millis) {
uint8_t green[3] = {1, 0, 0}, black[3] = {0, 0, 0};
for (int i = 0; i < count; i++) {
ws2812_show(ws_2812_pin, green, sizeof(green));
delay_ms(delay_millis);
ws2812_show(ws_2812_pin, black, sizeof(black));
delay_ms(delay_millis);
}
}
static void rainbow(int count) {
for (int i = 0; i < count; i++) {
uint8_t val = hueval(i);
val = (uint8_t) (val/100);
uint8_t rgb[3] = {0, val, val};
ws2812_show(ws_2812_pin, rgb, sizeof(rgb));
delay_ms(1);
}
}
int main(void) {
wdt_disable();
gpio_output(ws_2812_pin);
init_uart();
config_uart();
uint8_t cycle = 0;
for (;;) {
printf("Cycle %d\n", cycle++);
blink(2, 200);
rainbow(2500);
}
return 0;
}