diff --git a/.gitignore b/.gitignore
index fef79ce..9c8744e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,5 @@
/*.log
/target
/*-init.clj
-/resources/public/js/compiled
-out
resources/public/vendor/*
diff --git a/README.md b/README.md
index befdbc6..8441625 100644
--- a/README.md
+++ b/README.md
@@ -6,6 +6,10 @@ Works well in Chrome and Firefox; not tested in Internet Exploder.

+## Demo site
+
+There's a demo site [here](https://simon-brooke.github.io/swinging-needle-meter/resources/public/index.html).
+
## Intended uses
This is a component for a console, typically one controlling a technical or scientific instrument. It is
@@ -16,6 +20,63 @@ A cursor will be shown if the value of *setpoint* is between *min-value* and *ma
A red-zone may be shown if a *warn-value* is set which is between *min-value* and *max-value*. If such a *warn-value* is set, then if the current value (*model*) exceeds *warn-value*, a class *warning-class* is set on the meter indicating a warning status (by default the frame goes maroon).
+## Usage
+
+In your cljs file, require the following:
+
+```clojure
+ (:require [re-frame.core :as rf]
+ [swinging-needle-meter.swinging-needle-meter :refer [swinging-needle-meter]])
+```
+
+within a [re-com](https://github.com/day8/re-com) component,
+
+```clojure
+ [swinging-needle-meter
+ :model @(rf/subscribe [:old-value])
+ :setpoint @(rf/subscribe [:setpoint]) ;; optional
+ :unit @(rf/subscribe [:unit]) ;; optional
+ :min-value @(rf/subscribe [:min-val]) ;; optional; default 0
+ :warn-value @(rf/subscribe [:warn-val]) ;; optional; default 80
+ :max-value @(rf/subscribe [:max-val]) ;; optional; default 100
+ :tolerance 2 ;; optional; default 3
+ :alarm-class "snm-warning" ;; optional; default "snm-warning"
+ :gradations @(rf/subscribe [:gradations]) ;; optional; default 5
+ :height (int (* @(rf/subscribe [:size]) 6)) ;; optional; default 200 (pixels)
+ :width (int (* @(rf/subscribe [:size]) 10))];; optional; default 300 (pixels)
+```
+
+or, minimally, just
+
+```clojure
+ [swinging-needle-meter
+ :model @(rf/subscribe [:old-value])]
+```
+
+There are further arguments which may be set which are documented
+[here](https://simon-brooke.github.io/swinging-needle-meter/resources/public/index.html#parameters).
+
+Obviously, all the subscriptions above must be registered with `re-frame/reg-sub`. See [re-frame documentation](http://day8.github.io/re-frame/re-frame/).
+
+The value subscribed to as the value to `:model` is expected to be a floating point number between that of `:min-value` and `:max-value`.
+
+### Simulation of a mechanical meter needle with inertia and damping
+
+You don't need animated movement, you can simply jerk the needle to its new position; animation appeals to users who are used to mechanical meters and is easy on the eye, but obviously it means the needle lags a little behind changes in the underlying state.
+
+If you want animation, this is how it works.
+
+The event registered to be driven by `:timer` in `swinging-needle-meter/events.cljs` drives the animation of the movement of the needle. The value of `:timer` is initialised in the state to `(js/Date.)` in `swinging-needle-meter/state.js`. Thus, it's a clock that ticks.
+
+The actual value in the state which is tracked by the meter is the value of, in the example, `:target`. The `:timer` event moves `:old-value` progressively towards `:target` until they coincide. So in a real deployment you'd poll the actual real world value that you were tracking using a repeated asynchronous JSON request, and, on a response to such a request, you would update the value of `:target` in the state.
+
+Obviously, if you want to put multiple meters onto one page tracking different real world variables, you would minimally have to have a separate key in the state for
+
+1. The `target` of each meter;
+2. the `old-value` of each meter (if animation is desired);
+
+You might also want a separate key for the `warn-value` of each meter, and possibly also the `set-point`. Values of other parameters may be subscribed to from values in the state but it will probably be more convenient to hard-wire them or allow them to default.
+
## Development Mode
### Run application:
@@ -31,7 +92,6 @@ Wait a bit, then browse to [http://localhost:3449](http://localhost:3449).
## Production Build
-
To compile clojurescript to javascript:
```
@@ -42,5 +102,5 @@ lein cljsbuild once min
## License
Copyright © 2017 Simon Brooke. Licensed under the GNU General Public License,
version 2.0 or (at your option) any later version. If you wish to incorporate
-parts of Smeagol into another open source project which uses a less restrictive
+parts of this into another open source project which uses a less restrictive
license, please contact me; I'm open to dual licensing it.
diff --git a/index.html b/index.html
new file mode 100644
index 0000000..72e32c5
--- /dev/null
+++ b/index.html
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+ Example swinging needle meter following re-com conventions.
+
+
+
+
+ This isn't actually where you want to be.
+
+
+ If you're seeing this, you probably want to go here.
+
+
+
+
diff --git a/project.clj b/project.clj
index dd955a5..66c795d 100644
--- a/project.clj
+++ b/project.clj
@@ -1,4 +1,4 @@
-(defproject swinging-needle-meter "1.0.0"
+(defproject swinging-needle-meter "1.0.3"
:description "A swinging needle meter, as an experiment in animating SVG from re-frame. Draws heavily on re-com."
:dependencies [[org.clojure/clojure "1.8.0"]
[org.clojure/clojurescript "1.9.229"]
diff --git a/resources/public/css/re-com.css b/resources/public/css/re-com.css
index 026254e..89dd43f 100644
--- a/resources/public/css/re-com.css
+++ b/resources/public/css/re-com.css
@@ -14,7 +14,7 @@
/* The following style addresses: http://stackoverflow.com/questions/28636832/firefox-overflow-y-not-working-with-nested-flexbox */
* {
- min-height: 0px;
+ min-height: 0px;
min-width: 0px;
}
@@ -26,7 +26,7 @@ html, body {
letter-spacing: 0.002em;
height: 100%;
margin: 0px;
- padding: 0px;
+ padding: 0px 5%;
}
/*----------------------------------------------------------------------------------------
diff --git a/resources/public/css/standard.css b/resources/public/css/standard.css
new file mode 100644
index 0000000..e6639b5
--- /dev/null
+++ b/resources/public/css/standard.css
@@ -0,0 +1,282 @@
+/*
+ * Standard.css copied from Smeagol: a very simple Wiki engine
+ * Copyright (C) 2014 Simon Brooke
+
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ * USA.
+ */
+
+body {
+ margin: 0;
+ padding: 0;
+ font-family: sans-serif;
+}
+
+/* ids generally in document order */
+
+/* top-of-page navigation, not editable, provided by Smeagol */
+#nav{
+ margin: 0;
+ padding: 0;
+ top: 0;
+ width: 100%;
+ _position: absolute;
+ _top: expression(document.documentElement.scrollTop);
+ z-index: 149;
+ background:rgba(40, 40, 40,0.8);
+}
+
+#user {
+ font-height: 66%;
+ float: right;
+ padding: 0.1em 0.75em;
+ margin: 0;
+ color: white;
+}
+
+#user a {
+ color: silver;
+}
+
+/* only needed for fly-out menu effect on tablet and phone stylesheets */
+#nav-icon {
+ display: none;
+}
+
+#nav-menu {
+ margin: 0;
+ padding: 0;
+}
+
+#nav ul li {
+ padding: 0;
+ margin: 0;
+ display: inline;
+}
+
+#nav ul li a {
+ color: white;
+ text-decoration: none;
+ font-weight: bold;
+ padding: 0.1em 0.75em;
+ margin: 0;
+}
+
+#nav ul li.active a { background: silver;}
+li.nav-item a:hover { background: rgb( 240, 240, 240) }
+li.nav-item a:active { background: gray; color: white; }
+
+/* header for all pages in the Wiki - editable, provided by users. Within main-container */
+#header {
+ margin-top: 0;
+ width:100%;
+ background-color: gray;
+ color: white;
+}
+
+#header h1 {
+ margin-top: 0;
+}
+
+/* left bar for all pages in the Wiki - editable, provided by users. Within main-container */
+#left-bar {
+ width: 17%;
+ height: 100%;
+ float: left;
+}
+
+/* content of the current in the Wiki - editable, provided by users. Within main-container */
+#content {
+ border: thin solid silver;
+ width: 80%;
+ float: right;
+ padding-bottom: 5em;
+}
+
+/* cookies information box, fixed, in right margin, just above footer */
+#cookies {
+ width: 30%;
+ float: right;
+ position: fixed;
+ bottom: 1.5em;
+ right: 0;
+ z-index: 150;
+ background: transparent;
+}
+
+/* about-cookies box: permanently visible part of cookies information box */
+#about-cookies {
+ clear: right;
+ width: 10em;
+ font-size: 66%;
+ float: right;
+ text-align: right;
+ padding: 0.25em 2em;
+ color: white;
+ background:rgba(40,40,40,0.8);
+}
+
+/* more-about-cookies box, normally hidden */
+#more-about-cookies {
+ display: none;
+ padding: 0.25em 2em;
+ color: white;
+ background:rgba(40,40,40,0.8);
+ border-bottom: thin solid white;
+}
+
+/* but magically appears on mouseover */
+#cookies:hover #more-about-cookies {
+ display: block;
+}
+
+/* footer of the page - not-editable, provided by Smeagol */
+#footer {
+ clear: both;
+ font-size: smaller;
+ text-align: center;
+ color:white;
+ background:rgba(128,128,128,0.95);
+ width: 100%;
+ margin: 0;
+ padding: 0.25em 0;
+ bottom:0;
+ position:fixed;
+ vertical-align: top;
+ z-index:150;
+ _position:absolute;
+ _top: expression(eval(document.documentElement.scrollTop+
+ (document.documentElement.clientHeight-this.offsetHeight)));
+}
+
+
+.change {
+ background-color: rgb( 223, 223, 223);
+ border: thin solid silver;
+}
+
+
+.error {
+ width: 100%;
+ background-color: red;
+ color: white;
+}
+
+.message {
+ border: thin solid red;
+}
+
+.minor-controls {
+ width: 10em;
+ float: right;
+ padding: 0.25em 2em;
+ color: white;
+ background:rgba(40,40,40,0.8);
+ font-size: 66%;
+}
+
+.minor-controls a {
+ float: right;
+ color: white;
+}
+
+.warn {
+ color: maroon;
+}
+
+.widget {
+ background-color: silver;
+ border: thin solid white;
+ margin-top: 0;
+ margin-bottom: 0;
+ width: 100%;
+}
+
+.wiki {
+ margin: 0;
+}
+
+form {
+ border: thin solid silver;
+}
+
+del {
+ color: red;
+}
+
+div.content, form, p, pre, h1, h2, h3, h4, h5 {
+ padding: 0.25em 5%;
+}
+
+dl, menu, ol, table, ul {
+ margin: 0.25em 5%;
+}
+
+input {
+ background-color: white;
+}
+
+input.action {
+ background-color: green;
+}
+
+input.action-dangerous {
+ color: white;
+ background-color: red;
+}
+
+input.required:after {
+ content: " \*";
+ color: red;
+}
+
+ins {
+ color: green;
+}
+
+label {
+ width: 20%;
+ min-width: 20em;
+ border-right: thin solid gray;
+}
+
+menu li {
+ display: inline;
+}
+
+menu li::before {
+ content: "|| ";
+}
+
+table {
+ border: 2px solid black;
+ border-collapse: collapse;
+}
+
+table.music-ruled tr:nth-child(odd) {
+ background-color: silver;
+}
+
+th, td {
+ text-align: left;
+ vertical-align: top;
+ padding: 0.15em 1.5em;
+ border: 1px solid gray;
+}
+
+th {
+ background-color: silver;
+}
+
diff --git a/resources/public/favicon.ico b/resources/public/favicon.ico
new file mode 100644
index 0000000..de48631
Binary files /dev/null and b/resources/public/favicon.ico differ
diff --git a/resources/public/images/credits/cljs-icon.png b/resources/public/images/credits/cljs-icon.png
new file mode 100644
index 0000000..ce45c9e
Binary files /dev/null and b/resources/public/images/credits/cljs-icon.png differ
diff --git a/resources/public/images/credits/clojure-icon.gif b/resources/public/images/credits/clojure-icon.gif
new file mode 100644
index 0000000..84eee16
Binary files /dev/null and b/resources/public/images/credits/clojure-icon.gif differ
diff --git a/resources/public/images/credits/github-logo-transparent.png b/resources/public/images/credits/github-logo-transparent.png
new file mode 100644
index 0000000..6a37959
Binary files /dev/null and b/resources/public/images/credits/github-logo-transparent.png differ
diff --git a/resources/public/images/credits/gnu.small.png b/resources/public/images/credits/gnu.small.png
new file mode 100644
index 0000000..04177f6
Binary files /dev/null and b/resources/public/images/credits/gnu.small.png differ
diff --git a/resources/public/index.html b/resources/public/index.html
index f6f63a4..80b8678 100644
--- a/resources/public/index.html
+++ b/resources/public/index.html
@@ -3,19 +3,35 @@
-
+
-
Example swinging needle meter following re-com conventions.
-
+
+
+ Please be patient...
+
+
+ If you're seeing this, Javascript has not yet loaded. If you continue
+ to see this for more than a minute, it may be that something has broken.
+
+
+