From 26f1bf2f1e4bc95844e3434042cd9d1e031a1d92 Mon Sep 17 00:00:00 2001 From: cfif Date: Thu, 4 Dec 2025 10:51:44 +0300 Subject: [PATCH] Init --- APP/src/ADC_Temp_KST45-14-2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/APP/src/ADC_Temp_KST45-14-2.c b/APP/src/ADC_Temp_KST45-14-2.c index 64a757a..eb79a56 100644 --- a/APP/src/ADC_Temp_KST45-14-2.c +++ b/APP/src/ADC_Temp_KST45-14-2.c @@ -204,7 +204,7 @@ static adc_temp_lookup fast_lookup[TABLE_SIZE_LOOKUP]; // Таблица на TA void init_fast_lookup_table(eAlg use_alg) { // Создаем таблицу для быстрого преобразования АЦП->температура for (uint16_t i = 0; i < TABLE_SIZE_LOOKUP; i++) { - uint16_t adc = i * (uint8_t)roundf(4095.0f / (TABLE_SIZE_LOOKUP - 1)); // Для 12-битного АЦП (0-4095) + uint16_t adc = i * (uint8_t)roundf(ADC_MAX / (TABLE_SIZE_LOOKUP - 1)); // Для 12-битного АЦП (0-4095) float temp = get_temperature_from_adc_KST45(adc, use_alg); fast_lookup[i].adc_value = adc; fast_lookup[i].temp_c = (int16_t) (temp * 10.0f); // Храним с точностью 0.1°C @@ -213,7 +213,7 @@ void init_fast_lookup_table(eAlg use_alg) { int16_t get_temperature_fast_KST45(uint16_t adc_value) { // Простой поиск в таблице с линейной интерполяцией - uint16_t index = adc_value / (uint8_t)roundf(4095.0f / (TABLE_SIZE_LOOKUP - 1)); // Делим на 16 для TABLE_SIZE_LOOKUP = 256 + uint16_t index = adc_value / (uint8_t)roundf(ADC_MAX / (TABLE_SIZE_LOOKUP - 1)); // Делим на 16 для TABLE_SIZE_LOOKUP = 256 if (index >= (TABLE_SIZE_LOOKUP - 1)) return fast_lookup[TABLE_SIZE_LOOKUP - 1].temp_c; uint16_t adc1 = fast_lookup[index].adc_value;