HGD 0.4.0 Released

Version 0.4.0 is all rolled up, so come on people grab a copy! See the change log for full details but the biggest new feature is scripting support. You can now add your own functionality to HGD via Python! This means that adding new functionality like scrobbeling should be a few lines of plugin code. The plugin support still needs work but you should be able to get your hack-on now.

Whats new?

  • Scripting support (via experimental Python plugin system.)
  • Coloured output.
  • New Autoconf based build system
  • Tag support for mp3, ogg etc.
  • HUD refresh rate in hgdc configurable
  • Possible race condition fixed when voting off songs.
  • Password can be set in config file for the lazy
  • Bugfixes

For a full list of changes / issues see github.

Download!

Posted in Software | Leave a comment

Re-use and recycle: various gardening hacks

Rice container

Rice container

Upside-down Tomato Planter

I was reading online about upside-down tomato planters, and how particular varieties of tomato grow well in hanging baskets and the like.  We had recently finished a pot of rice, and I had kept the container just in case I could use it for something.

I drilled a couple of holes in the bottom of the container with the biggest drill-bit I could find.  This was very difficult because the pot kept spinning round when I tried to drill it!  I managed to wedge it on the ground and eventually made a tomato plant sized hole in the bottom.

Recycled tomato planter

Recycled tomato planter

I filled the container right to the top with compost mixed with fertiliser, put the lid back on, and then pushed the tomato plant into the base of the container.  I turned it upside-down again and made sure it was completely full of compost.  I then made a hole in the lid to facilitate watering, and hung the container up by the handle.

Since taking this photo, I have wrapped a tea towel around it, and secured it with pegs in order to protect the roots from the sun, which can damage them.


Recycled wine and port box planters

Wine box planters

Wine box planters

Our local Oddbins was closing down, so we went in to see what bargains were to be had.  Sadly, all the booze had been sold, but I spotted these wooden port and wine boxes, going for £2 each.  We grabbed a couple and headed home, thinking about what to plant in them.

 

Holes drilled in the bottom
Holes drilled in the bottom
Courgette plant
Courgette plant

 

I drilled four holes in each of them, and filled them with compost.  I have planted a courgette plant in one, and salads in the other.

 

Posted in Crafting, Gardening | Leave a comment

Hexy: Binary to Hex Array Converter.

Just after the second hack night,  Tim was temporarily staying at my house for a while, and one evening just happened to be working on some embedded PIC stuff.

He was writing a system to serve an image over a simple web server that was running on the chip itself. Now, I’m not too familiar with embedded C, but my skills as an application developer were still useful that evening!

In order to work with an image on a system with no filesystem, or indeed kernel, the binary data of the image file (in this case it was a jpeg) needed to be entered into an array of bytes within the C source code, a bit like the example shown here:

  unsigned byte data[] = {0x3C,0x3F,0x78,0x6D...};

Tim approached me to create a Windows tool that could automate this, and so I opened up Lazarus and got coding! In a few minutes I had a solution (at the time we named it TimHex). After a few more minutes of optimisation, the finished utility worked pretty well, and we were able to serve images up from the PIC.

hexy
Hexy for Windows

So why this blog post? Well, in the last week or so I resurrected TimHex, renamed it, tidied it up, made it cross-platform and open sourced it.  The result of all this hard work is Hexy, which can be found on my GitHub page.

Feel free to have a look and post comments.

I already have some plans for future changes to it, including a command-line only interface and configurable outputs. I hope to be able to continue working on it in my spare time.

Posted in Hardware, Programming | 1 Comment

Lazarus Talk at Barcamp Canterbury 1

This weekend just gone saw the first Barcamp to occur in my home town of Canterbury. It went incredibly well and was greatly enjoyable.

It was my first Barcamp, and I presented one presentation on the open source Lazarus IDE, the slides of which can be found here.

Big thanks to Andy for organising the Barcamp, and I really hope it happens again next year as it was really great to meet like-minded individuals all in one place and exchange ideas and information with one another.

It was also great to see Edd win the prize for best talk for his presentation on HGD.

Posted in Programming | 2 Comments

HGD 0.3.0 Released

We are still alive! We are pleased to announce the latest and greatest version of HGD. This is a maintenance release, and though we have new features there has been no API changes so you can continue using your old client/server as you want.

