Also disable the other buttons temporarily.
This commit is contained in:
parent
1e70cbb13d
commit
98cf010c4b
3 changed files with 15 additions and 5 deletions
|
@ -7,13 +7,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-exceptions")
|
||||||
|
|
||||||
# Initialise pico_sdk from installed location
|
# Initialise pico_sdk from installed location
|
||||||
# (note this can come from environment, CMake cache etc)
|
# (note this can come from environment, CMake cache etc)
|
||||||
#set(PICO_SDK_PATH "/usr/share/pico-sdk")
|
set(PICO_SDK_PATH "/usr/share/pico-sdk")
|
||||||
set(PICO_SDK_PATH "/home/martin/pico/pico-sdk")
|
#set(PICO_SDK_PATH "/home/martin/pico/pico-sdk")
|
||||||
|
|
||||||
# Pull in Raspberry Pi Pico SDK (must be before project)
|
# Pull in Raspberry Pi Pico SDK (must be before project)
|
||||||
include("cmake/pico_sdk_import.cmake")
|
include("cmake/pico_sdk_import.cmake")
|
||||||
|
|
||||||
project(gbmanager VERSION "1.0.2" LANGUAGES C CXX ASM)
|
project(gbmanager VERSION "1.0.3" LANGUAGES C CXX ASM)
|
||||||
|
|
||||||
# Initialise the Raspberry Pi Pico SDK
|
# Initialise the Raspberry Pi Pico SDK
|
||||||
pico_sdk_init()
|
pico_sdk_init()
|
||||||
|
|
|
@ -14,14 +14,22 @@ void Relais::activate(bool active) {
|
||||||
|
|
||||||
lastState = active;
|
lastState = active;
|
||||||
|
|
||||||
|
gpio_set_irq_enabled_with_callback(BUTTON_1_PIN, GPIO_IRQ_EDGE_FALL, false,
|
||||||
|
callback);
|
||||||
|
gpio_set_irq_enabled_with_callback(BUTTON_2_PIN, GPIO_IRQ_EDGE_FALL, false,
|
||||||
|
callback);
|
||||||
gpio_set_irq_enabled_with_callback(BUTTON_3_PIN, GPIO_IRQ_EDGE_FALL, false,
|
gpio_set_irq_enabled_with_callback(BUTTON_3_PIN, GPIO_IRQ_EDGE_FALL, false,
|
||||||
callback);
|
callback);
|
||||||
gpio_put(gpio, !active);
|
gpio_put(gpio, !active);
|
||||||
sleep_ms(100);
|
sleep_ms(100);
|
||||||
|
gpio_set_irq_enabled_with_callback(BUTTON_1_PIN, GPIO_IRQ_EDGE_FALL, true,
|
||||||
|
callback);
|
||||||
|
gpio_set_irq_enabled_with_callback(BUTTON_2_PIN, GPIO_IRQ_EDGE_FALL, true,
|
||||||
|
callback);
|
||||||
gpio_set_irq_enabled_with_callback(BUTTON_3_PIN, GPIO_IRQ_EDGE_FALL, true,
|
gpio_set_irq_enabled_with_callback(BUTTON_3_PIN, GPIO_IRQ_EDGE_FALL, true,
|
||||||
callback);
|
callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Relais::on() { activate(true); }
|
void Relais::on() { activate(true); }
|
||||||
|
|
||||||
void Relais::off() { activate(false); }
|
void Relais::off() { activate(false); }
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
#include "hardware/gpio.h"
|
#include "hardware/gpio.h"
|
||||||
#include "pico/stdlib.h"
|
#include "pico/stdlib.h"
|
||||||
|
|
||||||
|
extern const uint BUTTON_1_PIN; // declared in gbmanager.cpp
|
||||||
|
extern const uint BUTTON_2_PIN; // declared in gbmanager.cpp
|
||||||
extern const uint BUTTON_3_PIN; // declared in gbmanager.cpp
|
extern const uint BUTTON_3_PIN; // declared in gbmanager.cpp
|
||||||
|
|
||||||
class Relais {
|
class Relais {
|
||||||
|
@ -19,4 +21,4 @@ class Relais {
|
||||||
gpio_irq_callback_t callback;
|
gpio_irq_callback_t callback;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue