A GPS disciplined clock

Dependencies:   net lpc1768 crypto clock web log

Committer:
andrewboyson
Date:
Thu Jan 17 13:43:35 2019 +0000
Revision:
27:eb5728b9052b
Child:
28:7fb6b4e9ab80
Updated http-base library

Who changed what in which revision?

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