Merge pull request #549 from hubmartin/pinmap
Put all duplicated GPIO pin definitions to a single file
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "BatteryController.h"
|
||||
#include "drivers/PinMap.h"
|
||||
#include <hal/nrf_gpio.h>
|
||||
#include <nrfx_saadc.h>
|
||||
#include <algorithm>
|
||||
@@ -9,12 +10,12 @@ Battery* Battery::instance = nullptr;
|
||||
|
||||
Battery::Battery() {
|
||||
instance = this;
|
||||
nrf_gpio_cfg_input(chargingPin, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
|
||||
nrf_gpio_cfg_input(PinMap::Charging, static_cast<nrf_gpio_pin_pull_t> GPIO_PIN_CNF_PULL_Disabled);
|
||||
}
|
||||
|
||||
void Battery::Update() {
|
||||
isCharging = !nrf_gpio_pin_read(chargingPin);
|
||||
isPowerPresent = !nrf_gpio_pin_read(powerPresentPin);
|
||||
isCharging = !nrf_gpio_pin_read(PinMap::Charging);
|
||||
isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
|
||||
|
||||
if (isReading) {
|
||||
return;
|
||||
|
@@ -33,8 +33,6 @@ namespace Pinetime {
|
||||
static Battery* instance;
|
||||
nrf_saadc_value_t saadc_value;
|
||||
|
||||
static constexpr uint32_t chargingPin = 12;
|
||||
static constexpr uint32_t powerPresentPin = 19;
|
||||
static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7;
|
||||
uint16_t voltage = 0;
|
||||
uint8_t percentRemaining = 0;
|
||||
|
@@ -1,13 +1,13 @@
|
||||
#include "BrightnessController.h"
|
||||
#include <hal/nrf_gpio.h>
|
||||
#include "displayapp/screens/Symbols.h"
|
||||
|
||||
#include "drivers/PinMap.h"
|
||||
using namespace Pinetime::Controllers;
|
||||
|
||||
void BrightnessController::Init() {
|
||||
nrf_gpio_cfg_output(pinLcdBacklight1);
|
||||
nrf_gpio_cfg_output(pinLcdBacklight2);
|
||||
nrf_gpio_cfg_output(pinLcdBacklight3);
|
||||
nrf_gpio_cfg_output(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_cfg_output(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_cfg_output(PinMap::LcdBacklightHigh);
|
||||
Set(level);
|
||||
}
|
||||
|
||||
@@ -16,24 +16,24 @@ void BrightnessController::Set(BrightnessController::Levels level) {
|
||||
switch (level) {
|
||||
default:
|
||||
case Levels::High:
|
||||
nrf_gpio_pin_clear(pinLcdBacklight1);
|
||||
nrf_gpio_pin_clear(pinLcdBacklight2);
|
||||
nrf_gpio_pin_clear(pinLcdBacklight3);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightHigh);
|
||||
break;
|
||||
case Levels::Medium:
|
||||
nrf_gpio_pin_clear(pinLcdBacklight1);
|
||||
nrf_gpio_pin_clear(pinLcdBacklight2);
|
||||
nrf_gpio_pin_set(pinLcdBacklight3);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
break;
|
||||
case Levels::Low:
|
||||
nrf_gpio_pin_clear(pinLcdBacklight1);
|
||||
nrf_gpio_pin_set(pinLcdBacklight2);
|
||||
nrf_gpio_pin_set(pinLcdBacklight3);
|
||||
nrf_gpio_pin_clear(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
break;
|
||||
case Levels::Off:
|
||||
nrf_gpio_pin_set(pinLcdBacklight1);
|
||||
nrf_gpio_pin_set(pinLcdBacklight2);
|
||||
nrf_gpio_pin_set(pinLcdBacklight3);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightLow);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightMedium);
|
||||
nrf_gpio_pin_set(PinMap::LcdBacklightHigh);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -22,9 +22,6 @@ namespace Pinetime {
|
||||
const char* ToString();
|
||||
|
||||
private:
|
||||
static constexpr uint8_t pinLcdBacklight1 = 14;
|
||||
static constexpr uint8_t pinLcdBacklight2 = 22;
|
||||
static constexpr uint8_t pinLcdBacklight3 = 23;
|
||||
Levels level = Levels::High;
|
||||
Levels backupLevel = Levels::High;
|
||||
};
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include <hal/nrf_gpio.h>
|
||||
#include "systemtask/SystemTask.h"
|
||||
#include "app_timer.h"
|
||||
#include "drivers/PinMap.h"
|
||||
|
||||
APP_TIMER_DEF(shortVibTimer);
|
||||
APP_TIMER_DEF(longVibTimer);
|
||||
@@ -12,8 +13,8 @@ MotorController::MotorController(Controllers::Settings& settingsController) : se
|
||||
}
|
||||
|
||||
void MotorController::Init() {
|
||||
nrf_gpio_cfg_output(pinMotor);
|
||||
nrf_gpio_pin_set(pinMotor);
|
||||
nrf_gpio_cfg_output(PinMap::Motor);
|
||||
nrf_gpio_pin_set(PinMap::Motor);
|
||||
app_timer_init();
|
||||
|
||||
app_timer_create(&shortVibTimer, APP_TIMER_MODE_SINGLE_SHOT, StopMotor);
|
||||
@@ -30,7 +31,7 @@ void MotorController::RunForDuration(uint8_t motorDuration) {
|
||||
return;
|
||||
}
|
||||
|
||||
nrf_gpio_pin_clear(pinMotor);
|
||||
nrf_gpio_pin_clear(PinMap::Motor);
|
||||
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
|
||||
}
|
||||
|
||||
@@ -44,9 +45,9 @@ void MotorController::StartRinging() {
|
||||
|
||||
void MotorController::StopRinging() {
|
||||
app_timer_stop(longVibTimer);
|
||||
nrf_gpio_pin_set(pinMotor);
|
||||
nrf_gpio_pin_set(PinMap::Motor);
|
||||
}
|
||||
|
||||
void MotorController::StopMotor(void* p_context) {
|
||||
nrf_gpio_pin_set(pinMotor);
|
||||
nrf_gpio_pin_set(PinMap::Motor);
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@
|
||||
|
||||
namespace Pinetime {
|
||||
namespace Controllers {
|
||||
static constexpr uint8_t pinMotor = 16;
|
||||
|
||||
class MotorController {
|
||||
public:
|
||||
|
Reference in New Issue
Block a user