A few weeks ago my local LUG(which I've been a member of since the start) organized a so called "mini hackaton". We try to do this every three months or so, they're very popular. There's something special with getting together with other nerds and working on projects, be it software or hardware, for a day and chat.

I worked on this: Timerbox a small board with a relay, two buttons, a rotary encoder and an LCD that I've designed. The ┬ÁCU is an Attiny 4313. I managed to get the LCD working quite well with a library written by user alan2k on AVRfreaks.net. This library is based on the library by Peter Fleury modified by Martin Thomas and Andreas Heinzen. It removes most of the "unnecessary" functions like scrolling but adds a very crucial setting for my PCB; disabling/enabling the RW-line. My PCB has the RW-line tied to be write-only, since I very rarely will care if the display says it's done or not, I'll handle it with delays instead.

I did however miss some things on the board, as you always do with 0.1-versions. As you can see the relay is "on stilts", that's because I forgot to change pad size when I did the footprint. I also tied the relays coil pin to +5V instead of +12V for some reason, I don't know what I was thinking there. But it's just version 0.1, 0.2 will be a lot better :)

Today I've been coding a bit on my KSP Control Center project. It's so far just 11 buttons, three SPI-controlled LED-displays and an analouge gauge, but it's getting closer to something more "real" every day.

It's for playing Kerbal Space Program, one of my favourite games. Heres a video of me showing of some of the new displays.

The three position switch in the video is for going between surface, target and orbital velocity. The code's on my github for anyone interested.

I store all my photos on my Fileserver. I am using an android application called Foldersync to sync all my photos as soon as I connect to my homes wifi.
This means I've got a huge folder filled with photos that rarely gets sorted properly.
This is about to change, I've created a script which can find which date the photo was taken and move it to the corresponding folder. It's a fairly simple program, it uses Identify along with awk and friends to figure out the date. I will most likely rewrite it in some other language in the future since this script is a bit barebones.
This script runs as a cronjob each night.

#!/usr/bin/env bash
/usr/local/bin/sort-jpeg.sh /export/Mnt/Photos/sort /export/Mnt/Photos/. &> /root/sortphoto.log

I still need to figure out how to make my camera autoupload photos to that folder though.

I'm redoing my whole blog-thing(again) because logging in to the server, firing up vim and writing HTML is too much of a hassle. Jekyll seems cool and I don't know ruby, so why not? This is the post-recieve-hook I'm using

 #!/usr/bin/env bash
    GIT_REPO=$HOME/blag.git
    TMP_GIT_CLONE=$HOME/tmp/git/blag/
    TMP_WWW=$HOME/tmp/www/
    PUBLIC_WWW=/www/docs/hax0r.se

    git clone $GIT_REPO $TMP_GIT_CLONE
    jekyll build --source $TMP_GIT_CLONE --destination $TMP_WWW
    cp -r $TMP_WWW $PUBLIC_WWW
    rm -Rf $TMP_WWW
    rm -Rf $TMP_GIT_CLONE
    exit

At first it didn't work and I couldn't figure out why... this is like the easiest script in the world, right? Spelling is not my thing today, although I'm usually quite good at it. post-recieve != post-receive(I even misspelled it when I wrote it just now).

My minisumo for Robot SM is getting close to done. Here's a nice little GIF-image showing the assembly process of Perfected Titan.

. All the code can be found at my Gitweb.
I've also filmed a short video of Perfected Titan which you can see below. I'll probably add another video when I've "optimized" the target finding code a bit. It's a finite state machine which reads the front sensors and decides on state from that.
It has got seven states and seven "behaviours".
One thing I did differently with the code on this robot is that I did a function for setting the "heading" of the robot as opposed to setting individual motorspeeds. This gives you some interesting "effects" for free. For example; the "search"-behaviour is this;
set_heading(FULL_SPEED,(ad_value[0] - ad_value[1])*2);
Set_heading works by taking speed and then using the second argument, heading, to calculate individual motorspeeds. In this particular case it works great because if ad_value[1] is larger than ad_value[0] heading will be negative, and the robot will weer to the left, if it's positive it'll weer to the right.

void set_heading(int16_t speed, uint16_t difference) {

        // Set heading, left = speed + diff, right = speed - diff

        int left = speed + difference;

        left = constrain(255,-255,left);

        int right = speed - difference;

        right = constrain(255,-255,right);

        set_motors(left,right);

}

The constrain() is a function that keeps a value between x, y. Nothing fancy. Set_motors() just sets motorspeed on a -255 to 255 scale, where 255 is full speed forward and -255 is full reverse.
Another interesting part of the code is the ADC-reading code. It doesn't do any Kalman filtering or anything, but it constantly reads the ADC-values in an interrupt, roughly 125kHz. It works like this



// ad_value is an array that contains all the ad values

volatile uint16_t ad_value[NR_AD_CHANNEL];

// Local values

volatile unsigned char ad_count=0;



void init_adc(void) {

        //5V AREF

        ADMUX |= (1<<REFS0);



        //AD enable, AD interrupt enable and clk/128 prescaling

        ADCSRA |= (<<ADEN) | (1<<ADIE) | (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);

        

        // Prepares first ad channel

        ADMUX &= 0b11110000;



        // Disable digital on the ADC-pins

        DIDR0 = 0x01;



        //Starts the first conversion

        ADCSRA |= (1<<ADSC);

}



ISR(ADC_vect){

        ad_value[ad_count]=ADC;



        if(ad_count<(NR_AD_CHANNEL-1))

                ad_count++;

        else

                ad_count=0;



        // Select ADC channel with safety mask

        ADMUX = (ADMUX & 0b11110000) | ad_count;

        

        ADCSRA |= (1<<ADSC);

}


Neat huh?