Skip to content

Commit

Permalink
interrupt sort of working as expected...
Browse files Browse the repository at this point in the history
  • Loading branch information
echavemann committed Dec 7, 2024
1 parent f353bce commit ca4aa8f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#pragma once

#include "app_timer.h"
#include "config.hpp"
#include "drivers/driver_enums.hpp"
#include "drivers/gpio_pin.hpp"
#include "drivers/gpio_pin_event.hpp"
#include "microbit_v2.h"
#include "app_timer.h"
#include "nrfx_timer.h"
#include "nrf_gpio.h"
#include "nrfx_timer.h"
#include "util.hpp"

namespace edge::drivers {
Expand Down Expand Up @@ -37,8 +37,6 @@ class CapsenseController {
bool get_captouch_pressed();

void handle_gpio_interrupt(nrf_gpio_pin_sense_t sense, int pin);

};


} // namespace edge::drivers
Original file line number Diff line number Diff line change
@@ -1,32 +1,39 @@
#include "drivers/captouch_controller.hpp"

#include "drivers/driver_enums.hpp"
#include "drivers/driver_enums.hpp"
#include "drivers/capsense_driver.hpp"
#include "drivers/gpio_pin_event.hpp"
#include "hal/gpio_wrapper.hpp"
#include "hal/hal_enums.hpp"
#include "microbit_v2.h"
#include "nrf_gpio.h"
#include "userlib/syscalls.hpp"

namespace edge::drivers {

CapsenseController::CapsenseController() :
CapsenseController::CapsenseController() :
touched(false),
event{
TOUCH_LOGO, GPIOConfiguration::IN_NORES,
aidan::GPIOEventController::GPIOEventCallback::create<
CapsenseController, &CapsenseController::handle_gpio_interrupt>(*this)
}
{
aidan::clear_gpio_pin(TOUCH_LOGO);
};
{
aidan::clear_gpio_pin(TOUCH_LOGO);
nrf_gpio_cfg(
TOUCH_LOGO, NRF_GPIO_PIN_DIR_INPUT, NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE
);
};

CapsenseController& CapsenseController::get()
{
static CapsenseController capsenseController;
return capsenseController;
}

void CapsenseController::subscribe_captouch_press(ProcessCallbackPtr callback, uint8_t process_id)
void CapsenseController::subscribe_captouch_press(
ProcessCallbackPtr callback, uint8_t process_id
)
{
subscriptions[process_id] = callback;
return;
Expand All @@ -43,5 +50,4 @@ void CapsenseController::handle_gpio_interrupt(nrf_gpio_pin_sense_t sense, int p
touched = false;
}

} // end ns drivers

} // namespace edge::drivers
2 changes: 1 addition & 1 deletion src/drivers/driver_commands.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "drivers/driver_commands.hpp"

#include "drivers/button_driver.hpp"
#include "drivers/capsense_driver.hpp"
#include "drivers/captouch_controller.hpp"
#include "drivers/driver_enums.hpp"
#include "drivers/led_display.hpp"
#include "drivers/timer.hpp"
Expand Down
13 changes: 3 additions & 10 deletions src/user_programs/user_program_captouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@

void captouch_task(void)
{
while (1)
{
if (edge::userlib::get_captouch_pressed())
{
while (1) {
if (edge::userlib::get_captouch_pressed()) {
/* edge::userlib::debug_print("pressed\n"); */
}
else
{
else {
/* edge::userlib::debug_print("not pressed"); */
}


}


}

0 comments on commit ca4aa8f

Please sign in to comment.