-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Fix rak11310 Voltage Read #6618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,6 +295,22 @@ class AnalogBatteryLevel : public HasBatteryLevel | |
raw = raw / BATTERY_SENSE_SAMPLES; | ||
scaled = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / pow(2, BATTERY_SENSE_RESOLUTION_BITS)) * raw; | ||
#endif | ||
#if defined(RAK11310) | ||
float voltage_raw = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / 1023) * raw; | ||
|
||
LOG_INFO("[POWER DEBUG] AREF=%.2fV, ADC_RAW=%u, ADC_MULT=%.2f", | ||
(double)AREF_VOLTAGE, | ||
raw, | ||
(double)operativeAdcMultiplier); | ||
|
||
scaled = (voltage_raw * 1.22f) - 0.1f; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 1.22f seems to be a correction factor. can we make this a generic correction macro and remove the #ifdef bracket? In case we need it on more than the 11310 |
||
scaled = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / 4096) * raw; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you are computing scaled twice here. either the latter is in here by mistake or you can drop the former one. |
||
LOG_INFO("[POWER CORRECTION] Before=%.2fmV, After=%.2fmV", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please drop the [POWER CORRECTION] - Log lines will be auto-prefixed with the thread name. |
||
(double)voltage_raw, | ||
(double)scaled); | ||
#else | ||
scaled = operativeAdcMultiplier * ((1000 * AREF_VOLTAGE) / 1023) * raw; | ||
#endif | ||
adcDisable(); | ||
|
||
if (!initial_read_done) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't log an info called 'DEBUG' :-)