palm-client: clock line on Node (Visor, UTC, offset, radio, system pref)
The radio clock stays ~9 h behind although Settings shows UTC -5: at connect it was set to Visor time minus 5 h, i.e. an offset of +5 was in effect, and later saves read the radio clock without setting it. Rather than guess, Node now shows the Visor's clock, the computed UTC and the offset in effect, the radio's clock as last read, and Palm OS's prefMinutesWestOfGMT (the offset's default).
This commit is contained in:
1 parent
157646e093
commit
fa11770c13
3 files changed
+53
-1
No files matched your search
@@ -9,6 +9,7 @@
|
||||
#include "session.h"
|
||||
#include "app.h"
|
||||
#include "node_form.h"
|
||||
#include "ui/draw.h"
|
||||
|
||||
#define VM_LABEL_CHARS 22 /* the info labels in the .rcp are padded to this width */
|
||||
|
||||
@@ -70,6 +71,41 @@ static void ShowRadioInfo(FormType *form)
|
||||
CtlSetLabel(FrmGetObjectPtr(form, FrmGetObjectIndex(form, MainConnectButton)), "Disconnect");
|
||||
}
|
||||
|
||||
/*
|
||||
* Clock check, small font, under the radio details:
|
||||
* Visor 17:02 UTC 22:02 (-5h)
|
||||
* radio 11:57 UTC sys -300
|
||||
* "sys" is Palm OS's own minutes-west-of-GMT preference (the offset's default).
|
||||
*/
|
||||
static void DrawClockLine(void)
|
||||
{
|
||||
DateTimeType dt;
|
||||
RectangleType r;
|
||||
Char line[48], utc[8], radio[8];
|
||||
UInt32 now = TimGetSeconds();
|
||||
Int16 off = SessionUtcOffset();
|
||||
UInt32 rt = SessionRadioTime();
|
||||
FontID old = FntSetFont(vmSmallFont);
|
||||
|
||||
RctSetRectangle(&r, 0, 104, 160, 20);
|
||||
WinEraseRectangle(&r, 0);
|
||||
TimSecondsToDateTime(SessionNow() + 2082844800UL, &dt);
|
||||
StrPrintF(utc, "%02u:%02u", dt.hour, dt.minute);
|
||||
TimSecondsToDateTime(now, &dt);
|
||||
StrPrintF(line, "Visor %02u:%02u UTC %s (%s%d:%02dh)", dt.hour, dt.minute, utc,
|
||||
off < 0 ? "-" : "+", (off < 0 ? -off : off) / 60, (off < 0 ? -off : off) % 60);
|
||||
WinDrawChars(line, StrLen(line), 5, 105);
|
||||
if (rt) {
|
||||
TimSecondsToDateTime(rt + 2082844800UL, &dt);
|
||||
StrPrintF(radio, "%02u:%02u", dt.hour, dt.minute);
|
||||
} else {
|
||||
StrCopy(radio, "--:--");
|
||||
}
|
||||
StrPrintF(line, "radio %s UTC sys %ld", radio, (Int32)PrefGetPreference(prefMinutesWestOfGMT));
|
||||
WinDrawChars(line, StrLen(line), 5, 113);
|
||||
FntSetFont(old);
|
||||
}
|
||||
|
||||
static FormType *gStatusForm;
|
||||
|
||||
static void ShowStatus(const Char *text)
|
||||
@@ -90,6 +126,7 @@ static void ConnectOrDisconnect(FormType *form)
|
||||
gStatusForm = form;
|
||||
err = AppConnect(ShowStatus, true);
|
||||
ShowRadioInfo(form);
|
||||
DrawClockLine();
|
||||
if (err != errNone) {
|
||||
AppErrorText(err, msg);
|
||||
SetLabel(form, MainNameLabel, msg);
|
||||
@@ -127,10 +164,12 @@ Boolean NodeFormHandleEvent(EventType *event)
|
||||
FrmSetControlGroupSelection(form, MainLinkGroup, link);
|
||||
ShowRadioInfo(form);
|
||||
FrmDrawForm(form);
|
||||
DrawClockLine();
|
||||
return true;
|
||||
}
|
||||
case frmUpdateEvent:
|
||||
ShowRadioInfo(form);
|
||||
DrawClockLine();
|
||||
return true;
|
||||
|
||||
case ctlSelectEvent:
|
||||
|
||||
Reference in new issue
Block a user