Removed MSGEQ7 audio code, doesn't work well yet on the EPS8266.
This commit is contained in:
parent
58f56a1e1d
commit
b3d1dc8375
51
AudioLogic.h
51
AudioLogic.h
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ extern "C" {
|
||||
#include <FS.h>
|
||||
#include <EEPROM.h>
|
||||
#include <IRremoteESP8266.h>
|
||||
#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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user