Skip to content

Commit 2a9ef09

Browse files
committed
fix ft4 sequencing
1 parent 61ad561 commit 2a9ef09

File tree

12 files changed

+133
-30
lines changed

12 files changed

+133
-30
lines changed

SkyRoof/DSP/Slicer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public Slicer(double inputRate, double frequencyOffset = 0, Mode mode = Mode.USB
6363

6464
public void SetOffset(double offset)
6565
{
66+
if (!Enabled) return;
6667
this.offset = offset;
6768
if (CurrentMode != Mode.CW) offset += ModeOffsets[(int)CurrentMode];
6869
NativeLiquidDsp.nco_crcf_set_frequency(FirstMixer, (float)(Geo.TwoPi * offset / InputRate));

SkyRoof/FT4/Ft4QsoSequencer.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public Ft4QsoSequencer(string call, string square)
3535

3636
public void Reset()
3737
{
38-
LastHisCall = HisCall;
38+
if (!string.IsNullOrEmpty(HisCall)) LastHisCall = HisCall;
3939

4040
HisCall = null;
4141
HisSquare = null;
@@ -73,8 +73,6 @@ public bool ProcessMessage(DecodedItem item, bool forceReply)
7373

7474
GenerateMessages();
7575

76-
//var oldMessageType = MessageType;
77-
7876
// I am calling him
7977
if (item.Parse.DXCallsign != MyCall)
8078
MessageType = Ft4MessageType.DE;
@@ -86,7 +84,7 @@ public bool ProcessMessage(DecodedItem item, bool forceReply)
8684
// the rest: reply with next message type
8785
MessageType = hisMessageType + 1;
8886

89-
return true; // MessageType != oldMessageType;
87+
return true;
9088
}
9189

9290
// user clicked on a message type button

SkyRoof/FT4/NativeFT4Coder.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public enum QsoStage
3434

3535
public const int MAX_CALL_LENGTH = 12;
3636
public const long SLOTS_PER_DAY = 11520; // 86400 / 7.5
37+
public const int TIME_SLOTS_PER_MINUTE = 4;
3738

3839
[DllImport("ft4_coder", CallingConvention = CallingConvention.Cdecl)]
3940
public static extern void encode_ft4(byte[] message, ref float txAudioFrequency, float[] audioSamples);

SkyRoof/Forms/MainForm.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private void MainForm_Load(object sender, EventArgs e)
7373
VersionChecker.UpdateAvailable += UpdateAvailable_handler;
7474
VersionChecker.CheckVersionAsync().DoNotAwait();
7575

76-
ctx.AmsatStatusLoader.GetStatusesAsync();
76+
ctx.AmsatStatusLoader.GetStatusesAsync().DoNotAwait();
7777
}
7878

7979
private void UpdateAvailable_handler(object? sender, EventArgs e)
@@ -85,6 +85,7 @@ private void UpdateAvailable_handler(object? sender, EventArgs e)
8585
private void MainForm_FormClosing(object sender, EventArgs e)
8686
{
8787
timer.Enabled = false;
88+
if (ctx.Slicer != null) ctx.Slicer.Enabled = false;
8889

8990
// save settings
9091
ctx.Settings.Ui.StoreDockingLayout(DockHost);

SkyRoof/Panels/Ft4ConsolePanel.cs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,10 @@ private void Ft4Sender_AfterTransmit(object? sender, EventArgs e)
494494
TxCountdown = 0;
495495
Sender.Stop();
496496
QsoInfo qso = GetQsoInfo();
497+
bool newQso = Sequencer.LastHisCall != Sequencer.HisCall;
498+
if (newQso) ctx.LoqFt4QsoDialog.PopUp(ctx, qso);
497499
Sequencer.Reset();
498500
Sender.SetMessage(Sequencer.Message!);
499-
ctx.LoqFt4QsoDialog.PopUp(ctx, qso);
500501
}
501502
}
502503

@@ -537,6 +538,7 @@ private QsoInfo GetQsoInfo()
537538
//--------------------------------------------------------------------------------------------------------------
538539
// sequencer
539540
//--------------------------------------------------------------------------------------------------------------
541+
// any received message
540542
private void RxMessageToSequencer(DecodedItem message)
541543
{
542544
if (Sender.Mode != SenderMode.Sending) return;
@@ -545,6 +547,7 @@ private void RxMessageToSequencer(DecodedItem message)
545547
if (Sequencer.ProcessMessage(message, false)) SetTxMessage(Sender.TxOdd);
546548
}
547549

