guardano in giro sono arrivato ad un altro progetto dove veniva cambiata la modalità del display , ho provato a implementare questo codice non ottenendo ne errori ne cambio di visualizzazione .
PS : anche se questo non ha il peak classico con un tempo di ritorno .
const int buttonPin = 8; // the number of the pushbutton pin
int MY_ARRAY[]={0, 128, 192, 224, 240, 248, 252, 254, 255}; // default = standard pattern
int MY_MODE_1[]={0, 128, 192, 224, 240, 248, 252, 254, 255}; // standard pattern
int MY_MODE_2[]={0, 128, 64, 32, 16, 8, 4, 2, 1}; // only peak pattern
int MY_MODE_3[]={0, 128, 192, 160, 144, 136, 132, 130, 129}; // only peak + bottom point
int MY_MODE_4[]={0, 128, 192, 160, 208, 232, 244, 250, 253}; // one gap in the top , 3rd light onwards
int MY_MODE_5[]={0, 1, 3, 7, 15, 31, 63, 127, 255}; // standard pattern, mirrored vertically
int displaycolumn , displayvalue;
int displaymode = 3;
void displayModeChange() {
int reading = digitalRead(buttonPin);
if (reading == HIGH && previousState == LOW && millis() - lastDebounceTime > debounceDelay) // works only when pressed
{
switch (displaymode) {
case 1: // move from mode 1 to 2
displaymode = 2;
for (int i=0 ; i<=8 ; i++ ) {
MY_ARRAY[i]=MY_MODE_2[i];
}
break;
case 2: // move from mode 2 to 3
displaymode = 3;
for (int i=0 ; i<=8 ; i++ ) {
MY_ARRAY[i]=MY_MODE_3[i];
}
break;
case 3: // move from mode 3 to 4
displaymode = 4;
for (int i=0 ; i<=8 ; i++ ) {
MY_ARRAY[i]=MY_MODE_4[i];
}
break;
case 4: // move from mode 4 to 5
displaymode = 5;
for (int i=0 ; i<=8 ; i++ ) {
MY_ARRAY[i]=MY_MODE_5[i];
}
break;
case 5: // move from mode 5 to 1
displaymode = 1;
for (int i=0 ; i<=8 ; i++ ) {
MY_ARRAY[i]=MY_MODE_1[i];
}
break;
}
lastDebounceTime = millis();
}
previousState = reading;
}
e nel SendToDisplay questo
void SendToDisplay() {
for (int i = 0; i < xres; i++) {
if (EQ_ON)
data_avgs[i] = data_avgs[i] * (float)(eq[i]) / 100; // apply eq filter
data_avgs[i] = constrain(data_avgs[i], 0, 80); // set max & min values for buckets to 0-80
data_avgs[i] = map(data_avgs[i], 0, 80, 0, yres); // remap averaged values to yres 0-8
yvalue = data_avgs[i];
peaks[i] = peaks[i] - 1; // decay by one light
if (yvalue > peaks[i]) peaks[i] = yvalue; // save peak if > previuos peak
yvalue = peaks[i]; // pick peak to display
displayvalue=MY_ARRAY[yvalue];
displaycolumn=32-i;
setColumn(displaycolumn, displayvalue); // for left to right
}
pixel.show(); // show column
displayModeChange (); // check if button pressed to change display mode
}
comunque il codice completo e questo
up please help me
Prova_Ampiamento_Analizzatore.ino (14.7 KB)