From b3d1dc83755ecd935324603e546439dba2640a8b Mon Sep 17 00:00:00 2001 From: Jason Coon Date: Sat, 12 Mar 2016 08:35:21 -0600 Subject: [PATCH] Removed MSGEQ7 audio code, doesn't work well yet on the EPS8266. --- AudioLogic.h | 51 ----------------------------------- esp8266-fastled-webserver.ino | 28 ------------------- 2 files changed, 79 deletions(-) delete mode 100644 AudioLogic.h diff --git a/AudioLogic.h b/AudioLogic.h deleted file mode 100644 index f2f9a6e..0000000 --- a/AudioLogic.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * ESP8266 + FastLED + IR Remote + MSGEQ7: https://github.com/jasoncoon/esp8266-fastled-webserver - * Copyright (C) 2015 Jason Coon - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#define MSGEQ7_STROBE_PIN 4 -#define MSGEQ7_RESET_PIN 14 -#define MSGEQ7_OUT_PIN A0 - -const uint8_t bandCount = 7; - -uint8_t levels[bandCount]; -uint8_t filter = 200; - -void initializeAudio() { - pinMode(MSGEQ7_OUT_PIN, INPUT); - pinMode(MSGEQ7_RESET_PIN, OUTPUT); - pinMode(MSGEQ7_STROBE_PIN, OUTPUT); - digitalWrite(MSGEQ7_RESET_PIN, LOW); - digitalWrite(MSGEQ7_STROBE_PIN, HIGH); -} - -void readAudio() { - digitalWrite(MSGEQ7_RESET_PIN, HIGH); - digitalWrite(MSGEQ7_RESET_PIN, LOW); - - int level; - - for (uint8_t band = 0; band < bandCount; band++) { - digitalWrite(MSGEQ7_STROBE_PIN, LOW); - delayMicroseconds(30); - - uint16_t level = analogRead(MSGEQ7_OUT_PIN); - levels[band] = map(level, filter, 1023, 0, 255); - digitalWrite(MSGEQ7_STROBE_PIN, HIGH); - } -} - diff --git a/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver.ino index 71f174f..cb4c14d 100644 --- a/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver.ino @@ -28,7 +28,6 @@ extern "C" { #include #include #include -#include "AudioLogic.h" #include "GradientPalettes.h" #define RECV_PIN 12 @@ -44,7 +43,6 @@ const char WiFiAPPSK[] = ""; // Wi-Fi network to connect to (if not in AP mode) const char* ssid = ""; const char* password = ""; -const char* host = "esp8266"; ESP8266WebServer server(80); @@ -84,7 +82,6 @@ PatternAndNameList patterns = { { sinelon, "Sinelon" }, { juggle, "Juggle" }, { bpm, "BPM" }, - { audio, "Audio" }, { showSolidColor, "Solid Color" }, }; @@ -139,8 +136,6 @@ void setup(void) { irReceiver.enableIRIn(); // Start the receiver - initializeAudio(); - Serial.println(); Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); Serial.print( F("Boot Vers: ") ); Serial.println(system_get_boot_version()); @@ -301,10 +296,6 @@ void loop(void) { return; } - EVERY_N_MILLISECONDS(30) { - readAudio(); - } - // EVERY_N_SECONDS(10) { // Serial.print( F("Heap: ") ); Serial.println(system_get_free_heap_size()); // } @@ -889,22 +880,3 @@ void palettetest() fill_palette( leds, NUM_LEDS, startindex, (256 / NUM_LEDS) + 1, gCurrentPalette, 255, LINEARBLEND); } -void audio() { - fill_solid(leds, NUM_LEDS, CRGB::Black); - - uint32_t total = 0; - - for (uint8_t i = 0; i < bandCount; i++) - { - total += levels[i]; - } - - uint16_t level = total / bandCount; // 0 - 256 - - uint8_t scaled = level / 10; - - for(uint8_t i = 0; i < scaled && i < NUM_LEDS; i++) { - leds[i] = CHSV(level, 255, 255); - } -} -