Skip to content

Commit

Permalink
Save radio gain in config
Browse files Browse the repository at this point in the history
  • Loading branch information
pierr3 committed Apr 27, 2024
1 parent 3430074 commit e5f392c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
31 changes: 20 additions & 11 deletions src/app/components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from "react";
import React, { useEffect, useState } from "react";
import "../style/navbar.scss";
import Clock from "./clock";
import SettingsModal from "./settings-modal/settings-modal";
Expand Down Expand Up @@ -40,6 +40,16 @@ const Navbar: React.FC = () => {
state.setStationCallsign,
]);

useEffect(() => {
window.api.getConfig().then((config) => {
if (config) {
window.api.SetRadioGain((config.radioGain || 0.5)).then(() => {
setRadioGain(config.radioGain*100 || 50);
});
}
});
}, []);

const doConnect = () => {
setIsConnecting(true);
window.api.connect().then((ret) => {
Expand Down Expand Up @@ -145,17 +155,16 @@ const Navbar: React.FC = () => {
max="100"
step="1"
onChange={handleRadioGainChange}
defaultValue={radioGain}
></input>
{
platform === "linux" && (
<button
className="btn btn-danger m-2 hide-gain-value"
onClick={() => window.api.CloseMe()}
>
X
</button>
)
}
{platform === "linux" && (
<button
className="btn btn-danger m-2 hide-gain-value"
onClick={() => window.api.CloseMe()}
>
X
</button>
)}
</div>
{showModal && <SettingsModal closeModal={() => setShowModal(false)} />}
</>
Expand Down
1 change: 1 addition & 0 deletions src/config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export interface Configuration {

pttKey: number;
hardwareType: number;
radioGain: number;
}
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ let currentConfiguration: Configuration = {
callsign: "",
pttKey: 0,
hardwareType: 0,
radioGain: 0,
};
const store = new Store();

Expand Down Expand Up @@ -297,6 +298,8 @@ ipcMain.handle("setup-ptt", () => {

ipcMain.handle("set-radio-gain", (_, gain: number) => {
TrackAudioAfv.SetRadioGain(gain);
currentConfiguration.radioGain = gain;
saveConfig();
});

ipcMain.handle("set-hardware-type", (_, type: number) => {
Expand Down

0 comments on commit e5f392c

Please sign in to comment.