Category Archives: Projects

Any projects on which I am currently working.

Adventures with an ATmega

As part of some university coursework, I’ve recently been playing around with an Atmel 8-bit microcontroller in a quest to build a data logger for home brewing. The aim is to log various sensor readings over the course of primary fermentation of a batch of beer to see how it’s progressing without having to disturb the brew.

While working with hardware is fun, it has the downside that you’re working with hardware. Things break as much as they do in software, but are harder to debug. A nice solution to this is to use a simulator to test the software, rather than using the hardware itself. I’ve been using the simavr simulator. It’s got all the right features, but more importantly its code is easy to understand and extend. In fact, most of the simulator is written as a library which one can build a simulated circuit board around.

I’ve built simulations of several of the components used in the brewing logger now, including an SD card and a flash memory. The code isn’t brilliant, but they’re working well enough to get my firmware booting. Hopefully they might be useful to other people too — hence the code is on gitorious. The SD card simulator is for a generic SDv2 card. The flash memory is for an ST M25P16 (but should support any of the M25P family, with a little work). The serial LCD is for a custom LCD daughter board provided by my university, so that’s probably not so useful. The RHT03 temperature/humidity sensor is general purpose; as is the DS3231 real-time clock.

Put together, and with a little extra work, these will allow closed loop testing of the microcontroller firmware — without ever having to go near the hardware itself. Bliss. (This is all under the misguided assumption that the simulations are sound and complete, but they’ll get there eventually.)

As an example of how easy simavr makes this, take a look at the code needed to instantiate and hook up the humidity sensor simulation:

/* Create the sensor. */
rht03_t rht03;
rht03_init (avr, &rht03);

/* Connect its bidirectional data pin to pin D3 on the microcontroller. */
avr_connect_irq (avr_io_getirq (avr, AVR_IOCTL_IOPORT_GETIRQ ('D'), 3), rht03.irq + IRQ_RHT03_DATA);
avr_connect_irq (rht03.irq + IRQ_RHT03_DATA, avr_io_getirq (avr, AVR_IOCTL_IOPORT_GETIRQ ('D'), 3));

Recent libgdata work

Having totally failed to blog much recently, I thought I'd post an update on libgdata, and the work I've been doing over the last few days on it.

I'm aiming to get libgdata 0.8.0 released in good time to be used in GNOME 3.0, since it contains a lot of fixes and API breaks. What will be new in 0.8? The major change is that libgdata will be fully asynchronous — every long-running operation now has an asynchronous API. As part of the work on this, I've changed the way uploads work, too, so that they're now conducted exclusively via streaming I/O. This means that the data being uploaded to PicasaWeb as a new photo (for example) can just as easily come from memory as it can from disk.

Other improvements include lots of XML escaping fixes, some memory leak fixes, and improvements to cancellation support. Cancellation support is one of the things left on the to-do list before 0.8.0 can be released. While I naïvely thought that cancellation support in libgdata had been fairly good, after poking around in the code for the last few days I've been shown to be very, very wrong. Cancellation doesn't work in many cases, and is racy in others. That will be fixed before 0.8.0

Funnily enough, all this work was prompted by the need to fix the test suite so that libgdata passed its tests on build.gnome.org. It turns out that due to a recent change to g_str_hash() in GLib master, libgdata's test suites started to fail, as they implicitly relied on the order of entries in a hash table when doing XML comparisons using strcmp(). Obviously, this wasn't a brilliant idea. I suppose this is a little word of warning, then: if things involving hash tables in your program suddenly break with GLib ? 2.27.4, it might be because you're (erroneously) relying on the order of entries in a hash table.

The changes to fix the test suite have been backported to libgdata's 0.6 and 0.7 branches, and are present in the new 0.6.6 release. I was a little over-eager with the 0.7 branch, and released 0.7.1 too early, so that doesn't have the fixes. They'll be in 0.7.2 though, whenever that comes out.

MCUS 0.3.0 released

The main window of MCUS 0.3.0.Just a little note to say that:

  1. I'm still alive, and
  2. I've released version 0.3.0 of my microcontroller simulator, MCUS.

It's had a UI overhaul, and I've added accessibility support to the custom widgets (and improved it for the rest of the interface too). It's primarily intended for use in schools in the UK who teach A-level electronics, but I suppose it could be adapted to work for other purposes. It can be downloaded as a tarball (source), NSIS installer or ZIP package (for Windows).

Almanah 0.5.0

Main window of Almanah 0.5.0.

It seems to be release week for me. Here's Almanah Diary 0.5.0. Of note with this release is the support for text formatting (bold, italic and underline — nothing particularly fancy), persistent window dimensions, the ability to set the encryption key, and better recovery from database corruption/errors (although it's still not perfect).

Packagers should note that the GTK+ dependency has been bumped from 2.12 to 2.14, and the GConf dependency is no longer optional — though the GtkSpell dependency now is (as spell checking support is now optional).

I've now also completed the application name migration to "Almanah Diary", and as such, the source is now at http://svn.gnome.org/svn/almanah/, and localisation statistics are at http://l10n.gnome.org/module/almanah/.

Plans for future versions include:

  • Proper accessibility support
  • Automatic link types (yes, this is a stupid name), so that (for example) past Evolution appointments would be shown for each day
  • Documentation
  • Export to blog, text file, HTML, etc.
  • Undo/Redo support

The first three are what I'd like to definitely get done for 0.6.0, but before I can do that I need to sort out the naming for "links" and "automatic links". Obviously these are rubbish names, especially considering one can currently add a "note link". I had considered "attachments", but that's not much better. Does anyone have any ideas?

MCUS version 0.2.1

Here's an announcement I've wanted to make for a while: I'm releasing my microcontroller simulator, MCUS. It's a fairly simple simulator designed to aid in teaching the OCR 2008 A-level electronics syllabus to UK students. As far as I know, it's the only simulator available which follows the new syllabus (for which OCR have deigned to write their own simple assembly language, obsoleting any previous simulators used in schools).

It's already had three releases (this is the fourth), but I didn't want to make the 0.1.x releases too public, as they were mainly for testing the program at school. The 0.2.0 release was a brown paper bag release, due to a bad GTK+ version dependency, and some files necessary for the Windows zip package not being included.

It's available on the MCUS project page, with 0.2.1 being the latest release. A Windows installer is available too, built with NSIS; as well as a simple zip package of the installed directory tree on Windows, since the program's relocatable.

My school is already using it, and I'm releasing it in the hope of other schools being able to make use of it. As always, it's open source, released under the GPLv3+.

Future plans include a graph to visualise the ADC waveform, and the addition of more simulated input and output hardware.

Hitori version 0.2

It's been a long time coming, but here's Hitori version 0.2!

As a short overview, the new version introduces:

  • Dynamic board sizing (allowing for boards from 5×5 to 10×10)
  • Rendering improvements, a Tangoisation, and a conversion to use GtkStyle
  • Relicense to GPLv3+
  • A new user manual!
  • Improvements to the algorithms, halving memory usage in the best case
  • A new icon by Jakub Szypulka
  • A desktop file

Hitori now depends on GTK+ >= 2.13, so it may not be easily compilable on some distributions, which is an unfortunate side-effect of using the new gtk_show_uri function.

As before, please contact me to report bugs.

I don't really have any plans to extend the program any further, but if anybody has any ideas, I'm open to them.

Diary version 0.3

I've just released Diary 0.3.1. This is a pretty simple release, fixing a crasher bug, improving corner-case encryption behaviour, adding a French translation by Jean-François Martin, a swizz icon by Jakub Szypulka (and a corresponding desktop file), and finally adding basic search support.

There are no dependency or config changes with this release, so upgrading should be seamless. Any bugs should be reported to the Diary product on GNOME Bugzilla.

Update: I've just released 0.3.1, which is a semi-brown-paper-bag release to fix build failure when compiling without encryption support, as well as fix the desktop file translation.

