summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore4
-rw-r--r--Makefile4
-rw-r--r--README86
-rw-r--r--freack_gen.hs32
4 files changed, 126 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..6d14492
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.o
+*.hi
+.*.swp
+freack_gen
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..fe71899
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+all: freack_gen
+
+freack_gen: freack_gen.hs
+ ghc --make $< -o $@
diff --git a/README b/README
new file mode 100644
index 0000000..391d04b
--- /dev/null
+++ b/README
@@ -0,0 +1,86 @@
+A compiler for the Speevers Click'n'Play light ball system.
+
+A Click'n'Play ball has a micro-USB port in its side. This port is used
+for charging. If you connect it to a computer with a data cable it
+exposes a device with a single FAT partition (no partition table).
+
+It has a single file called "SPEEVERS.fls". This is the program that the
+ball uses.
+
+The site to generate such files: http://www.speevers.com/freack .
+
+As a last resort, there is a small reset button hidden on the board
+(near the LEDs. At least on one of the sides).
+
+== Structure
+
+=== Colors
+Color sequences are represented by integers, built of two words:
+length and color.
+
+* Length: miliseconds
+* Color
+ * Blue: 0c
+ * Red: c0
+ * Green: 30
+* Each of those has two bits. Is there a single bit for the LED of each
+ side?
+* Other colors are combinations of the basic colors:
+ * Black (none): 00
+ * Magenta: cc (red + blue)
+ * Turqoise: 3c (red + green)
+ * Yellow: f0 (red + green)
+ * White: fc (red + green + blue)
+
+=== Single Color
+
+5aa5 SDLY 0101 0101 0001 0000 0000 0000
+0000 0000 0001 CLN1 0008 0001 CLR1
+
+CLR1: sequence of colors.
+
+CLN1: length of CLR1 (in integers)
+
+SDLY: integer. shutdown delay, in seconds
+
+=== Two Colors
+5aa5 SDLY 0101 0101 0001 0000 0000 0000
+0000 0000 0002 CLN1 000e CNT1 CLN2 0010
+CNT2 CLR1 CLR2
+
+=== Three Colors
+
+5aa5 SDLY 0101 0101 0001 0000 0000 0000
+0000 0000 0003 CLN1 0014 CNT1 CLN2 0016
+CNT2 CLN3 001a CNT3 CLR1 CLR2 CLR3
+
+=== Four Colors
+5aa5 SDLY 0101 0101 0001 0000 0000 0000
+0000 0000 0004 CLN1 001a CNT1 CLN2 001c
+CNT2 CLN3 001e CNT3 CLN4 0022 CNT4 CLR1
+CLR2 CLR3 CLR4
+
+=== Five Colors
+5aa5 SDLY 0101 0101 0001 0000 0000 0000
+0000 0000 0005 CLN1 0020 CNT1 CLN2 0022
+CNT2 CLN3 0024 CNT3 CLN4 0026 CNT4 CLN5
+0028 CNT5 CLR1 CLR2 CLR3 CLR4 CLR5
+
+
+=== Index
+
+CLNn: The length (in ints) of CLRn.
+CLRn: an integer or two describing the color (and also legth?) of a basic
+ color unit (combination of LEDs).
+CNTn: the number of times color /n/ will appear.
+SDLY: shutdown delay (seconds)
+
+
+== Web UI Bugs
+* Settings => Shutdown delay: claims to be in 1/10 of seconds.
+ In practice: seconds.
+* Shutdown delay tooltip has an odd floating point rounding bug.
+* CNT1: claims to have a maximum of 100. In practice it has a maximum of 96.
+
+=== TODO
+* What does Settings => Double click interval have?
diff --git a/freack_gen.hs b/freack_gen.hs
new file mode 100644
index 0000000..6802a8a
--- /dev/null
+++ b/freack_gen.hs
@@ -0,0 +1,32 @@
+import qualified Data.ByteString.Lazy as BL
+import Data.Binary.Put
+
+s_delay = 0
+num_cycles = 1
+colors_list = [(0x32, 0x30)] -- green
+
+magic 1 x = 2 + 6 * x
+
+color_number t = fst t * 2^8 + snd t
+
+serialiseSomething :: Put
+serialiseSomething = do
+ putWord16le 0x5aa5
+ putWord16le s_delay
+ putWord16le 0x101
+ putWord16le 0x101
+ putWord16le 0x1
+ putWord16le 0
+ putWord16le 0
+ putWord16le 0
+ putWord16le 0
+ putWord16le 0
+ putWord16le num_cycles
+ putWord16le $ fromIntegral $ length colors_list
+ putWord16le $ magic num_cycles 1
+ putWord16le $ fromIntegral $ color_number $ head colors_list
+
+main :: IO ()
+main = BL.putStr $ runPut serialiseSomething
+
+