diff --git a/static/data-updater.js b/static/data-updater.js
new file mode 100644
index 0000000..fac9d57
--- /dev/null
+++ b/static/data-updater.js
@@ -0,0 +1,34 @@
+const vdd = document.getElementById('vdd');
+const vref = document.getElementById('vref');
+const vadj = document.getElementById('vadj');
+const ts = document.getElementById('timestamp');
+const table = document.getElementById('data');
+
+let old_channel_count=0;
+
+async function update () {
+
+ data = await fetch("/data").then((data)=>{return data.json()});
+ vdd.innerHTML = "VDD: " + parseFloat(data["ratio"]["pivdd"]);
+ vref.innerHTML = "VREF: " + parseFloat(data["ratio"]["vref"]);
+ vadj.innerHTML = "VADJ: " + parseFloat(data["ratio"]["vadj"]);
+ ts.innerHTML = "Last updated: " + data["time"];
+ for (let i=0; i {
+ let unit = e["unit"];
+ let value = e["value"];
+ let channel = e["id"];
+
+ let row = table.insertRow(-1);
+ row.insertCell(0).innerText = channel;
+ row.insertCell(1).innerText = value;
+ row.insertCell(2).innerText = unit;
+ old_channel_count++;
+ });
+}
+update();
+setInterval(update, 1000);
\ No newline at end of file
diff --git a/templates/index.tmpl b/templates/index.tmpl
new file mode 100644
index 0000000..e1ab139
--- /dev/null
+++ b/templates/index.tmpl
@@ -0,0 +1,27 @@
+{{ define "page_index" }}
+
+
+
+
+
+
+ {{ .title }}
+
+
+ TH7
+
+
+ Channel |
+ Value |
+ Unit |
+
+
+ VDD:
+ VREF:
+ VADJ:
+ Last updated:
+
+
+
+
+{{ end }}
\ No newline at end of file
diff --git a/web/gin.go b/web/gin.go
index bb7a227..98c2259 100644
--- a/web/gin.go
+++ b/web/gin.go
@@ -83,6 +83,12 @@ func (g *GinAdapter) DataHandler(c *gin.Context) {
})
}
+func (g *GinAdapter) IndexHandler(c *gin.Context) {
+ c.HTML(http.StatusOK, "page_index", gin.H{
+ "title": "TH7",
+ })
+}
+
func NewGinAdapter(corePort ports.CorePort, port int) *GinAdapter {
var adapter GinAdapter
@@ -97,6 +103,10 @@ func NewGinAdapter(corePort ports.CorePort, port int) *GinAdapter {
adapter.router.GET("/time", adapter.TimestampHandler)
adapter.router.GET("/data", adapter.DataHandler)
+ adapter.router.LoadHTMLGlob("./templates/*.tmpl")
+ adapter.router.Static("/assets", "./static")
+ adapter.router.GET("/", adapter.IndexHandler)
+
return &adapter
}