diff --git a/CMakeLists.txt b/CMakeLists.txt index cdfabac..666451e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # Generated Cmake Pico project file -cmake_minimum_required(VERSION 3.28) +cmake_minimum_required(VERSION 3.26) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 23) @@ -14,8 +14,8 @@ set(PICO_BOARD pico CACHE STRING "Board type") # Pull in Raspberry Pi Pico SDK (must be before project) include(pico_sdk_import.cmake) -if (PICO_SDK_VERSION_STRING VERSION_LESS "2.0.0") - message(FATAL_ERROR "Raspberry Pi Pico SDK version 2.0.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}") +if (PICO_SDK_VERSION_STRING VERSION_LESS "1.5.0") + message(FATAL_ERROR "Raspberry Pi Pico SDK version 1.5.0 (or later) required. Your version is ${PICO_SDK_VERSION_STRING}") endif() project(raspikeyer VERSION "0.0.1" LANGUAGES C CXX ASM) diff --git a/src/raspikeyer.cpp b/src/raspikeyer.cpp index cbb36fe..18c9ea4 100644 --- a/src/raspikeyer.cpp +++ b/src/raspikeyer.cpp @@ -2,10 +2,10 @@ #include #include +#include #include "bsp/board.h" #include "hardware/adc.h" -#include "pico/flash.h" #include "pico/binary_info/code.h" #include "pico/multicore.h" #include "pico/stdlib.h" @@ -102,6 +102,10 @@ void core1_main() } } +void test() { + printf("Test\n"); +} + int main() { timer_hw->dbgpause = 0; // workaround for problem with debug and sleep_ms @@ -131,7 +135,10 @@ int main() KeyerQueueData keyerQueueData {KeyerQueueCommand::Run, currentWpm, settings.mode, 0}; queue_add_blocking(&keyerQueue, &keyerQueueData); + std::function f_observer = test; + WinKeyer winKeyer; + winKeyer.addObserver(f_observer); pio_hw_t *pio = pio0; TM1637 display {DISPLAY_DIO_PIN, DISPLAY_CLK_PIN, pio}; diff --git a/src/settings.cpp b/src/settings.cpp index 2f8316b..0786140 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1,7 +1,6 @@ #include #include "pico/stdlib.h" -#include "pico/flash.h" #include "settings.h" @@ -67,4 +66,4 @@ Settings read_settings() } return settings; -} +} \ No newline at end of file diff --git a/src/settings.h b/src/settings.h index e3a78cf..cd19270 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,6 +1,6 @@ #pragma once -#include "hardware/flash.h" +#include "pico/flash.h" const uint16_t MAGIC_NUMBER = 4; diff --git a/src/winkeyer.cpp b/src/winkeyer.cpp index c0c53fb..3a35ba3 100644 --- a/src/winkeyer.cpp +++ b/src/winkeyer.cpp @@ -103,4 +103,10 @@ void WinKeyer::run(queue_t &queue) m_commandState = CommandState::None; } } +} + +void WinKeyer::addObserver(std::function obs) { + m_observers.push_back(obs); + + obs(); } \ No newline at end of file diff --git a/src/winkeyer.h b/src/winkeyer.h index e0aabee..19e02c5 100644 --- a/src/winkeyer.h +++ b/src/winkeyer.h @@ -1,11 +1,15 @@ #pragma once +#include +#include + #include "pico/util/queue.h" class WinKeyer final { public: void run(queue_t &queue); + void addObserver(std::function obs); private: enum class CommandState { @@ -24,4 +28,5 @@ class WinKeyer final CommandState m_commandState {CommandState::None}; WkMode m_wkMode {WkMode::WK1}; bool m_hostOpen {false}; + std::vector> m_observers; }; \ No newline at end of file