Skip to content

Commit

Permalink
Merge pull request #243 from neilenns/neilenns/issue242
Browse files Browse the repository at this point in the history
Add option to control how long callsigns stay on the action
  • Loading branch information
neilenns authored Aug 16, 2024
2 parents e712b84 + 4592399 commit bd22b16
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 23 deletions.
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,22 @@ configure the station status action like this to show that RX is enabled and the
### Station status settings <!-- omit from toc -->

| Setting | Description | Default |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| Title | The title to show on the action. Optional. | Station callsign and listen to value |
| Callsign | The callsign for the station you want to display status for. Required. | |
| Listen to | What status to display on the button, either RX, TX, or XCA. Required. | RX |
| Show last callsigns | Sets the number of last received callsigns to display, newest to oldest, and will age off after five minutes. Only supported when listen to is set to `RX` or `XCA`. If set to `0` no last received callsigns will be shown. | `0` |
| Active comms | The image to display when a transmission is actively taking place. Optional. | ![Orange background](docs/images/stationstatus-receiving.png) |
| Listening | The image to display when the station is active. Optional. | ![Green background](docs/images/stationstatus-listening.png) |
| Not listening | The image to display when the station is not currently active. Optional. | ![Black background](docs/images/stationstatus-notlistening.png) |
| Unavailable | The image to display when the station is not added in TrackAudio. Optional, defaults to a warning icon. | ![Warning icon](docs/images/stationstatus-unavailable.png) |
| Show callsign | Show the callsign on the action. | false |
| Show frequency | Show the callsign's frequency on the action. | false |
| Show last received callsign | Show the last received callsign on the action. | true |
| Show listen to | Show the listen to value on the action. | false |
| Show title | Show the title on the action. | true |
| Setting | Description | Default |
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| Title | The title to show on the action. Optional. | Station callsign and listen to value |
| Callsign | The callsign for the station you want to display status for. Required. | |
| Listen to | What status to display on the button, either RX, TX, or XCA. Required. | RX |
| Show last callsigns | Sets the number of last received callsigns to display, newest to oldest, and will age off after five minutes. Only supported when listen to is set to `RX` or `XCA`. If set to `0` no last received callsigns will be shown. | `0` |
| Active comms | The image to display when a transmission is actively taking place. Optional. | ![Orange background](docs/images/stationstatus-receiving.png) |
| Listening | The image to display when the station is active. Optional. | ![Green background](docs/images/stationstatus-listening.png) |
| Not listening | The image to display when the station is not currently active. Optional. | ![Black background](docs/images/stationstatus-notlistening.png) |
| Unavailable | The image to display when the station is not added in TrackAudio. Optional, defaults to a warning icon. | ![Warning icon](docs/images/stationstatus-unavailable.png) |
| Show callsign | Show the callsign on the action. | false |
| Show frequency | Show the callsign's frequency on the action. | false |
| Show last received callsign | Show the last received callsign on the action. | true |
| Show listen to | Show the listen to value on the action. | false |
| Show title | Show the title on the action. | true |
| Clear callsigns after (minutes) | How long to leave callsigns displayed before they age off. Set to 0 to persist callsigns until they are pushed by newer callsigns. | 3 minutes |

## Configuring a hotline action

Expand Down
14 changes: 14 additions & 0 deletions com.neil-enns.trackaudio.sdPlugin/pi/stationStatus.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@
label="Show title"
default="true"
></sdpi-checkbox>

<sdpi-item
label="Clear callsigns after (minutes)"
style="text-align: right"
>
<sdpi-range
setting="clearAfterInMinutes"
min="0"
max="5"
step="1"
default="2"
showlabels
></sdpi-range>
</sdpi-item>
</details>
</sdpi-item>

Expand Down
13 changes: 7 additions & 6 deletions src/actions/stationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,17 @@ export class StationStatus extends SingletonAction<StationSettings> {
}

export interface StationSettings {
title?: string;
clearAfterInMinutes?: number;
activeCommsImagePath?: string;
callsign?: string;
lastReceivedCallsignCount?: number;
listeningImagePath?: string;
listenTo: ListenTo | null;
notListeningImagePath?: string;
listeningImagePath?: string;
activeCommsImagePath?: string;
unavailableImagePath?: string;
showTitle?: boolean;
showCallsign?: boolean;
showFrequency?: boolean;
showListenTo?: boolean;
lastReceivedCallsignCount?: number;
showTitle?: boolean;
title?: string;
unavailableImagePath?: string;
}
12 changes: 10 additions & 2 deletions src/controllers/stationStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ export class StationStatusController extends BaseController {
return (this.settings.lastReceivedCallsignCount ?? 0) > 0;
}

/**
* Returns the number of minutes to clear callsigns after, or three if it wasn't defined
* by the user in settings.
*/
get clearAfterInMinutes() {
return this.settings.clearAfterInMinutes ?? 3;
}

/**
* Gets the settings.
*/
Expand All @@ -254,11 +262,11 @@ export class StationStatusController extends BaseController {

this._settings = newValue;

// Recreate the last received callsign cache with the new length
// Recreate the last received callsign cache with the new length and TTL
if ((this._settings.lastReceivedCallsignCount ?? 0) > 0) {
this._lastReceivedCallsignHistory = new LRUCache<string, string>({
max: this._settings.lastReceivedCallsignCount,
ttl: 1000 * 60 * 5, // 10 seconds
ttl: this.clearAfterInMinutes * 60 * 1000, // Convert minutes to milliseconds. If this is zero it automatically disables TTL.
ttlAutopurge: true,
allowStale: false,
disposeAfter: (
Expand Down

0 comments on commit bd22b16

Please sign in to comment.