summaryrefslogtreecommitdiff
path: root/led.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2019-12-17 23:59:05 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2019-12-17 23:59:05 -0800
commit63966da14ab66bf711547f94e4d185f2027ad253 (patch)
treefddaf4558fb2ed23952768ad549f9dff36422e53 /led.c
parentc5047bb9952655dc8d0fabf6a54b9e278b243d8b (diff)
downloadchristmas_lights-63966da14ab66bf711547f94e4d185f2027ad253.tar.gz
christmas_lights-63966da14ab66bf711547f94e4d185f2027ad253.tar.xz
add sound-reactive mode and pattern-cycling interrupt
Diffstat (limited to 'led.c')
-rw-r--r--led.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/led.c b/led.c
index 5ea9923..8d53dea 100644
--- a/led.c
+++ b/led.c
@@ -3,7 +3,7 @@
#include <avr/io.h>
-void signal_bit_0() {
+static void signal_bit_0() {
asm volatile (
"sbi %0, %1\n\t"
"cbi %0, %1\n\t"
@@ -11,11 +11,11 @@ void signal_bit_0() {
"rjmp .+0\n\t"
"rjmp .+0\n\t"
:
- : "I" (_SFR_IO_ADDR(PORTB)), "I" (PIN_LED)
+ : "I" (_SFR_IO_ADDR(PORTB)), "I" (LED_PIN)
);
}
-void signal_bit_1() {
+static void signal_bit_1() {
asm volatile (
"sbi %0, %1\n\t"
"rjmp .+0\n\t"
@@ -24,11 +24,11 @@ void signal_bit_1() {
"rjmp .+0\n\t"
"nop\n\t"
:
- : "I" (_SFR_IO_ADDR(PORTB)), "I" (PIN_LED)
+ : "I" (_SFR_IO_ADDR(PORTB)), "I" (LED_PIN)
);
}
-void signal_byte(unsigned char byte) {
+static void signal_byte(unsigned char byte) {
for (unsigned char mask = 0x80; mask != 0; mask >>= 1) {
if (byte & mask)
signal_bit_1();
@@ -37,20 +37,20 @@ void signal_byte(unsigned char byte) {
}
}
-void signal_led(struct colour *c) {
+static void signal_led(struct colour *c) {
signal_byte(c->r);
signal_byte(c->g);
signal_byte(c->b);
}
-void signal_led_sequence(int num_leds, struct colour *seq, int num_seq, int width, int start) {
+void led_signal_sequence(int num_leds, struct colour *seq, int num_seq, int col_width, int seq_start) {
for(int i = 0; i < num_leds; ++i) {
- int j, p = i - start;
+ int j, p = i - seq_start;
if (p >= 0)
- j = (p / width % num_seq);
+ j = (p / col_width % num_seq);
else
- j = (num_seq - ((p + 1) / -width % num_seq) - 1);
+ j = (num_seq - ((p + 1) / -col_width % num_seq) - 1);
signal_led(&seq[j]);
}