void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
int tabPulseSinusTotal[101];
int tabPulseSinusOn[101];
float vrai =0.0f;
float erreur = 0.0f;
float target = 0.0f;
for (int32_t I = 0; I < 101; I++) {
tabPulseSinusTotal[I] = -1;
tabPulseSinusOn[I] = -1;
target = float(I) / 100.0;
for (int32_t T = 20; T < 101; T++) {
for (int32_t N = 0; N <= T; N++) {
if (T % 2 == 1 || N % 2 == 0) { // Valeurs impaires du total ou pulses pairs pour éviter courant continu
vrai = float(N) / float(T);
erreur = abs(vrai - target);
if (erreur < 0.004) {
tabPulseSinusTotal[I] = T;
tabPulseSinusOn[I] = N;
N = 101;
T = 101;
}
}
}
}
}
for (int32_t I = 0; I < 101; I++) {
Serial.printf("%d;%d;%d;%d\n",I, tabPulseSinusOn[I], tabPulseSinusTotal[I], tabPulseSinusTotal[I] - tabPulseSinusOn[I]);
}
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}