Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
clock/http-clock-html.c
- Committer:
- andrewboyson
- Date:
- 2019-03-19
- Revision:
- 73:4e769dbbf9f2
- Parent:
- 62:74036bb0d1dc
- Child:
- 77:4689596a2f3f
File content as of revision 73:4e769dbbf9f2:
#include <time.h>
#include "http.h"
#include "page.h"
#include "page-derived.h"
#include "http-server.h"
#include "clk.h"
#include "rtc.h"
#include "clkutc.h"
#include "clkgov.h"
#include "scan.h"
#include "ntpclient.h"
void HttpClockHtml()
{
HttpOk("text/html; charset=UTF-8", "no-cache", NULL, NULL);
PageAddHeader(PageSite, "Clock", "settings.css", "clock.js");
PageAddNav(CLOCK_PAGE);
PageAddH1(PageSite, "Clock");
PageAddH2("Status");
PageAddAjaxLed(10.0, "RTC is set" , "ajax-rtc-set" );
PageAddAjaxLed(10.0, "Clock is set" , "ajax-clock-set" );
PageAddAjaxLed(10.0, "External source is ok", "ajax-source-ok" );
PageAddAjaxLed(10.0, "Time synchronised" , "ajax-time-locked");
PageAddAjaxLed(10.0, "Rate synchronised" , "ajax-rate-locked");
PageAddH2("Server UTC time");
HttpAddText("<div id='date-utc'></div>\r\n");
PageAddH2("Server local time");
HttpAddText("<div id='date-pc'></div>\r\n");
PageAddH2("Server - PC (ms)");
HttpAddText("<div id='date-diff'></div>\r\n");
PageAddH2("UTC");
PageAddAjaxInputToggle(16, "Enable epoch change" , "ajax-leap-enable" , "chg-clock-leap-enable" );
PageAddAjaxInputToggle(16, "Direction of next epoch" , "ajax-leap-forward" , "chg-clock-leap-forward");
PageAddAjaxInput (12, "Year next epoch starts" , 5.2 , "ajax-leap-year" , "set-clock-leap-year" );
PageAddAjaxInput (12, "Month next epoch starts" , 5.2 , "ajax-leap-month" , "set-clock-leap-month" );
PageAddAjaxInput (12, "Current era offset" , 5.2 , "ajax-leap-count" , "set-clock-leap-count" );
HttpAddText("<div><button type='button' onclick='DisplayLeap()'>Display Leap</button></div>\r\n");
HttpAddText("<div>The leap seconds list is available from <a href='https://www.ietf.org/timezones/data/leap-seconds.list' target='_blank'>ietf</a></div>\r\n");
PageAddH2("Governer");
PageAddInputInt (12, "Ppb", 5, ClkGovGetPpb() , "/clock", "ppb" );
PageAddInputInt (12, "Ppb divisor", 5, ClkGovFreqDivisor , "/clock", "ppbdivisor" );
PageAddInputInt (12, "Ppb max change", 5, ClkGovFreqChangeMaxPpb , "/clock", "ppbmaxchange" );
PageAddInputInt (12, "Ppb synced limit", 5, ClkGovFreqSyncedLimPpb , "/clock", "syncedlimitppb");
PageAddInputInt (12, "Ppb synced hysteresis", 5, ClkGovFreqSyncedHysPpb , "/clock", "syncedhysppb" );
PageAddInputInt (12, "Offset divisor", 5, ClkGovSlewDivisor , "/clock", "slewdivisor" );
PageAddInputInt (12, "Offset max (ms)", 5, ClkGovSlewChangeMaxMs , "/clock", "slewmax" );
PageAddInputInt (12, "Offset synced limit (ms)", 5, ClkGovSlewSyncedLimNs / 1000000 , "/clock", "syncedlimitns" );
PageAddInputInt (12, "Offset synced hys (ms)", 5, ClkGovSlewSyncedHysNs / 1000000 , "/clock", "syncedhysns" );
PageAddInputInt (12, "Offset reset limit (s)", 5, ClkGovSlewOffsetMaxSecs , "/clock", "maxoffsetsecs" );
if (ClkGovTrace) PageAddInputButton(10, "Trace gov is on", "turn off", "/clock", "clockgovtrace");
else PageAddInputButton(10, "Trace gov is off", "turn on" , "/clock", "clockgovtrace");
PageAddH2("NTP");
PageAddInputText(12, "Server url", 5, NtpClientQueryServerName, "/clock", "ntpserver" );
PageAddInputInt (12, "Initial interval (s)", 5, NtpClientQueryInitialInterval, "/clock", "clockinitial" );
PageAddInputInt (12, "Normal interval (m)", 5, NtpClientQueryNormalInterval / 60, "/clock", "clocknormal" );
PageAddInputInt (12, "Retry interval (s)", 5, NtpClientQueryRetryInterval, "/clock", "clockretry" );
PageAddInputInt (12, "Offset (ms)", 5, NtpClientReplyOffsetMs, "/clock", "clockoffset" );
PageAddInputInt (12, "Max delay (ms)", 5, NtpClientReplyMaxDelayMs, "/clock", "clockmaxdelay");
PageAddH2("Scan times");
PageAddLabelledInt(17, "Program cycles avg", ScanAverage);
PageAddLabelledInt(17, "Program cycles max", ScanMaximum);
PageAddLabelledInt(17, "Program cycles min", ScanMinimum);
PageAddH2("Ajax");
HttpAddText("<code id='ajax-headers'></code>\r\n");
HttpAddText("<code id='ajax-response'></code>\r\n");
PageAddEnd();
}