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@14:c3c43c8faf0e, 2018-12-29 (annotated)
- Committer:
- andrewboyson
- Date:
- Sat Dec 29 19:01:39 2018 +0000
- Revision:
- 14:c3c43c8faf0e
- Child:
- 15:2cea2bbd5046
Simplified and tidied. Most things now called HTTP rather than HTML.
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 | 14:c3c43c8faf0e | 7 | #include "clock.h" |
| andrewboyson | 14:c3c43c8faf0e | 8 | #include "rtc.h" |
| andrewboyson | 14:c3c43c8faf0e | 9 | #include "clkstate.h" |
| andrewboyson | 14:c3c43c8faf0e | 10 | #include "scan.h" |
| andrewboyson | 14:c3c43c8faf0e | 11 | |
| andrewboyson | 14:c3c43c8faf0e | 12 | void HttpClockHtml() |
| andrewboyson | 14:c3c43c8faf0e | 13 | { |
| andrewboyson | 14:c3c43c8faf0e | 14 | HttpOk("text/html; charset=UTF-8", "no-cache", NULL, NULL); |
| andrewboyson | 14:c3c43c8faf0e | 15 | PageAddHeader(NavSite, "Clock", "settings.css", "clock.js"); |
| andrewboyson | 14:c3c43c8faf0e | 16 | NavAdd(CLOCK_PAGE); |
| andrewboyson | 14:c3c43c8faf0e | 17 | PageAddH1(NavSite, "Clock"); |
| andrewboyson | 14:c3c43c8faf0e | 18 | |
| andrewboyson | 14:c3c43c8faf0e | 19 | PageAddH2("Sync status"); |
| andrewboyson | 14:c3c43c8faf0e | 20 | if (! RtcIsSet()) HttpAddText("<div>RTC is not set!</div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 21 | if (!ClockIsSet()) HttpAddText("<div>Clock is not set!</div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 22 | PageAddAjaxToggle(10.0, "PPS is stable", "ajax-pps-stable", ""); |
| andrewboyson | 14:c3c43c8faf0e | 23 | PageAddAjaxToggle(10.0, "Rate synchronised", "ajax-rate-locked", ""); |
| andrewboyson | 14:c3c43c8faf0e | 24 | PageAddAjaxToggle(10.0, "Time synchronised", "ajax-time-locked", ""); |
| andrewboyson | 14:c3c43c8faf0e | 25 | |
| andrewboyson | 14:c3c43c8faf0e | 26 | PageAddH2("Server local time"); |
| andrewboyson | 14:c3c43c8faf0e | 27 | HttpAddText("<div id='date-pc'></div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 28 | |
| andrewboyson | 14:c3c43c8faf0e | 29 | PageAddH2("Server UTC time"); |
| andrewboyson | 14:c3c43c8faf0e | 30 | HttpAddText("<div id='date-utc'></div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 31 | |
| andrewboyson | 14:c3c43c8faf0e | 32 | PageAddH2("Server - PC"); |
| andrewboyson | 14:c3c43c8faf0e | 33 | HttpAddText("<div id='date-diff'></div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 34 | PageAddH2("Ajax"); |
| andrewboyson | 14:c3c43c8faf0e | 35 | HttpAddText("<code id='ajax-headers'></code>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 36 | HttpAddText("<code id='ajax-response'></code>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 37 | |
| andrewboyson | 14:c3c43c8faf0e | 38 | PageAddH2("Leap seconds"); |
| andrewboyson | 14:c3c43c8faf0e | 39 | PageAddAjaxToggle(10.0, "Next leap enable" , "ajax-leap-enable" , "chg-clock-leap-enable" ); |
| andrewboyson | 14:c3c43c8faf0e | 40 | PageAddAjaxToggle(10.0, "Next leap backward" , "ajax-leap-backward", "chg-clock-leap-backward"); |
| andrewboyson | 14:c3c43c8faf0e | 41 | PageAddAjaxHex ( 6.0, "Next Year" , 5.2 , "ajax-leap-year" , "set-clock-leap-year" ); |
| andrewboyson | 14:c3c43c8faf0e | 42 | PageAddAjaxHex ( 6.0, "Next Month" , 5.2 , "ajax-leap-month" , "set-clock-leap-month" ); |
| andrewboyson | 14:c3c43c8faf0e | 43 | PageAddAjaxHex ( 6.0, "Count" , 5.2 , "ajax-leap-count" , "set-clock-leap-count" ); |
| andrewboyson | 14:c3c43c8faf0e | 44 | |
| andrewboyson | 14:c3c43c8faf0e | 45 | HttpAddText("<button type='button' onclick='DisplayLeap()'>Display Leap</button>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 46 | |
| andrewboyson | 14:c3c43c8faf0e | 47 | PageAddH2("Time"); |
| andrewboyson | 14:c3c43c8faf0e | 48 | struct tm tm; |
| andrewboyson | 14:c3c43c8faf0e | 49 | ClockTmUtc(&tm); |
| andrewboyson | 14:c3c43c8faf0e | 50 | HttpAddText("<div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 51 | PageAddTm(&tm); |
| andrewboyson | 14:c3c43c8faf0e | 52 | HttpAddText("</div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 53 | ClockTmLocal(&tm); |
| andrewboyson | 14:c3c43c8faf0e | 54 | HttpAddText("<div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 55 | PageAddTm(&tm); |
| andrewboyson | 14:c3c43c8faf0e | 56 | HttpAddText("</div>\r\n"); |
| andrewboyson | 14:c3c43c8faf0e | 57 | PageAddLabelledInt("Freq ppb", 17, ClockPpb); |
| andrewboyson | 14:c3c43c8faf0e | 58 | |
| andrewboyson | 14:c3c43c8faf0e | 59 | PageAddH2("Scan times"); |
| andrewboyson | 14:c3c43c8faf0e | 60 | PageAddLabelledInt("Program cycles avg", 17, ScanAverage); |
| andrewboyson | 14:c3c43c8faf0e | 61 | PageAddLabelledInt("Program cycles max", 17, ScanMaximum); |
| andrewboyson | 14:c3c43c8faf0e | 62 | PageAddLabelledInt("Program cycles min", 17, ScanMinimum); |
| andrewboyson | 14:c3c43c8faf0e | 63 | |
| andrewboyson | 14:c3c43c8faf0e | 64 | PageAddEnd(); |
| andrewboyson | 14:c3c43c8faf0e | 65 | } |