Whats new?

  • Config files!
  • Flood-limit is now configurable.
  • Bug Fixes.

Download!

Posted in Software | Leave a comment

HGD 0.2.0 Released

Our first public release of HGD is now available!

There are lots of bug fixes and feature tweaks added since the last time we talked about HGD for full details see our changelog.

The most important changes are:

  • SSL encryption
  • User Authenticaion
  • Many bug fixes

And this what we will be working on next:

So grab the source and give it a try!

Posted in Software | Leave a comment

Getting Faster USB Charging from an In Car Charger

The other day I was driving to work with my brand new Google Nexus S Android phone on the dashboard, as usual. A new version of Google Maps had just come out, and coupled with the fact that I had just got a new phone, I decided to test the navigation.

Nexus S

Google Nexus S

When I got to work, I noticed the battery level on my phone was lower than I would have expected, so I viewed the battery discharge graph, and was surprised to see that the battery charge had been depleting all the while I was navigating with the screen on, even though the Nexus S was connected to the in car USB port, and charging all the while. My in car USB port is rated at 1A, but something was surely up.

After some Googling, I came to the conclusion that the phone was thinking it was connected to a standard USB port, not an AC adapter, and was therefore limiting itself to only draw 500mA of current, irrespective of what the charger can deliver, to remain compliant with USB standards (where a computer USB port can only deliver a maximum of 500mA).

To confirm what I had suspected, I used the Nexus’s diagnostic mode. To enter this mode, I simply tap the code *#*#INFO#*#* into the dialer. When the main diagnostic screen appeared, I clicked “Battery information” to see what source the Nexus thought it was connected to. Sure enough, when connected to the in car USB, this screen was reporting “USB”, meaning that the phone is not able to take advantage of the 1A output of the car charger.

So what I wanted to do was make the phone think it was connected to an AC adapter. To do this, the data lines on the USB connector (D+ and D-) must be shorted together. this signals to the phone that it is not connected to a computer and then the phone will go into fast charging mode.

I then took a cheap micro USB cable and used a multimeter to check the connections on the cables, as we don’t want to short out the power + and – lines, that would be really bad! Once the correct cables were determined, I simply cut them, and soldered them together, as shown in the image.

USB

Shorting the data lines

After putting the case back on the connector on the cable, I connected the phone back up to the car’s USB port, and sure enough, the phone reported itself as connected to AC as the charging mode on the INFO Screen.

Testing this the next day, the battery graph showed a slight increase in charge over the course of the journey rather than the slight discharge of before, so the hack was a success.

So now I have a cable specifically for using in the car. I do not recommend using this to connect to a PC or other “real” USB port, just in case!

Posted in Hardware | 14 Comments

pwn PWM

Not really much of a hack for this hack session, but still a lot of fun – PWM output control in a PIC microcontroller for a configurable H bridge / 3 phase bridge. A High/Low pair of outputs is set up in complementary mode with a dead time (where in a transition, both outputs are off for a short period of time) so we never get the scenario with slow reacting FET’s, of both High and Low sides of the bridge being on at the same time hence shorting the circuit.

Oscilloscope Complementary H/L PWM trace

The simplest implementation here is a H bridge – we have two High-Low bridges with say a DC motor connected across the centre of the bridge. In that case, we complementary control PWM on one side of the H bridge, and we logic control the other side. We control the duty cycle of the PWM which controls the speed of the motor, and we could swap sides that are being PWM and Logic, to make the motor move in the opposite direction.

Finally, we throw in some varying setpoints to alter the duty cycle. I also added some code to allow the motor to move in either direction from a positive or negative set point.

And there we have it;

void pwmForward(void) {
  P1OVDCONbits.POVD1L = 1;    /* PWM */
  P1OVDCONbits.POVD1H = 1;    /* PWM */
  P1OVDCONbits.POVD2L = 0;    /* Override */
  P1OVDCONbits.POVD2H = 0;    /* Override */
}

void pwmReverse(void) {
  P1OVDCONbits.POVD1L = 0;    /* Override */
  P1OVDCONbits.POVD1H = 0;    /* Override */
  P1OVDCONbits.POVD2L = 1;    /* PWM */
  P1OVDCONbits.POVD2H = 1;    /* PWM */
}

