Fix out of range refresh rate
This commit is contained in:
@@ -263,7 +263,7 @@
|
||||
|
||||
<div class="control-group">
|
||||
<label>Rate(Hz)</label>
|
||||
<input type="number" id="sampleRate" value="10000" min="1" max="83333">
|
||||
<input type="number" id="sampleRate" value="20000" min="20000" max="2000000">
|
||||
</div>
|
||||
|
||||
<div class="control-group" style="display: none;">
|
||||
@@ -279,10 +279,10 @@
|
||||
<div class="control-group">
|
||||
<label>Atten</label>
|
||||
<select id="atten">
|
||||
<option value="0">0dB</option>
|
||||
<option value="1">2.5dB</option>
|
||||
<option value="2">6dB</option>
|
||||
<option value="3" selected>11dB</option>
|
||||
<option value="0">0dB (0–1.0V)</option>
|
||||
<option value="1">2.5dB (0–1.34V)</option>
|
||||
<option value="2">6dB (0–2.0V)</option>
|
||||
<option value="3" selected>11dB (0–3.6V)</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
||||
19
main/main.c
19
main/main.c
@@ -40,8 +40,11 @@ static void start_webserver(void);
|
||||
#define ADC_ATTEN ADC_ATTEN_DB_11
|
||||
#define ADC_BIT_WIDTH ADC_BITWIDTH_12
|
||||
|
||||
#define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2
|
||||
#define ADC_GET_DATA(p_data) ((p_data)->type2.data)
|
||||
// TYPE2 is only available on newer chips (S3, C6, etc.). ESP32 (WROOM-32) requires TYPE1.
|
||||
// #define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE2
|
||||
// #define ADC_GET_DATA(p_data) ((p_data)->type2.data)
|
||||
#define ADC_OUTPUT_TYPE ADC_DIGI_OUTPUT_FORMAT_TYPE1
|
||||
#define ADC_GET_DATA(p_data) ((p_data)->type1.data)
|
||||
|
||||
/*
|
||||
* Web Server Configuration
|
||||
@@ -421,9 +424,15 @@ static esp_err_t params_handler(httpd_req_t* req) {
|
||||
cJSON* root = cJSON_Parse(buf);
|
||||
if (root) {
|
||||
cJSON* sample_rate = cJSON_GetObjectItem(root, "sample_rate");
|
||||
if (sample_rate && s_sample_rate != sample_rate->valueint) {
|
||||
s_reconfig_needed = true;
|
||||
s_sample_rate = sample_rate->valueint;
|
||||
if (sample_rate) {
|
||||
uint32_t requested = (uint32_t)sample_rate->valueint;
|
||||
// ESP32 ADC continuous mode valid range: 20kHz – 2MHz (SOC_ADC_SAMPLE_FREQ_THRES_LOW/HIGH)
|
||||
if (requested < 20000) requested = 20000;
|
||||
if (requested > 2000000) requested = 2000000;
|
||||
if (s_sample_rate != requested) {
|
||||
s_reconfig_needed = true;
|
||||
s_sample_rate = requested;
|
||||
}
|
||||
}
|
||||
cJSON* atten = cJSON_GetObjectItem(root, "atten");
|
||||
if (atten && s_atten != (adc_atten_t)atten->valueint) {
|
||||
|
||||
Reference in New Issue
Block a user