N1MM has two columns of band buttons beside its entry window, CW in one and phone in the other, with the band the radio is on marked. This has the same. A button does not jump to the band edge every time: BandMemory keeps the frequency the operator was last on for each band and mode, so leaving 20 metres at 14032 and coming back lands on 14032. The first visit to a band starts where that part of it starts, which the band plan says — the bottom edge for CW, the CW-to-phone boundary for phone — and a band the plan says nothing about starts at its bottom edge. Phone picks the sideband the band calls for, so 40 metres is lower sideband and 20 is upper. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
using Nonemm.Core;
|
|
|
|
namespace Nonemm.Session;
|
|
|
|
/// Where the operator was last on each band and mode. The band buttons use it,
|
|
/// so moving to 40 metres and back puts the radio where it was rather than at
|
|
/// the band edge. N1MM remembers the same thing.
|
|
public sealed class BandMemory
|
|
{
|
|
private readonly Dictionary<(string Band, ModeCategory Mode), Frequency> places = [];
|
|
|
|
public void Remember(Frequency frequency, Mode mode)
|
|
{
|
|
if (Bands.ForFrequency(frequency) is { } band)
|
|
{
|
|
places[(band.Name, mode.Category)] = frequency;
|
|
}
|
|
}
|
|
|
|
/// Where to go for that band and mode: where the operator left it, or the
|
|
/// start of that part of the band. A band the plan says nothing about
|
|
/// starts at its bottom edge.
|
|
public Frequency Where(Band band, ModeCategory mode, BandPlan plan)
|
|
{
|
|
if (places.TryGetValue((band.Name, mode), out Frequency remembered))
|
|
{
|
|
return remembered;
|
|
}
|
|
BandSegments? segments = plan.For(band);
|
|
return mode switch
|
|
{
|
|
ModeCategory.Phone when segments is { HasPhone: true } => segments.PhoneLow,
|
|
ModeCategory.Digital when segments is { HasDigital: true } => segments.DigitalLow,
|
|
_ => band.Low,
|
|
};
|
|
}
|
|
}
|