Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
eb8dbb3987 | |||
665e50f456 |
4 changed files with 32 additions and 2 deletions
|
@ -18,9 +18,20 @@ if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_PATH} AND (NOT PICO_SDK_FETCH_FROM_GIT_P
|
|||
message("Using PICO_SDK_FETCH_FROM_GIT_PATH from environment ('${PICO_SDK_FETCH_FROM_GIT_PATH}')")
|
||||
endif ()
|
||||
|
||||
if (DEFINED ENV{PICO_SDK_FETCH_FROM_GIT_TAG} AND (NOT PICO_SDK_FETCH_FROM_GIT_TAG))
|
||||
set(PICO_SDK_FETCH_FROM_GIT_TAG $ENV{PICO_SDK_FETCH_FROM_GIT_TAG})
|
||||
message("Using PICO_SDK_FETCH_FROM_GIT_TAG from environment ('${PICO_SDK_FETCH_FROM_GIT_TAG}')")
|
||||
endif ()
|
||||
|
||||
if (PICO_SDK_FETCH_FROM_GIT AND NOT PICO_SDK_FETCH_FROM_GIT_TAG)
|
||||
set(PICO_SDK_FETCH_FROM_GIT_TAG "master")
|
||||
message("Using master as default value for PICO_SDK_FETCH_FROM_GIT_TAG")
|
||||
endif()
|
||||
|
||||
set(PICO_SDK_PATH "${PICO_SDK_PATH}" CACHE PATH "Path to the Raspberry Pi Pico SDK")
|
||||
set(PICO_SDK_FETCH_FROM_GIT "${PICO_SDK_FETCH_FROM_GIT}" CACHE BOOL "Set to ON to fetch copy of SDK from git if not otherwise locatable")
|
||||
set(PICO_SDK_FETCH_FROM_GIT_PATH "${PICO_SDK_FETCH_FROM_GIT_PATH}" CACHE FILEPATH "location to download SDK")
|
||||
set(PICO_SDK_FETCH_FROM_GIT_TAG "${PICO_SDK_FETCH_FROM_GIT_TAG}" CACHE FILEPATH "release tag for SDK")
|
||||
|
||||
if (NOT PICO_SDK_PATH)
|
||||
if (PICO_SDK_FETCH_FROM_GIT)
|
||||
|
@ -34,14 +45,14 @@ if (NOT PICO_SDK_PATH)
|
|||
FetchContent_Declare(
|
||||
pico_sdk
|
||||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||
GIT_TAG master
|
||||
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
|
||||
GIT_SUBMODULES_RECURSE FALSE
|
||||
)
|
||||
else ()
|
||||
FetchContent_Declare(
|
||||
pico_sdk
|
||||
GIT_REPOSITORY https://github.com/raspberrypi/pico-sdk
|
||||
GIT_TAG master
|
||||
GIT_TAG ${PICO_SDK_FETCH_FROM_GIT_TAG}
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
|
||||
#include "bsp/board.h"
|
||||
#include "hardware/adc.h"
|
||||
|
@ -101,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
|
||||
|
@ -130,7 +135,10 @@ int main()
|
|||
KeyerQueueData keyerQueueData {KeyerQueueCommand::Run, currentWpm, settings.mode, 0};
|
||||
queue_add_blocking(&keyerQueue, &keyerQueueData);
|
||||
|
||||
std::function<void()> f_observer = test;
|
||||
|
||||
WinKeyer winKeyer;
|
||||
winKeyer.addObserver(f_observer);
|
||||
|
||||
pio_hw_t *pio = pio0;
|
||||
TM1637 display {DISPLAY_DIO_PIN, DISPLAY_CLK_PIN, pio};
|
||||
|
|
|
@ -103,4 +103,10 @@ void WinKeyer::run(queue_t &queue)
|
|||
m_commandState = CommandState::None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WinKeyer::addObserver(std::function<void()> obs) {
|
||||
m_observers.push_back(obs);
|
||||
|
||||
obs();
|
||||
}
|
|
@ -1,11 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include "pico/util/queue.h"
|
||||
|
||||
class WinKeyer final
|
||||
{
|
||||
public:
|
||||
void run(queue_t &queue);
|
||||
void addObserver(std::function<void()> 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<std::function<void()>> m_observers;
|
||||
};
|
Loading…
Reference in a new issue