Diary version 0.2

Using my exam leave productively, I've tidied up and released version 0.2 of my diary editor. This version fixes the crash some people were getting with version 0.1, and introduces database encryption and printing support.

The new version should seamlessly upgrade plaintext databases to encrypted ones, and uses the key from /desktop/pgp/default_key in GConf. If you don't want encryption support – perhaps, for example, as it depends on GPGME – you can compile with --disable-encryption.

The printing support allows you to print the entries in a specified date range in a simple format — nothing suitable for binding for posterity's sake, unfortunately. It's there nonetheless.

Get the Bazaar branch from my website with bzr branch -r tag:V_0_2_0 http://tecnocode.co.uk/diary, from Launchpad, or download the tarball!

Diary editor

The main window of the Diary.I've been keeping a personal diary for a while, but recently I've found that my previous storage method for it – keeping each day's entry in a separate file, stored in a folder hierarchy – was getting too unwieldy. That's why over the last few weeks I've written a small program to manage a diary.

I initially started writing it in Vala, but I found that I was having to put in dirty hacks every couple of tens of lines just to get the simplest things working with an SQLite database. Either due to my own lack of knowledge of Vala, or teething problems for the language and its bindings, I couldn't get it to work, so about a week ago I scrapped it and ported the program to old-fashioned C.

So here it is: version 0.1 of my diary program. It supports basic editing of diary entries, a calendar view of the month and the ability to add "links" to each entry. A "link" is something which connects the diary entry to the wider world, much like a hyperlink connects one web page to another. At the moment only "URI", "file" and "note" link types are supported, but in the future I plan for one to be able to link to anything from an F-Spot album to a section of a chat log in Empathy. Such links would allow references to conversations, e-mails, photo albums (etc.) in diary entries to be easily followed to find the goodies mentioned.

I also have plans to add Evolution calendar integration, as well as potential integration with Mugshot. It would be nice to see diary entries which can show all of what happened on that day, from doctor's appointments in Evolution to the songs Mugshot says you listened to.

Keeping my feet more grounded in reality, however, I think the next thing on the agenda is encryption for the database the diary uses, so your darkest secrets aren't so easily discovered.

To get it, you can either download the tarball or get the latest bzr tree from my website using the following command:

bzr branch http://tecnocode.co.uk/diary/

Thanks to people in the comments for pointing out a better way of branching.

The only requirements are gtk+-2.0 >= 2.12, sqlite3 and gtkspell-2.0, and it's built in the usual fashion.

Feedback is welcomed warmly and given somewhere to stay for the night.

Auto-generated class hierarchy diagrams

Unfortunately still working on that coursework, I've just added support in the API documentation makefile to automatically generate a class hierarchy diagram using the GObject hierarchy file created by gtk-doc and marshalling it to GraphViz. It basically analyses the depth of each line in the hierarchy file and creates relationships in the dot file as appropriate. It doesn't sound complex, but it took a heck of a lot of fiddling to get automake happy with my syntax.

graph-build.stamp:
	echo "digraph class_hierarchy" > $(DOC_MODULE).dot
	echo "{" >> $(DOC_MODULE).dot
	(IFS=$$'\n'; \
	for current_line in `cat $(DOC_MODULE).hierarchy`; do \
		depth_colours=( red green blue yellow ); \
		depth=`echo $$current_line | grep -o "  " | wc -l | sed s/\ //g`; \
		echo "$$current_line [shape=box, color=$${depth_colours[$$depth]}]" >> $(DOC_MODULE).dot; \
		last_line[$$depth]=$$current_line; \
		if [ $$depth -gt 0 ]; then \
			echo "$${last_line[`expr $$depth - 1`]} -> $$current_line" >> $(DOC_MODULE).dot; \
		fi; \
	done)
	echo "}" >> $(DOC_MODULE).dot
	dot -Tpng $(DOC_MODULE).dot > $(DOC_MODULE).png
	touch graph-build.stamp