Compare commits
3 commits
5dc8d5e76d
...
d4278d6098
Author | SHA1 | Date | |
---|---|---|---|
d4278d6098 | |||
0bbb794346 | |||
7b56534fee |
8 changed files with 45 additions and 24 deletions
20
.vscode/launch.json
vendored
20
.vscode/launch.json
vendored
|
@ -1,4 +1,4 @@
|
|||
{
|
||||
{
|
||||
// Use IntelliSense to learn about possible attributes.
|
||||
// Hover to view descriptions of existing attributes.
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
|
@ -11,21 +11,19 @@
|
|||
"request": "launch",
|
||||
"type": "cortex-debug",
|
||||
"servertype": "openocd",
|
||||
"gdbPath" : "arm-none-eabi-gdb",
|
||||
"gdbPath": "gdb-multiarch",
|
||||
"device": "RP2040",
|
||||
//"showDevDebugOutput": "parsed",
|
||||
"configFiles": [
|
||||
"interface/picoprobe.cfg",
|
||||
"interface/raspberrypi-swd.cfg",
|
||||
"target/rp2040.cfg"
|
||||
],
|
||||
"svdFile": "${env:PICO_SDK_PATH}/src/rp2040/hardware_regs/rp2040.svd",
|
||||
"runToEntryPoint": "main",
|
||||
// Give restart the same functionality as runToMain
|
||||
//"postRestartCommands": [
|
||||
// "break main",
|
||||
// "continue"
|
||||
//],
|
||||
"searchDir": ["${env:HOME}/src/openocd/tcl"],
|
||||
// Give restart the same functionality as runToEntryPoint - main
|
||||
"postRestartCommands": [
|
||||
"break main",
|
||||
"continue"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
|
@ -14,8 +14,6 @@
|
|||
"visibility": "hidden"
|
||||
},
|
||||
},
|
||||
"cortex-debug.openocdPath": "${env:HOME}/src/openocd/src/openocd",
|
||||
"cmake.generator": "Unix Makefiles",
|
||||
"C_Cpp.clang_format_fallbackStyle": "LLVM",
|
||||
"files.watcherExclude": {
|
||||
"**/.git/objects/**": true,
|
||||
|
|
|
@ -3,16 +3,17 @@ cmake_minimum_required(VERSION 3.13)
|
|||
set(CMAKE_C_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-volatile")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fno-exceptions")
|
||||
|
||||
# Initialise pico_sdk from installed location
|
||||
# (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")
|
||||
|
||||
# Pull in Raspberry Pi Pico SDK (must be before project)
|
||||
include("cmake/pico_sdk_import.cmake")
|
||||
|
||||
project(gbmanager VERSION "1.0.0" LANGUAGES C CXX ASM)
|
||||
project(gbmanager VERSION "1.0.1" LANGUAGES C CXX ASM)
|
||||
|
||||
# Initialise the Raspberry Pi Pico SDK
|
||||
pico_sdk_init()
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit d5af2a1e1d81c3cb21805e332c8185607ee74b1d
|
||||
Subproject commit 6399467cf7687ecb7f8f4e4923303349e0ecf160
|
|
@ -14,8 +14,8 @@ pico_set_program_name(${CMAKE_PROJECT_NAME} "gbmanager")
|
|||
pico_set_program_version(${CMAKE_PROJECT_NAME} ${PROJECT_VERSION})
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
pico_enable_stdio_uart(${CMAKE_PROJECT_NAME} 1)
|
||||
pico_enable_stdio_usb(${CMAKE_PROJECT_NAME} 0)
|
||||
pico_enable_stdio_uart(${CMAKE_PROJECT_NAME} 0)
|
||||
pico_enable_stdio_usb(${CMAKE_PROJECT_NAME} 1)
|
||||
else()
|
||||
pico_enable_stdio_uart(${CMAKE_PROJECT_NAME} 0)
|
||||
pico_enable_stdio_usb(${CMAKE_PROJECT_NAME} 0)
|
||||
|
|
|
@ -31,7 +31,7 @@ using std::string;
|
|||
|
||||
void buttonPressedCallback(uint gpio, [[maybe_unused]] uint32_t events) {
|
||||
absolute_time_t now = get_absolute_time();
|
||||
if (absolute_time_diff_us(lastPressed, now) < 750000) {
|
||||
if (absolute_time_diff_us(lastPressed, now) < 500000) {
|
||||
return;
|
||||
} else {
|
||||
lastPressed = now;
|
||||
|
@ -65,7 +65,9 @@ int main() {
|
|||
oneWire.single_device_read_rom(address);
|
||||
|
||||
// Initialize the relais
|
||||
Relais relais(RELAIS_PIN);
|
||||
// It need the button callback function, since it has to disable the on/off
|
||||
// button for a short amount of time
|
||||
Relais relais(RELAIS_PIN, &buttonPressedCallback);
|
||||
|
||||
// Initialize the Buttons
|
||||
gpio_set_irq_enabled_with_callback(BUTTON_1_PIN, GPIO_IRQ_EDGE_FALL, true,
|
||||
|
@ -88,6 +90,8 @@ int main() {
|
|||
sleep_ms(3000);
|
||||
|
||||
while (true) {
|
||||
uint64_t destTime = time_us_64() + 1000000;
|
||||
|
||||
oneWire.convert_temperature(address, true, false);
|
||||
temp_act = oneWire.temperature(address);
|
||||
|
||||
|
@ -109,5 +113,7 @@ int main() {
|
|||
CUSTOM_CHAR_DEG, systemInfo);
|
||||
myLCD.setCursor(0, 0);
|
||||
myLCD.sendString(lcdText);
|
||||
|
||||
sleep_until((absolute_time_t){destTime});
|
||||
}
|
||||
}
|
|
@ -1,12 +1,26 @@
|
|||
#include "relais.h"
|
||||
|
||||
Relais::Relais(uint gpio) : gpio{gpio} {
|
||||
Relais::Relais(uint gpio, gpio_irq_callback_t callback)
|
||||
: gpio{gpio}, callback{callback} {
|
||||
gpio_init(gpio);
|
||||
gpio_set_dir(gpio, GPIO_OUT);
|
||||
off();
|
||||
}
|
||||
|
||||
void Relais::activate(bool active) { gpio_put(gpio, !active); }
|
||||
void Relais::activate(bool active) {
|
||||
if (active == lastState) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastState = active;
|
||||
|
||||
gpio_set_irq_enabled_with_callback(BUTTON_3_PIN, GPIO_IRQ_EDGE_FALL, false,
|
||||
callback);
|
||||
gpio_put(gpio, !active);
|
||||
sleep_ms(100);
|
||||
gpio_set_irq_enabled_with_callback(BUTTON_3_PIN, GPIO_IRQ_EDGE_FALL, true,
|
||||
callback);
|
||||
}
|
||||
|
||||
void Relais::on() { activate(true); }
|
||||
|
||||
|
|
|
@ -4,15 +4,19 @@
|
|||
#include "hardware/gpio.h"
|
||||
#include "pico/stdlib.h"
|
||||
|
||||
extern const uint BUTTON_3_PIN; // declared in gbmanager.cpp
|
||||
|
||||
class Relais {
|
||||
public:
|
||||
Relais(uint gpio);
|
||||
Relais(uint gpio, gpio_irq_callback_t callback);
|
||||
void activate(bool active);
|
||||
void on();
|
||||
void off();
|
||||
|
||||
private:
|
||||
uint gpio;
|
||||
bool lastState;
|
||||
gpio_irq_callback_t callback;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue