#define DOTPERWAVE 8
uint16_t volt[DOTPERWAVE];
void setup() {
Serial.begin(115200);
volt[0] = 400;
volt[1] = 300;
volt[2] = 200;
volt[3] = 100;
volt[4] = 200;
volt[5] = 300;
volt[6] = 400;
volt[7] = 500;
for (int i = 0; i < DOTPERWAVE; i++ ) Serial.print(volt[i]);
Serial.println();
int idxZC0 = 5;
if (idxZC0 > 0) { // on fait la manoeuvre seulement si c'est necessaire
size_t Q = idxZC0 * sizeof(volt[0]); // taille pour la quantité d'élément debut de tableau jusque l'index ZC
int *buftmp = (int *)malloc(Q); // prend de l'espace mémoire, juste le necéssaire
if (buftmp != NULL) { // on a obtenu l'espace mémoire qui servira pour les déplacements
memcpy(buftmp, &volt[0], Q); // save copy du début du tableau
memmove(&volt[0], &volt[idxZC0], (DOTPERWAVE - idxZC0) * sizeof(volt[0])); // glisse le contenu du tableau après idxZC vers le début
memcpy(&volt[DOTPERWAVE - idxZC0], buftmp, Q); // replace ce qu'on a sauvé au bon endroit
free(buftmp); // libere la RAM
} // si pas de mémoire, tant pis
}
for (int i = 0; i < DOTPERWAVE; i++ ) Serial.print(volt[i]);
Serial.println();
}
void loop() {
delay(10); // this speeds up the simulation
}