Updated Drivers

This commit is contained in:
Kevin Thomas
2026-03-23 09:33:04 -04:00
parent 6ee30d0520
commit 91faba6800
31 changed files with 834 additions and 344 deletions
+11 -2
View File
@@ -33,6 +33,7 @@
static uint32_t debounce_delay_ms = 20;
/**
* @brief Confirm a raw active-low pin read by waiting for the debounce period
*
@@ -43,11 +44,12 @@ static uint32_t debounce_delay_ms = 20;
* @param pin GPIO pin number to re-sample
* @return bool true if the pin is still low after the debounce delay
*/
static bool debounce_confirm(uint32_t pin) {
static bool _debounce_confirm(uint32_t pin) {
sleep_ms(debounce_delay_ms);
return !gpio_get(pin);
}
void button_init(uint32_t pin, uint32_t debounce_ms) {
debounce_delay_ms = debounce_ms;
gpio_init(pin);
@@ -55,19 +57,26 @@ void button_init(uint32_t pin, uint32_t debounce_ms) {
gpio_pull_up(pin);
}
bool button_is_pressed(uint32_t pin) {
if (!gpio_get(pin)) {
return debounce_confirm(pin);
return _debounce_confirm(pin);
}
return false;
}
void button_led_init(uint32_t pin) {
gpio_init(pin);
gpio_set_dir(pin, GPIO_OUT);
gpio_put(pin, false);
}
void button_led_set(uint32_t pin, bool on) {
gpio_put(pin, on);
}
void button_led_set(uint32_t pin, bool on) {
gpio_put(pin, on);
}