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
http-clock-html.c@24:0ed9f1faea96, 2019-01-10 (annotated)
- Committer:
- andrewboyson
- Date:
- Thu Jan 10 16:08:27 2019 +0000
- Revision:
- 24:0ed9f1faea96
- Parent:
- 22:f45bbb468439
- Child:
- 25:467494781985
Updated clock library
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 | 14:c3c43c8faf0e | 3 | #include "http.h" |
| andrewboyson | 14:c3c43c8faf0e | 4 | #include "page.h" |
| andrewboyson | 14:c3c43c8faf0e | 5 | #include "nav.h" |
| andrewboyson | 14:c3c43c8faf0e | 6 | #include "http-base.h" |
| andrewboyson | 19:598dd2145e84 | 7 | #include "clk.h" |
| andrewboyson | 14:c3c43c8faf0e | 8 | #include "rtc.h" |
| andrewboyson | 19:598dd2145e84 | 9 | #include "clkutc.h" |
| andrewboyson | 19:598dd2145e84 | 10 | #include "clkgov.h" |
| andrewboyson | 14:c3c43c8faf0e | 11 | #include "scan.h" |
| andrewboyson | 14:c3c43c8faf0e | 12 | |
| andrewboyson | 14:c3c43c8faf0e | 13 | void HttpClockHtml() |
| andrewboyson | 14:c3c43c8faf0e | 14 | { |
| andrewboyson | 14:c3c43c8faf0e | 15 | HttpOk("text/html; charset=UTF-8", "no-cache", NULL, NULL); |
| andrewboyson | 14:c3c43c8faf0e | 16 | PageAddHeader(NavSite, "Clock", "settings.css", "clock.js"); |
| andrewboyson | 14:c3c43c8faf0e | 17 | NavAdd(CLOCK_PAGE); |
| andrewboyson | 14:c3c43c8faf0e | 18 | PageAddH1(NavSite, "Clock"); |
| andrewboyson | 14:c3c43c8faf0e | 19 | |
| andrewboyson | 24:0ed9f1faea96 | 20 | PageAddH2("Status"); |
| andrewboyson | 15:2cea2bbd5046 | 21 | PageAddAjaxToggle(10.0, "RTC is set" , "ajax-rtc-set" , ""); |
| andrewboyson | 15:2cea2bbd5046 | 22 | PageAddAjaxToggle(10.0, "Clock is set" , "ajax-clock-set" , ""); |
| andrewboyson | 15:2cea2bbd5046 | 23 | PageAddAjaxToggle(10.0, "External source is ok", "ajax-source-ok" , ""); |
| andrewboyson | 15:2cea2bbd5046 | 24 | PageAddAjaxToggle(10.0, "Rate synchronised" , "ajax-rate-locked", ""); |
| andrewboyson | 15:2cea2bbd5046 | 25 | PageAddAjaxToggle(10.0, "Time synchronised" , "ajax-time-locked", ""); |
| andrewboyson | 15:2cea2bbd5046 | 26 | |
| andrewboyson | 15:2cea2bbd5046 | 27 | PageAddH2("Server UTC time"); |
| andrewboyson | 15:2cea2bbd5046 | 28 | HttpAddText("<div id='date-utc'></div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 29 | |
| andrewboyson | 14:c3c43c8faf0e | 30 | PageAddH2("Server local time"); |
| andrewboyson | 14:c3c43c8faf0e | 31 | HttpAddText("<div id='date-pc'></div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 32 | |
| andrewboyson | 24:0ed9f1faea96 | 33 | PageAddH2("Server - PC (ms)"); |
| andrewboyson | 14:c3c43c8faf0e | 34 | HttpAddText("<div id='date-diff'></div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 35 | |
| andrewboyson | 24:0ed9f1faea96 | 36 | PageAddH2("UTC"); |
| andrewboyson | 24:0ed9f1faea96 | 37 | PageAddAjaxToggle(10.0, "Enable epoch change" , "ajax-leap-enable" , "chg-clock-leap-enable" ); |
| andrewboyson | 24:0ed9f1faea96 | 38 | PageAddAjaxToggle(10.0, "Direction of next epoch" , "ajax-leap-forward" , "chg-clock-leap-forward"); |
| andrewboyson | 24:0ed9f1faea96 | 39 | PageAddAjaxHex ( 6.0, "Year next epoch starts" , 5.2 , "ajax-leap-year" , "set-clock-leap-year" ); |
| andrewboyson | 24:0ed9f1faea96 | 40 | PageAddAjaxHex ( 6.0, "Month next epoch starts" , 5.2 , "ajax-leap-month" , "set-clock-leap-month" ); |
| andrewboyson | 24:0ed9f1faea96 | 41 | PageAddAjaxHex ( 6.0, "Current era offset" , 5.2 , "ajax-leap-count" , "set-clock-leap-count" ); |
| andrewboyson | 14:c3c43c8faf0e | 42 | |
| andrewboyson | 22:f45bbb468439 | 43 | HttpAddText("<div><button type='button' onclick='DisplayLeap()'>Display Leap</button></div>\r\n"); |
| andrewboyson | 21:048b7dbdf0aa | 44 | |
| andrewboyson | 22:f45bbb468439 | 45 | 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 | 46 | |
| andrewboyson | 24:0ed9f1faea96 | 47 | PageAddH2("Governer"); |
| andrewboyson | 19:598dd2145e84 | 48 | PageAddIntInput ("/clock", 0, "Ppb", 12, "ppb", 5, ClkGovGetPpb() ); |
| andrewboyson | 19:598dd2145e84 | 49 | PageAddIntInput ("/clock", 0, "Ppb divisor", 12, "ppbdivisor", 5, ClkGovPpbDivisor ); |
| andrewboyson | 19:598dd2145e84 | 50 | PageAddIntInput ("/clock", 0, "Ppb max change", 12, "ppbmaxchange", 5, ClkGovPpbChangeMax ); |
| andrewboyson | 19:598dd2145e84 | 51 | PageAddIntInput ("/clock", 0, "Ppb synced limit", 12, "syncedlimitppb", 5, ClkGovSyncedLimitPpb ); |
| andrewboyson | 19:598dd2145e84 | 52 | PageAddIntInput ("/clock", 0, "Ppb synced hysteresis", 12, "syncedhysppb", 5, ClkGovSyncedHysterisPpb ); |
| andrewboyson | 15:2cea2bbd5046 | 53 | |
| andrewboyson | 19:598dd2145e84 | 54 | PageAddIntInput ("/clock", 0, "Offset divisor", 12, "slewdivisor", 5, ClkGovSlewDivisor ); |
| andrewboyson | 19:598dd2145e84 | 55 | PageAddIntInput ("/clock", 0, "Offset max (ms)", 12, "slewmax", 5, ClkGovSlewMaxMs ); |
| andrewboyson | 19:598dd2145e84 | 56 | PageAddIntInput ("/clock", 0, "Offset synced limit (ms)",12, "syncedlimitns", 5, ClkGovSyncedLimitNs / 1000000 ); |
| andrewboyson | 19:598dd2145e84 | 57 | PageAddIntInput ("/clock", 0, "Offset synced hys (ms)", 12, "syncedhysns", 5, ClkGovSyncedHysterisNs / 1000000 ); |
| andrewboyson | 19:598dd2145e84 | 58 | PageAddIntInput ("/clock", 0, "Offset reset limit (s)", 12, "maxoffsetsecs", 5, ClkGovMaxOffsetSecs ); |
| andrewboyson | 20:007fb5796d20 | 59 | |
| andrewboyson | 20:007fb5796d20 | 60 | PageAddH2("Trace"); |
| andrewboyson | 20:007fb5796d20 | 61 | if (ClkGovTrace) PageAddCheckInput("/clock", "Trace gov", "clockgovtrace", "on"); |
| andrewboyson | 20:007fb5796d20 | 62 | else PageAddCheckInput("/clock", "Trace gov", "clockgovtrace", "off"); |
| andrewboyson | 15:2cea2bbd5046 | 63 | |
| andrewboyson | 14:c3c43c8faf0e | 64 | PageAddH2("Scan times"); |
| andrewboyson | 14:c3c43c8faf0e | 65 | PageAddLabelledInt("Program cycles avg", 17, ScanAverage); |
| andrewboyson | 14:c3c43c8faf0e | 66 | PageAddLabelledInt("Program cycles max", 17, ScanMaximum); |
| andrewboyson | 14:c3c43c8faf0e | 67 | PageAddLabelledInt("Program cycles min", 17, ScanMinimum); |
| andrewboyson | 14:c3c43c8faf0e | 68 | |
| andrewboyson | 15:2cea2bbd5046 | 69 | PageAddH2("Ajax"); |
| andrewboyson | 15:2cea2bbd5046 | 70 | HttpAddText("<code id='ajax-headers'></code>\r\n"); |
| andrewboyson | 15:2cea2bbd5046 | 71 | HttpAddText("<code id='ajax-response'></code>\r\n"); |
| andrewboyson | 15:2cea2bbd5046 | 72 | |
| andrewboyson | 14:c3c43c8faf0e | 73 | PageAddEnd(); |
| andrewboyson | 14:c3c43c8faf0e | 74 | } |