From cea915733e6284dce66085bafb706a1f15739296 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 May 2022 21:02:52 +0200 Subject: [PATCH 1/3] Bootloader: Ignore __pycache__ in Git --- bootloader/ota-dfu-python/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 bootloader/ota-dfu-python/.gitignore diff --git a/bootloader/ota-dfu-python/.gitignore b/bootloader/ota-dfu-python/.gitignore new file mode 100644 index 0000000000..ed8ebf583f --- /dev/null +++ b/bootloader/ota-dfu-python/.gitignore @@ -0,0 +1 @@ +__pycache__ \ No newline at end of file From 21f80d11afd6482206ed3f4e9b0163725f653f91 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 May 2022 21:10:10 +0200 Subject: [PATCH 2/3] SystemTask: Use "&&" instead of "and" for operators As per the coding style, only primary spelling should be used for operators. --- src/systemtask/SystemTask.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index a429c42e3f..ad5998673e 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -264,15 +264,16 @@ void SystemTask::Work() { case Messages::TouchWakeUp: { if (touchHandler.GetNewTouchInfo()) { auto gesture = touchHandler.GestureGet(); - if (gesture != Pinetime::Applications::TouchEvents::None and - ((gesture == Pinetime::Applications::TouchEvents::DoubleTap and - settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) or - (gesture == Pinetime::Applications::TouchEvents::Tap and + if (gesture != Pinetime::Applications::TouchEvents::None && + ((gesture == Pinetime::Applications::TouchEvents::DoubleTap && + settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::DoubleTap)) || + (gesture == Pinetime::Applications::TouchEvents::Tap && settingsController.isWakeUpModeOn(Pinetime::Controllers::Settings::WakeUpMode::SingleTap)))) { GoToRunning(); } } - } break; + break; + } case Messages::GoToSleep: if (doNotGoToSleep) { break; From f0049eb4a96ace0b3b605ac9af915b63db031ccb Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 May 2022 21:10:28 +0200 Subject: [PATCH 3/3] System: Refactor pin and interrupt setup This should ensure better readability of the pin setup procedure, as well as allow the configuration of the hardware button enable pin and the accelerometer interrupt pin via the pin mapping header. --- src/drivers/PinMap.h | 2 ++ src/systemtask/SystemTask.cpp | 28 +++++++++------------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/drivers/PinMap.h b/src/drivers/PinMap.h index 579bf38a85..7170f58b28 100644 --- a/src/drivers/PinMap.h +++ b/src/drivers/PinMap.h @@ -16,8 +16,10 @@ namespace Pinetime { static constexpr uint8_t Button = 13; #endif + static constexpr uint8_t ButtonEnable = 15; static constexpr uint8_t Cst816sIrq = 28; static constexpr uint8_t PowerPresent = 19; + static constexpr uint8_t Bma421Irq = 8; static constexpr uint8_t Motor = 16; diff --git a/src/systemtask/SystemTask.cpp b/src/systemtask/SystemTask.cpp index ad5998673e..e1b01db99c 100644 --- a/src/systemtask/SystemTask.cpp +++ b/src/systemtask/SystemTask.cpp @@ -172,39 +172,29 @@ void SystemTask::Work() { buttonHandler.Init(this); - // Button - nrf_gpio_cfg_output(15); - nrf_gpio_pin_set(15); - + // Setup Interrupts nrfx_gpiote_in_config_t pinConfig; pinConfig.skip_gpio_setup = false; pinConfig.hi_accuracy = false; pinConfig.is_watcher = false; - pinConfig.sense = static_cast(NRF_GPIOTE_POLARITY_TOGGLE); - pinConfig.pull = static_cast(GPIO_PIN_CNF_PULL_Pulldown); + // Button + nrf_gpio_cfg_output(PinMap::ButtonEnable); + nrf_gpio_pin_set(PinMap::ButtonEnable); + pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE; + pinConfig.pull = NRF_GPIO_PIN_PULLDOWN; nrfx_gpiote_in_init(PinMap::Button, &pinConfig, nrfx_gpiote_evt_handler); nrfx_gpiote_in_event_enable(PinMap::Button, true); // Touchscreen - nrf_gpio_cfg_sense_input(PinMap::Cst816sIrq, - static_cast(GPIO_PIN_CNF_PULL_Pullup), - static_cast(GPIO_PIN_CNF_SENSE_Low)); - - pinConfig.skip_gpio_setup = true; - pinConfig.hi_accuracy = false; - pinConfig.is_watcher = false; - pinConfig.sense = static_cast(NRF_GPIOTE_POLARITY_HITOLO); - pinConfig.pull = static_cast(GPIO_PIN_CNF_PULL_Pullup); - + pinConfig.sense = NRF_GPIOTE_POLARITY_HITOLO; + pinConfig.pull = NRF_GPIO_PIN_PULLUP; nrfx_gpiote_in_init(PinMap::Cst816sIrq, &pinConfig, nrfx_gpiote_evt_handler); + nrfx_gpiote_in_event_enable(PinMap::Cst816sIrq, true); // Power present pinConfig.sense = NRF_GPIOTE_POLARITY_TOGGLE; pinConfig.pull = NRF_GPIO_PIN_NOPULL; - pinConfig.is_watcher = false; - pinConfig.hi_accuracy = false; - pinConfig.skip_gpio_setup = false; nrfx_gpiote_in_init(PinMap::PowerPresent, &pinConfig, nrfx_gpiote_evt_handler); nrfx_gpiote_in_event_enable(PinMap::PowerPresent, true);