550+
// click on someone's message
548551
private void MessageListWidget_MessageClick(object sender, Ft4MessageEventArgs e)
549552
{
550553
if (e.Item.FromMe && ModifierKeys == Keys.Control)
@@ -555,6 +558,7 @@ private void MessageListWidget_MessageClick(object sender, Ft4MessageEventArgs e
555558
SetTxMessage(!e.Item.Odd);
556559
}
557560

561+
// message selection buttons
558562
private void MessageBtn_Click(object sender, EventArgs e)
559563
{
560564
if (!CheckTxEnabled()) return;
@@ -566,6 +570,7 @@ private void MessageBtn_Click(object sender, EventArgs e)
566570
private void SetTxMessage(bool odd)
567571
{
568572
bool wasSending = Sender.SenderPhase == SendingStage.Sending;
573+
bool oddChanged = Sender.TxOdd != odd;
569574

570575
Sender.TxOdd = odd;
571576

@@ -582,45 +587,47 @@ private void SetTxMessage(bool odd)
582587
}
583588

584589
Sender.SetMessage(Sequencer.Message!);
590+
if (wasSending && oddChanged) Sender.Stop();
585591
Sender.StartSending();
586-
TxCountdown = ctx.Settings.Ft4Console.Transmit.TxWatchDog * 4;
592+
TxCountdown = ctx.Settings.Ft4Console.Transmit.TxWatchDog * NativeFT4Coder.TIME_SLOTS_PER_MINUTE;
587593

588594
TxMessageLabel.Text = Sequencer.Message!;
589595
UpdateTxButtons();
590596
UpdateMessageButtons();
591597
UpdateControls();
592598
ctx.MainForm.FrequencyWidget.SetXit(Sender.XitOffset);
593599

594-
if (wasSending)
600+
// changing the message on the fiy, show it in the list
601+
if (wasSending && !oddChanged)
595602
{
596603
var item = MakeTxItem();
597604
AddTxMessageToList(item);
598605
SaveMessageToFile(item);
599606
}
600607
}
601608

602-
public void TestQDateTime()
603-
{
604-
for (int h = 0; h < 48; h += 6)
605-
{
606-
var utc = DateTime.UtcNow.Date + TimeSpan.FromHours(h);
609+
//public void TestQDateTime()
610+
//{
611+
// for (int h = 0; h < 48; h += 6)
612+
// {
613+
// var utc = DateTime.UtcNow.Date + TimeSpan.FromHours(h);
607614

608-
// c# write
609-
long julianDay = (long)Math.Floor(utc.ToOADate()) + 2415019;
610-
uint milliseconds = (uint)(utc.TimeOfDay.TotalMilliseconds);
615+
// // c# write
616+
// long julianDay = (long)Math.Floor(utc.ToOADate()) + 2415019;
617+
// uint milliseconds = (uint)(utc.TimeOfDay.TotalMilliseconds);
611618

612-
// c# original read
613-
var date = DateTime.FromOADate(julianDay - 2415018.5).Date;
614-
DateTime outUtc = date.AddMilliseconds(milliseconds);
619+
// // c# original read
620+
// var date = DateTime.FromOADate(julianDay - 2415018.5).Date;
621+
// DateTime outUtc = date.AddMilliseconds(milliseconds);
615622

616-
// Delphi read
617-
double delphiDouble = julianDay - 2415019 + milliseconds / 86400000d;
618-
DateTime delphiUtc = DateTime.SpecifyKind(DateTime.FromOADate(delphiDouble), DateTimeKind.Unspecified);
623+
// // Delphi read
624+
// double delphiDouble = julianDay - 2415019 + milliseconds / 86400000d;
625+
// DateTime delphiUtc = DateTime.SpecifyKind(DateTime.FromOADate(delphiDouble), DateTimeKind.Unspecified);
619626

620627

621-
Debug.WriteLine($"{utc:yyyy-MM-dd HH:mm} {julianDay,10} {milliseconds / 86400000d:F3} c#: {outUtc:yyyy-MM-dd HH:mm} Delphi: {delphiDouble:F3} {delphiUtc:yyyy-MM-dd HH:mm}");
622-
}
623-
}
628+
// Debug.WriteLine($"{utc:yyyy-MM-dd HH:mm} {julianDay,10} {milliseconds / 86400000d:F3} c#: {outUtc:yyyy-MM-dd HH:mm} Delphi: {delphiDouble:F3} {delphiUtc:yyyy-MM-dd HH:mm}");
629+
// }
630+
//}
624631

625632

626633

SkyRoof/Widgets/FrequencyScale.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public double PixelToNominalFreq(SatellitePass pass, DateTime time, int x)
8787
//----------------------------------------------------------------------------------------------
8888
// paint
8989
//----------------------------------------------------------------------------------------------
90-
// todo: simplied draw when only the green rect moves
90+
// todo: simplify draw when only the green rect moves
9191
private void FrequencyScale_Paint(object sender, PaintEventArgs e)
9292
{
9393
var g = e.Graphics;

SkyRoof/Widgets/Ft4MessageListWidget.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private int FindInsertionPoint(DecodedItem item)
221221
public void AddMessage(DecodedItem item)
222222
{
223223
int index = FindInsertionPoint(item);
224-
listBox.Items.Insert(index, item); // todo: remove IF
224+
listBox.Items.Insert(index, item);
225225
}
226226

227227
// sending message
@@ -386,8 +386,8 @@ private void ShowTooltip(string? title, string? tooltip)
386386

387387
private void ShowSeparatorTooltip(DecodedItem hotItem)
388388
{
389-
string title = (hotItem.Odd ? "Odd (2-nd)" : "Even (1-st)");
390-
string tooltip = string.Format("slot {0} {1:%h} hours {1:%m} minutes ago",
389+
string title = hotItem.Odd ? "Odd (2-nd)" : "Even (1-st)";
390+
string tooltip = string.Format("slot {0}\n{1:%h} hours {1:%m} minutes ago",
391391
hotItem.SlotNumber % NativeFT4Coder.SLOTS_PER_DAY, DateTime.UtcNow - hotItem.Utc);
392392
ShowTooltip(title, tooltip);
393393
}

docs/images/ft4_console.png

105 KB
Loading

docs/images/ft4_uplink_offset.png

43.9 KB
Loading

docs/images/ft4_wide_waterfall.png

60.5 KB
Loading

0 commit comments

Comments
 (0)