Skip to content

Commit

Permalink
Add an auto-set listen mode setting to status actions
Browse files Browse the repository at this point in the history
Fixes #297
  • Loading branch information
neilenns committed Nov 23, 2024
1 parent 2be36ee commit e21d219
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 6 additions & 0 deletions com.neil-enns.trackaudio.sdPlugin/pi/stationStatus.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@
label="Automatically enable speaker mode"
></sdpi-checkbox>

<summary>Advanced options</summary>
<sdpi-checkbox
setting="autoSetRx"
label="Automatically set Rx mode"
></sdpi-checkbox>

<sdpi-checkbox
setting="showCallsign"
label="Show callsign"
Expand Down
3 changes: 2 additions & 1 deletion src/actions/stationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ export class StationStatus extends SingletonAction<StationSettings> {
}

export interface StationSettings {
autoSetSpk?: boolean;
autoSetListen?: boolean;
autoSetRx?: boolean;
blockedCommsImagePath?: string;
activeCommsImagePath?: string;
callsign?: string;
Expand Down
9 changes: 8 additions & 1 deletion src/controllers/stationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,17 @@ export class StationStatusController extends BaseController {
/**
* Returns the autoSetSpk setting, or false if undefined.
*/
get autoAddSpk() {
get autoSetSpk() {
return this.settings.autoSetSpk ?? false;
}

/**
* Returns the autoSetRx setting, or false if undefined.
*/
get autoSetRx() {
return this.settings.autoSetRx ?? false;
}

/**
* Returns the showTitle setting, or true if undefined.
*/
Expand Down
6 changes: 4 additions & 2 deletions src/managers/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,17 @@ class ActionManager extends EventEmitter {
this.getStationStatusControllers()
.filter((entry) => entry.frequency === frequency)
.forEach((entry) => {
// Set up the base message to send.
const update = {
type: "kSetStationState",
value: {
frequency: entry.frequency,
headset: !entry.autoAddSpk, // Headset is the opposite of speaker, so invert the value
headset: entry.autoSetSpk ? false : undefined, // Headset is the opposite of speaker, so use false to turn on speaker.
rx: entry.autoSetRx ? true : undefined,
},
} as SetStationState;

if (entry.settings.autoSetSpk) {
if (entry.autoSetSpk || entry.autoSetRx) {
trackAudioManager.sendMessage(update);
}
});
Expand Down

0 comments on commit e21d219

Please sign in to comment.