A gotcha – Using Port IO on the logic side left the output at a mid level – there is however an override register which sets or clears the logic level so use this rather than conventional TRIS/LAT when using PWM. (It is all in the documentation, but hack night is about beer and fun, not documents!)

/* Low side active when override active */
P1OVDCONbits.POUT1L = 1;

/* High side inactive when override active */
P1OVDCONbits.POUT1H = 0;

/* Low side active when override active */
P1OVDCONbits.POUT2L = 1;

/* High side inactive when override active */
P1OVDCONbits.POUT2H = 0;
Posted in Programming | Leave a comment

Unveiling HGD – The Hackathon Gunther Daemon

If you have been following the canthack blog, you will have read about the LPD hack and undoubtedly noted it’s limitations.

So… At the last hack, we tested some code myself and Mex have been working on in our spare time. I hereby introduce HGD – The Hackathon Gunther Daemon.

HGD is a music system suitable for hackathons, internet cafes, LAN parties etc. Music is played on one set of speakers and clients queue up media from their own machines over the network. Because we use MPlayer to play media, you can send anything MPlayer understands, including video.

HGD was inspired by the LPD hack — a music system used at OpenBSD hackathons. We plan to implement similar functionality and extend it.

Current features
—————-

  • Network listener daemon.
  • Player daemon (uses mplayer).
  • Command line client with the ability queue and vote-off tracks.
  • Works on Linux and OpenBSD.

A few bugs were found at the hack, but we believe we have fixed them.

Please go ahead and test it — we plan to tag a release fairly soon, so if you find bugs, please file them on github. After this we plan to add authentication support.

There is also a GTK client on the way from Mex. If you pester him, he might put the code up. The HGD protocol is very simple, so if you want to write a client, it should not be too difficult — you will just need to bone up on TCP socket programming in your favorite language (Someone please write an android client).

Enjoy

Posted in Programming, Unix | 1 Comment

Run in case of Death

And every day it gets harder to fight the urge to su to the user and freak people out.

OK so I figured – I’ve got irssi running in screen on my virtual server, like most good geeks.  What happens if I get hit by a bus/fall down a well/die from a phase-to-phase electrical shock?

Assuming that my bank account continues to work for some time, I will continue paying my subscription and my server will continue to operate.  My screen session will stay active for quite some time after that.  So, after I die, I will still be joined to #sparkfun and #openrightsgroup – and nobody in there will be the wiser that one of the people on their channel is in fact dead.  If you are in a busy channel (say, #ubuntu or #debian) it is very possible that one of the people in there is in fact dead.  And you’d never know it.  Spooky, eh?

So, I wanted to try and rectify this problem.  As such, I started hacking together a Python script which I will run on a cron-job (once it is completed).  It’s pretty simple:

#!/usr/bin/env python

import os
import time

QUESTIONABLE = 48 * 3600
VERY_QUESTIONABLE = 72 * 3600
DEAD = 14 * 24 * 3600

alivefile = os.stat('~/.alive')
difference = time.time() - alivefile.st_atime

if (difference > QUESTIONABLE):
        print "You might be dead .... I'll ask"
if (difference > VERY_QUESTIONABLE):
        print "You're starting to worry my now"
elif (difference > DEAD):
        print "You're dead.  I'll tell your friends"
else:
        print "You're alive.  Yay!"

It’s really nothing special, all it does is check the access time on a file (called “alive”).

Currently, it doesn’t do anything other than print something when it gets worried.  However, I plan to hook into Clickatel and have it send me a SMS in that instance, and remind me to ping it should I forget.

I’ve added a line to my .bashrc

touch ~/.alive

So every time I log in, it updates the access time on the file.

Sending a SMS to my AQL number can also run a script which will update the access time on the file.

After that, I need to write some irssi plugins that hook into every time I send a message to update the access time again (gotta be alive to send a message on irssi).

And finally, once I’ve done this, I’ll write some plugins for irssi that will run in the case of my death.  I’m not entirely sure what it might do – maybe let everyone know that I am now dead and leave all of the channels.  Or try and freak people out a bit and switch to a Markov chain bot which uses all of the text I’ve ever said on IRC from my log files – and make it look like I’m still there (but possibly deranged).

Now, the question is – can find a service which will let me programatically send a letter via some kind of API, and send out a condolences greeting card for myself?

Posted in Programming | 1 Comment