summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2019-12-23 08:13:14 -0800
committerDavid Vazgenovich Shakaryan <dvshakaryan@gmail.com>2019-12-23 08:13:14 -0800
commited5a276f9b8a5da636e5cda4f3e33a54b0382bdf (patch)
tree7b4a58d29c1b0fd685803af23ef168787c4f3b73 /main.c
parent335b89cbd79d2623a68984f6d99e7480272a44e9 (diff)
downloadchristmas_lights-ed5a276f9b8a5da636e5cda4f3e33a54b0382bdf.tar.gz
christmas_lights-ed5a276f9b8a5da636e5cda4f3e33a54b0382bdf.tar.xz
minor adjustments and fixes
Diffstat (limited to 'main.c')
-rw-r--r--main.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/main.c b/main.c
index 06c585e..7f64e30 100644
--- a/main.c
+++ b/main.c
@@ -2,7 +2,6 @@
#include "eq.h"
#include "led.h"
-#include <avr/eeprom.h>
#include <avr/interrupt.h>
#include <stdbool.h>
#include <string.h>
@@ -59,6 +58,8 @@ void rainbow() {
void sound_reactive() {
memset(seq, 0, 3 * sizeof(seq[0]));
+ int offset = 0;
+
while (1) {
if (interrupted == true) {
interrupted = false;
@@ -69,18 +70,20 @@ void sound_reactive() {
seq[0].r = (eq_levels[0] > eq_levels[1]) ? eq_levels[0] : eq_levels[1];
unsigned char t = (eq_levels[2] > eq_levels[3]) ? eq_levels[2] : eq_levels[3];
- seq[1].g = (t > eq_levels[4]) ? t : eq_levels[4];
- seq[2].b = (eq_levels[5] > eq_levels[6]) ? eq_levels[5] : eq_levels[6];
-
- led_signal_sequence(LED_COUNT, seq, 3, 1, 0);
- for (int i = 0; i < 20; ++i) {
- eq_decay();
- }
+ t = (t > eq_levels[4]) ? t : eq_levels[4];
+ seq[1].r = t;
+ seq[1].g = t * 170 / 255;
+ seq[1].b = t * 65 / 255;
+ seq[2].g = (eq_levels[5] > eq_levels[6]) ? eq_levels[5] : eq_levels[6];
+
+ led_signal_sequence(LED_COUNT, seq, 3, 1, offset/60);
+ if (++offset == 180)
+ offset = 0;
+ eq_decay(10);
_delay_ms(50);
}
}
-
int main() {
DDRB |= (1 << LED_PIN);
PORTB &= ~(1 << LED_PIN);