#define BASEDECIMAL 10
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
float moyPWx = 123.5;
char bufMoyPW[20] = {0};
sprintf(bufMoyPW, "%.3f", moyPWx); // retourne toujours 3 chiffres apres la virgule, 0 si necessaire ...
char *ptr = strchr(bufMoyPW, '.'); // on aura toujours un point avec la ligne avant
Serial.printf("%.3f -> '%s'\n", moyPWx, bufMoyPW);
memmove(ptr, ptr + 1, strlen(ptr)); // supprime le point de la chaine texte
Serial.printf("%.4f -> '%s'\n", moyPWx, bufMoyPW);
int fx1000 = 31415;
char decim[5] = {0};
snprintf(decim, 4, "%d000", int(fx1000 - 1000*(fx1000/1000)));
decim[3] = 0;
Serial.printf("%d.%s",fx1000/1000,decim);
float PmaxReseau = 36000.0f;
char Value[] = "12345";
Serial.println(strtoul(Value, NULL, BASEDECIMAL));
Serial.println(uint32_t(PmaxReseau));
uint32_t _SINSTS = 99;
Serial.println(_SINSTS);
_SINSTS = constrain(strtoul(Value, NULL, BASEDECIMAL), 0UL, uint32_t(PmaxReseau));
Serial.println(_SINSTS);
}
void loop() {
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
}