Merge branch 'hardware' into beta-0.4
This commit is contained in:
commit
d6b0f39dc7
BIN
hardware/MusiqueBox.fzz
Normal file
BIN
hardware/MusiqueBox.fzz
Normal file
Binary file not shown.
BIN
hardware/MusiqueBox_bb.png
Normal file
BIN
hardware/MusiqueBox_bb.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 379 KiB |
BIN
hardware/MusiqueBox_schem.png
Normal file
BIN
hardware/MusiqueBox_schem.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 197 KiB |
@ -167,7 +167,8 @@ struct Runner
|
||||
|
||||
Interpreter interpreter;
|
||||
std::shared_ptr<serialport::State> serial_state;
|
||||
std::optional<std::jthread> serial_event_loop;
|
||||
std::thread serial_event_loop;
|
||||
std::atomic<bool> serial_event_loop_stop = false;
|
||||
|
||||
/// Setup interpreter and midi connection with given port
|
||||
explicit Runner(std::optional<unsigned> output_port)
|
||||
@ -183,8 +184,8 @@ struct Runner
|
||||
interpreter.serialport = serial_state;
|
||||
serialport::initialize();
|
||||
|
||||
serial_event_loop = std::jthread([this](std::stop_token token) mutable{
|
||||
serialport::event_loop(token, *serial_state);
|
||||
serial_event_loop = std::thread([this]() mutable {
|
||||
serialport::event_loop(serial_event_loop_stop, *serial_state);
|
||||
});
|
||||
|
||||
Env::global->force_define("say", +[](Interpreter &interpreter, std::vector<Value> args) -> Result<Value> {
|
||||
@ -207,6 +208,13 @@ struct Runner
|
||||
Runner& operator=(Runner const&) = delete;
|
||||
Runner& operator=(Runner &&) = delete;
|
||||
|
||||
~Runner() {
|
||||
serial_event_loop_stop = true;
|
||||
if (serial_event_loop.joinable()) {
|
||||
serial_event_loop.join();
|
||||
}
|
||||
}
|
||||
|
||||
/// Consider given input file as new definition of parametless function
|
||||
///
|
||||
/// Useful for deffering execution of files to the point when all configuration of midi devices
|
||||
|
@ -38,9 +38,9 @@ namespace serialport{
|
||||
return 8;
|
||||
}
|
||||
|
||||
void event_loop(std::stop_token token, State &state)
|
||||
void event_loop(std::atomic<bool> &stop, State &state)
|
||||
{
|
||||
while(!token.stop_requested()){
|
||||
while(!stop){
|
||||
try {
|
||||
/// Search for the right device
|
||||
auto const ports = serial::list_ports();
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <string>
|
||||
#include <serial/serial.h>
|
||||
#include <stop_token>
|
||||
#include <memory>
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
@ -26,7 +25,7 @@ namespace serialport{
|
||||
};
|
||||
|
||||
void initialize();
|
||||
void event_loop(std::stop_token token, State &state);
|
||||
void event_loop(std::atomic<bool> &stop, State &state);
|
||||
std::uint8_t get_byte();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user