<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     >
  <channel>
    <title>Sparks</title>
    <link>http://www.sparkslabs.com/blog</link>
    <description>Thoughts and creations by Michael Sparks</description>
    <pubDate>Mon, 12 Feb 2018 02:01:05 GMT</pubDate>
    <generator>Blogofile</generator>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Hello IOT-Kit, Introduction By Example</title>
      <link>http://www.sparkslabs.com/michael/blog/2018/02/12/hello-iot-kit,-introduction-by-example</link>
      <pubDate>Mon, 12 Feb 2018 01:54:10 GMT</pubDate>
      <category><![CDATA[iotkit]]></category>
      <category><![CDATA[python]]></category>
      <category><![CDATA[iot]]></category>
      <category><![CDATA[C++]]></category>
      <category><![CDATA[definitions]]></category>
      <category><![CDATA[iotoy]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2018/02/12/hello-iot-kit,-introduction-by-example</guid>
      <description>Hello IOT-Kit, Introduction By Example</description>
      <content:encoded><![CDATA[<p>IOT-Kit is a toolkit for enabling the creation of IOT devices, by people
who can make simple arduino based devices. Rather than waffle on about
why, how, etc, I think the best way of explaining what this does, is by
example. </p>
<p>Specifically, this post covers:</p>
<ul>
<li>Suppose you can make little arduino based robots</li>
<li>Suppose you want to remote control your robots over the local network,
  trivially from something like python. (Really over HTTP in fact!)</li>
</ul>
<p>What do you as a device maker need to do to make this happen?</p>
<h2>IOT-Kit - Make your Arduino Device an IOT Device, easily</h2>
<p>So the really short version is this: you can make a simple robot, but
you want to make it usable as an IOT device too. You don't want to
build the entire stack. You don't want to build everything yourself.</p>
<p>You want your users to be able to type something like this program
and have it search for the robot on the network, and have it control
the robot.</p>
<div class="codehilite"><pre><span class="kn">from</span> <span class="nn">iotoy.local</span> <span class="kn">import</span> <span class="n">simplebot</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">random</span>

<span class="n">simplebot</span><span class="o">.</span><span class="n">lights</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
    <span class="n">choice</span> <span class="o">=</span> <span class="n">random</span><span class="o">.</span><span class="n">choice</span><span class="p">((</span><span class="s2">&quot;forward&quot;</span><span class="p">,</span> <span class="s2">&quot;backward&quot;</span><span class="p">,</span> <span class="s2">&quot;left&quot;</span><span class="p">,</span> <span class="s2">&quot;right&quot;</span><span class="p">,</span> <span class="s2">&quot;blink&quot;</span><span class="p">,</span> <span class="s2">&quot;stop&quot;</span><span class="p">))</span>
    <span class="k">if</span> <span class="n">choice</span> <span class="o">==</span> <span class="s2">&quot;forward&quot;</span><span class="p">:</span>
        <span class="n">simplebot</span><span class="o">.</span><span class="n">forward</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">choice</span> <span class="o">==</span> <span class="s2">&quot;backward&quot;</span><span class="p">:</span>
        <span class="n">simplebot</span><span class="o">.</span><span class="n">backward</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">choice</span> <span class="o">==</span> <span class="s2">&quot;left&quot;</span><span class="p">:</span>
        <span class="n">simplebot</span><span class="o">.</span><span class="n">left</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">choice</span> <span class="o">==</span> <span class="s2">&quot;right&quot;</span><span class="p">:</span>
        <span class="n">simplebot</span><span class="o">.</span><span class="n">right</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">choice</span> <span class="o">==</span> <span class="s2">&quot;blink&quot;</span><span class="p">:</span>
        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">):</span>
            <span class="n">simplebot</span><span class="o">.</span><span class="n">lights</span> <span class="o">=</span> <span class="mi">1</span>
            <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span>
            <span class="n">simplebot</span><span class="o">.</span><span class="n">lights</span> <span class="o">=</span> <span class="mi">0</span>
            <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.5</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">choice</span> <span class="o">==</span> <span class="s2">&quot;stop&quot;</span><span class="p">:</span>
        <span class="n">simplebot</span><span class="o">.</span><span class="n">stop</span><span class="p">()</span>

    <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">5</span><span class="p">)</span>
</pre></div>


<p><strong>NOTE:</strong> While this is python, this actually maps to a bunch of
deterministic http web calls, and actually can be written in
any langauge. iotoy/iotkit just provides a bunch of convenience
functions to do these calls in a way that also maps cleanly to
python. (It also would map cleanly in javascript, ruby, perl, etc)</p>
<p>How do we get to this?</p>
<h2>Building the Robot - Hardware</h2>
<p>These is the easy part. We could use a DAGU mini-driver. This can control a
number of servos and also provides serial access over plain old hardware
serial bluetooth.</p>
<h2>Building the Robot - Software, No IOT</h2>
<p>If we were just controlling the robot without any remote control, we could use
Pyxie to program this. The Pyxie program you might use could look like this:</p>
<div class="codehilite"><pre><span class="cp">#include</span> <span class="cpf">&lt;Servo.h&gt;</span><span class="cp"></span>

<span class="n">leftwheel</span> <span class="o">=</span> <span class="n">Servo</span><span class="p">()</span>
<span class="n">rightwheel</span> <span class="o">=</span> <span class="n">Servo</span><span class="p">()</span>

<span class="n">headlights_led_pin</span> <span class="o">=</span> <span class="mi">13</span>
<span class="n">leftwheel_pin</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">rightwheel_pin</span> <span class="o">=</span> <span class="mi">3</span>

<span class="n">pinMode</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">OUTPUT</span><span class="p">)</span>
<span class="n">leftwheel</span><span class="p">.</span><span class="n">attach</span><span class="p">(</span><span class="n">leftwheel_pin</span><span class="p">)</span>
<span class="n">rightwheel</span><span class="p">.</span><span class="n">attach</span><span class="p">(</span><span class="n">rightwheel_pin</span><span class="p">)</span>

<span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
<span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>

<span class="k">while</span> <span class="nl">True</span><span class="p">:</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">)</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">)</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span>

    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">)</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span>

    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span>

    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">)</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span>

    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">)</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">)</span>

    <span class="n">digitalWrite</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">HIGH</span><span class="p">)</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span>
    <span class="n">digitalWrite</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">LOW</span><span class="p">)</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span>
</pre></div>


<p>This program assume 2 continuous rotation servos, where the centre point 90 means stationary, 0 means full reverse, and 180 means full forward.</p>
<p>What this program means is "forward, right, backward, left, stop, blink headlights".</p>
<p>Pyxie generates C++ code, which we can use as a starting point for our code:</p>
<div class="codehilite"><pre><span class="cp">#include</span> <span class="cpf">&lt;Servo.h&gt;</span><span class="cp"></span>

<span class="cp">#include</span> <span class="cpf">&quot;iterators.cpp&quot;</span><span class="cp"></span>

<span class="kt">void</span> <span class="nf">setup</span><span class="p">()</span> <span class="p">{</span>
    <span class="kt">int</span> <span class="n">headlights_led_pin</span><span class="p">;</span>
    <span class="n">Servo</span> <span class="n">leftwheel</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">leftwheel_pin</span><span class="p">;</span>
    <span class="n">Servo</span> <span class="n">rightwheel</span><span class="p">;</span>
    <span class="kt">int</span> <span class="n">rightwheel_pin</span><span class="p">;</span>

    <span class="n">leftwheel</span> <span class="o">=</span> <span class="n">Servo</span><span class="p">();</span>
    <span class="n">rightwheel</span> <span class="o">=</span> <span class="n">Servo</span><span class="p">();</span>
    <span class="n">headlights_led_pin</span> <span class="o">=</span> <span class="mi">13</span><span class="p">;</span>
    <span class="n">leftwheel_pin</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span>
    <span class="n">rightwheel_pin</span> <span class="o">=</span> <span class="mi">3</span><span class="p">;</span>
    <span class="n">pinMode</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">OUTPUT</span><span class="p">);</span>
    <span class="p">(</span><span class="n">leftwheel</span><span class="p">).</span><span class="n">attach</span><span class="p">(</span><span class="n">leftwheel_pin</span><span class="p">);</span>
    <span class="p">(</span><span class="n">rightwheel</span><span class="p">).</span><span class="n">attach</span><span class="p">(</span><span class="n">rightwheel_pin</span><span class="p">);</span>
    <span class="p">(</span><span class="n">leftwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">);</span>
    <span class="p">(</span><span class="n">rightwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">);</span>
    <span class="k">while</span> <span class="p">(</span><span class="nb">true</span><span class="p">)</span> <span class="p">{</span>
        <span class="p">(</span><span class="n">leftwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
        <span class="p">(</span><span class="n">rightwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
        <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
        <span class="p">(</span><span class="n">leftwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
        <span class="p">(</span><span class="n">rightwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
        <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
        <span class="p">(</span><span class="n">leftwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
        <span class="p">(</span><span class="n">rightwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
        <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
        <span class="p">(</span><span class="n">leftwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
        <span class="p">(</span><span class="n">rightwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
        <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
        <span class="p">(</span><span class="n">leftwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">);</span>
        <span class="p">(</span><span class="n">rightwheel</span><span class="p">).</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">);</span>
        <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
        <span class="n">digitalWrite</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">HIGH</span><span class="p">);</span>
        <span class="n">delay</span><span class="p">(</span><span class="mi">1000</span><span class="p">);</span>
        <span class="n">digitalWrite</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">LOW</span><span class="p">);</span>
        <span class="n">delay</span><span class="p">(</span><span class="mi">1000</span><span class="p">);</span>
    <span class="p">};</span>
<span class="p">}</span>

<span class="kt">void</span> <span class="nf">loop</span><span class="p">()</span> <span class="p">{</span>
<span class="p">}</span>
</pre></div>


<h2>Making a simple device abstraction layer for our device.</h2>
<p>A device abstraction layer just means creating names for the key
functionality we care about. At some point, pyxie will help here,
but pyxie is currently very simple and can't create functions, so
we take the C++ code we have so far and work from there.</p>
<p>The interators in the iterators.cpp file are not used, so we can ditch
that too.</p>
<h3>Creating functions for functionality</h3>
<p>So our first step is to pull out and name all the functions. While we're at it, unlike pyxie, we'll split out the contents of what would normally be in a setup() and loop() in an arduino program.</p>
<div class="codehilite"><pre><span class="cp">#include</span> <span class="cpf">&lt;Servo.h&gt;</span><span class="cp"></span>

<span class="kt">int</span> <span class="n">headlights_led_pin</span><span class="p">;</span>

<span class="n">Servo</span> <span class="n">leftwheel</span><span class="p">;</span>
<span class="n">Servo</span> <span class="n">rightwheel</span><span class="p">;</span>

<span class="kt">int</span> <span class="n">leftwheel_pin</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">rightwheel_pin</span><span class="p">;</span>

<span class="kt">void</span> <span class="nf">forward</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">backward</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">left</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">right</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">stop</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">lights_on</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">digitalWrite</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">HIGH</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">lights_off</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">digitalWrite</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">LOW</span><span class="p">);</span>
<span class="p">}</span>

<span class="kt">void</span> <span class="nf">setup</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span> <span class="o">=</span> <span class="n">Servo</span><span class="p">();</span>
    <span class="n">rightwheel</span> <span class="o">=</span> <span class="n">Servo</span><span class="p">();</span>
    <span class="n">headlights_led_pin</span> <span class="o">=</span> <span class="mi">13</span><span class="p">;</span>
    <span class="n">leftwheel_pin</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span>
    <span class="n">rightwheel_pin</span> <span class="o">=</span> <span class="mi">3</span><span class="p">;</span>

    <span class="n">pinMode</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">OUTPUT</span><span class="p">);</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">attach</span><span class="p">(</span><span class="n">leftwheel_pin</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">attach</span><span class="p">(</span><span class="n">rightwheel_pin</span><span class="p">);</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">);</span>
<span class="p">}</span>

<span class="kt">void</span> <span class="nf">loop</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">forward</span><span class="p">();</span>
    <span class="n">right</span><span class="p">();</span>
    <span class="n">backward</span><span class="p">();</span>
    <span class="n">left</span><span class="p">();</span>

    <span class="n">lights_on</span><span class="p">();</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">1000</span><span class="p">);</span>
    <span class="n">lights_off</span><span class="p">();</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">1000</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>


<h3>Device abstraction for our robot</h3>
<p>So the device abstraction layer for our device has the following signature:</p>
<div class="codehilite"><pre>void forward();
void backward();
void left();
void right();
void stop();
void lights_on();
void lights_off();
</pre></div>


<p>This is the what we need to build an IOT-Kit interface for. </p>
<h2>Minimal IOT-Kit Interface</h2>
<p>Our starting point for our IOT-Kit interface is something minimal. Initially
we'll try to cover the following parts of our device abstraction:</p>
<div class="codehilite"><pre>void forward();
void stop();
void lights_on();
void lights_off();
</pre></div>


<p>We'll then add the rest in.</p>
<h3>Changes to support minimal control API</h3>
<p>We add the following include near the top of the file:</p>
<div class="codehilite"><pre><span class="cp">#include</span> <span class="cpf">&lt;CommandHostTiny.h&gt;</span><span class="cp"></span>
</pre></div>


<p>In order to make our device introspectable and controllable,
we need to add in a class which subclasses "CommandHostTiny".</p>
<p>The skeleton of this class looks like this:</p>
<div class="codehilite"><pre><span class="k">class</span> <span class="n">SimplebotHost</span> : <span class="n">public</span> <span class="n">CommandHostTiny</span> {
<span class="n">private:</span>
    <span class="n">char</span> <span class="n">temp_str</span>[<span class="mi">128</span>];   // <span class="n">needed</span> <span class="k">for</span> <span class="n">parsing</span> <span class="n">input</span>
    <span class="nb">int</span> <span class="n">lights</span>;           // <span class="n">To</span> <span class="n">store</span> <span class="k">state</span> <span class="k">of</span> <span class="n">the</span> <span class="n">headlight</span>
<span class="n">public:</span>
    <span class="n">SimplebotHost</span>() : <span class="n">lights</span>(<span class="mi">0</span>) { }
    ~<span class="n">SimplebotHost</span>() { }

    <span class="n">const</span> <span class="n">char</span> *<span class="n">hostid</span>(); // <span class="n">Returns</span> <span class="n">the</span> <span class="nb">name</span> <span class="k">of</span> <span class="n">the</span> <span class="n">device</span>
    <span class="n">const</span> <span class="n">char</span> * <span class="n">attrs</span>(); // <span class="n">Returns</span> <span class="n">the</span> <span class="n">list</span> <span class="k">of</span> <span class="n">attributes</span>(+<span class="n">types</span>) <span class="n">that</span> <span class="nb">can</span> <span class="n">be</span> <span class="n">changed</span>
    <span class="n">const</span> <span class="n">char</span> * <span class="n">funcs</span>(); // <span class="n">Returns</span> <span class="n">the</span> <span class="n">list</span> <span class="k">of</span> <span class="n">functions</span> <span class="n">the</span> <span class="n">device</span> <span class="n">understands</span>.

    <span class="nb">bool</span> <span class="n">has_help</span>(<span class="n">char</span> * <span class="nb">name</span>); // <span class="n">To</span> <span class="n">allow</span> <span class="n">us</span> <span class="nb">to</span> <span class="n">find</span> <span class="n">out</span> <span class="n">whether</span> <span class="n">a</span> <span class="k">given</span> <span class="nb">name</span> <span class="k">has</span> <span class="n">help</span>.

    <span class="nb">void</span> <span class="n">help</span>(<span class="n">char</span> * <span class="nb">name</span>); // <span class="n">Returns</span> <span class="n">the</span> <span class="n">help</span> <span class="k">for</span> <span class="n">a</span> <span class="k">given</span> <span class="nb">name</span> - <span class="n">usually</span> <span class="n">a</span> <span class="n">function</span>
                            // <span class="n">Includes</span> <span class="n">machine</span> <span class="n">parsable</span> <span class="n">type</span> <span class="nb">signature</span>

    <span class="nb">bool</span> <span class="nb">exists</span>(<span class="n">char</span> * <span class="n">attribute</span>); // <span class="n">Returns</span> <span class="nb">true</span><span class="o">/</span><span class="n">false</span> <span class="k">for</span> <span class="n">an</span> <span class="n">attribute</span> <span class="n">existing</span>.

    <span class="n">const</span> <span class="n">char</span> *<span class="n">get</span>(<span class="n">char</span> * <span class="n">attribute</span>); // <span class="n">Gets</span> <span class="n">the</span> <span class="nb">value</span> <span class="k">for</span> <span class="n">an</span> <span class="n">attribute</span>

    <span class="nb">int</span> <span class="n">set</span>(<span class="n">char</span>* <span class="n">attribute</span>, <span class="n">char</span>* <span class="n">raw_value</span>); // <span class="n">Sets</span> <span class="n">the</span> <span class="nb">value</span> <span class="k">for</span> <span class="n">attributes</span>

    <span class="nb">int</span> <span class="n">callfunc</span>(<span class="n">char</span>* <span class="n">funcname</span>, <span class="n">char</span>* <span class="n">raw_args</span>); // <span class="n">Calls</span> <span class="n">the</span> <span class="k">given</span> <span class="n">function</span> <span class="n">with</span> <span class="k">given</span> <span class="n">raw_args</span>
};
</pre></div>


<p>So by way of example, hostid, attrs and funcs in this case look like this:</p>
<div class="codehilite"><pre><span class="nt">const</span> <span class="nt">char</span> <span class="o">*</span><span class="nt">hostid</span><span class="o">()</span> <span class="p">{</span>    <span class="n">return</span> <span class="s2">&quot;simplebot&quot;</span><span class="p">;</span>     <span class="p">}</span>
<span class="nt">const</span> <span class="nt">char</span> <span class="o">*</span> <span class="nt">attrs</span><span class="o">()</span> <span class="p">{</span>    <span class="n">return</span> <span class="s2">&quot;lights:int&quot;</span><span class="p">;</span>    <span class="p">}</span>
<span class="nt">const</span> <span class="nt">char</span> <span class="o">*</span> <span class="nt">funcs</span><span class="o">()</span> <span class="p">{</span>    <span class="n">return</span> <span class="s2">&quot;forward,stop&quot;</span><span class="p">;</span>  <span class="p">}</span>
</pre></div>


<p>Note that the name returned as host id here - "simplebot" - is used as the name to advertise the robot on the network, and that is how this line of python is made to work:</p>
<div class="codehilite"><pre><span class="kn">from</span> <span class="nn">iotoy.local</span> <span class="kn">import</span> <span class="n">simplebot</span>
</pre></div>


<p>Help is implemented in two ways - firstly to note that help is available and then to return the help available:</p>
<div class="codehilite"><pre>bool has_help(char * name) {
    if (strcmp(name,&quot;forward&quot;)==0) return true;
    if (strcmp(name,&quot;stop&quot;)==0) return true;
    return false;
}

void help(char * name) {
    if (strcmp(name,&quot;forward&quot;)==0) Serial.println(F(&quot;forward -&gt; - Move forward for 1/2 second&quot;));
    else if (strcmp(name,&quot;stop&quot;)==0) Serial.println(F(&quot;stop -&gt; - Stop moving&quot;));
    else Serial.println(F(&quot;-&quot;));
}
</pre></div>


<p>Attribute handling is then done as follows. Note we only have one attribute - lights. ANd here I choose to update the LED state whenever the lights value changes:</p>
<div class="codehilite"><pre>bool exists(char * attribute) {
    if (strcmp(attribute,&quot;lights&quot;)==0) return true;
    return false;
}

const char *get(char * attribute) {
    if (strcmp(attribute,&quot;lights&quot;)==0) { 
        itoa (lights, temp_str, 10); 
        return temp_str; 
    }
    return &quot;-&quot;;
}

int set(char* attribute, char* raw_value) {
    if (strcmp(attribute,&quot;lights&quot;)==0) {
        int value = atoi(raw_value);
        lights = value;
        if (lights) {
            lights_on();
        } else {
            lights_off();
        }
        return 200;
    }
    return 404;
}
</pre></div>


<p>Handling function calls is pretty simple:</p>
<div class="codehilite"><pre>int callfunc(char* funcname, char* raw_args) { 
    if (strcmp(funcname,&quot;forward&quot;)==0) { forward(); return 200; }
    if (strcmp(funcname,&quot;stop&quot;)==0) { backward(); return 200; }
    return 404; 
}
</pre></div>


<h2>IOT-kit final step</h2>
<p>At this stage, the command host isn't being used.</p>
<p>Our final step in our transformation boils down to:</p>
<ul>
<li>Add the other functions from our device abstraction</li>
<li>Move the setup for the robot into a setup function in the class</li>
<li>Make sure that setup also sets up the command host</li>
<li>Make the arduino set up set up our robot</li>
<li>Remove the custom code from loop() and run the command host instead.</li>
</ul>
<p>In practice this means that our final code looks like this:</p>
<div class="codehilite"><pre><span class="cp">#include</span> <span class="cpf">&lt;Servo.h&gt;</span><span class="cp"></span>
<span class="cp">#include</span> <span class="cpf">&lt;CommandHostTiny.h&gt;</span><span class="cp"></span>

<span class="kt">int</span> <span class="n">headlights_led_pin</span><span class="p">;</span>

<span class="n">Servo</span> <span class="n">leftwheel</span><span class="p">;</span>
<span class="n">Servo</span> <span class="n">rightwheel</span><span class="p">;</span>

<span class="kt">int</span> <span class="n">leftwheel_pin</span><span class="p">;</span>
<span class="kt">int</span> <span class="n">rightwheel_pin</span><span class="p">;</span>

<span class="kt">void</span> <span class="nf">forward</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">backward</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">left</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">right</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">180</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">stop</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">0</span><span class="p">);</span>
    <span class="n">delay</span><span class="p">(</span><span class="mi">500</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">lights_on</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">digitalWrite</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">HIGH</span><span class="p">);</span>
<span class="p">}</span>
<span class="kt">void</span> <span class="nf">lights_off</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">digitalWrite</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">LOW</span><span class="p">);</span>
<span class="p">}</span>

<span class="n">class</span> <span class="nl">SimplebotHost</span> <span class="p">:</span> <span class="n">public</span> <span class="n">CommandHostTiny</span> <span class="p">{</span>
<span class="nl">private</span><span class="p">:</span>

    <span class="kt">char</span> <span class="n">temp_str</span><span class="p">[</span><span class="mi">128</span><span class="p">];</span>
    <span class="kt">int</span> <span class="n">lights</span><span class="p">;</span> <span class="c1">//</span>

<span class="nl">public</span><span class="p">:</span>
    <span class="n">SimplebotHost</span><span class="p">()</span> <span class="o">:</span> <span class="n">lights</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="p">}</span>
    <span class="o">~</span><span class="n">SimplebotHost</span><span class="p">()</span> <span class="p">{</span> <span class="p">}</span>

    <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">hostid</span><span class="p">()</span> <span class="p">{</span>    <span class="k">return</span> <span class="s">&quot;simplebot&quot;</span><span class="p">;</span>     <span class="p">}</span>
    <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">attrs</span><span class="p">()</span> <span class="p">{</span>    <span class="k">return</span> <span class="s">&quot;lights:int&quot;</span><span class="p">;</span>    <span class="p">}</span>
    <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">funcs</span><span class="p">()</span> <span class="p">{</span>    <span class="k">return</span> <span class="s">&quot;forward,backward,left,right,stop&quot;</span><span class="p">;</span>  <span class="p">}</span>

    <span class="kt">bool</span> <span class="n">has_help</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span> <span class="n">name</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;forward&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;backward&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;left&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;right&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;stop&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
        <span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="kt">void</span> <span class="n">help</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span> <span class="n">name</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;forward&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="n">Serial</span><span class="p">.</span><span class="n">println</span><span class="p">(</span><span class="n">F</span><span class="p">(</span><span class="s">&quot;forward -&gt; - Move forward for 1/2 second&quot;</span><span class="p">));</span>
        <span class="k">else</span> <span class="nf">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;backward&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="n">Serial</span><span class="p">.</span><span class="n">println</span><span class="p">(</span><span class="n">F</span><span class="p">(</span><span class="s">&quot;backward -&gt; - Move backward for 1/2 second&quot;</span><span class="p">));</span>
        <span class="k">else</span> <span class="nf">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;left&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="n">Serial</span><span class="p">.</span><span class="n">println</span><span class="p">(</span><span class="n">F</span><span class="p">(</span><span class="s">&quot;left -&gt; - Spin left for 1/2 second&quot;</span><span class="p">));</span>
        <span class="k">else</span> <span class="nf">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;right&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="n">Serial</span><span class="p">.</span><span class="n">println</span><span class="p">(</span><span class="n">F</span><span class="p">(</span><span class="s">&quot;right -&gt; - Spin right for 1/2 second&quot;</span><span class="p">));</span>
        <span class="k">else</span> <span class="nf">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">name</span><span class="p">,</span><span class="s">&quot;stop&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="n">Serial</span><span class="p">.</span><span class="n">println</span><span class="p">(</span><span class="n">F</span><span class="p">(</span><span class="s">&quot;stop -&gt; - Stop moving&quot;</span><span class="p">));</span>
        <span class="k">else</span> <span class="n">Serial</span><span class="p">.</span><span class="n">println</span><span class="p">(</span><span class="n">F</span><span class="p">(</span><span class="s">&quot;-&quot;</span><span class="p">));</span>
    <span class="p">}</span>

    <span class="kt">bool</span> <span class="n">exists</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span> <span class="n">attribute</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">attribute</span><span class="p">,</span><span class="s">&quot;lights&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="k">return</span> <span class="nb">true</span><span class="p">;</span>
        <span class="k">return</span> <span class="nb">false</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">get</span><span class="p">(</span><span class="kt">char</span> <span class="o">*</span> <span class="n">attribute</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">attribute</span><span class="p">,</span><span class="s">&quot;lights&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> 
            <span class="n">itoa</span> <span class="p">(</span><span class="n">lights</span><span class="p">,</span> <span class="n">temp_str</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span> 
            <span class="k">return</span> <span class="n">temp_str</span><span class="p">;</span> 
        <span class="p">}</span>
        <span class="k">return</span> <span class="s">&quot;-&quot;</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="kt">int</span> <span class="n">set</span><span class="p">(</span><span class="kt">char</span><span class="o">*</span> <span class="n">attribute</span><span class="p">,</span> <span class="kt">char</span><span class="o">*</span> <span class="n">raw_value</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">attribute</span><span class="p">,</span><span class="s">&quot;lights&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
            <span class="kt">int</span> <span class="n">value</span> <span class="o">=</span> <span class="n">atoi</span><span class="p">(</span><span class="n">raw_value</span><span class="p">);</span>
            <span class="n">lights</span> <span class="o">=</span> <span class="n">value</span><span class="p">;</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">lights</span><span class="p">)</span> <span class="p">{</span>
                <span class="n">lights_on</span><span class="p">();</span>
            <span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
                <span class="n">lights_off</span><span class="p">();</span>
            <span class="p">}</span>
            <span class="k">return</span> <span class="mi">200</span><span class="p">;</span>
        <span class="p">}</span>
        <span class="k">return</span> <span class="mi">404</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="kt">int</span> <span class="n">callfunc</span><span class="p">(</span><span class="kt">char</span><span class="o">*</span> <span class="n">funcname</span><span class="p">,</span> <span class="kt">char</span><span class="o">*</span> <span class="n">raw_args</span><span class="p">)</span> <span class="p">{</span> 
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">funcname</span><span class="p">,</span><span class="s">&quot;forward&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="n">forward</span><span class="p">();</span> <span class="k">return</span> <span class="mi">200</span><span class="p">;</span> <span class="p">}</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">funcname</span><span class="p">,</span><span class="s">&quot;backward&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="n">backward</span><span class="p">();</span> <span class="k">return</span> <span class="mi">200</span><span class="p">;</span> <span class="p">}</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">funcname</span><span class="p">,</span><span class="s">&quot;left&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="n">left</span><span class="p">();</span> <span class="k">return</span> <span class="mi">200</span><span class="p">;</span> <span class="p">}</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">funcname</span><span class="p">,</span><span class="s">&quot;right&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="n">right</span><span class="p">();</span> <span class="k">return</span> <span class="mi">200</span><span class="p">;</span> <span class="p">}</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">strcmp</span><span class="p">(</span><span class="n">funcname</span><span class="p">,</span><span class="s">&quot;stop&quot;</span><span class="p">)</span><span class="o">==</span><span class="mi">0</span><span class="p">)</span> <span class="p">{</span> <span class="n">backward</span><span class="p">();</span> <span class="k">return</span> <span class="mi">200</span><span class="p">;</span> <span class="p">}</span>
        <span class="k">return</span> <span class="mi">404</span><span class="p">;</span> 
    <span class="p">}</span>

    <span class="kt">void</span> <span class="n">setup</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span> <span class="p">{</span>
        <span class="c1">// Setup the pins</span>
        <span class="n">CommandHostTiny</span><span class="o">::</span><span class="n">setup</span><span class="p">();</span>

        <span class="n">leftwheel</span> <span class="o">=</span> <span class="n">Servo</span><span class="p">();</span>
        <span class="n">rightwheel</span> <span class="o">=</span> <span class="n">Servo</span><span class="p">();</span>
        <span class="n">headlights_led_pin</span> <span class="o">=</span> <span class="mi">13</span><span class="p">;</span>
        <span class="n">leftwheel_pin</span> <span class="o">=</span> <span class="mi">2</span><span class="p">;</span>
        <span class="n">rightwheel_pin</span> <span class="o">=</span> <span class="mi">3</span><span class="p">;</span>

        <span class="n">leftwheel</span><span class="p">.</span><span class="n">attach</span><span class="p">(</span><span class="n">leftwheel_pin</span><span class="p">);</span>
        <span class="n">rightwheel</span><span class="p">.</span><span class="n">attach</span><span class="p">(</span><span class="n">rightwheel_pin</span><span class="p">);</span>
        <span class="n">leftwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">);</span>
        <span class="n">rightwheel</span><span class="p">.</span><span class="n">write</span><span class="p">(</span><span class="mi">90</span><span class="p">);</span>

        <span class="n">pinMode</span><span class="p">(</span><span class="n">headlights_led_pin</span><span class="p">,</span> <span class="n">OUTPUT</span><span class="p">);</span>
    <span class="p">}</span>
<span class="p">};</span>

<span class="n">SimplebotHost</span> <span class="n">MyCommandHost</span><span class="p">;</span>

<span class="kt">void</span> <span class="nf">setup</span><span class="p">()</span>
<span class="p">{</span>
    <span class="n">MyCommandHost</span><span class="p">.</span><span class="n">setup</span><span class="p">();</span>
<span class="p">}</span>

<span class="kt">void</span> <span class="nf">loop</span><span class="p">()</span> <span class="p">{</span>
    <span class="n">MyCommandHost</span><span class="p">.</span><span class="n">run_host</span><span class="p">();</span>
<span class="p">}</span>
</pre></div>


<h2>Final notes</h2>
<p>So, that's a whistle stop tour of the device layer. The fun thing now:
assuming this robot has a hardware serial bluetooth (ala the dagu mini),
then this is everything you need to do as an arduino based maker to
make your device an IOT-able device. If you're not using bluetooth,
then your device assumes it's doing serial down a cable.</p>
<p>Either way though, as a device maker, this is all the changes you need
to do to enable the python program we started with to be able to control
your robot over a network.</p>
<p>I'll explain how this works in a later blog post, but I thought this
would make a good fun first example about how IOT-Kit gets implemented
by a device maker to enable a very high level of abstraction to take
place.</p>]]></content:encoded>
    </item>
    <item>
      <title>Escaping The Panopticon of Things?</title>
      <link>http://www.sparkslabs.com/michael/blog/2018/02/11/escaping-the-panopticon-of-things-</link>
      <pubDate>Sun, 11 Feb 2018 22:48:10 GMT</pubDate>
      <category><![CDATA[iotkit]]></category>
      <category><![CDATA[python]]></category>
      <category><![CDATA[iot]]></category>
      <category><![CDATA[C++]]></category>
      <category><![CDATA[definitions]]></category>
      <category><![CDATA[iotoy]]></category>
      <category><![CDATA[opinion]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2018/02/11/escaping-the-panopticon-of-things-</guid>
      <description>Escaping The Panopticon of Things?</description>
      <content:encoded><![CDATA[<h2>The Panopticon of Things</h2>
<p>The Internet of Things. Ask 100 different people what it means to them
and you get a 100 different answers. I know, because I have done... When
you do, in my experience you some different versions and themes.</p>
<p>For many companies though, futurists, and techies it boils down to some
variation of this:</p>
<ul>
<li>People have devices, which can detect things or have small
    amounts of processing power added</li>
<li>These devices monitor their state or activity, or similar</li>
<li>This is published on the internet via a central service</li>
<li>This information can be aggregated and worked on, and often can
    be drilled into down to individual items</li>
</ul>
<p>But is that really an <strong><em>internet</em></strong> of things? Let alone "The internet
of things"? No, it's internet connected things that reports information
about you, your environment or your activity to a centralised system.
Some extend this to the idea of connecting these centralised systems
to each other.</p>
<p>So no, they're not really an internet of things. They're a
<strong>panopticon of things</strong>.</p>
<p>If you're doing this, stop and think. Do you really want to build a
panopticon?</p>
<h2>A Panopticon of Internet Connected Things</h2>
<p>The idea of the panopticon is a relatively old idea. A panopticon was
a building where all (pan-) the residents could be observed (-opticon).
If that sounds a little creepy, consider it was originally meant as a
design for a prison...</p>
<p>It's actually been implemented in both the real world and in fiction. In
the real world, it's been implemented as prisons in a variety of places
around the world... In fiction, the most recent mainstream "up-beat"
example is the floating prison in Captain America Civil War.  The most
and well known realisation of the idea of turning the general world
into a panopticon is in the world of "big brother" in 1984.</p>
<p>One key point: the purpose of the panopticon is NOT to benefit those
staying in the panopticon. The purpose is to benefit the owner of the
panopticon in some fashion.</p>
<p>This means that any panopticon of things is designed to benefit the
person running the panopticon, not the person who owns the things
(however well intentioned the maker was/is). Indeed, it can mean
the panopticon views you and your things as a product to be sold
(advertising, data, etc), not as customers to provide value to.
This isn't be universally the case, but it's common enough.</p>
<p>I don't buy products to benefit some random company. Do you? I buy
or use products either for my benefit or for the benefit of those I
buy them for. Don't get me wrong, being able to opt-in can have benefits.
Google maps being able to give you a different route based on real time
data is useful.</p>
<p>But be clear - it's based on using data from a panopticon, built on
internet connected things.</p>
<h2>Obsolescence Really Means Junk</h2>
<p>Internet connected things isn't really a new idea. That means we've now
gone through the full product cycle more than once. Be it a Nabaztag,
Mattel IM-ME, AIBO, or similar. I've picked these ones for a variety of
reasons:</p>
<ul>
<li>They might have been acclaimed</li>
<li>The manufacturer thought it was a "Big" thing, and mass produced them</li>
<li>They seemed hackable and interesting</li>
<li>They're all kinda fun or interesting from some angle, but aren't really now</li>
</ul>
<p>They all relied on some form of central service, and as those services
disappeared, they became less useful or in some cases instantly useless
junk. I also picked them because they all had many active hacker groups
work to make them useful for many years - often in ways the original
manufacturers didn't consider.</p>
<p>For each of these, there are dozens of other active objects with similar
issues. They all relied on some form of central service. They all became
obsolete when the service they relied on to work disappeared. They all
contained interesting tech.</p>
<p>These devices all became junk. The value was in the service, not in the
device. Even though with all of these devices they had value to the owner,
and could've retained value without the central service.</p>
<h2>A Panopticon of Internet Connected Junk</h2>
<p>So this is really what this sort of internet of things really means.
Building a network of benefit to the owner of the network using devices
that become useless <em>when</em> the owner decides to cease supporting
the devices.</p>
<p>That means the creation of electrical junk, that is wasteful, and in the
end of limited benefit to the customer.</p>
<h2>Reframing the question.</h2>
<p>Rather than ask "what is the internet of things", ask yourself - "What is
the internet of my things?" "what should the internet of things be -- for
me?". Or I could ask you "what is the Internet of Things of Yours" ?)</p>
<ul>
<li>Tracking of my "stuff"</li>
<li>Monitoring and controlling my own devices which are networked</li>
<li>Taking my networks at home and using them all in a unified manner</li>
<li>Allowing my devices to work with each other.</li>
<li>Using my data and devices in ways that benefit me, and those
  I get them for.</li>
</ul>
<p>These are somewhat different answers. Similar, but different. They don't preclude working <em>with</em> panopticons. But they do take a different angle.</p>
<p>This reframed question is the reason behind:</p>
<ul>
<li>IOT-KIT - a toolkit for creating systems and experiences based around
  allowing you to control networked devices that you own.<ul>
<li><a href="http://www.sparkslabs.com/iot-kit/">http://www.sparkslabs.com/iot-kit/</a></li>
<li><a href="https://github.com/sparkslabs/iot-kit/">https://github.com/sparkslabs/iot-kit/</a></li>
</ul>
</li>
<li>IOTOY - a set of protocol specifications enabling an "Internet Of
  Things Of Yours"<ul>
<li><a href="http://iot-kit.org/">http://iot-kit.org/</a></li>
<li><a href="http://iotoy.org/">http://iotoy.org/</a></li>
</ul>
</li>
</ul>
<p>I'll be describing in a short series of posts:</p>
<ul>
<li>IOT-KIT and its motivation</li>
<li>How to use IOT-KIT to make your own IOT devices that have
  longevity of value to the owner.</li>
<li>IOTOY specifications<ul>
<li>Device layer</li>
<li>Web Layer</li>
</ul>
</li>
<li>An overview of how this was implemented in the microbit prototype</li>
<li>How to implement this in your own systems.</li>
</ul>
<p>The core underlying ideas were:</p>
<ul>
<li>
<p>Suppose you can make an arduino (or similar) based device. You
  should be able to make it an IOT-KIT based device trivially.
  (ie low barrier to entry)</p>
</li>
<li>
<p>Suppose you know very limited python, can you use and control
  the IOT devices that sit on your network. (Note, this allows
  you to then trigger behaviour between devices)</p>
</li>
<li>
<p>No "centre". Minimal standard interfaces making it normal for
  individuals, groups, companies and consortia to create their own
  domain specific standards. (Much like these days we use JSON,
  rather than centralised XML schemas for many services...)</p>
</li>
<li>
<p>Plan for "obsolescence means ongoing utilty". If your devices
  can continue to remain useful after the manufacturer disappears,
  then you build value, not junk.</p>
</li>
</ul>
<p>These goals are effectively all designed for a low barrier to entry, while still inter-operating.</p>
<p>If you're interested, please like, share, comment or similar, and as
always feedback welcome.</p>]]></content:encoded>
    </item>
    <item>
      <title>Pyxie 0.1.25 Released</title>
      <link>http://www.sparkslabs.com/michael/blog/2018/02/09/pyxie-0.1.25-released</link>
      <pubDate>Fri, 09 Feb 2018 19:54:39 GMT</pubDate>
      <category><![CDATA[python]]></category>
      <category><![CDATA[subset]]></category>
      <category><![CDATA[compilation]]></category>
      <category><![CDATA[C++]]></category>
      <category><![CDATA[microcontrollers]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2018/02/09/pyxie-0.1.25-released</guid>
      <description>Pyxie 0.1.25 Released</description>
      <content:encoded><![CDATA[<p>I've made a new release of <a href="http://www.sparkslabs.com/pyxie/">pyxie</a>. Largely internal changes.</p>
<p>The focus of this release is the result of the independent intermediate
node refactoring project I was undertaking. This was to transform the list
oriented data structure for representing a "pure" intermediate form of
code into a more stuctured/generalisable format.</p>
<p>The motivation behind this change was the realisation that implementation
of end user functions (ie <code>def</code>) would be very difficult with this more
structured approach.</p>
<p>The actual release notes (and source releases) are here:</p>
<ul>
<li>https://github.com/sparkslabs/pyxie/releases/tag/v0.1.25</li>
</ul>
<p>Github repo:</p>
<ul>
<li>https://github.com/sparkslabs/pyxie</li>
</ul>
<p>Package on PyPI:</p>
<ul>
<li>https://pypi.org/project/pyxie/</li>
</ul>
<p>Also via PPA for Ubuntu:</p>
<ul>
<li>sudo add-apt-repository ppa:sparkslabs/packages</li>
<li>sudo apt-get update</li>
<li>apt-get install python-pyxie</li>
</ul>
<h3>What's new user facing</h3>
<p>Before I dive into those changes, it's perhaps worth noting some of the
other more minor changes, but are more noticeable from a user perspective.</p>
<ul>
<li>A collection of docs added in doc/</li>
<li>A start on documenting the models used in Pyxie</li>
<li>Licensing on pyxie's output. (Yes, it's what you want, but explicitly so)</li>
<li>Some new examples focussed on specific aspects of language:<ul>
<li><code>if</code></li>
<li><code>if-else</code></li>
<li><code>pass</code> </li>
<li><code>print</code>  </li>
<li><code>while-break</code> </li>
<li><code>while-continue</code></li>
</ul>
</li>
<li>The arduin profile has been extended to support  the <code>Adafruit_NeoPixel</code> library</li>
<li><code>neopixel</code> example added</li>
</ul>
<p>Worth noting:</p>
<ul>
<li>While there is an example "simplest_function" it is not expected to compile yet</li>
</ul>
<h4>Neopixel example</h4>
<p>This is quite nice, and so since it's perhaps more interesting I'm including
a snapshot here:</p>
<div class="codehilite"><pre><span class="cp">#include</span> <span class="cpf">&lt;Adafruit_NeoPixel.h&gt;</span><span class="cp"></span>

<span class="n">pin</span> <span class="o">=</span> <span class="mi">6</span>
<span class="n">number_of_pixels</span> <span class="o">=</span> <span class="mi">16</span>
<span class="n">delayval</span> <span class="o">=</span> <span class="mi">500</span>

<span class="n">pixels</span> <span class="o">=</span> <span class="n">Adafruit_NeoPixel</span><span class="p">(</span><span class="n">number_of_pixels</span><span class="p">,</span> <span class="n">pin</span><span class="p">,</span> <span class="n">NEO_GRB</span> <span class="o">+</span> <span class="n">NEO_KHZ800</span><span class="p">)</span>

<span class="n">pixels</span><span class="p">.</span><span class="n">begin</span><span class="p">()</span>

<span class="k">while</span> <span class="nl">True</span><span class="p">:</span>
    <span class="k">for</span> <span class="n">i</span> <span class="n">in</span> <span class="n">range</span><span class="p">(</span><span class="n">number_of_pixels</span><span class="p">)</span><span class="o">:</span>
        <span class="n">pixels</span><span class="p">.</span><span class="n">setPixelColor</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">pixels</span><span class="p">.</span><span class="n">Color</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">150</span><span class="p">,</span><span class="mi">0</span><span class="p">))</span>
        <span class="n">pixels</span><span class="p">.</span><span class="n">show</span><span class="p">()</span>
        <span class="n">delay</span><span class="p">(</span><span class="n">delayval</span><span class="p">)</span>
</pre></div>


<p>Note: This reuses the fact that #include is a comment in python. It might
change at somepoint to be more like this...</p>
<div class="codehilite"><pre><span class="kn">from</span> <span class="nn">Adafruit_NeoPixel</span> <span class="kn">import</span> <span class="o">*</span>
</pre></div>


<p>...since that's logically closer, but for now this is a pragmatic approach
that works.</p>
<h3>Rationale behind changes</h3>
<p>Before this change, pyxie used the following data structures, and code
phases when parsing, analysing, transforming and performing code
generation.</p>
<p>These were not ideal:</p>
<ul>
<li>Code phase: Parser - read in the source, parsed it, and created a
  data structure<ul>
<li>Data structure: pynodes - these represent the concrete python
  syntax, and are generated during the code generation phase. These
  are python objects in a class hierarchy. Once created they are
  analysed and placed into a context to analyse datatypes.</li>
</ul>
</li>
<li>Code phase: Analysis. - Analyses the code, and decorates the existing
  pynodes with type information to understand the programs data and data
  types. (does not create a new data structure).</li>
<li>Transform phase: walks the pynode CST, and generates an intermediate
  data structure intended to represent the program in the abstract
  independent of the language used. An independent intermediate form
  if you like.<ul>
<li>Data structure: independent intermediate  form - This is used
  to model the program in a "pure form" - which isn't constrained
  by the source language, and contains enough information for the
  target language output to be generated. That was the theory. In
  practice it was a nested list of  list of lists ... Not ideal.
  More on this below.</li>
</ul>
</li>
<li>Code generation phase: This walked the independent intermediate form
  (the lists of lists), and created an output data structure representing
  the concrete final program.</li>
<li>The third/final data structure is intended to represent the final
  output language. ie it is intended to be a concrete representation of
  the output language. This final data structure is then capable of
  creating the output. Again, forms a hierarchy and could be called
  "CppNodes" (Though they weren't before this change)</li>
</ul>
<p>The problem here is that while the pynodes are currently well defined (to
a large extent) and that the CppNodes are pretty well defined (even if
they could be better), the independent intermediate form sucked because
it was just nested lists. This meant in practice the code was fragile,
difficult to change, and increasingly difficult to work with. In the early 
days of Pyxie this simplistic structure made sense. However as data
analysis becomes more complex and tricky. This mirrors the fact that
the same was true in the early days of the parsing side. </p>
<p>So the focus of this sub-project was to replace the intermediate form,
and tighten up the differences and make clearer in the code base that
we have PyNodes, iiNodes, and CppNodes, where:</p>
<ul>
<li>Pynodes - are the current structures, unchanged - note these are
  currently prefixed Py - PyDefStatement for example.</li>
<li>CppNodes - are map to objects/hierarchy/etc that represents C++ programs,
  but made clearer (slightly). These are now prefixed Cpp rather than the
  previous C_ which <em>some</em> of the objects use.</li>
<li>iiNodes - represent the independent, intermediate nodes. Since iiNodes
  need to be used in source code where there are either PyNodes + iiNodes
  or  CppNodes + iiNodes, they have the prefix "ii" enable differentiation.</li>
</ul>
<p>Since all 3 of these are actually <em>models</em>, the code for these has all
moved to sit below pyxie.models.</p>
<p>At some point there will be a need to restructure the code more generally.
Parsing, transforming to IINodes and code generation are actually all
transforms, and should sit together. That was out of scope for this
already relatively major internal change.</p>
<h2>Changelog</h2>
<p>I could include the changelog, but if you're curious about that, check
out the release notes mentioned above.</p>
<h2>Future</h2>
<p>I'm not going to put a timeline on this - I've made that mistake in the
past for pet projects but the following goals exist for future iterations:</p>
<ul>
<li>Code structure:<ul>
<li>Consolidate the structure of CppNodes and make them "cleaner"</li>
<li>Similar for iiNodes</li>
<li>Shift type inference and variable detection from PyNodes to iiNodes</li>
<li>Change iiNodes to be more ECS based</li>
<li>Do the analysis/type inference in more of a visitor pattern (ala ECS)</li>
</ul>
</li>
<li>Types<ul>
<li>Better implement core datatypes to allow transforms</li>
<li>Strings need implementing better</li>
<li>Aim for closest match representation of datatypes</li>
<li>Allow JSON type structures to exist<ul>
<li>Implement lists</li>
<li>Implement dictionaries</li>
</ul>
</li>
<li>Implement tuples</li>
</ul>
</li>
<li>Language/structural<ul>
<li>def's with no arguments, and no local variables</li>
<li>def's with arguments</li>
<li>def's with local variables</li>
<li>classes</li>
</ul>
</li>
<li>Example system goals:<ul>
<li>It should ideally be possible to run a perceptron style neural network
  on an Atmega 8A with the aim of making a robot that can follow a line
  based on said network.</li>
</ul>
</li>
</ul>
<p>The example system is deliberately ambitious/difficult - at least for
a version of python compiled to C++ to run on such a small device.</p>
<p>Some parts of this will go quicker than others, and won't be done strictly
in that order.</p>
<p>Most of it however relies upon better internal code structure. (When
I started after all it wasn't clear that this would work or be a good
approach, so used json objects throughout. As time goes on it becomes
clearer that those ad-hoc structures are in the right sort of places,
but could do with being more consistent to increase flexibility.</p>
<p>In order to keep releases interesting though, I'll <em>try</em> to add interesting
examples at each stage :-) </p>
<p>As usual comments welcome - especially with regard to what examples
you might find interesting.</p>]]></content:encoded>
    </item>
    <item>
      <title>Days 4,5 - Live Below Below the Line (food diary)</title>
      <link>http://www.sparkslabs.com/michael/blog/2017/07/27/days-4,5---live-below-below-the-line-(food-diary)</link>
      <pubDate>Thu, 27 Jul 2017 23:27:26 BST</pubDate>
      <category><![CDATA[livebelowtheline]]></category>
      <category><![CDATA[justgiving]]></category>
      <category><![CDATA[lbtlfooddiary]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2017/07/27/days-4,5---live-below-below-the-line-(food-diary)</guid>
      <description>Days 4,5 - Live Below Below the Line (food diary)</description>
      <content:encoded><![CDATA[<p>End of day 5. So here's the food diary for days 4 and 5.</p>
<p>Again, if this is the first time you're seeing this, some context:</p>
<ul>
From 23-28 July, I'm Living below the line - £6 for 6 days food (total) in
order to raise awareness of food poverty in the UK, and more specifically,
I'm aiming to try and raise as large a proportion of £2500 as possible. 
(That would help 100 families in need in manchester).

<P><a href='http://www.justgiving.com/sparkslabs'>For more info, and/or to sponsor me, please visit/share this justgiving link.</a>

<P>If you can't sponsor, please share the justgiving link!
</ul>

<p>Anyway, as I said, here's the food diary for todsy and yesterday. (And as before, RDA calories for me is
2327...)</p>
<p>As per other days, I'm using 3 flasks to take tea and hot food to work.</p>
<h2>Day 4: Wednesday 26 July 2017 - 1898 Kcal</h2>
<h3>Morning -  510 Kcal</h3>
<ul>
<li>Tes</li>
<li>3 slices toast, jam, marg (8nstead of porridge)</li>
<li>1 budget flap jack</li>
</ul>
<h3>Afternoon - 437 Kcal</h3>
<ul>
<li>Tea</li>
<li>Not pot moodle - with added grsvy and mustard (to give a soy sauce effect - worked quite well)</li>
<li>Tea</li>
</ul>
<h3>Evening - 732 Kcal</h3>
<ul>
<li>Tesco value mash (1/3rd of a new batch)</li>
<li>Peas</li>
<li>3 Asda smartprice sausages</li>
<li>Gravy and mustard</li>
<li>squash</li>
<li>1 ginger nut</li>
</ul>
<h3>Night - 219 Kcal</h3>
<ul>
<li>Tea</li>
<li>Chocolate mousse</li>
<li>3 ginger nuts (somethinh nice late)</li>
</ul>
<p>(Late evening really)</p>
<h3>Summary</h3>
<p>Calorie Deficit: ~350 calories</p>
<p>The addition of mustard and gravy to the sorta pot noodle seems to have been a good
idea. Skipping porridge today was a nice change. As per yesterday it's all a bit samey.
Would be nice to have some variety, but that's not an option at the moment. No coffee
is definitely a downside here. Super strong tea is a partial sustitute, but not the
same.</p>
<p>Fundraising stalled today  which is a bit frustrating, but breaking filter bubbles is
hard, not everyone who sees this can donate, etc, and most people who see this probably
donate to something, probably including foodbanks already. So thst's all good. If you
read this, any suggestions for reaching Â£ 1000 would be great...</p>
<h2>Day 5: Thursday 27 July 2017 - 2065 Kcal</h2>
<h3>Morning -  374 Kcal</h3>
<ul>
<li>Tea</li>
<li>Budget Flap Jack</li>
<li>Tea</li>
<li>Porridge</li>
</ul>
<h3>Afternoon - 467 Kcal</h3>
<ul>
<li>Pasta 'Not Pot Noodle', with added gravy / mustard for seasoning</li>
<li>Tea</li>
<li>Squash</li>
<li>Tea</li>
</ul>
<h3>Evening - 606 Kcal</h3>
<ul>
<li>Tea</li>
<li>3 Asda smartprice sausages</li>
<li>Tesco value mash</li>
<li>Peas</li>
<li>Gravy, Mustard</li>
</ul>
<h3>Night - 618 Kcal</h3>
<ul>
<li>1 Budget flap jack</li>
<li>2 slices toast, jam, marg</li>
<li>2 ginger nuts</li>
<li>1 tesco value chocolate mousse</li>
</ul>
<p>(Late evening really)</p>
<h3>Summary</h3>
<p>Calorie Deficit: ~300 calories</p>
<p>Reached 920 today, which is pretty awesome, and makes 1000 seem
possible. Also, now at the stage where I now know that the food left for
tomorrow is all pretty much fair game. It's all pretty much the same stuff
but it is something at least.</p>
<p>Even a small amount more (and people banding funds together) allowing
some variety, fruit, veg would've been nice.</p>
<p>Also, despite consistently under RDA calories by a wide margin, I've
gained 0.8kg this week. That's either just 'in transit' so to speak
(lack of fibre?), or due to low nutritional content. Either way, it
strikes me theres an issue with low cost diets that is probably
related to obesity.</p>
<p>Unlike many I know tomorrow this ends. For others, often demonised by
politicians and media, this goes on week in, week out, relentlessly,
being kicked when they're down. That's the oppressive reality of
Austerity, and we meed to do better. But for now, we can at least
make the job of foodbanks easier...</p>
<h3>Please do donate</h3>
<p>Overall though, this is worth it. At the end of Day 5, the amount raised so
far is £920.  That's a fantastic amount, and will help a lot of people.
Reaching Â£1000 would be amazong though!</p>
<p>If you'd like to help push me towards the goal of helping 100 families, in
Manchester <a href='http://www.justgiving.com/sparkslabs'>please sponsor me
on justgiving.</a></p>
<p>Either way, thanks for your interest, and please share this, or the
justgiving page.</p>]]></content:encoded>
    </item>
    <item>
      <title>Day 3 - Living Below the Line (Food Diary)</title>
      <link>http://www.sparkslabs.com/michael/blog/2017/07/26/day-3---living-below-the-line-(food-diary)</link>
      <pubDate>Wed, 26 Jul 2017 12:31:00 BST</pubDate>
      <category><![CDATA[livebelowtheline]]></category>
      <category><![CDATA[justgiving]]></category>
      <category><![CDATA[lbtlfooddiary]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2017/07/26/day-3---living-below-the-line-(food-diary)</guid>
      <description>Day 3 - Living Below the Line (Food Diary)</description>
      <content:encoded><![CDATA[<p>So, end of Day 3. So here's the food diary for today..</p>
<p>Again, if this is the first time you're seeing this, some context:</p>
<ul>
From 23-28 July, I'm Living below the line - £6 for 6 days food (total) in
order to raise awareness of food poverty in the UK, and more specifically,
I'm aiming to try and raise as large a proportion of £2500 as possible. 
(That would help 100 families in need in manchester).

<P><a href='http://www.justgiving.com/sparkslabs'>For more info, and/or to sponsor me, please visit/share this justgiving link.</a>

<P>If you can't sponsor, please share the justgiving link!
</ul>

<p>Anyway, as I said, here's today. (And as before, RDA calories for me is
2327...)</p>
<h2>Day 3: Tuesday 25 July 2017 - 2101 Kcal</h2>
<p>Much like yesterday, I'm using 3 flasks to take tea/etc to work</p>
<h3>Morning -  388 Kcal</h3>
<p>Home:</p>
<ul>
<li>Tea - from teapot (2 teabags left in pot overnight with hot water), microwaved
  Remainder of tea was also microwaved/boiled, put in flask with 2 teabags.
  Then teaport refilled to brew during day...</li>
<li>1 slice jam sandwich</li>
<li>1 ginger nut</li>
</ul>
<p>Work:</p>
<ul>
<li>Tea - from flask (The topped up). Incredibly strong (since tea made from strong tea...)</li>
<li>Mid Morning - Porridge from flask</li>
</ul>
<h3>Afternoon - 563 Kcal</h3>
<ul>
<li>One of the "not pot noodle" pasta dishes from the food flask.</li>
<li>Tea (from flask)</li>
<li>1 budget flap jack</li>
<li>Tea (from flask)</li>
<li>Squash (600ml)</li>
</ul>
<h3>Evening - 837 Kcal</h3>
<ul>
<li>1/3 pack of value mash (Remainder from days 1 &amp; 2) heated up in microwave</li>
<li>3 sausages, cooked sunday, heated up with mash in microwave</li>
<li>81g frozen peas (+4g marg to improve)</li>
<li>15g Gravy (+140ml water)</li>
<li>11g Mustard</li>
</ul>
<p>Later in evening, watching film:</p>
<ul>
<li>5 Ginger nuts, broken up into small pieces to be a bit like popcorn :-)</li>
</ul>
<h3>Night - 356 Kcal</h3>
<p>(Late evening really)</p>
<ul>
<li>Tea</li>
<li>2 slices of toast (marg, jam)</li>
<li>Tesco Value Chocolate Mousse</li>
<li>Glass squash</li>
</ul>
<h3>Summary</h3>
<p>Calorie Deficit: ~200 calories</p>
<p>Overall very similar to yesterday. Little changes though. Toast late with a
chocolate pot (which I'd almost forgotten about) was very welcome.  The
"budget" flapjack was nice too.  Perhaps a little squidgy this time, but
perhaps just means it needed to cooked for a bit longer ideally.</p>
<p>(Flapjacks are one of the earliest things I remember cooking for myself,
so they're always a bit of a treat :) )</p>
<p>Calorie deficit is better today. But then eating a little less earlier in
the week means I'm less likely to run out at the end of the week, which is
the way round I'd prefer it personally...</p>
<p>Something sweet/treat before sleep is nice...</p>
<p>Only downside is knowing that tomorrow's food will be the same as today...</p>
<p>The other thing though is that it is still not <em>satisfying</em>. It's food. It's
clearly close to the right amount of calories, but it's not satisfying.</p>
<p>The other thing is the Morrisons M Saver gravy &amp; mustard really help. I
added a dollop of mustard to the "not pot noodle" when I was heating it up
and it added something.  I might try adding some of the gravy tomorrow.  I
suspect I'll regret that, but worth trying :-)</p>
<h3>Please do donate</h3>
<p>Overall though, this is worth it. At the end of Day 2, the amount raised so
far is £885.  That's a really amazing amount from very generous sponsors. 
We could go higher though. It's 35% of where I'm aiming for...</p>
<p>If you'd like to help push me towards the goal of helping 100 families, in
Manchester <a href='http://www.justgiving.com/sparkslabs'>please sponsor me
on justgiving.</a></p>
<p>Either way, thanks for your interest, and please share this, or the
justgiving page.</p>]]></content:encoded>
    </item>
    <item>
      <title>Days 1, 2, Living Below the Line</title>
      <link>http://www.sparkslabs.com/michael/blog/2017/07/25/days-1,-2,-living-below-the-line</link>
      <pubDate>Tue, 25 Jul 2017 12:45:00 BST</pubDate>
      <category><![CDATA[livebelowtheline]]></category>
      <category><![CDATA[justgiving]]></category>
      <category><![CDATA[lbtlfooddiary]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2017/07/25/days-1,-2,-living-below-the-line</guid>
      <description>Days 1, 2, Living Below the Line</description>
      <content:encoded><![CDATA[<p>Day 3 of Living below the line for manchester foodbanks...</p>
<ul>
Living below the line - £6 for 6 days food (total) in order to raise
awareness of food poverty in the UK, and more specifically, I'm aiming to
try and raise as large a proportion of £2500 as possible.  (That would help
100 families in need in manchester).

<P><a href='http://www.justgiving.com/sparkslabs'>For more info, and/or to sponsor me, please visit/share this justgiving link.</a>

<P>If you can't sponsor, please share the justgiving link!
</ul>

<p>As I start, I note I haven't put my food diary online anywhere. I've said
what I've bought, and I've said what I intended to eat, but not actually
posted what I have eaten.  As a result, I've created a new category on this
site, which means you can jump straight here:</p>
<ul>
<li><a href="http://www.sparkslabs.com/michael/blog/category/lbtlfooddiary/">http://www.sparkslabs.com/michael/blog/category/lbtlfooddiary/</a></li>
</ul>
<p>Regarding brands, etc, please see the <a href="http://www.sparkslabs.com/michael/blog/2017/07/23/live-below-the-line">first day's entry</a></p>
<p>For each day/part of day, I list the calories I get those days. For
reference, my RDA calories for age, weight, height, gender are 2327 at the
moment. (<a href="https://en.wikipedia.org/wiki/Basal_metabolic_rate">Based on the Mifflin St Jeor equation, and sedentary activity factor</a> )</p>
<h2>Day 1: Sunday 23 July 2017 - 1413 Kcal</h2>
<p>You'll note I use the microwave to make the tea stronger. I normally drink a
fair amount of black coffee.  Judicious use of a tea pot and microwave
results in stronger tea.  Not coffee strength, but coffee colour.</p>
<h3>Morning - 0Kcal</h3>
<p>No breakfast in the morning because I hadn't been shopping. No tea, no
coffee, no juice.  Water though</p>
<p>That said, while doing the shopping, there was a very welcome bite/free
sample of flan, so since that's free and open to everyone, I take and
enjoy :-) (Since I was really hungry at that point it was welcome)</p>
<p>Can't afford eggs this week. Or milk. Or flour. Or pre-made flan...</p>
<h3>Afternoon - 495Kcal</h3>
<p>Got back with the shopping. Starving. Ate 2 giner nuts &amp; some squash while
brewing tea, and making porridge as a late breakfast.  Later had toast as
a late "lunch"</p>
<ul>
<li>Blackcurrent squash, 1 glass</li>
<li>
<p>2 Ginger Nuts</p>
</li>
<li>
<p>Cup of tea - <a href="http://www.independent.co.uk/life-style/health-and-families/heating-cups-tea-microwave-health-benefits-warm-kettle-scientist-dr-quan-vuong-a7678451.html">Made in cup in microwave</a>. Tea bag added to tea pot. Second tea bag
  added to pot, topped up with hot water, left to stew.</p>
</li>
<li>
<p>Porridge - Asda Oats, 41g (+water)</p>
</li>
<li>
<p>Tea - Made by microwaving a cup of tea from the tea pot, and adding hot water to pot (and a tea bag)</p>
</li>
<li>Toast - 2 slices bread, 9g marg, 20g Jam</li>
</ul>
<h3>Evening - 642 Kcal</h3>
<p>Evening meal. Had earlier than I would otherwise, since hungry. Since I'm
cooking for one, but have things like mash - which serves several, I cook a
fair amount this evening, most of which will go in the fridge.  Mash lasts 3
days.  I'm planning on 3 "sausages"/meal (asda value sausages are OK if you
like chip shop sausages.  If you don't like those, you wouldn't like these
ones).  That would leave 2 "spare" sausages which I plan to use as lunch
during the week, which I cooked that evening...</p>
<p>So I cook:</p>
<ul>
<li>I pack of value mash (using more water, but no milk). Add 13g of marg to
  improve flavour/season</li>
<li>17g of gravy (140ml)</li>
<li>98g of peas (aimed for 100, being a bit under was fine)</li>
<li>11 sausages.</li>
</ul>
<p>And I eat:</p>
<ul>
<li>3 sausages</li>
<li>1/3 pack of value mash</li>
<li>17g/140ml of gravy</li>
<li>98g gravy</li>
<li>10g mustard</li>
</ul>
<p>With that I have more squash</p>
<h3>Night - 138 Kcal</h3>
<p>Peckish in late evening</p>
<ul>
<li>3 ginger nuts</li>
<li>Cup of tea. (Again, pour from pot, microwave, add boiling water to pot)</li>
</ul>
<h3>Other</h3>
<p>That evening I also prepared:</p>
<ul>
<li>My lunches for the week. Cooked 5, froze 3. (left 2 in fridge)</li>
<li>Some "budget flapjacks" to have as "snacks". (You'll note the low number of calories above...)</li>
</ul>
<p>I'll cover those two in separate blog posts, as individual recipes, since
they're probably quite useful to have in a separately viewable category (as
well as this one - I'll update this post with links when they're added). </p>
<p>As summary the lunches are spaghetti, curry sauce, peas + those 2 spare
sausages - which I call a "not noodle" below.  The budget jacks are oats,
water, margarine (less than normal) and strawberry jam.</p>
<h3>Summary</h3>
<p>Deficit of ~900Kcal below RDA</p>
<p>Calories are well below RDA for the day. I kinda expected that, but that's
due to poor lunch really, and small breakfast.  No milk in tea/porridge
saves <em>a lot</em> during the week.  But might look odd.  I've had enough black
tea in the past though...</p>
<h2>Day 2: Monday 24 July 2017 - 1910 Kcal</h2>
<p>First day at work while living below the line. While there is tea and coffee
freely available at work, I work on the assumption that I can't have that
this week, so I'm using flasks.</p>
<p>At home I have a number of flasks. 3 food flasks, and a couple of hot water
flasks.  (accumulated over years) They're important this week.</p>
<p>First thing I do in the morning is prepare 3 flasks:</p>
<ul>
<li>One with 2 tea bags, and hot water. (To use as a tea pot) (I take two more
  tea bags with me to work, but don't use them)</li>
<li>One with hot water + 58g oats</li>
<li>One with the "not-noodle" lunch which I'm having, after microwaving it.</li>
</ul>
<p>Also a water bottle filled with water with 75g of squash added.</p>
<p>When using a food flask, you need to fill with boiling water before using,
leave for 10 minutes (helps overcome thermal inertia), and then immediately
fill with overly hot food.  In this case I simply pour the hot water from
the flask back in the tea pot that morning...</p>
<p>(I then promptly forget to bring the antibiotics I'm taking for the leg
infection I gained last week)</p>
<h3>Morning - 327 Kcal</h3>
<p>Home</p>
<ul>
<li>Tea - from teapot, microwaved</li>
<li>Breakfast - Toast (while making everything else) 1 slice, marg, jam</li>
</ul>
<p>Work:</p>
<ul>
<li>Tea - from flask. Hot water added/topped up</li>
<li>Mid Morning - Porridge fro flask. (Porridge made in a flask over a period
  of 2 hours is much nicer than on a hob if using just water/oats)</li>
<li>Tea - from flask. Hot water added/topped up</li>
</ul>
<h3>Afternoon - 400 Kcal</h3>
<ul>
<li>Drink squash</li>
<li>The "not noodle" lunch - from food flask</li>
<li>Tea - remainder of tea from flask</li>
</ul>
<h3>Evening - 1045 Kcal</h3>
<p>Get home, have to have antibiotics first. So have tea, and a single biscuit.</p>
<p>Wait an hour, cook dinner...</p>
<ul>
<li>1/3 pack of value mash (1/2 of what's left over from night before) heated
  up in microwave</li>
<li>3 sausages, cooked last night, heated up with mash in microwave</li>
<li>98g frozen peas (+4g marg to improve)</li>
<li>17g Gravy (+140ml water)</li>
<li>11g Mustard</li>
</ul>
<p>A bit later as "dessert":</p>
<ul>
<li>2 jam sandwiches, and one of the budget flapjacks.</li>
</ul>
<h3>Night - 138 Kcal</h3>
<p>Late evening, watching TV....</p>
<ul>
<li>Tea (from pot, microwaved)</li>
<li>3 ginger nuts</li>
</ul>
<h3>Summary</h3>
<p>Deficit of ~500Kcal below RDA</p>
<p>More calories than yesterday, didn't feel massively hungry at the end of
the day, but definitely felt hungry during the day/evening - more so than
normal.  This is a bit odd - while 1876 calories looks low relative to RDA,
relative to what I've been having for the past 6 months (I've been dieting)
it's actually higher than normal.  </p>
<p>The difference I think is the fact this is unbalanced towards carbs, away
from veg and away from protein.  (That said, I've been quite careful to
manage the foods I've had over the previous 6 months to balance/prevent
hunger, none of which tricks I can do this week)</p>
<p>If I wanted to not feel hungry I'd've need to have more food in the early
and later evening.  The food I'm having tastes either OK or nice, but isn't
really satisfying.</p>
<p>I've got photos of most of the food I've eaten which I'll add later.
In part so people can see what some of this really looks like.</p>
<h3>Please do donate</h3>
<p>Overall though, this is worth it. At the end of Day 2, the amount raised so
far is £885.  That's a really amazing amount from very generous sponsors. 
We could go higher though. It's 35% of where I'm aiming for...</p>
<p>I've also heard several people wonder how it's even possible to live on £6
for 6 days, and hopefully this is of interest to them.  Bear in mind though
that almost any deviation from this requires more funds.  Raising it to
£1.50/day would make a huge difference in practice.  £2/day brings it to the
level which foodbanks effectively budget for (based on looking at the
numbers they publish).</p>
<p>That's a shockingly low figure, and without donations people in need -
people who aren't supported by the the safety nets we're supposed to have -
including people  from all walks of life.</p>
<p>So please donate. Or share. Or donate at your local foodbank/supermarket. </p>
<p>If you'd like to help push me towards the goal of helping 100 families, in
Manchester <a href='http://www.justgiving.com/sparkslabs'>please sponsor me
on justgiving.</a></p>
<p>Either way, thanks for your interest, and please share this, or the
justgiving page.</p>]]></content:encoded>
    </item>
    <item>
      <title>Live Below The Line</title>
      <link>http://www.sparkslabs.com/michael/blog/2017/07/23/live-below-the-line</link>
      <pubDate>Sun, 23 Jul 2017 18:09:00 BST</pubDate>
      <category><![CDATA[livebelowtheline]]></category>
      <category><![CDATA[justgiving]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2017/07/23/live-below-the-line</guid>
      <description>Live Below The Line</description>
      <content:encoded><![CDATA[<p>So, I've posted on facebook about this, and posted on twitter, and posted on
justgiving, but I've not posted here. What am I doing?</p>
<p>This week - Sunday 23 July through Friday 28th July, I'm living below the
line to raise funds for Manchester Central Foodbanks, and to raise awareness
of the issue of food &amp; child poverty in general.  (In the UK, there are 4
million children in poverty right now, and foodbanks were accessed over 1.1
million times last year - 1.1 million times people would've literally gone
hungry if foodbanks did not exist.  (Which is an epic fail for our society
IMO)</p>
<p>You can find out more about this, and how to give on the justgiving site
here:</p>
<ul>
<li><a href="https://www.justgiving.com/fundraising/sparkslabs">https://www.justgiving.com/fundraising/sparkslabs</a></li>
</ul>
<p>Short version is please either donate or share that page if you can, it
makes a huge difference to the foodbanks.  I'm aiming to raise as much of
£2500 as possible, and through the generosity of others, raise £795 before
gift aid is added on (bringing the total to around £900 so far).  £2500
would help 100 families on our doorsteps in their time of need.</p>
<h2>Day 1</h2>
<h3>Background</h3>
<p>This is the first update this week, so let's dive in.</p>
<p>Today I started my "Live below the line" challenge to raise funds for
manchester foodbanks.  This is where I have just 6 pounds for all food and
drink for the next 6 days (including today).  So today's first order was to
go shopping so I could have breakfast (and also get food for the next 5
days).</p>
<p>£1/day is the world food poverty line, below which almost a billion people
live.  (Well, technically it was £1 in 2011, <a href="http://www.worldbank.org/en/topic/poverty/brief/global-poverty-line-faq">it is now about £1.40</a> )</p>
<h3>Plans vs reality...</h3>
<p>So this was the £6...</p>
<p class="inlineimage">
<a href="/michael/images/6days/20170723_112442809-coins.jpg"><img src="/michael/images/6days/20170723_112442809-coins-w.jpg" /></a>
</p>

<p>(I took cash, since it makes it representative. Also in the UK, unless
you're homeless, you tend to get paid either weekly (benefits/low end wages)
or monthly, so I think taking it all in one go is reasonable.)</p>
<p>I've taken a bunch of photos, and will summarise as I go through the week
what the plan is, but I thought when I went out I'd spend £5.99 In Asda I
thought I'd won back 6p, with oats costing 59p there rather than 65p in
Tesco.  However, I was caught out with peas in Tesco now being 76p not 69p
(literally overnight).  So that means my total now came in at precisely £6 -
which is a bit close to the wire.</p>
<p>So what have I got? Some things might surprise, and some might look like odd
choices.  I'd always decided when doing this that rather than just scrape
by, I'd try and live as well as possible doing this.  There's limits, but
anyone who's live on the breadline in the past (I had cuppa soups thickened
with instant mash as lunch for a very extended period 20 years ago...),
you'll know that you can't live at subsistence level and just have nothing
nice.  So this takes that into account.</p>
<h3>Reciepts</h3>
<p>Everyone who does this tends to post reciepts, so here they are...
(Morrisons one is doublesided)</p>
<p class="inlineimage">
<a href="/michael/images/6days/20170723_155545269-morrisons-1.jpg"><img src="/michael/images/6days/20170723_155545269-morrisons-1-w.jpg" /></a>
<a href="/michael/images/6days/20170723_155558339-morrisons-2.jpg"><img src="/michael/images/6days/20170723_155558339-morrisons-2-w.jpg" /></a>
<a href="/michael/images/6days/20170723_155446645-asda.jpg"><img src="/michael/images/6days/20170723_155446645-asda-w.jpg" /></a>
<a href="/michael/images/6days/20170723_155515533-tesco.jpg"><img src="/michael/images/6days/20170723_155515533-tesco-w.jpg" /></a>
</p>

<h3>Nutrition</h3>
<p>Also there's the issue of getting enough calories. I know currently, I'm
losing weight by eating about 75-80% of RDA calories, but that's not the
point here.  If I'm not to lose weight, I should eat about 2300 calories for
my height/weight/age/gender.</p>
<p>I should also aim to get a decent mix of proteins, vegetables, carbs etc. 
I'm not convinced it is possible to have a nutritionally balanced diet in
the UK on £6 for 6 days...</p>
<p>What I've got is not nutritionally balanced, it's literally the maximum
amount of food I can get to try and get enough calories.  It's not too bad
overall I guess, but it's definitely carb heavy, protein and nutrient light.</p>
<h3>What's missing?</h3>
<p>Dairy. Fresh fruits. Decent quality protein.</p>
<h3>What did I get? Well, here's a photo:</h3>
<p class="inlineimage">
<a href="/michael/images/6days/20170723_144645228-shopping.jpg"><img src="/michael/images/6days/20170723_144645228-shopping-w.jpg" /></a>
</p>

<p>Specifically in that photo:</p>
<ul>
<li>2 packs of tesco everyday value instant mash. (Theoretically 8 portions, but I don't have milk so 6 portions)</li>
<li>40 tesco everyday value tea bags</li>
<li>1x Morrisons M Saver loaf of brown bread (24 slices)</li>
<li>20 Asda Smartprice Sausages</li>
<li>900g Tesco Everyday Value peas</li>
<li>1x Jar Morrisons M Saver Strawberry Jam</li>
<li>500g Asda Scottish Oats</li>
<li>1 litre Morrisons M Saver Blackcurrent Squash</li>
<li>1 jar Morrisons M Saver Curry Sauce</li>
<li>1 jar Morrisons M Saver Mustard</li>
<li>1 pack Morrisons M Saver Gravy</li>
<li>1 Pack 4 Tesco Everyday Value Chocolate Mousses</li>
<li>1 pack Tesco Everyday Value Ginger Nuts</li>
<li>500g Morrisons M Savers Spaghetti</li>
<li>250g pack Asda Brilliantly Buttery Margarine</li>
</ul>
<p>(When I found that the oats were 6p cheaper than I expected, I thought I'd
be able to substitute the bisuits and mousses for some fruit, but the fact
the peas were 7p more expensive scuppered that)</p>
<h2>Breakfast Today</h2>
<p>So, once I'd bought all this I was able to have breakfast. Since I was
hungry at this point, I had a snack of 2 ginger nuts and some blackcurrent
squash, while making breakfast.</p>
<p>Breakfast itself consisted of tea and porridge (40g). Neither made with
milk.  I discovered a while ago that porridge made without milk is actually
OK, which surprised me a touch.  I won't be making breakfast this way during
the week, but it's OK for the weekend.</p>
<p>Anyway this was breakfast:</p>
<p class="inlineimage">
<a href="/michael/images/6days/20170723_151900614-porridge.jpg"><img src="/michael/images/6days/20170723_151900614-porridge-w.jpg" /></a>
<a href="/michael/images/6days/20170723_150611076-tea.jpg"><img src="/michael/images/6days/20170723_150611076-tea-w.jpg" /></a>
</p>

<p>I got the tea that strong by:</p>
<ul>
<li>Putting water in a jug with 2 tea bags. Microwaving it for about 4 minutes.</li>
<li>Then emptying 1/2 into a mug, with a tea bag and standing for a minute. Then
  putting rest (+tea bags) into tea pot with more hot water. I then make tea
  using the tea itself as hot water, with an added tea bag each time.</li>
</ul>
<p>It's not the same as coffee, but it's the right colour :-)</p>
<h3>What's with ...</h3>
<p>As I said above, some things might look a little odd to some eyes when
looking at what I've bought.  Specifically things that might jump out are:
jam, ginger nuts and chocolate mousses.</p>
<p>Thing is, we all need something nice, and I wanted to show that there are
little things that can help.  What you get to add to the foodbank thing at
the front should include little things like this.  Though each of these does
actually have a specific reason.</p>
<ul>
<li>
<p>Jam. Gives you something to put on toast, or in a sandwich. It's cheap,
  and it's a source of sugar/energy.  It's the closest I'll get to fruit
  this week too.  Being over 60% sugar though also opens up some options
  I'll discuss in a different post, but it's the fact that Jam can be
  repurposed that the reason it's Jam, not (say) cheap peanut butter.  It is
  also very cheap -- 28p</p>
</li>
<li>
<p>Ginger nuts. Starchy carb + sugar. Similar reason. Gets you through a
  moment of "I need something, now".  (Not "I want something now", more
  "need something")  -- 25p</p>
</li>
<li>
<p>Chocolate Mousse. Closest thing to a luxury. It's also the closest I'll
  get to dairy this week.  Again, it's calories + a flavour.  For 20p you
  don't actually get a lot here, but it's something.  And given all I had
  left was 20p - I couldn't afford fruit, and there was very little that
  was available as an alternative, so why not?</p>
</li>
<li>
<p>Gravy. Looks like a luxury, but isn't. Gravy is essentially extra meat
  flavouring and helps make poor quality meats (such as cheap sausages)
  taste nice. It can also be added to sauces to make sauces more meaty.</p>
</li>
<li>
<p>Mustard. Similar role to gravy. Got this in part because I was surprised
  that anyone actually did a mustard that cheap (23p), and was partly
  curious.  I do know though that it helps with improving flavour as I say. 
  It is also going to be useful with the curry sauce for 2 reasons.  Firstly
  mustard is an emulsifier, which means adding some may help thicken the
  sauce slightly - helping it go further.  Secondly, it will help with the
  spicyness.  Cheap curry sauces often lack any kick.  (Bit like chip shop
  curry sauce)</p>
</li>
<li>
<p>"Buttery" Margarine? This is pure practicality. per kg, buttery margarines
  and their ilk are more expensive than the value (M Saver, everyday value,
  smartprice) alternatives.  But as a unit cost 250g of this is cheaper than
  1kg or 2kg of the value alternative...</p>
</li>
</ul>
<p>ie out of these the jam, gravy, mustard (and to an extent the ginger nuts)
have a dual usage.</p>
<ul>
<li>Pasta &amp; Curry Sauce? Pasta and no pasta sauce (or tomato product) looks a
  bit odd.  The aim is to use the curry sauce with the pasta instead.  This
  will probably taste a bit odd, but will explain later.  This is sheerly
  down to cost.  Curry sauce is cheaper that pasta sauce.  I considered
  sweet and sour sauce instead, but figured that would be too wierd.
  Also, I'd need 3p which I didn't have.</li>
</ul>
<h2>What's for Dinner/etc then?</h2>
<p>Well, clearly today I will be having Jam on Toast for lunch. (admittedly late)</p>
<p>For dinner I'll be having sausages, mash and peas, with gravy and mustard. I
won't be having a choc pot though.</p>
<p>But I'll follow up on these later.</p>
<h2>Closing thoughts...</h2>
<p>I actually couldn't see any real alternatives than this to be frank. £6 for
6 days is so tight, it's quite painful.  You wouldn't want to do this for
longer.</p>
<ul>
<li>Actually that's not true, I did briefly consider purely vegetarian based
  on rice and mixed veg, and a couple of sauces, but I'd be climbing the
  wall by the end of the week, and still be lacking protein.  (I'm not
  practiced at a vegetarian diet, but that <em>may</em> be more practical.  I'm not
  certain though)</li>
</ul>
<p>I know though if I was doing £2/day for a week it would actually be an awful
lot easier and varied. And that's not really that much more.</p>
<p>But quite frankly, the nastiest part about this is knowing that 
<a href="http://www.manchestereveningnews.co.uk/news/greater-manchester-news/quarter-children-live-poverty-salford-12609243">there are families in salford living right now on £1.50/day for food</a>.  In Eccles the
shelves of the M Saver foods were stripped almost clear.  Meanwhile next to
this is all the other foods many of us take for granted were right next to them.</p>
<p>I think in a way, this is why places like Aldi work. They're not the
cheapest (you'll note nothing I bought was from Aldi - they don't have
"budget" alternatives generally), but if you're on just a touch more than
£1/day (say 1.50/day/person or 2.00/day/person), most of their food comes
into budget <em>AND</em> you're not faced with aisle upon aisle, upon aisle of food
you simply can't afford.</p>
<p>Some of the foods I've bought this week are ones I'll happily buy the rest
of the time.  Some aren't.  Just because it's cheap doesn't make it bad. 
But I do tend to pick and choose.  I bought instant mash from Tesco because
the Asda smartprice mash is pretty grim IMO. Same goes for value tea.</p>
<p>But the point is normally I can choose. Today I couldn't really. And going
shopping hungry (because you've not done this week's shop) and being faced
with all that "choice" you can't choose, really is in your face.</p>
<p>I think people talk about inequality a lot, and miss it when it's right
under their faces.</p>
<p>Might be worth remembering the next time you see/hear of a show demonising
people on benefits...</p>
<p>Lastly, but not least, please do sponsor me via this link or share this link...</p>
<ul>
<li><a href="https://www.justgiving.com/fundraising/sparkslabs">https://www.justgiving.com/fundraising/sparkslabs</a></li>
</ul>
<p>... whether or not you think this is what you expected or whether or not you
think it's worthwhile.  I actually hestitated before doing this - even
though the idea comes from Unicef and The Hunger Project, because I worried
it was a little "gauche".  I then figured "Who cares?  If I can raise more
money than I can personally donate, that's all that counts"</p>
<p>Every little helps. Every penny. Thank you.</p>]]></content:encoded>
    </item>
    <item>
      <title>Go See Ghostbusters</title>
      <link>http://www.sparkslabs.com/michael/blog/2016/07/16/go-see-ghostbusters</link>
      <pubDate>Sat, 16 Jul 2016 22:48:14 BST</pubDate>
      <category><![CDATA[Ghostbusters]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2016/07/16/go-see-ghostbusters</guid>
      <description>Go See Ghostbusters</description>
      <content:encoded><![CDATA[<p>My inner 10 year old who saw the original Ghostbusters at the cinema
<em>says: GO SEE GHOSTBUSTERS.  IT IS BETTER THAN THE ORIGINAL</em></p>
<p>Seriously, I was utterly obsessed with ghostbusters as a kid, and this
so much more amazeballs.  Utterly funhilartasticdoaiousness.  GO SEE
IT</p>
<p>They turned the dial up to <em>12</em> with Ghostbusters. It's that good.</p>
<p>I Ain't afraid of no ghost! Fan. Bloody. Tastic. Best Ghostbusters
EVER!</p>
<p>If you loved the original, this was <em>better</em> ! If you liked the
sequel, this stomps on the statue.  The series?  @straczynski should
be proud.</p>
<p>I really cannot rave about how much I liked Ghostbusters. I was
literally dancing in my seat in the end credits.  It was that bloody
awesome.</p>
<p>Rated 12/10 by inner child.</p>
<p>In case it's unclear - I think it's possible to misconstrue my
previous comments, so to clarify...</p>
<p>Yes, I liked it. A lot. A really lot,so amazingly lot it can't be
described how much I liked it.  I liked it that much.  You might think
a cup of hot chocolate made with the finest belgian chocolates (and a
drop of courvoisier) topped with hand whipped extra thick double
brandy cream, teeny marshmallows on top, then with the finest dark
chocolate lightly grated on top, with a dark chocolate spoon to stir
the drink sounds pretty awesome, but believe me this is SOOOOO much
better.</p>
<p>Go. See. Ghostbusters.</p>
<p>If you don't like it, rethink your entire value system. Once you do,
and realise just how utterly amazingly awesome it is, it will be so
utterly worth it.  It's That good.</p>
<p>This has been brought to you by me bouncing around the seat at the
cinema, in the car on the way back and ever since getting back home.</p>
<p>And yes, I even have the book of the original film. Still. This is
amazingly so much better.</p>
<p>But did I enjoy it?</p>
<p>Oh soo soo bloody much :-)</p>
<p>There was a moment in the film when I just thought "OMG. This is
<em>actually better</em> than the original"</p>
<p>And I was <em>10</em> when the first one came out and utterly obsessed.</p>
<p>I used to draw the logo, like, all the time</p>
<p>I wrote a review for it at school</p>
<p>I even read out a passage at school when we had to read out a passage
from our favourite books from it</p>
<p>I mean NO ONE obsesses like a 10 year old can.</p>
<p>Some properly creepy moments to make small children jump too, and some
things which were just so...  Well.  I don't want to spoil anything. 
:-)</p>
<p>Let's just say I'm pretty certain the original cast would have loved
it :-)</p>
<p>If you need help to convince someone to go, I'm a walking talking
advert</p>
<p>I went in with a clear assumption "let's go in assuming they'll do
good" after having made sure I'd seen some things over the past year
or two with the two main actresses in, and thought "I can see this
working".  And if you've not seen them "identity thief" and
"bridesmaids" are great films.</p>
<p>It's had so much hate on the internet as well in the weeks and months
leading up to the film too based on the trailer.  Which is really sad. 
But I now am certain it says more about the haters than the film.  I
hope the haters go see it and enjoy it - they'll be better people for
it(!).</p>
<p>I have never <em>literally</em> danced in my seat in the cinema before - but
with this I did.  It was utterly, utterly, perfect.</p>
<p>It's a film that's made with so much love, and so much irreverence. 
:-)</p>
<p>Go see it, you won't regret it.</p>]]></content:encoded>
    </item>
    <item>
      <title>Peace and Goodwill?</title>
      <link>http://www.sparkslabs.com/michael/blog/2015/12/02/peace-and-goodwill-</link>
      <pubDate>Wed, 02 Dec 2015 20:50:00 GMT</pubDate>
      <category><![CDATA[politics]]></category>
      <category><![CDATA[sadness]]></category>
      <category><![CDATA[peace]]></category>
      <category><![CDATA[war]]></category>
      <category><![CDATA[notinmyname]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2015/12/02/peace-and-goodwill-</guid>
      <description>Peace and Goodwill?</description>
      <content:encoded><![CDATA[<p>Peace and Goodwill?</p>
<p>You don't make peace by using bombs. You don't bring people around to your
perspective by killing their family, their friends and children.  Did
bombing paris make us like or sympathise with ISIS?  No.  Will bombing Syria
make the Syrians (and anyone in ISIS who happens to get hit) sympathise with
our views?  No.</p>
<p>Furthermore, while these fanatics (in ISIS) have no more right to call
themselves representatives of muslim, anyone who supports bombing innocents
in Syria is <em>equally</em> a fanatic, and simply don't deserve respect from
anyone, let alone power.  The people in Syria are <em>people</em>.  So, let's be
blunt.  Bombing innocents in Syria, is <em>Bombing innocents</em>.  Bombing
innocents in the hope you might get a couple of bad guys is NOT the way
forward.</p>
<p>Also, how many of those voting in favour of bombing, or calling for voting
in favour of bombing will in this and coming weeks call for "peace and
goodwill to all mankind" (religious or not - I'm not, but I like the
message) in the form of christmas cards and so on?  If they do vote in
favour of mass murder and killing, it is #notinmyname</p>]]></content:encoded>
    </item>
    <item>
      <title>Websites for Projects</title>
      <link>http://www.sparkslabs.com/michael/blog/2015/08/12/websites-for-projects</link>
      <pubDate>Wed, 12 Aug 2015 23:24:12 BST</pubDate>
      <category><![CDATA[pyxie]]></category>
      <category><![CDATA[iotoy]]></category>
      <category><![CDATA[guild]]></category>
      <guid isPermaLink="true">http://www.sparkslabs.com/michael/blog/2015/08/12/websites-for-projects</guid>
      <description>Websites for Projects</description>
      <content:encoded><![CDATA[<p>I've decided that I ought to have a small website for at least some of the
projects I've created over the years, so I've started doing this for the
projects that I view as current.</p>
<p>The initial set of pages are these:</p>
<ul>
<li><a href="http://www.sparkslabs.com/pyxie/">Pyxie</a> - my nascent python to C++ compiler</li>
<li><a href="http://www.sparkslabs.com/guild/">Guild</a> - my new actor library that I'm finding is minimally
  sufficient</li>
<li><a href="http://www.sparkslabs.com/iotoy/">Iotoy</a> - An IOT statck/project that I started at work, and now
  maintain on my own time.</li>
</ul>
<p>All of these share a common infrastructure and design - which is based on a
principle of <em>panels</em>.</p>
<p>This was borne from the recognition that many websites today actually look
a lot like presentations or slidedecks, just with all the slides on one page. 
As a result, each page is based on a collection of panels.  A panel is
analogous to a slide in a presentation, and each panel could potentially be
styled differently and laid out differently - in the same way slides can
relate to slide designs/slide masters.</p>
<p>As a result, each site has a collection of pages, a bit of meta data about
them, and potentially a bunch of includes - that include panels.  Again,
each panel has a collection of metadata, controlling how it's rendered.</p>
<p>The idea of panels though is also to make things enabling responsive sites
easier. (though this isn't implemented)</p>
<p>All content is written/created using markdown.</p>
<p>The three sites are then built in the same way:</p>
<ul>
<li>Their base repository has a site/ directory in the root of the repository</li>
<li>Inside there there is a build_site.py script</li>
<li>When run, that looks inside the src directory, works through the contents,
  pulls in any panels used from src/panels, styles them using templates, and
  dumps the result into a site directory</li>
<li>The result is then sync'd into the sparkslabs's web tree.</li>
</ul>
<p>The pyxie site uses a local hook to use the same markdown documents to
create the contents of a docs directory and also to update the module
documentation when someone types "help(pyxie)"</p>
<p>At the moment, the three sites have very basic styling, but this will be
simple to make prettier later.</p>
<p>At somepoint I'll use the same approach to switch over this blog, probably -
which could do with a makeover - since this look is now around 4-5 years
old!</p>]]></content:encoded>
    </item>
  </channel>
</rss>
