From b593db4bb376b9828568e9438bbb336a1dc94dba Mon Sep 17 00:00:00 2001 From: Robin Davies Date: Wed, 18 May 2022 06:25:40 -0400 Subject: [PATCH 1/7] Update BuildPrerequisites.md --- docs/BuildPrerequisites.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/BuildPrerequisites.md b/docs/BuildPrerequisites.md index 04dda68..fccd240 100644 --- a/docs/BuildPrerequisites.md +++ b/docs/BuildPrerequisites.md @@ -4,7 +4,7 @@ Run the following commands to install build tools required by the PiPedal build. # install CMake sudo apt update - sudo apt install cmake ninja-build + sudo apt install -y cmake ninja-build The PiPedal build process also requires version 12 or later of `node.js`. Type `node --version` to see if you have a version of `node.js` installed already. Otherwise run the following commands as root to install the v14.x lts version of `node.js`: @@ -22,10 +22,10 @@ with Run the following commands to install dependent libraries required by the PiPedal build. sudo apt update - sudo apt install liblilv-dev libboost-dev jackd2 libjack-jackd2-dev libnl-3-dev libnl-genl-3-dev libsystemd-dev catch - sudo apt install libasound2-dev jackd2 uuid-dev - sudo apt install libwebsocketpp-dev authbind - sudo apt install libavahi-client-dev + sudo apt install -y liblilv-dev libboost-dev jackd2 libjack-jackd2-dev libnl-3-dev libnl-genl-3-dev libsystemd-dev catch + sudo apt install -y libasound2-dev jackd2 uuid-dev + sudo apt install -y libwebsocketpp-dev authbind + sudo apt install -y libavahi-client-dev ### Installing Sources From 918e8070b8993d71f150662771aefc7737e71c57 Mon Sep 17 00:00:00 2001 From: Robin Davies Date: Wed, 18 May 2022 06:35:28 -0400 Subject: [PATCH 2/7] Update BuildPrerequisites.md --- docs/BuildPrerequisites.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/BuildPrerequisites.md b/docs/BuildPrerequisites.md index fccd240..cb5b1fe 100644 --- a/docs/BuildPrerequisites.md +++ b/docs/BuildPrerequisites.md @@ -36,6 +36,12 @@ Clone the rerdavies/pipdal package from github. Use the source control tools fro cd ~/src # or whereever you keep your source repositories. git clone https://github.com/rerdavies/pipedal.git +In the project root, run the following commands to initialze and update pipedal submodules + + cd ~/src/pipedal + git submodule init + git submodule update + Run the following command to install and configure React dependencies. cd ~/src/pipedal From 0e61660a3e003ea26eedd78b39985c77a39bfd3f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 19 May 2022 03:39:20 +0000 Subject: [PATCH 3/7] Bump nokogiri from 1.13.4 to 1.13.6 in /docs Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.13.4 to 1.13.6. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.13.4...v1.13.6) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] --- docs/Gemfile.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index a528550..769b5c6 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -231,9 +231,9 @@ GEM jekyll-seo-tag (~> 2.1) minitest (5.15.0) multipart-post (2.1.1) - nokogiri (1.13.4-aarch64-linux) + nokogiri (1.13.6-aarch64-linux) racc (~> 1.4) - nokogiri (1.13.4-x86_64-linux) + nokogiri (1.13.6-x86_64-linux) racc (~> 1.4) octokit (4.22.0) faraday (>= 0.9) From d9fb48d7e08e3b6b08827c13207f0f6c47c3634d Mon Sep 17 00:00:00 2001 From: Robin Davies Date: Thu, 19 May 2022 09:55:31 -0400 Subject: [PATCH 4/7] Update Installing.md Raspberry Pi OS no longer supports apt-get install of .deb packages. --- docs/Installing.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/Installing.md b/docs/Installing.md index b21c45a..2fab8eb 100644 --- a/docs/Installing.md +++ b/docs/Installing.md @@ -11,8 +11,10 @@ Install the package by running ``` sudo apt update cd ~/Downloads - sudo apt-get install ./pipedal_0.9.10_arm64.deb + sudo dpkg --install pipedal_0.9.10_arm64.deb ``` +On Raspberry Pi OS, if you have a graphical desktop installed, you can also install package by double-clicking on the downloaded package in the File Manager. + After installing, follow the instructions in [Configuring PiPedal after Installation](Configuring.md). -------- From 774a9f0a7401cea542075fa9a5bb7c3aad668f87 Mon Sep 17 00:00:00 2001 From: Robin Davies Date: Thu, 19 May 2022 10:00:56 -0400 Subject: [PATCH 5/7] Fixes uninstall problems. --- CMakeLists.txt | 4 ++-- README.md | 2 +- debian/control | 4 ++-- debian/postinst | 2 +- debian/prerm | 2 +- docs/Installing.md | 4 ++-- docs/download.md | 4 ++-- docs/index.md | 2 +- src/AdminClient.cpp | 11 ++++------- src/CMakeLists.txt | 8 -------- src/ConfigMain.cpp | 41 ++++++++++++++++++++++++++++----------- src/DeviceIdFile.cpp | 19 +++++++++--------- src/JackConfiguration.cpp | 2 +- src/PiPedalModel.cpp | 10 +++++++++- 14 files changed, 65 insertions(+), 50 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c31133d..cc623d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,10 @@ cmake_minimum_required(VERSION 3.16.0) project(pipedal - VERSION 0.9.10 + VERSION 0.9.11 DESCRIPTION "PiPedal Guitar Effect Pedal For Raspberry Pi" HOMEPAGE_URL "https://rerdavies.github.io/pipedal" ) -set (DISPLAY_VERSION "v0.9.10-rc-1") +set (DISPLAY_VERSION "v0.9.11-rc-2") set (CMAKE_INSTALL_PREFIX "/usr/") diff --git a/README.md b/README.md index 5667402..028e6cd 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -Download: v0.9.10-rc-1      Website: [https://rerdavies.github.io/pipedal](https://rerdavies.github.io/pipedal). +Download: v0.9.11-rc-2      Website: [https://rerdavies.github.io/pipedal](https://rerdavies.github.io/pipedal). Use your Raspberry Pi as a guitar effects pedal. Configure and control PiPedal with your phone or tablet. diff --git a/debian/control b/debian/control index ce587f0..7ce47cf 100644 --- a/debian/control +++ b/debian/control @@ -3,12 +3,12 @@ Depends: libstdc++6 (>= 9), libasound2 (>= 1.0.16), libc6 (>= 2.34), libgcc-s1 ( Description: IoT guitar effect for Raspberry Pi IoT guitar effect pedal for Raspberry Pi, with phone-friendly web interface. Homepage: https://github.com/rerdavies/pipedal -Maintainer: Robin Davies Source: pipedal Package: pipedal Pre-Depends: hostapd;authbind Priority: optional Section: sound -Version: 0.1.4 +Version: 0.9.11 Installed-Size: 15147 diff --git a/debian/postinst b/debian/postinst index 2c01f69..5b6d830 100755 --- a/debian/postinst +++ b/debian/postinst @@ -1,2 +1,2 @@ #!/usr/bin/bash -/usr/local/pipedalconfig --install +/usr/bin/pipedalconfig --install diff --git a/debian/prerm b/debian/prerm index 47f515a..12ec940 100755 --- a/debian/prerm +++ b/debian/prerm @@ -1,2 +1,2 @@ #!/usr/bin/bash -/usr/local/pipedalconfig --uninstall +/usr/bin/pipedalconfig --uninstall diff --git a/docs/Installing.md b/docs/Installing.md index b21c45a..d61f3ea 100644 --- a/docs/Installing.md +++ b/docs/Installing.md @@ -4,14 +4,14 @@ Download the most recent Debian (.deb) package for your platform: -- [Raspberry Pi OS (64-bit) v0.9.10-rc-1](https://github.com/rerdavies/pipedal/releases/download/v0.9.10-rc-1/pipedal_0.9.10_arm64.deb) +- [Raspberry Pi OS (64-bit) v0.9.11-rc-2](https://github.com/rerdavies/pipedal/releases/download/v0.9.11-rc-2/pipedal_0.9.11_arm64.deb) Install the package by running ``` sudo apt update cd ~/Downloads - sudo apt-get install ./pipedal_0.9.10_arm64.deb + sudo apt-get install ./pipedal_0.9.11_arm64.deb ``` After installing, follow the instructions in [Configuring PiPedal after Installation](Configuring.md). diff --git a/docs/download.md b/docs/download.md index f7053d0..cbab4ab 100644 --- a/docs/download.md +++ b/docs/download.md @@ -4,14 +4,14 @@ Download the most recent Debian (.deb) package for your platform: -- [Ubuntu or Raspberry Pi OS (64-bit)](https://github.com/rerdavies/pipedal/releases/download/v0.9.10-rc-1/pipedal_0.9.10_arm64.deb) v0.9.10-rc-1 +- [Ubuntu or Raspberry Pi OS (64-bit)](https://github.com/rerdavies/pipedal/releases/download/v0.9.11-rc-2/pipedal_0.9.11_arm64.deb) v0.9.11-rc-2 Install the package by running ``` sudo apt update cd ~/Downloads - sudo apt-get install ./pipedal_0.9.10_arm64.deb + sudo apt-get install ./pipedal_0.9.11_arm64.deb ``` Follow the instructions in [_Configuring PiPedal After Installation_](https://rerdavies.github.io/pipedal/Configuring.html) to complete the installation. diff --git a/docs/index.md b/docs/index.md index 180c834..67be215 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,7 +1,7 @@ -v0.9.10-rc-1 +v0.9.11-rc-2 Use your Raspberry Pi as a guitar effects pedal. Configure and control PiPedal with your phone or tablet. diff --git a/src/AdminClient.cpp b/src/AdminClient.cpp index 9d7dbd6..4f77e59 100644 --- a/src/AdminClient.cpp +++ b/src/AdminClient.cpp @@ -64,7 +64,8 @@ bool AdminClient::WriteMessage(const char *message) } catch (const std::exception &e) { - Lv2Log::error(SS("Failed to connect to PiPedal Admin service.")); + // Socket permissions require membership in pipedal_d group. + Lv2Log::error(SS("Failed to connect to PiPedal Admin service. " << e.what())); return false; } } @@ -168,7 +169,7 @@ void AdminClient::MonitorGovernor(const std::string &governor) bool result = WriteMessage(cmd.str().c_str()); if (!result) { // unexpected. Should throw exception on failure. - throw PiPedalException("Operation failed."); + Lv2Log::warning("Not monitoring CPU governor status."); } } void AdminClient::UnmonitorGovernor() @@ -180,9 +181,5 @@ void AdminClient::UnmonitorGovernor() std::stringstream cmd; cmd << "UnmonitorGovernor"; cmd << '\n'; - bool result = WriteMessage(cmd.str().c_str()); - if (!result) - { // unexpected. Should throw exception on failure. - throw PiPedalException("Operation failed."); - } + bool ignored = WriteMessage(cmd.str().c_str()); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3eb5259..1a82cd3 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -8,14 +8,6 @@ set (USE_PCH 1) include(FindPkgConfig) -# apt install libsdbus-c++-dev -# apt install libsdbus-c++-bin -find_package(sdbus-c++ REQUIRED) - - - - - # Can't get the pkg_check to work. # pkg_check_modules(LIBNL3 "nl-genl-3") diff --git a/src/ConfigMain.cpp b/src/ConfigMain.cpp index ebaa2cf..256c86e 100644 --- a/src/ConfigMain.cpp +++ b/src/ConfigMain.cpp @@ -64,7 +64,7 @@ using namespace pipedal; #define PIPEDAL_P2PD_SERVICE "pipedal_p2pd" #define JACK_SERVICE "jack" -#define REMOVE_OLD_SERVICE 1 // Grandfathering: whether to remove the old shutdown service (now pipedaladmind) +#define REMOVE_OLD_SERVICE 0 // Grandfathering: whether to remove the old shutdown service (now pipedaladmind) #define OLD_SHUTDOWN_SERVICE "pipedalshutdownd" std::filesystem::path GetServiceFileName(const std::string &serviceName) @@ -101,27 +101,27 @@ void EnableService() { if (sysExec(SYSTEMCTL_BIN " enable " NATIVE_SERVICE ".service") != EXIT_SUCCESS) { - cout << "Error: Failed to enable the " NATIVE_SERVICE " service."; + cout << "Error: Failed to enable the " NATIVE_SERVICE " service.\n"; } if (sysExec(SYSTEMCTL_BIN " enable " ADMIN_SERVICE ".service") != EXIT_SUCCESS) { - cout << "Error: Failed to enable the " ADMIN_SERVICE " service."; + cout << "Error: Failed to enable the " ADMIN_SERVICE " service.\n"; } } void DisableService() { if (sysExec(SYSTEMCTL_BIN " disable " NATIVE_SERVICE ".service") != EXIT_SUCCESS) { - cout << "Error: Failed to disable the " NATIVE_SERVICE " service."; + cout << "Error: Failed to disable the " NATIVE_SERVICE " service.\n"; } if (sysExec(SYSTEMCTL_BIN " disable " ADMIN_SERVICE ".service") != EXIT_SUCCESS) { - cout << "Error: Failed to disable the " ADMIN_SERVICE " service."; + cout << "Error: Failed to disable the " ADMIN_SERVICE " service.\n"; } #if REMOVE_OLD_SERVICE if (sysExec(SYSTEMCTL_BIN " disable " OLD_SHUTDOWN_SERVICE ".service") != EXIT_SUCCESS) { - cout << "Error: Failed to disable the " OLD_SHUTDOWN_SERVICE " service."; + cout << "Error: Failed to disable the " OLD_SHUTDOWN_SERVICE " service.\n"; } #endif } @@ -130,24 +130,24 @@ void StopService(bool excludeShutdownService = false) { if (sysExec(SYSTEMCTL_BIN " stop " NATIVE_SERVICE ".service") != EXIT_SUCCESS) { - cout << "Error: Failed to stop the " NATIVE_SERVICE " service."; + cout << "Error: Failed to stop the " NATIVE_SERVICE " service.\n"; } if (!excludeShutdownService) { if (sysExec(SYSTEMCTL_BIN " stop " ADMIN_SERVICE ".service") != EXIT_SUCCESS) { - cout << "Error: Failed to stop the " ADMIN_SERVICE " service."; + cout << "Error: Failed to stop the " ADMIN_SERVICE " service.\n"; } #if REMOVE_OLD_SERVICE if (sysExec(SYSTEMCTL_BIN " stop " OLD_SHUTDOWN_SERVICE ".service") != EXIT_SUCCESS) { - cout << "Error: Failed to stop the " OLD_SHUTDOWN_SERVICE " service."; + cout << "Error: Failed to stop the " OLD_SHUTDOWN_SERVICE " service.\n"; } #endif } if (sysExec(SYSTEMCTL_BIN " stop " JACK_SERVICE ".service") != EXIT_SUCCESS) { - throw PiPedalException("Failed to stop the " JACK_SERVICE " service."); + cout << "Error: Failed to stop the " JACK_SERVICE " service.\n"; } } @@ -527,9 +527,24 @@ static void PrepareDeviceidFile() { DeviceIdFile deviceIdFile; - deviceIdFile.deviceName = "PiPedal-" + RandomChars(2); + deviceIdFile.deviceName = "PiPedal"; deviceIdFile.uuid = MakeUuid(); deviceIdFile.Save(); + } else { + DeviceIdFile deviceIdFile; + if (deviceIdFile.deviceName == "" || deviceIdFile.uuid == "") + { + if (deviceIdFile.deviceName == "") + { + deviceIdFile.deviceName = "PiPedal"; + } + if (deviceIdFile.uuid == "") + { + deviceIdFile.uuid = MakeUuid(); + } + deviceIdFile.Save(); + } + } } @@ -539,6 +554,10 @@ void Install(const std::filesystem::path &programPrefix, const std::string endpo { throw PiPedalException("Failed to create audio service group."); } + if (sysExec(GROUPADD_BIN " -f " SERVICE_GROUP_NAME) != EXIT_SUCCESS) + { + throw PiPedalException("Failed to create pipedald service group."); + } PrepareDeviceidFile(); InstallJackService(); diff --git a/src/DeviceIdFile.cpp b/src/DeviceIdFile.cpp index ecccddb..027f0cc 100644 --- a/src/DeviceIdFile.cpp +++ b/src/DeviceIdFile.cpp @@ -39,16 +39,16 @@ const char DeviceIdFile::DEVICEID_FILE_NAME[] = "/etc/pipedal/config/device_uuid void DeviceIdFile::Load() { - ifstream f; - - f.open(DEVICEID_FILE_NAME); - if (!f.is_open()) { - throw invalid_argument("Can't open file " + std::string(DEVICEID_FILE_NAME)); - } + ifstream f; - std::getline(f, uuid); - std::getline(f, deviceName); + f.open(DEVICEID_FILE_NAME); + if (f.is_open()) + { + std::getline(f, uuid); + std::getline(f, deviceName); + } + } } void DeviceIdFile::Save() { @@ -67,10 +67,9 @@ void DeviceIdFile::Save() { throw logic_error("Group not found: pipedal_d"); } - std::ignore = chown(path.c_str(),-1,group_->gr_gid); + std::ignore = chown(path.c_str(), -1, group_->gr_gid); std::ignore = chmod(path.c_str(), S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); - f << uuid << endl; f << deviceName << endl; } diff --git a/src/JackConfiguration.cpp b/src/JackConfiguration.cpp index b211ac7..2d8565f 100644 --- a/src/JackConfiguration.cpp +++ b/src/JackConfiguration.cpp @@ -163,7 +163,7 @@ void JackConfiguration::Initialize() AddPorts(client, &this->outputAudioPorts_, "system", JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput); AddPorts(client, &this->inputMidiPorts_, "system", JACK_DEFAULT_MIDI_TYPE, JackPortIsOutput); AddPorts(client, &this->outputMidiPorts_, "system", JACK_DEFAULT_MIDI_TYPE, JackPortIsInput); - isValid_ = true; + isValid_ = (this->inputAudioPorts_.size() > 0 && this->outputAudioPorts_.size() > 0); this->errorStatus_ = ""; jack_client_close(client); } diff --git a/src/PiPedalModel.cpp b/src/PiPedalModel.cpp index 0c375c1..5e7d1f7 100644 --- a/src/PiPedalModel.cpp +++ b/src/PiPedalModel.cpp @@ -688,7 +688,15 @@ void PiPedalModel::UpdateDnsSd() DeviceIdFile deviceIdFile; deviceIdFile.Load(); - avahiService.Announce(webPort,deviceIdFile.deviceName,deviceIdFile.uuid,"pipedal"); + if (deviceIdFile.deviceName != "" && deviceIdFile.uuid != "") + { + avahiService.Announce(webPort,deviceIdFile.deviceName,deviceIdFile.uuid,"pipedal"); + } else { + // device_uuid file is written at install time. This warning is harmless if you're debugging. + // Without it, we can't pulblish the website via dnsDS. + // Run "pipedalconfig --install" to create the file. + Lv2Log::warning("Cant read device_uuid file. dnsSD announcement skipped."); + } } void PiPedalModel::SetWifiDirectConfigSettings(const WifiDirectConfigSettings &wifiDirectConfigSettings) From 20d8296f5076096b14a79964ed20da8850646f6d Mon Sep 17 00:00:00 2001 From: Robin Davies Date: Tue, 24 May 2022 01:02:51 -0400 Subject: [PATCH 6/7] Zoom all UI controls on small touch displays. --- react/public/img/ic_navigate_before.svg | 1 + react/public/img/ic_navigate_next.svg | 1 + react/public/var/config.json | 2 +- react/src/PiPedalModel.tsx | 90 +++++++++- react/src/PluginControl.tsx | 2 +- react/src/ZoomedUiControl.tsx | 221 ++++++++++++++++++------ src/main.cpp | 10 +- 7 files changed, 271 insertions(+), 56 deletions(-) create mode 100644 react/public/img/ic_navigate_before.svg create mode 100644 react/public/img/ic_navigate_next.svg diff --git a/react/public/img/ic_navigate_before.svg b/react/public/img/ic_navigate_before.svg new file mode 100644 index 0000000..f4a753b --- /dev/null +++ b/react/public/img/ic_navigate_before.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/react/public/img/ic_navigate_next.svg b/react/public/img/ic_navigate_next.svg new file mode 100644 index 0000000..6f4bc0a --- /dev/null +++ b/react/public/img/ic_navigate_next.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/react/public/var/config.json b/react/public/var/config.json index 20919e1..6dc7986 100644 --- a/react/public/var/config.json +++ b/react/public/var/config.json @@ -1,5 +1,5 @@ { - "socket_server_port": 8080, + "socket_server_port": 80, "socket_server_address": "*", "debug": true, "max_upload_size": 1048576, diff --git a/react/src/PiPedalModel.tsx b/react/src/PiPedalModel.tsx index a45c7d0..e5d0616 100644 --- a/react/src/PiPedalModel.tsx +++ b/react/src/PiPedalModel.tsx @@ -63,6 +63,7 @@ export interface PluginPresetsChangedHandle { export interface ZoomedControlInfo { source: HTMLElement; + name: string; instanceId: number; uiControl: UiControl; } @@ -432,6 +433,9 @@ export interface PiPedalModel { getAlsaDevices(): Promise; zoomUiControl(sourceElement: HTMLElement, instanceId: number, uiControl: UiControl): void; + + onPreviousZoomedControl() : void; + onNextZoomedControl() : void; clearZoomedControl(): void; setFavorite(pluginUrl: string, isFavorite: boolean): void; @@ -2088,8 +2092,92 @@ class PiPedalModelImpl implements PiPedalModel { } zoomUiControl(sourceElement: HTMLElement, instanceId: number, uiControl: UiControl): void { - this.zoomedUiControl.set({ source: sourceElement, instanceId: instanceId, uiControl: uiControl }); + let name = uiControl.name; + if (uiControl.port_group !== "") + { + let pedalboard = this.pedalBoard.get(); + if (pedalboard) + { + let plugin = pedalboard.getItem(instanceId); + let uiPlugin = this.getUiPlugin(plugin.uri); + if (uiPlugin) + { + for (let i = 0; i < uiPlugin.port_groups.length; ++i) + { + if (uiPlugin.port_groups[i].symbol === uiControl.port_group) + { + name = uiPlugin.port_groups[i].name + " / " + name; + break; + } + } + } + } + } + this.zoomedUiControl.set({ source: sourceElement, name: name, instanceId: instanceId, uiControl: uiControl }); } + onPreviousZoomedControl() : void + { + let currentUiControl = this.zoomedUiControl.get(); + if (!currentUiControl) return; + + let currentSymbol = currentUiControl.uiControl.symbol; + + let pedalboard = this.pedalBoard.get(); + if (!pedalboard) return; + + let pedalboardItem = pedalboard.getItem(currentUiControl.instanceId); + + let uiPlugin = this.getUiPlugin(pedalboardItem.uri); + if (!uiPlugin) return; + + let i = 0; + let ix = -1; + for (i = 0; i < uiPlugin.controls.length; ++i) + { + if (uiPlugin.controls[i].symbol === currentSymbol) { + ix = i; + break; + } + } + if (ix === -1) return; + + ++ix; + if (ix >= uiPlugin.controls.length) return; + + this.zoomUiControl(currentUiControl.source,currentUiControl.instanceId,uiPlugin.controls[ix]); + } + onNextZoomedControl() : void + { + let currentUiControl = this.zoomedUiControl.get(); + if (!currentUiControl) return; + + let currentSymbol = currentUiControl.uiControl.symbol; + + let pedalboard = this.pedalBoard.get(); + if (!pedalboard) return; + + let pedalboardItem = pedalboard.getItem(currentUiControl.instanceId); + + let uiPlugin = this.getUiPlugin(pedalboardItem.uri); + if (!uiPlugin) return; + + let i = 0; + let ix = -1; + for (i = 0; i < uiPlugin.controls.length; ++i) + { + if (uiPlugin.controls[i].symbol === currentSymbol) { + ix = i; + break; + } + } + if (ix === -1) return; + + --ix; + if (ix < 0) return; + + this.zoomUiControl(currentUiControl.source,currentUiControl.instanceId,uiPlugin.controls[ix]); + } + clearZoomedControl(): void { this.zoomedUiControl.set(undefined); } diff --git a/react/src/PluginControl.tsx b/react/src/PluginControl.tsx index 0cab300..5ebe0c3 100644 --- a/react/src/PluginControl.tsx +++ b/react/src/PluginControl.tsx @@ -1,4 +1,4 @@ -// Copyright (c) 2022 Robin Davies + // Copyright (c) 2022 Robin Davies // // Permission is hereby granted, free of charge, to any person obtaining a copy of // this software and associated documentation files (the "Software"), to deal in diff --git a/react/src/ZoomedUiControl.tsx b/react/src/ZoomedUiControl.tsx index 8539d67..dd17d8e 100644 --- a/react/src/ZoomedUiControl.tsx +++ b/react/src/ZoomedUiControl.tsx @@ -17,22 +17,42 @@ // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -import React, {SyntheticEvent} from 'react'; +import React, {ReactNode, SyntheticEvent } from 'react'; +import MenuItem from '@mui/material/MenuItem'; +import Select from '@mui/material/Select'; +import Switch from '@mui/material/Switch'; +import { UiControl, ScalePoint } from './Lv2Plugin'; import { Theme } from '@mui/material/styles'; -import { WithStyles,withStyles } from '@mui/styles'; +import { WithStyles, withStyles } from '@mui/styles'; import createStyles from '@mui/styles/createStyles'; import { ZoomedControlInfo } from './PiPedalModel'; import DialogEx from './DialogEx'; import Typography from '@mui/material/Typography'; -import { PiPedalModelFactory,PiPedalModel } from './PiPedalModel'; +import { PiPedalModelFactory, PiPedalModel } from './PiPedalModel'; import ZoomedDial from './ZoomedDial'; +import IconButton from '@mui/material/IconButton'; +import NavigateBeforeIcon from '@mui/icons-material/NavigateBefore'; +import NavigateNextIcon from '@mui/icons-material/NavigateNext'; const styles = (theme: Theme) => createStyles({ + switchTrack: { + height: '100%', + width: '100%', + borderRadius: 14 / 2, + zIndex: -1, + transition: theme.transitions.create(['opacity', 'background-color'], { + duration: theme.transitions.duration.shortest + }), + backgroundColor: theme.palette.secondary.main, + opacity: theme.palette.mode === 'light' ? 0.38 : 0.3 + } + }); interface ZoomedUiControlProps extends WithStyles { + theme: Theme; dialogOpen: boolean; onDialogClose: () => void; onDialogClosed: () => void; @@ -59,8 +79,7 @@ const ZoomedUiControl = withStyles(styles, { withTheme: true })( model: PiPedalModel; - constructor(props: ZoomedUiControlProps) - { + constructor(props: ZoomedUiControlProps) { super(props); this.model = PiPedalModelFactory.getInstance(); this.state = { @@ -69,25 +88,45 @@ const ZoomedUiControl = withStyles(styles, { withTheme: true })( } getCurrentValue(): number { - if (!this.props.controlInfo) - { + if (!this.props.controlInfo) { return 0; } else { let uiControl = this.props.controlInfo.uiControl; let instanceId = this.props.controlInfo.instanceId; if (instanceId === -1) return 0; let pedalBoardItem = this.model.pedalBoard.get()?.getItem(instanceId); - let value: number = pedalBoardItem?.getControlValue(uiControl.symbol)??0; + let value: number = pedalBoardItem?.getControlValue(uiControl.symbol) ?? 0; return value; } } - hasControlChanged(oldProps: ZoomedUiControlProps, newProps: ZoomedUiControlProps) - { - if (oldProps.controlInfo === null) - { + + + onSelectChanged(val: string | number) { + let v = Number.parseFloat(val.toString()); + this.setState({ value: v }); + if (this.props.controlInfo) { + this.model.setPedalBoardControlValue( + this.props.controlInfo.instanceId, + this.props.controlInfo.uiControl.symbol, + v); + } + } + + onCheckChanged(checked: boolean): void { + let v = checked ? 1: 0; + this.setState({ value: v }); + if (this.props.controlInfo) { + this.model.setPedalBoardControlValue( + this.props.controlInfo.instanceId, + this.props.controlInfo.uiControl.symbol, + v); + } + } + + hasControlChanged(oldProps: ZoomedUiControlProps, newProps: ZoomedUiControlProps) { + if (oldProps.controlInfo === null) { return newProps.controlInfo !== null; - } else if (newProps.controlInfo === null) - { + } else if (newProps.controlInfo === null) { return oldProps.controlInfo !== null; } else { if (newProps.controlInfo?.instanceId !== oldProps.controlInfo?.instanceId) return true; @@ -97,14 +136,11 @@ const ZoomedUiControl = withStyles(styles, { withTheme: true })( } - componentDidUpdate(oldProps: ZoomedUiControlProps, oldState: ZoomedUiControlState) - { - if (this.hasControlChanged(oldProps,this.props)) - { + componentDidUpdate(oldProps: ZoomedUiControlProps, oldState: ZoomedUiControlState) { + if (this.hasControlChanged(oldProps, this.props)) { let currentValue = this.getCurrentValue(); - if (this.state.value !== currentValue) - { - this.setState({value: this.getCurrentValue()}); + if (this.state.value !== currentValue) { + this.setState({ value: this.getCurrentValue() }); } } } @@ -115,46 +151,129 @@ const ZoomedUiControl = withStyles(styles, { withTheme: true })( return false; } + makeSelect(control: UiControl, value: number): ReactNode { + if (control.isOnOffSwitch()) { + // normal gray unchecked state. + return ( + { + this.onCheckChanged(event.target.checked); + }} + /> + ); + } + if (control.isAbToggle()) { + // unchecked color is not gray. + return ( + { + this.onCheckChanged(event.target.checked); + }} + classes={{ + track: this.props.classes.switchTrack + }} + style={{ color: this.props.theme.palette.secondary.main }} + /> + ); + } else { + return ( + + ); + } + } render() { - let displayValue = this.props.controlInfo?.uiControl.formatDisplayValue(this.state.value)??""; + if (!this.props.controlInfo) { + return false; + } + let uiControl = this.props.controlInfo.uiControl; + + let displayValue = uiControl.formatDisplayValue(this.state.value) ?? ""; + if (uiControl.isOnOffSwitch()) + { + displayValue = this.state.value !== 0 ? "On": "Off"; + } else if (uiControl.isSelect()) + { + displayValue = "\u00A0"; + } return ( - { this.props.onDialogClose()}} - onAbort={()=> { this.props.onDialogClose()}} + { this.props.onDialogClose() }} + onAbort={() => { this.props.onDialogClose() }} > -
+ { + this.model.onNextZoomedControl(); + } + } > + + +
- - {this.props.controlInfo?.uiControl.name??""} + + {this.props.controlInfo.name} - { - this.setState({value: v}); - }} - onSetValue={(v)=> { - this.setState({value: v}); - if (this.props.controlInfo) - { - this.model.setPedalBoardControlValue( - this.props.controlInfo.instanceId, - this.props.controlInfo.uiControl.symbol, - v); - } - }} + {uiControl.isDial() ? ( + + { + this.setState({ value: v }); + }} + onSetValue={(v) => { + this.setState({ value: v }); + if (this.props.controlInfo) { + this.model.setPedalBoardControlValue( + this.props.controlInfo.instanceId, + this.props.controlInfo.uiControl.symbol, + v); + } + }} /> - - + ) : +
+ {this.makeSelect(uiControl,this.state.value)} +
+ } + + {displayValue} +
+ { + this.model.onPreviousZoomedControl(); + } + } + > + +
diff --git a/src/main.cpp b/src/main.cpp index 6fc8c76..03d04f7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -423,12 +423,18 @@ public: } std::string GetConfig(const std::string &fromAddress) { - std::string linkLocalAddress = GetLinkLocalAddress(fromAddress); + #define LINK_LOCAL_WEB_SOCKET 1 + #if LINK_LOCAL_WEB_SOCKET + std::string webSocketAddress = GetLinkLocalAddress(fromAddress); + Lv2Log::info(SS("Web Socket Adddress: " << webSocketAddress << ":" << portNumber)); + #else + std::string webSocketAddress = "*"; + #endif std::stringstream s; s << "{ \"socket_server_port\": " << portNumber - << ", \"socket_server_address\": \"" << linkLocalAddress << "\", \"ui_plugins\": [ ], \"max_upload_size\": " << maxUploadSize << " }"; + << ", \"socket_server_address\": \"" << webSocketAddress << "\", \"ui_plugins\": [ ], \"max_upload_size\": " << maxUploadSize << " }"; return s.str(); } From e5eb5007b095fab05c6043c0db8d03ae7a49ca99 Mon Sep 17 00:00:00 2001 From: Robin Davies Date: Tue, 24 May 2022 15:35:00 -0400 Subject: [PATCH 7/7] p2p connection issues More consistent P2P connections. --- src/SetWifiConfig.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SetWifiConfig.cpp b/src/SetWifiConfig.cpp index 52de880..0a7902f 100644 --- a/src/SetWifiConfig.cpp +++ b/src/SetWifiConfig.cpp @@ -488,7 +488,8 @@ void pipedal::SetWifiDirectConfig(const WifiDirectConfigSettings &settings) dhcpcd.InsertLine(line++, "interface p2p-wlan0-0"); dhcpcd.InsertLine(line++, " static ip_address=" P2P_INTERFACE_ADDR); - dhcpcd.InsertLine(line++, " domain_name_servers=" P2P_IP_ADDRESS); + dhcpcd.InsertLine(line++, " nohook wpa_supplicant"); + //dhcpcd.InsertLine(line++, " domain_name_servers=" P2P_IP_ADDRESS); dhcpcd.Save(dhcpcdConfig); }