-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into echavemann/demo-code
- Loading branch information
Showing
28 changed files
with
337 additions
and
206 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include "drivers/driver_enums.hpp" | ||
#include "drivers/gpio_pin.hpp" | ||
#include "drivers/gpio_pin_event.hpp" | ||
#include "microbit_v2.h" | ||
#include "nrf_gpio.h" | ||
#include "scheduler/user_callback_storage.hpp" | ||
#include "util.hpp" | ||
|
||
namespace edge::drivers { | ||
|
||
class CapsenseController { | ||
GPIOPin touch_logo{TOUCH_LOGO, GPIOConfiguration::IN_NORES}; | ||
|
||
UserCallbackStorage subscriptions; | ||
|
||
bool touched; | ||
|
||
bool prev_touched; | ||
|
||
uint32_t time_test_started; | ||
|
||
GPIOPinEvent event; | ||
|
||
CapsenseController(); | ||
~CapsenseController() = default; | ||
|
||
public: | ||
CapsenseController(const CapsenseController&) = delete; | ||
CapsenseController(CapsenseController&&) = delete; | ||
CapsenseController& operator=(const CapsenseController&) = delete; | ||
CapsenseController& operator=(CapsenseController&&) = delete; | ||
|
||
static CapsenseController& get(); | ||
|
||
void subscribe_captouch_press(ProcessCallbackPtr callback, uint8_t process_id); | ||
|
||
bool get_captouch_pressed(); | ||
|
||
void handle_gpio_interrupt(nrf_gpio_pin_sense_t sense, int pin); | ||
|
||
void start_capacitive_test(); | ||
}; | ||
|
||
} // namespace edge::drivers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#pragma once | ||
|
||
#include "config.hpp" | ||
#include "util.hpp" | ||
|
||
namespace edge { | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "drivers/captouch_controller.hpp" | ||
|
||
#include "config.hpp" | ||
#include "microbit_v2.h" | ||
#include "nrf_gpio.h" | ||
|
||
namespace edge::drivers { | ||
|
||
CapsenseController::CapsenseController() : | ||
touched(false), prev_touched(false), | ||
event{ | ||
TOUCH_LOGO, GPIOConfiguration::IN_NORES, | ||
aidan::GPIOEventController::GPIOEventCallback::create< | ||
CapsenseController, &CapsenseController::handle_gpio_interrupt>(*this) | ||
} | ||
{ | ||
touch_logo.clear(); | ||
nrf_gpio_cfg( | ||
TOUCH_LOGO, NRF_GPIO_PIN_DIR_OUTPUT, 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 | ||
) | ||
{ | ||
subscriptions.set_callback(process_id, callback); | ||
} | ||
|
||
bool CapsenseController::get_captouch_pressed() | ||
{ | ||
return touched; | ||
} | ||
|
||
void CapsenseController::handle_gpio_interrupt(nrf_gpio_pin_sense_t sense, int pin) | ||
{ | ||
if (sense == NRF_GPIO_PIN_SENSE_LOW) { | ||
touched = true; | ||
} | ||
else if (sense == NRF_GPIO_PIN_SENSE_HIGH) { | ||
touched = false; | ||
} | ||
if ((prev_touched != touched)) { | ||
for (int process_id = 0; process_id < MAX_PROCESSES; ++process_id) { | ||
if (subscriptions.has_callback(process_id)) { | ||
subscriptions.call_callback( | ||
process_id, static_cast<int>(to_cap_sense_state(sense)) | ||
); | ||
} | ||
} | ||
} | ||
prev_touched = touched; | ||
} | ||
|
||
} // namespace edge::drivers |
Oops, something went wrong.