From 3efc86edf4fd8365b74f6a4b61fc244f2999c87d Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 15 Jun 2023 13:04:14 +0200 Subject: [PATCH] current conversion --- main/configuration.h | 1 + main/gatt_svcs.c | 2 +- main/power_profiler.c | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/main/configuration.h b/main/configuration.h index fda306f..9b1b2b1 100644 --- a/main/configuration.h +++ b/main/configuration.h @@ -5,4 +5,5 @@ typedef struct { uint32_t refresh_delay; uint32_t* offsets; + int range; } configuration; diff --git a/main/gatt_svcs.c b/main/gatt_svcs.c index f0a4398..077c25d 100644 --- a/main/gatt_svcs.c +++ b/main/gatt_svcs.c @@ -13,7 +13,7 @@ static struct char_pres_format current_char_pres_format = { .format = FORMAT_UINT32, - .exponent = -3, + .exponent = -6, .unit = AMPERE_UNIT_UUID, .namespc = 1, .descrH = NSP_DESC_MAIN & 0xff, diff --git a/main/power_profiler.c b/main/power_profiler.c index fda8978..27cf643 100644 --- a/main/power_profiler.c +++ b/main/power_profiler.c @@ -125,6 +125,7 @@ void app_main(void){ configuration main_conf = { .refresh_delay = 1000, .offsets = offsets, + .range = R100, }; uint32_t meas_volts[INPUTS_NUM]; @@ -157,6 +158,7 @@ void app_main(void){ ESP_ERROR_CHECK(adc_cali_raw_to_voltage(adc_conv_h[i], val, &mv)); ESP_LOGI(TAG, "IN %d : %d mV (%lu / %lu)", i, mv, meas_res_buff[i], meas_nb_buff[i]); meas_volts[i] = mv; + meas_amp[i] = mv * 1000000 / ranges[main_conf.range].resistance; } notify_update(&meas);