This commit is contained in:
Robin Davies
2022-04-30 09:06:40 -04:00
parent 179ff9c276
commit f0f075ae4e
16 changed files with 209 additions and 77 deletions
+2 -2
View File
@@ -1,10 +1,10 @@
cmake_minimum_required(VERSION 3.16.0)
project(pipedal
VERSION 0.1.8
VERSION 0.1.9
DESCRIPTION "PiPedal Guitar Effect Pedal For Raspberry Pi"
HOMEPAGE_URL "https://rerdavies.github.io/pipedal"
)
set (DISPLAY_VERSION "v0.1.8-beta-4")
set (DISPLAY_VERSION "v0.1.9-beta-5")
set (CMAKE_INSTALL_PREFIX "/usr/")
+1 -1
View File
@@ -1,7 +1,7 @@
<img src='docs/GithubBanner.png' width="100%" />
Download: <a href='docs/download.md'>v0.1.8-beta-4</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Website: [https://rerdavies.github.io/pipedal](https://rerdavies.github.io/pipedal).
Download: <a href='docs/download.md'>v0.1.9-beta-5</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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.
+2 -2
View File
@@ -4,14 +4,14 @@
Download the most recent Debian (.deb) package for your platform:
- [Raspberry Pi OS (64-bit) v0.1.8-beta-4](https://github.com/rerdavies/pipedal/releases/download/v0.1.8-beta-4/pipedal_0.1.8_arm64.deb)
- [Raspberry Pi OS (64-bit) v0.1.9-beta-5](https://github.com/rerdavies/pipedal/releases/download/v0.1.9-beta-5/pipedal_0.1.9_arm64.deb)
Install the package by running
```
sudo apt update
cd ~/Downloads
sudo apt-get install ./pipedal_0.1.8_arm64.deb
sudo apt-get install ./pipedal_0.1.9_arm64.deb
```
After installing, follow the instructions in [Configuring PiPedal after Installation](Configuring.md).
+2 -2
View File
@@ -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.1.8-beta-4/pipedal_0.1.8_arm64.deb) v0.1.8-beta-4
- [Ubuntu or Raspberry Pi OS (64-bit)](https://github.com/rerdavies/pipedal/releases/download/v0.1.9-beta-5/pipedal_0.1.9_arm64.deb) v0.1.9-beta-5
Install the package by running
```
sudo apt update
cd ~/Downloads
sudo apt-get install ./pipedal_0.1.8_arm64.deb
sudo apt-get install ./pipedal_0.1.9_arm64.deb
```
Follow the instructions in [_Configuring PiPedal After Installation_](https://rerdavies.github.io/pipedal/Configuring.html) to complete the installation.
+1 -1
View File
@@ -1,7 +1,7 @@
<img src="GithubBanner.png" width="100%"/>
<a href="Installing.html"><i>v0.1.8-beta-4</i></a>
<a href="Installing.html"><i>v0.1.9-beta-5</i></a>
Use your Raspberry Pi as a guitar effects pedal. Configure and control PiPedal with your phone or tablet.
+1 -1
View File
@@ -31,7 +31,7 @@
-->
<title>PiPedal</title>
</head>
<body>
<body style="background: #D0D0D0">
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
+1 -1
View File
@@ -1,5 +1,5 @@
{
"socket_server_port": 80,
"socket_server_port": 8080,
"socket_server_address": "*",
"debug": true,
"max_upload_size": 1048576,
+14 -3
View File
@@ -264,6 +264,7 @@ type AppState = {
presetChanged: boolean;
banks: BankIndex;
bankDisplayItems: number;
showStatusMonitor: boolean;
};
interface AppProps extends WithStyles<typeof appStyles> {
}
@@ -309,7 +310,8 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
bankDialogOpen: false,
editBankDialogOpen: false,
zoomedControlOpen: false,
bankDisplayItems: 5
bankDisplayItems: 5,
showStatusMonitor: this.model_.showStatusMonitor.get()
};
@@ -319,6 +321,7 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
this.alertMessageChangedHandler = this.alertMessageChangedHandler.bind(this);
this.handleCloseAlert = this.handleCloseAlert.bind(this);
this.banksChangedHandler = this.banksChangedHandler.bind(this);
this.showStatusMonitorHandler = this.showStatusMonitorHandler.bind(this);
}
@@ -450,6 +453,11 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
handleCloseAlert(e?: any, reason?: any) {
this.model_.alertMessage.set("");
}
showStatusMonitorHandler() {
this.setState({
showStatusMonitor: this.model_.showStatusMonitor.get()
});
}
banksChangedHandler() {
this.setState({
banks: this.model_.banks.get()
@@ -484,6 +492,7 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
this.model_.pedalBoard.addOnChangedHandler(this.presetChangedHandler);
this.model_.alertMessage.addOnChangedHandler(this.alertMessageChangedHandler);
this.model_.banks.addOnChangedHandler(this.banksChangedHandler);
this.model_.showStatusMonitor.addOnChangedHandler(this.showStatusMonitorHandler);
this.alertMessageChangedHandler();
}
@@ -508,7 +517,8 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
this.model_.errorMessage.removeOnChangedHandler(this.errorChangeHandler_);
this.model_.state.removeOnChangedHandler(this.stateChangeHandler_);
this.model_.pedalBoard.removeOnChangedHandler(this.presetChangedHandler);
this.model_.banks.addOnChangedHandler(this.banksChangedHandler);
this.model_.banks.removeOnChangedHandler(this.banksChangedHandler);
this.model_.banks.removeOnChangedHandler(this.showStatusMonitorHandler);
}
@@ -814,7 +824,8 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
</Button>
</DialogActions>
</Dialog>
<JackStatusView />
{ this.state.showStatusMonitor && (<JackStatusView />) }
<div className={classes.errorContent} style={{
display: (this.state.displayState === State.Reconnecting || this.state.displayState === State.ApplyingChanges)
? "block" : "none"
+38 -23
View File
@@ -314,7 +314,8 @@ export interface PiPedalModel {
serverVersion?: PiPedalVersion;
errorMessage: ObservableProperty<string>;
alertMessage: ObservableProperty<string>;
showStatusMonitor: ObservableProperty<boolean>;
setShowStatusMonitor(show: boolean): void;
state: ObservableProperty<State>;
visibilityState: ObservableProperty<VisibilityState>;
@@ -458,6 +459,9 @@ class PiPedalModelImpl implements PiPedalModel {
errorMessage: ObservableProperty<string> = new ObservableProperty<string>("");
alertMessage: ObservableProperty<string> = new ObservableProperty<string>("");
showStatusMonitor: ObservableProperty<boolean> = new ObservableProperty<boolean>(true);
pedalBoard: ObservableProperty<PedalBoard> = new ObservableProperty<PedalBoard>(new PedalBoard());
plugin_classes: ObservableProperty<PluginClass> = new ObservableProperty<PluginClass>(new PluginClass());
jackConfiguration: ObservableProperty<JackConfiguration> = new ObservableProperty<JackConfiguration>(new JackConfiguration());
@@ -512,8 +516,7 @@ class PiPedalModelImpl implements PiPedalModel {
onSocketReconnecting(retry: number, maxRetries: number): void {
if (this.visibilityState.get() === VisibilityState.Hidden) return;
//if (retry !== 0) {
if (this.restartExpected)
{
if (this.restartExpected) {
this.setState(State.ApplyingChanges);
} else {
this.setState(State.Reconnecting);
@@ -563,6 +566,9 @@ class PiPedalModelImpl implements PiPedalModel {
if (!this.compareFavorites(favorites, this.favorites.get())) {
this.favorites.set(favorites);
}
} else if (message === "onShowStatusMonitorChanged") {
let value = body as boolean;
this.showStatusMonitor.set(value);
} else if (message === "onChannelSelectionChanged") {
let channelSelectionBody = body as ChannelSelectionChangedBody;
let channelSelection = new JackChannelSelection().deserialize(channelSelectionBody.jackChannelSelection);
@@ -655,7 +661,7 @@ class PiPedalModelImpl implements PiPedalModel {
}
} else {
throw new PiPedalStateError("Unrecognized message received from server.");
throw new PiPedalStateError("Unrecognized message received from server: " + message);
}
}
setError(message: string): void {
@@ -708,15 +714,13 @@ class PiPedalModelImpl implements PiPedalModel {
}
onSocketConnectionLost() {
if (this.isAndroidHosted())
{
if (this.isAndroidHosted()) {
this.androidHost?.setDisconnected(true);
}
}
onSocketReconnected() {
if (this.isAndroidHosted())
{
if (this.isAndroidHosted()) {
this.androidHost?.setDisconnected(false);
}
@@ -732,6 +736,11 @@ class PiPedalModelImpl implements PiPedalModel {
.then(data => {
this.pedalBoard.set(new PedalBoard().deserialize(data));
return this.getWebSocket().request<boolean>("getShowStatusMonitor");
})
.then(data => {
this.showStatusMonitor.set(data);
return this.getWebSocket().request<any>("getWifiConfigSettings");
})
.then(data => {
@@ -833,13 +842,13 @@ class PiPedalModelImpl implements PiPedalModel {
this.webSocket = new PiPedalSocket(
this.socketServerUrl,
{
onMessageReceived : this.onSocketMessage,
onMessageReceived: this.onSocketMessage,
onError: this.onSocketError,
onConnectionLost: this.onSocketConnectionLost,
onReconnect: this.onSocketReconnected,
onReconnect: this.onSocketReconnected,
onReconnecting: this.onSocketReconnecting
}
);
);
return this.webSocket.connect();
})
.then(() => {
@@ -856,6 +865,7 @@ class PiPedalModelImpl implements PiPedalModel {
})
.then((clientId) => {
this.clientId = clientId;
return this.getWebSocket().request<string>("imageList");
})
.then((data) => {
@@ -907,7 +917,11 @@ class PiPedalModelImpl implements PiPedalModel {
.then(data => {
this.governorSettings.set(new GovernorSettings().deserialize(data));
return this.getWebSocket().request<boolean>("getShowStatusMonitor");
})
.then(data => {
this.showStatusMonitor.set(data);
return this.getWebSocket().request<any>("getJackServerSettings");
})
.then(data => {
@@ -976,11 +990,10 @@ class PiPedalModelImpl implements PiPedalModel {
}
backgroundStateTimeout?: NodeJS.Timeout = undefined;
backgroundStateTimeout?: NodeJS.Timeout = undefined;
exitBackgroundState() {
if (this.backgroundStateTimeout)
{
if (this.backgroundStateTimeout) {
clearTimeout(this.backgroundStateTimeout);
this.backgroundStateTimeout = undefined;
return;
@@ -996,10 +1009,8 @@ class PiPedalModelImpl implements PiPedalModel {
// on Android, delay entering background state by 3 seconds,
// so that screen-flips don't trigger disconnects.
if (this.isAndroidHosted())
{
if (this.backgroundStateTimeout)
{
if (this.isAndroidHosted()) {
if (this.backgroundStateTimeout) {
clearTimeout(this.backgroundStateTimeout);
}
this.backgroundStateTimeout = setTimeout(() => {
@@ -1009,7 +1020,7 @@ class PiPedalModelImpl implements PiPedalModel {
} else {
this.enterBackgroundState_();
}
}
}
enterBackgroundState_() {
if (this.state.get() !== State.Background) {
console.log("Entering background state.");
@@ -1181,6 +1192,7 @@ class PiPedalModelImpl implements PiPedalModel {
}
}
setPedalBoardControlValue(instanceId: number, key: string, value: number): void {
this._setPedalBoardControlValue(instanceId, key, value, true);
}
@@ -1219,6 +1231,10 @@ class PiPedalModelImpl implements PiPedalModel {
}
setShowStatusMonitor(show: boolean): void {
this.webSocket?.send("setShowStatusMonitor", show);
}
loadPedalBoardPlugin(itemId: number, selectedUri: string): number {
let pedalBoard = this.pedalBoard.get();
if (pedalBoard === undefined) throw new PiPedalArgumentError("Can't clone an undefined object.");
@@ -1497,7 +1513,7 @@ class PiPedalModelImpl implements PiPedalModel {
expectRestart() {
this.restartExpected = true;
}
setJackSettings(jackSettings: JackChannelSelection): void {
@@ -2108,8 +2124,7 @@ class PiPedalModelImpl implements PiPedalModel {
isAndroidHosted(): boolean { return this.androidHost !== undefined; }
showAndroidDonationActivity(): void {
if (this.androidHost)
{
if (this.androidHost) {
this.androidHost.showSponsorship();
}
}
+46 -20
View File
@@ -18,6 +18,7 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
import React, { SyntheticEvent, Component } from 'react';
import Switch from "@mui/material/Switch";
import OkCancelDialog from './OkCancelDialog';
import ListSelectDialog from './ListSelectDialog';
import IconButton from '@mui/material/IconButton';
@@ -56,6 +57,8 @@ interface SettingsDialogProps extends WithStyles<typeof styles> {
};
interface SettingsDialogState {
showStatusMonitor: boolean;
showStatusMonitorDialog: boolean;
jackConfiguration: JackConfiguration;
jackSettings: JackChannelSelection;
jackServerSettings: JackServerSettings;
@@ -153,6 +156,9 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
this.handleDialogClose = this.handleDialogClose.bind(this);
this.state = {
showStatusMonitor: this.model.showStatusMonitor.get(),
showStatusMonitorDialog: false,
jackServerSettings: this.model.jackServerSettings.get(),
jackConfiguration: this.model.jackConfiguration.get(),
jackStatus: undefined,
@@ -183,10 +189,15 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
this.handleWifiDirectConfigSettingsChanged = this.handleWifiDirectConfigSettingsChanged.bind(this);
this.handleGovernorSettingsChanged = this.handleGovernorSettingsChanged.bind(this);
this.handleConnectionStateChanged = this.handleConnectionStateChanged.bind(this);
this.handleShowStatusMonitorChanged = this.handleShowStatusMonitorChanged.bind(this);
}
handleShowStatusMonitorChanged(): void {
this.setState({ showStatusMonitor: this.model.showStatusMonitor.get() });
}
handleConnectionStateChanged(): void {
if (this.model.state.get() === State.Ready) {
this.setState({ isAndroidHosted: this.model.isAndroidHosted() });
@@ -290,6 +301,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
this.active = active;
if (active) {
this.model.state.addOnChangedHandler(this.handleConnectionStateChanged);
this.model.showStatusMonitor.addOnChangedHandler(this.handleShowStatusMonitorChanged);
this.model.jackSettings.addOnChangedHandler(this.handleJackSettingsChanged);
this.model.jackConfiguration.addOnChangedHandler(this.handleJackConfigurationChanged);
this.model.jackServerSettings.addOnChangedHandler(this.handleJackServerSettingsChanged);
@@ -312,6 +324,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
this.handleConnectionStateChanged();
this.handleJackConfigurationChanged();
this.handleJackSettingsChanged();
this.handleShowStatusMonitorChanged();
this.handleJackServerSettingsChanged();
this.handleWifiConfigSettingsChanged();
this.handleWifiDirectConfigSettingsChanged();
@@ -321,6 +334,8 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
clearInterval(this.timerHandle);
}
this.model.state.removeOnChangedHandler(this.handleConnectionStateChanged);
this.model.showStatusMonitor.removeOnChangedHandler(this.handleShowStatusMonitorChanged);
this.model.jackConfiguration.removeOnChangedHandler(this.handleJackConfigurationChanged);
this.model.jackSettings.removeOnChangedHandler(this.handleJackSettingsChanged);
this.model.jackServerSettings.removeOnChangedHandler(this.handleJackServerSettingsChanged);
@@ -436,7 +451,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
});
}
handleRestart() {
this.setState({showRestartOkDialog: true});
this.setState({ showRestartOkDialog: true });
}
handleRestartOk() {
this.setState({ restarting: true });
@@ -452,7 +467,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
}
handleShutdown() {
this.setState({ showShutdownOkDialog: true});
this.setState({ showShutdownOkDialog: true });
}
handleShutdownOk() {
this.setState({ shuttingDown: true });
@@ -525,7 +540,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
)
}
<Divider/>
<Divider />
<Typography className={classes.sectionHead} display="block" variant="caption" color="secondary">
AUDIO
</Typography>
@@ -592,7 +607,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
this.state.isAndroidHosted &&
(
<ButtonBase className={classes.setting} disabled={!this.state.wifiConfigSettings.valid}
onClick={() => this.model.chooseNewDevice() } >
onClick={() => this.model.chooseNewDevice()} >
<SelectHoverBackground selected={false} showHover={true} />
<div style={{ width: "100%" }}>
<Typography className={classes.primaryItem} display="block" variant="body2" color="textPrimary" noWrap>
@@ -606,7 +621,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
)
}
<ButtonBase
<ButtonBase
className={classes.setting} disabled={!this.state.wifiConfigSettings.valid}
onClick={() => this.handleShowWifiDirectConfigDialog()} >
<SelectHoverBackground selected={false} showHover={true} />
@@ -654,16 +669,28 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
</ButtonBase>
<ButtonBase
className={classes.setting} disabled={!this.state.wifiConfigSettings.valid}
onClick={() => { } } >
className={classes.setting}
onClick={() => { this.setState({ showStatusMonitorDialog: true }); }} >
<SelectHoverBackground selected={false} showHover={true} />
<div style={{ width: "100%" }}>
<Typography className={classes.primaryItem} display="block" variant="body2" color="textPrimary" noWrap>
Show status monitor on main screen.</Typography>
<Typography display="block" variant="caption" noWrap color="textSecondary">
Enabled
</Typography>
<div style={{
width: "100%", display: "flex", flexDirection: "row", flexWrap: "nowrap",
alignItems: "center", maxWidth: 400
}}>
<div style={{ flex: "1 1 auto" }}>
<Typography className={classes.primaryItem} display="block" variant="body2" color="textPrimary" noWrap>
Show status monitor on main screen.</Typography>
</div>
<div style={{ flex: "0 0 auto" }}>
<Switch
checked={this.state.showStatusMonitor}
onChange={
(e) => { this.model.setShowStatusMonitor(e.target.checked); }
}
/>
</div>
</div>
</div>
</ButtonBase>
@@ -735,7 +762,6 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
>
</ListSelectDialog>
)
}
{
(this.state.showMidiSelectDialog) &&
@@ -756,15 +782,15 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
onClose={() => this.setState({ showWifiDirectConfigDialog: false })}
onOk={(wifiDirectConfigSettings: WifiDirectConfigSettings) => this.handleApplyWifiDirectConfig(wifiDirectConfigSettings)}
/>
<OkCancelDialog text="Are you sure you want to reboot?" okButtonText='Reboot'
<OkCancelDialog text="Are you sure you want to reboot?" okButtonText='Reboot'
open={this.state.showRestartOkDialog}
onOk={()=> { this.setState({showRestartOkDialog: false}); this.handleRestartOk();}}
onClose={()=> { this.setState({showRestartOkDialog: false}); } }
onOk={() => { this.setState({ showRestartOkDialog: false }); this.handleRestartOk(); }}
onClose={() => { this.setState({ showRestartOkDialog: false }); }}
/>
<OkCancelDialog text="Are you sure you want to shut down?" okButtonText='Shut down'
<OkCancelDialog text="Are you sure you want to shut down?" okButtonText='Shut down'
open={this.state.showShutdownOkDialog}
onOk={()=> { this.setState({showShutdownOkDialog: false}); this.handleShutdownOk();}}
onClose={()=> { this.setState({showShutdownOkDialog: false}); } }
onOk={() => { this.setState({ showShutdownOkDialog: false }); this.handleShutdownOk(); }}
onClose={() => { this.setState({ showShutdownOkDialog: false }); }}
/>
</DialogEx >
+4 -6
View File
@@ -29,6 +29,8 @@
using namespace pipedal;
using namespace std;
const bool ENABLE_KEEP_ALIVE = false;
using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
const size_t MAX_READ_SIZE = 1 * 1024 * 204;
@@ -164,8 +166,7 @@ namespace pipedal
virtual const std::string &get(const std::string &key) const { return m_request.get_header(key); }
virtual bool keepAlive() const
{
m_request.get_version() != "1.0" || m_request.get_header("Connection") == "keep-alive";
return true;
return ENABLE_KEEP_ALIVE && (m_request.get_version() != "1.0" || m_request.get_header("Connection") == "keep-alive");
}
};
class HttpResponseImpl : public HttpResponse
@@ -187,7 +188,7 @@ namespace pipedal
virtual void setBody(const std::string &body) { request.set_body(body); }
virtual void keepAlive(bool value)
{
if (!value)
if ((!value) || (!ENABLE_KEEP_ALIVE))
{
set("Connection", "close");
}
@@ -418,9 +419,6 @@ namespace pipedal
if (requestHandler->wants(req.method(), requestUri))
{
try
{
+30
View File
@@ -735,6 +735,36 @@ WifiDirectConfigSettings PiPedalModel::GetWifiDirectConfigSettings()
return this->storage.GetWifiDirectConfigSettings();
}
void PiPedalModel::SetShowStatusMonitor(bool show)
{
IPiPedalModelSubscriber **t;
size_t n;
{
std::lock_guard<std::recursive_mutex> guard(mutex); // copy atomically.
t = new IPiPedalModelSubscriber *[this->subscribers.size()];
n = this->subscribers.size();
storage.SetShowStatusMonitor(show);
// Notify clients.
IPiPedalModelSubscriber **t = new IPiPedalModelSubscriber *[this->subscribers.size()];
for (size_t i = 0; i < subscribers.size(); ++i)
{
t[i] = this->subscribers[i];
}
for (size_t i = 0; i < n; ++i)
{
t[i]->OnShowStatusMonitorChanged(show);
}
delete[] t;
}
}
bool PiPedalModel::GetShowStatusMonitor()
{
std::lock_guard<std::recursive_mutex> guard(mutex); // copy atomically.
return storage.GetShowStatusMonitor();
}
JackConfiguration PiPedalModel::GetJackConfiguration()
{
std::lock_guard<std::recursive_mutex> guard(mutex); // copy atomically.
+4
View File
@@ -67,6 +67,7 @@ public:
virtual void OnWifiDirectConfigSettingsChanged(const WifiDirectConfigSettings&wifiDirectConfigSettings) = 0;
virtual void OnGovernorSettingsChanged(const std::string &governor) = 0;
virtual void OnFavoritesChanged(const std::map<std::string,bool> &favorites) = 0;
virtual void OnShowStatusMonitorChanged(bool show) = 0;
virtual void Close() = 0;
};
@@ -214,6 +215,9 @@ public:
void SetJackChannelSelection(int64_t clientId,const JackChannelSelection &channelSelection);
JackChannelSelection GetJackChannelSelection();
void SetShowStatusMonitor(bool show);
bool GetShowStatusMonitor();
void SetWifiConfigSettings(const WifiConfigSettings&wifiConfigSettings);
WifiConfigSettings GetWifiConfigSettings();
+15
View File
@@ -924,6 +924,16 @@ public:
pReader->read(&jackSettings);
this->model.SetJackChannelSelection(this->clientId, jackSettings);
}
else if (message == "setShowStatusMonitor")
{
bool showStatusMonitor;
pReader->read(&showStatusMonitor);
this->model.SetShowStatusMonitor(showStatusMonitor);
}
else if (message == "getShowStatusMonitor")
{
Reply(replyTo,"getShowStatusMonitor",this->model.GetShowStatusMonitor());
}
else if (message == "version")
{
PiPedalVersion version(this->model);
@@ -1255,6 +1265,11 @@ public:
{
Send("onFavoritesChanged",favorites);
}
virtual void OnShowStatusMonitorChanged(bool show) {
Send("onShowStatusMonitorChanged",show);
}
virtual void OnChannelSelectionChanged(int64_t clientId, const JackChannelSelection &channelSelection)
{
ChannelSelectionChangedBody body;
+32 -13
View File
@@ -33,7 +33,9 @@ const char *BANK_EXTENSION = ".bank";
const char *BANKS_FILENAME = "index.banks";
#define WIFI_CONFIG_SETTINGS_FILENAME "wifiConfigSettings.json";
#define GOVERNOR_SETTINGS_FILENAME "governorSettings.json";
#define USER_SETTINGS_FILENAME "userSettings.json";
Storage::Storage()
{
@@ -228,7 +230,7 @@ void Storage::Initialize()
}
LoadWifiConfigSettings();
LoadWifiDirectConfigSettings();
LoadGovernorSettings();
LoadUserSettings();
}
@@ -854,9 +856,14 @@ int64_t Storage::UploadBank(BankFile&bankFile,int64_t uploadAfter)
return lastBank;
}
void Storage::SetGovernorSettings(const std::string & governor)
{
std::filesystem::path path = this->dataRoot / GOVERNOR_SETTINGS_FILENAME;
userSettings.governor_ = governor;
SaveUserSettings();
}
void Storage::SaveUserSettings() {
std::filesystem::path path = this->dataRoot / USER_SETTINGS_FILENAME;
{
std::ofstream f(path);
if (!f.is_open())
@@ -864,13 +871,22 @@ void Storage::SetGovernorSettings(const std::string & governor)
throw PiPedalException("Unable to write to " + ((std::string)path));
}
json_writer writer(f);
writer.write(governor);
this->governorSettings = governor;
writer.write(userSettings);
}
}
void Storage::SetShowStatusMonitor(bool show)
{
this->userSettings.showStatusMonitor_ = show;
SaveUserSettings();
}
bool Storage::GetShowStatusMonitor() const
{
return this->userSettings.showStatusMonitor_;
}
std::string Storage::GetGovernorSettings() const
{
return this->governorSettings;
return this->userSettings.governor_;
}
@@ -925,9 +941,9 @@ void Storage::SetWifiDirectConfigSettings(const WifiDirectConfigSettings & wifiD
this->wifiDirectConfigSettings = copyToStore;
}
void Storage::LoadGovernorSettings()
void Storage::LoadUserSettings()
{
std::filesystem::path path = this->dataRoot / GOVERNOR_SETTINGS_FILENAME;
std::filesystem::path path = this->dataRoot / USER_SETTINGS_FILENAME;
try {
if (std::filesystem::is_regular_file(path))
@@ -935,16 +951,13 @@ void Storage::LoadGovernorSettings()
std::ifstream f(path);
if (!f.is_open())
{
throw PiPedalException("Unable to write to " + ((std::string)path));
throw PiPedalException("Unable to read from " + ((std::string)path));
}
json_reader reader(f);
std::string governorSettings;
reader.read(&governorSettings);
this->governorSettings = governorSettings;
reader.read(&userSettings);
}
} catch (const std::exception&)
{
this->governorSettings = "performance";
}
this->wifiConfigSettings.valid_ = true;
@@ -1293,6 +1306,12 @@ void Storage::SetFavorites(const std::map<std::string,bool>&favorites) {
}
JSON_MAP_BEGIN(UserSettings)
JSON_MAP_REFERENCE(UserSettings,governor)
JSON_MAP_REFERENCE(UserSettings,showStatusMonitor)
JSON_MAP_END()
JSON_MAP_BEGIN(CurrentPreset)
JSON_MAP_REFERENCE(CurrentPreset,modified)
JSON_MAP_REFERENCE(CurrentPreset,preset)
+16 -2
View File
@@ -41,6 +41,15 @@ public:
DECLARE_JSON_MAP(CurrentPreset);
};
class UserSettings {
public:
std::string governor_ = "performance";
bool showStatusMonitor_ = true;
DECLARE_JSON_MAP(UserSettings);
};
// controls user-defined storage. Implmentation hidden to allow to later migration to a database (perhaps)
class Storage {
@@ -77,7 +86,8 @@ private:
JackChannelSelection jackChannelSelection;
WifiConfigSettings wifiConfigSettings;
WifiDirectConfigSettings wifiDirectConfigSettings;
std::string governorSettings = "performance";
UserSettings userSettings;
public:
Storage();
void Initialize();
@@ -93,7 +103,8 @@ public:
void LoadWifiConfigSettings();
void LoadWifiDirectConfigSettings();
void LoadGovernorSettings();
void LoadUserSettings();
void SaveUserSettings();
void LoadBank(int64_t instanceId);
const PedalBoard& GetCurrentPreset();
void SaveCurrentPreset(const PedalBoard&pedalBoard);
@@ -154,6 +165,9 @@ public:
std::map<std::string,bool> GetFavorites() const;
void SetFavorites(const std::map<std::string,bool>&favorites);
void SetShowStatusMonitor(bool show);
bool GetShowStatusMonitor() const;
};