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@77:4689596a2f3f, 2019-03-23 (annotated)
- Committer:
- andrewboyson
- Date:
- Sat Mar 23 12:26:49 2019 +0000
- Revision:
- 77:4689596a2f3f
- Parent:
- 73:4e769dbbf9f2
- Child:
- 87:c51478679090
Changed from using float to using flex for creating left and right aligned lines.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| andrewboyson | 14:c3c43c8faf0e | 1 | #include <time.h> |
| andrewboyson | 14:c3c43c8faf0e | 2 | |
| andrewboyson | 30:6a08abbe6301 | 3 | #include "http.h" |
| andrewboyson | 30:6a08abbe6301 | 4 | #include "page.h" |
| andrewboyson | 30:6a08abbe6301 | 5 | #include "page-derived.h" |
| andrewboyson | 30:6a08abbe6301 | 6 | #include "http-server.h" |
| andrewboyson | 30:6a08abbe6301 | 7 | #include "clk.h" |
| andrewboyson | 30:6a08abbe6301 | 8 | #include "rtc.h" |
| andrewboyson | 30:6a08abbe6301 | 9 | #include "clkutc.h" |
| andrewboyson | 30:6a08abbe6301 | 10 | #include "clkgov.h" |
| andrewboyson | 30:6a08abbe6301 | 11 | #include "scan.h" |
| andrewboyson | 62:74036bb0d1dc | 12 | #include "ntpclient.h" |
| andrewboyson | 14:c3c43c8faf0e | 13 | |
| andrewboyson | 14:c3c43c8faf0e | 14 | void HttpClockHtml() |
| andrewboyson | 14:c3c43c8faf0e | 15 | { |
| andrewboyson | 14:c3c43c8faf0e | 16 | HttpOk("text/html; charset=UTF-8", "no-cache", NULL, NULL); |
| andrewboyson | 30:6a08abbe6301 | 17 | PageAddHeader(PageSite, "Clock", "settings.css", "clock.js"); |
| andrewboyson | 30:6a08abbe6301 | 18 | PageAddNav(CLOCK_PAGE); |
| andrewboyson | 30:6a08abbe6301 | 19 | PageAddH1(PageSite, "Clock"); |
| andrewboyson | 14:c3c43c8faf0e | 20 | |
| andrewboyson | 24:0ed9f1faea96 | 21 | PageAddH2("Status"); |
| andrewboyson | 77:4689596a2f3f | 22 | PageAddAjaxLed("RTC is set" , "ajax-rtc-set" ); |
| andrewboyson | 77:4689596a2f3f | 23 | PageAddAjaxLed("Clock is set" , "ajax-clock-set" ); |
| andrewboyson | 77:4689596a2f3f | 24 | PageAddAjaxLed("External source is ok", "ajax-source-ok" ); |
| andrewboyson | 77:4689596a2f3f | 25 | PageAddAjaxLed("Time synchronised" , "ajax-time-locked"); |
| andrewboyson | 77:4689596a2f3f | 26 | PageAddAjaxLed("Rate synchronised" , "ajax-rate-locked"); |
| andrewboyson | 73:4e769dbbf9f2 | 27 | |
| andrewboyson | 15:2cea2bbd5046 | 28 | PageAddH2("Server UTC time"); |
| andrewboyson | 77:4689596a2f3f | 29 | HttpAddText("<div id='ajax-date-utc'></div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 30 | |
| andrewboyson | 14:c3c43c8faf0e | 31 | PageAddH2("Server local time"); |
| andrewboyson | 77:4689596a2f3f | 32 | HttpAddText("<div id='ajax-date-pc'></div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 33 | |
| andrewboyson | 24:0ed9f1faea96 | 34 | PageAddH2("Server - PC (ms)"); |
| andrewboyson | 77:4689596a2f3f | 35 | HttpAddText("<div id='ajax-date-diff'></div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 36 | |
| andrewboyson | 24:0ed9f1faea96 | 37 | PageAddH2("UTC"); |
| andrewboyson | 77:4689596a2f3f | 38 | PageAddAjaxInputToggle("Enable epoch change" , "ajax-leap-enable" , "chg-clock-leap-enable" ); |
| andrewboyson | 77:4689596a2f3f | 39 | PageAddAjaxInputToggle("Direction of next epoch" , "ajax-leap-forward" , "chg-clock-leap-forward"); |
| andrewboyson | 77:4689596a2f3f | 40 | PageAddAjaxInput ("Year next epoch starts" , 4, "ajax-leap-year" , "set-clock-leap-year" ); |
| andrewboyson | 77:4689596a2f3f | 41 | PageAddAjaxInput ("Month next epoch starts" , 4, "ajax-leap-month" , "set-clock-leap-month" ); |
| andrewboyson | 77:4689596a2f3f | 42 | PageAddAjaxInput ("Current era offset" , 4, "ajax-leap-count" , "set-clock-leap-count" ); |
| andrewboyson | 14:c3c43c8faf0e | 43 | |
| andrewboyson | 22:f45bbb468439 | 44 | HttpAddText("<div><button type='button' onclick='DisplayLeap()'>Display Leap</button></div>\r\n"); |
| andrewboyson | 21:048b7dbdf0aa | 45 | |
| andrewboyson | 22:f45bbb468439 | 46 | 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"); |
| andrewboyson | 14:c3c43c8faf0e | 47 | |
| andrewboyson | 24:0ed9f1faea96 | 48 | PageAddH2("Governer"); |
| andrewboyson | 77:4689596a2f3f | 49 | PageAddAjaxInput("Ppb", 5, "ajax-ppb" , "ppb" ); |
| andrewboyson | 77:4689596a2f3f | 50 | PageAddInputInt ("Ppb divisor", 5, ClkGovFreqDivisor , "/clock", "ppbdivisor" ); |
| andrewboyson | 77:4689596a2f3f | 51 | PageAddInputInt ("Ppb max change", 5, ClkGovFreqChangeMaxPpb , "/clock", "ppbmaxchange" ); |
| andrewboyson | 77:4689596a2f3f | 52 | PageAddInputInt ("Ppb synced limit", 5, ClkGovFreqSyncedLimPpb , "/clock", "syncedlimitppb"); |
| andrewboyson | 77:4689596a2f3f | 53 | PageAddInputInt ("Ppb synced hysteresis", 5, ClkGovFreqSyncedHysPpb , "/clock", "syncedhysppb" ); |
| andrewboyson | 15:2cea2bbd5046 | 54 | |
| andrewboyson | 77:4689596a2f3f | 55 | PageAddInputInt ("Offset divisor", 5, ClkGovSlewDivisor , "/clock", "slewdivisor" ); |
| andrewboyson | 77:4689596a2f3f | 56 | PageAddInputInt ("Offset max (ms)", 5, ClkGovSlewChangeMaxMs , "/clock", "slewmax" ); |
| andrewboyson | 77:4689596a2f3f | 57 | PageAddInputInt ("Offset synced limit (ms)", 5, ClkGovSlewSyncedLimNs / 1000000 , "/clock", "syncedlimitns" ); |
| andrewboyson | 77:4689596a2f3f | 58 | PageAddInputInt ("Offset synced hys (ms)", 5, ClkGovSlewSyncedHysNs / 1000000 , "/clock", "syncedhysns" ); |
| andrewboyson | 77:4689596a2f3f | 59 | PageAddInputInt ("Offset reset limit (s)", 5, ClkGovSlewOffsetMaxSecs , "/clock", "maxoffsetsecs" ); |
| andrewboyson | 20:007fb5796d20 | 60 | |
| andrewboyson | 77:4689596a2f3f | 61 | if (ClkGovTrace) PageAddInputButton("Trace gov is on", "turn off", "/clock", "clockgovtrace"); |
| andrewboyson | 77:4689596a2f3f | 62 | else PageAddInputButton("Trace gov is off", "turn on" , "/clock", "clockgovtrace"); |
| andrewboyson | 15:2cea2bbd5046 | 63 | |
| andrewboyson | 62:74036bb0d1dc | 64 | PageAddH2("NTP"); |
| andrewboyson | 77:4689596a2f3f | 65 | PageAddInputText("Server url", 5, NtpClientQueryServerName, "/clock", "ntpserver" ); |
| andrewboyson | 77:4689596a2f3f | 66 | PageAddInputInt ("Initial interval (s)", 5, NtpClientQueryInitialInterval, "/clock", "clockinitial" ); |
| andrewboyson | 77:4689596a2f3f | 67 | PageAddInputInt ("Normal interval (m)", 5, NtpClientQueryNormalInterval / 60, "/clock", "clocknormal" ); |
| andrewboyson | 77:4689596a2f3f | 68 | PageAddInputInt ("Retry interval (s)", 5, NtpClientQueryRetryInterval, "/clock", "clockretry" ); |
| andrewboyson | 77:4689596a2f3f | 69 | PageAddInputInt ("Offset (ms)", 5, NtpClientReplyOffsetMs, "/clock", "clockoffset" ); |
| andrewboyson | 77:4689596a2f3f | 70 | PageAddInputInt ("Max delay (ms)", 5, NtpClientReplyMaxDelayMs, "/clock", "clockmaxdelay"); |
| andrewboyson | 62:74036bb0d1dc | 71 | |
| andrewboyson | 14:c3c43c8faf0e | 72 | PageAddH2("Scan times"); |
| andrewboyson | 77:4689596a2f3f | 73 | PageAddAjaxLabelled("Program cycles avg", "ajax-scan-avg"); |
| andrewboyson | 77:4689596a2f3f | 74 | PageAddAjaxLabelled("Program cycles max", "ajax-scan-max"); |
| andrewboyson | 77:4689596a2f3f | 75 | PageAddAjaxLabelled("Program cycles min", "ajax-scan-min"); |
| andrewboyson | 14:c3c43c8faf0e | 76 | |
| andrewboyson | 15:2cea2bbd5046 | 77 | PageAddH2("Ajax"); |
| andrewboyson | 15:2cea2bbd5046 | 78 | HttpAddText("<code id='ajax-headers'></code>\r\n"); |
| andrewboyson | 15:2cea2bbd5046 | 79 | HttpAddText("<code id='ajax-response'></code>\r\n"); |
| andrewboyson | 15:2cea2bbd5046 | 80 | |
| andrewboyson | 14:c3c43c8faf0e | 81 | PageAddEnd(); |
| andrewboyson | 14:c3c43c8faf0e | 82 | } |