diff options
| author | JF <jf@codingfield.com> | 2020-11-10 19:32:36 (GMT) |
|---|---|---|
| committer | JF <jf@codingfield.com> | 2020-11-10 19:32:36 (GMT) |
| commit | 04abc91f157f5925ffa404728291a69893acf8cf (patch) | |
| tree | 5c887c6d22ba8d901022ebae395a7b6c165d9dc0 /src/Components/Battery/BatteryController.cpp | |
| parent | 65ecb65b57bd55582c1aa1a5babd4d76df89e621 (diff) | |
| parent | f0e1f98823e41bfc2d9743fa8de70c882f26f93b (diff) | |
Merge branch 'develop' into master
Diffstat (limited to 'src/Components/Battery/BatteryController.cpp')
| -rw-r--r-- | src/Components/Battery/BatteryController.cpp | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/Components/Battery/BatteryController.cpp b/src/Components/Battery/BatteryController.cpp deleted file mode 100644 index 198ce5a..0000000 --- a/src/Components/Battery/BatteryController.cpp +++ /dev/null @@ -1,45 +0,0 @@ -#include <drivers/include/nrfx_saadc.h> -#include <hal/nrf_gpio.h> -#include <libraries/log/nrf_log.h> -#include "BatteryController.h" - -using namespace Pinetime::Controllers; - -void Battery::Init() { - nrf_gpio_cfg_input(chargingPin, (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pullup); - nrf_gpio_cfg_input(powerPresentPin, (nrf_gpio_pin_pull_t)GPIO_PIN_CNF_PULL_Pullup); - - nrfx_saadc_config_t adcConfig = NRFX_SAADC_DEFAULT_CONFIG; - nrfx_saadc_init(&adcConfig, SaadcEventHandler); - nrf_saadc_channel_config_t adcChannelConfig = { - .resistor_p = NRF_SAADC_RESISTOR_DISABLED, - .resistor_n = NRF_SAADC_RESISTOR_DISABLED, - .gain = NRF_SAADC_GAIN1_5, - .reference = NRF_SAADC_REFERENCE_INTERNAL, - .acq_time = NRF_SAADC_ACQTIME_3US, - .mode = NRF_SAADC_MODE_SINGLE_ENDED, - .burst = NRF_SAADC_BURST_DISABLED, - .pin_p = batteryVoltageAdcInput, - .pin_n = NRF_SAADC_INPUT_DISABLED - }; - nrfx_saadc_channel_init(0, &adcChannelConfig); -} - -void Battery::Update() { - isCharging = !nrf_gpio_pin_read(chargingPin); - isPowerPresent = !nrf_gpio_pin_read(powerPresentPin); - - nrf_saadc_value_t value = 0; - nrfx_saadc_sample_convert(0, &value); - - // see https://forum.pine64.org/showthread.php?tid=8147 - voltage = (value * 2.0f) / (1024/3.0f); - percentRemaining = ((voltage - 3.55)*100)*3.9; - -// NRF_LOG_INFO("BATTERY " NRF_LOG_FLOAT_MARKER " %% - " NRF_LOG_FLOAT_MARKER " v", NRF_LOG_FLOAT(percentRemaining), NRF_LOG_FLOAT(voltage)); -// NRF_LOG_INFO("POWER Charging : %d - Power : %d", isCharging, isPowerPresent); -} - -void Battery::SaadcEventHandler(nrfx_saadc_evt_t const * event) { - -}
\ No newline at end of file |
