Close

Work-to-date

A project log for Knickknack

Knickknack does not do much right now ... but who doesn't have an item or two of little value ...

chrisChris 12/16/2014 at 08:050 Comments

I started playing with the idea of a state machine a few weeks ago and at this point I have a functional one. Not surprisingly, The states of the machine are modelled as c++ object instances with the type of state defined by the class of the object.

I am a big fan of interpreted languages (like python) for this kind of stuff but I do not imagine you could get a lot done with a python interpreter loaded on an Arduino. I did want the flexibility of being able to define states easily and potentially dynamically. To that end the state machine loads itself from an XML definition (I used TinyXML to parse this definition).

Loading state from XML is kind-of interesting ... while testing the basic state machine I was loading the states dynamically from the serial monitor ... it raises interesting possibilities for re-programming the device remotely.

There is definitely an overhead cost to parsing the XML and maintaining a hierarchy of state objects ... it works well but this whole idea may need to be optimized or totally re-evaluated for memory consumption if the device gets very sophisticated.

So far I have a few states (for testing):

The hardware so far consists of:
I also have access to (that I can think of):
My goal is to use mostly scavenged parts for this project; this limits functionality and definitely means I will not be making a watch. However, I can definitely fit all of these parts and a bit more in a small-enough case for this contest ... the question is what will this device do?

Discussions