summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eq.c15
-rw-r--r--led.c15
-rw-r--r--main.c15
3 files changed, 30 insertions, 15 deletions
diff --git a/eq.c b/eq.c
index 846e1fa..a67274e 100644
--- a/eq.c
+++ b/eq.c
@@ -8,20 +8,23 @@ unsigned char eq_levels[7];
static const unsigned char thresholds[][2] = { EQ_THRESHOLDS };
-static void reset() {
+static void reset()
+{
PORTB |= (1 << EQ_PIN_RESET);
PORTB &= ~(1 << EQ_PIN_RESET);
_delay_us(36);
}
-static void strobe() {
+static void strobe()
+{
PORTB |= (1 << EQ_PIN_STROBE);
_delay_us(36);
PORTB &= ~(1 << EQ_PIN_STROBE);
_delay_us(36);
}
-static unsigned char map_level(unsigned char val, unsigned char min, unsigned char max) {
+static unsigned char map_level(unsigned char val, unsigned char min, unsigned char max)
+{
if (val <= min)
return 0;
else if (val >= max)
@@ -30,7 +33,8 @@ static unsigned char map_level(unsigned char val, unsigned char min, unsigned ch
return (val - min) * 255 / (max - min);
}
-void eq_read() {
+void eq_read()
+{
reset();
for (int i = 0; i < 7; ++i) {
@@ -42,7 +46,8 @@ void eq_read() {
}
}
-void eq_decay(int cycles) {
+void eq_decay(int cycles)
+{
for (int i = 0; i < cycles; ++i) {
reset();
diff --git a/led.c b/led.c
index 8d53dea..72ff250 100644
--- a/led.c
+++ b/led.c
@@ -3,7 +3,8 @@
#include <avr/io.h>
-static void signal_bit_0() {
+static void signal_bit_0()
+{
asm volatile (
"sbi %0, %1\n\t"
"cbi %0, %1\n\t"
@@ -15,7 +16,8 @@ static void signal_bit_0() {
);
}
-static void signal_bit_1() {
+static void signal_bit_1()
+{
asm volatile (
"sbi %0, %1\n\t"
"rjmp .+0\n\t"
@@ -28,7 +30,8 @@ static void signal_bit_1() {
);
}
-static 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,13 +40,15 @@ static void signal_byte(unsigned char byte) {
}
}
-static 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 led_signal_sequence(int num_leds, struct colour *seq, int num_seq, int col_width, int seq_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 - seq_start;
diff --git a/main.c b/main.c
index e7ed542..f96a707 100644
--- a/main.c
+++ b/main.c
@@ -10,7 +10,8 @@
static struct colour seq[6];
static bool interrupted = false;
-void red_green() {
+void red_green()
+{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmemset-elt-size"
memset(seq, 0, 2 * sizeof(seq[0]));
@@ -32,7 +33,8 @@ void red_green() {
}
}
-void rainbow() {
+void rainbow()
+{
memset(seq, 0, 6 * sizeof(seq[0]));
seq[0].r = 255;
@@ -58,7 +60,8 @@ void rainbow() {
}
}
-void sound_reactive() {
+void sound_reactive()
+{
memset(seq, 0, 3 * sizeof(seq[0]));
int offset = 0;
@@ -87,7 +90,8 @@ void sound_reactive() {
}
}
-int main() {
+int main()
+{
DDRB |= (1 << LED_PIN);
PORTB &= ~(1 << LED_PIN);
@@ -114,7 +118,8 @@ int main() {
return 0;
}
-ISR(PCINT0_vect) {
+ISR(PCINT0_vect)
+{
if (!(PINB & (1 << ISR_PIN)))
interrupted = true;
}