Update xsns_02_analog.ino

This commit is contained in:
Theo Arends 2024-07-26 11:02:27 +02:00
parent 9af25c73d6
commit 4cf741e6eb

View File

@ -163,7 +163,6 @@ struct {
} Adcs; } Adcs;
struct { struct {
// float mq_samples[ANALOG_MQ_SAMPLES];
float *mq_samples; float *mq_samples;
float temperature = 0; float temperature = 0;
float current = 0; float current = 0;
@ -263,11 +262,10 @@ void AdcAttach(uint32_t pin, uint8_t type) {
Adc[Adcs.present].pin = pin; Adc[Adcs.present].pin = pin;
if (adcAttachPin(Adc[Adcs.present].pin)) { if (adcAttachPin(Adc[Adcs.present].pin)) {
if (ADC_MQ == type) { if (ADC_MQ == type) {
Adc[Adcs.present].mq_samples = (float*)calloc(sizeof(float), ANALOG_MQ_SAMPLES); // Need calloc to reset registers to 0/false Adc[Adcs.present].mq_samples = (float*)calloc(sizeof(float), ANALOG_MQ_SAMPLES); // Need calloc to reset registers to 0
if (nullptr == Adc[Adcs.present].mq_samples) { return; } if (nullptr == Adc[Adcs.present].mq_samples) { return; }
} }
Adc[Adcs.present].type = type; Adc[Adcs.present].type = type;
// analogSetPinAttenuation(Adc[Adcs.present].pin, ADC_11db); // Default
Adcs.present++; Adcs.present++;
} }
} }