Wierd... worked on this for hours...
Now got errors at end of compile:
c:/users/matt/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\matt\AppData\Local\Temp\arduino_build_999641/bf2.ino.elf section `.dram0.bss' will not fit in region `dram0_0_seg'
c:/users/matt/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: DRAM segment data does not fit.
c:/users/matt/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/1.22.0-80-g6c4433a-5.2.0/bin/../lib/gcc/xtensa-esp32-elf/5.2.0/../../../../xtensa-esp32-elf/bin/ld.exe: region `dram0_0_seg' overflowed by 206824 bytes
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compiling for board NodeMCU-32S.
Here is code... i'm a bit drwosty so it may be confusing
#include "esp32-hal-ledc.h"
//Define array slots by name
#define IO_ 1
#define I__ 2
#define IOT 3
#define IP -1
#define X 0
#define IN 1
#define OUT 2
int pinNo = 1;
int waveA = 2;
int waveB = 3;
int ir = 4;
int r = 5;
int g = 6;
int b = 7;
int uv = 8;
int vibrate = 9;
int len = 10;
int repeatNo = 11;
int repeatDur = 12;
int profile = 0;
int stp = 1;
int msInto = 2;
int startMS = 3;
int event = 0;
int down = 0;
int up = 1;
int maxModes = 16;
#define maxProfiles 16
#define dataSize 1024
int bfPlaying[8][maxProfiles] = { 0 };
long unsigned bfstartMS[maxProfiles] = { 0 };
int bfprofile[2][dataSize] = { 0 }; // SIMPLE event-> profiles array profile then event#
int bfNew[16] = { 0 }; //This stores the changed bf stuff
int bfData[16][4096] = { 0 }; //where the tones and flash patterns are stored
// 0 1 2 3 4 5 6 7 8 9 10 11 12
// "profile# PinNo WaveA WaveB IR R G B UV Vibrate len repeatNo repeatDur
String bfNames[4096] = { "reserved" };
int arr16[16];
int arr1024[1024];
//**** PIN MAP ******************************************
int analogPins[16] = { 1, 3, 13, 16, 17, 18, 19, 21 }; //8 chans for now...
int pinNos32[40] = {
1, 3, 13, 14, 16, 17, 18, 19, 21, 22, 23,
25, 26, 27, 32, 33, 34, 35, 36, 39
};
int pinCapabilities[40] = {
IO_, IO_, IOT, IO_, IOT, IOT, IOT, IOT, IO_, IO_, IO_,
IO_, IO_, IO_, IO_, IO_, I__, I__, I__, I__
};
int installed[40] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
};//IP, X, IN, OUT
//**********************************
//fx prototypes
int bfEvent(int);
int bf(int);
int bfChange(int);
int arrayChangeFind(int, int, int, int);
int arrayFind(int, int, int);
void setup() {
ledCstuff();
}
int ledCstuff() {
for (int i = 0; i <= 8; i++) {
ledcAttachPin(analogPins[i], i);
ledcSetup(i, 12000, 8); // 12 kHz PWM, 8-bit resolution
}
}
void loop() {
bf(0);
}
int bfEvent(int event) {
//a new event
int events[dataSize];
//put all profiles into playprofiles[]
int playprofiles[maxProfiles] = { 0 };
//2 to 1 dimensional array convert
for (int row = 0; row < maxProfiles; row++)
{
arr16[row] = bfprofile[profile][row];
}
for (int n; n <= dataSize; n++) {
for (int row = 0; row < dataSize; row++)
{
arr1024[row] = bfprofile[event][row];
}
//count matching profiles
int profileCount = std::count(arr1024, arr1024 + dataSize, event);
//locate profiles for this event
int profiles[maxProfiles];
for (int n; n <= profileCount; n++) {
int x = arrayFind(event, dataSize, n);
//get profile #s... stored in profiles[]
if (x < 0) {
//none found
return -1;
}
int profile = bfprofile[profile][x]; //GOT profile #
//find open playing slot
...[TRUNCATED]...
}
int arrayFind(int value, int sz, int match = 0) {
int i;
int matched = 0;
for (i = 0; i < sz; i++) {
if (sz == 16) {
if (arr16[i] == value) {
matched++;
if (matched == match) {
return i;
}
}
}
if (sz == 1024) {
if (arr1024[i] == value) {
matched++;
if (matched == match) {
return i;
}
}
}
}
}
int arrayChangeFind(int sz = 16, int startAt = 0, int thresh = 0, int dirc = down) {
//returns i of changed array value
int intFind;
if (sz == 16) {
intFind = arr16[startAt];
if (dirc == down) {
for (int i = startAt; i <= sz; i++) {
if (abs(intFind - arr16[i]) > thresh - 0.0001) {
return i;
}
}
} else {
for (int i = sz; i <= startAt; i--) {
if (abs(intFind - arr16[i]) > thresh - 0.0001) {
return i;
}
}
}
return -1;
}
if (sz == 1024) {
intFind = arr16[startAt];
if (dirc == down) {
for (int i = startAt; i <= sz; i++) {
if (abs(intFind - arr1024[i]) > thresh - 0.0001) {
return i;
}
}
} else {
for (int i = sz; i <= startAt; i--) {
if (abs(intFind - arr1024[i]) > thresh - 0.0001) {
return i;
}
}
}
return -1;
}
}