Skip to content

lawrie/piglowd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

piglowd

A daemon for PiGlow.

Overview:

This project is a low impact background daemon to display patterns on a PiGlow LED display board.

The PiGlow hardware is dedicated to the Raspberry Pi computer, so this daemon is not relevant outside a Raspberry Pi.

The daemon can be set up to provide a simple visual indicator of the status of the Pi.

The patterns are generated by a simple pattern language, requiring minimal resource from the Pi.

The daemon reads its pattern library as a set of one line pattern specifications contained in it's config file,and changes pattern under control of a file in the /tmp file system. Patterns can be terminating or run continually.

It depends on the WiringPi library for the low level control routines.

Install:

The daemon is only available as source code.

First install and test the WiringPi library.

Copy the provided Makefile and piglowd.c source to a build directory and type make.

Copy the resulting piglowd object to a suitable location in the path. /usr/bin is one such suitable location.

Copy the provided piglowd.conf to /etc/piglowd.

Feel free to edit the order and contents of the included patterns as suits your needs. The pattern language is described below.

Test:

Run "sudo gpio load i2c" to initialise the interface. This setup is required once after each boot.

As an unpriviliged user run "piglowd" to start the background daemon.

It will run pattern 0 by default, which is a terminating pattern in the provided piglowd.conf file, so will run a few rounds of a pattern and then the PiGlow will blank.

Controls:

The daemon responds to single characture messages written to the file /tmp/piglowfifo

The present command set is sixteen pattern specifications 0-f and commands to freeze the display, clear the dislay, re-read the config file and close down the daemon.

To issue commands to the daemon "echo >/tmp/piglowfifo".

Thus -

echo x >/tmp/piglowfifo will shut down the daemon. echo q >/tmp/piglowfifo will turn off the display echo s >/tmp/piglowfifo will freeze the display echo n >/tmp/piglowfifo will step to the next pattern state echo g >/tmp/piglowfifo will unfreeze the display echo r >/tmp/piglowfifo will force a reload of the config file

and any char from 0 to f will load the pattern at that index in the config file.

Autorun:

If you want to autostart the daemon on a Raspebian distribution, copy the supplied piglowd.sh start script to /etc/init.d and run rc.update to generate the apropriate startup and shutdown links.

The piglowd will start after all services load, and will stop early in the Pi's shutdown sequence.

Pattern language:

Currently 16 patterns can be concurrently loaded to the daemon. That set can be changed while the daemon is active by modifying the config file and forcing the daemon to re-read its config file.

You define a pattern by a line in /etc/piglowd/piglowd.conf. The order of patterns in the config file defines their index in the daemons pattern list.

The pattern language is based on up to three nested for loops with subscripts i, j and k.

The PiGlow hardware offers 18 LED's three of each of six colours. The LED's are mounted in concentric circles with each circle offset, to give a three legged whirlpool effect.

LEDs are numbered by ring and leg number, following the same convention as wiringPi.

"Legs" numbers are 0-2 and "rings" numbers are 0-5 counting from the outside in.

The pattern line consists of a set of tokens separated by spaces.

The tokens are -

For loop token

index=start-end where index is i,j or k and start and end are integers (0 to 65000). if the second integer is omitted it is assumed infinite. optionally the integer(s) are followed by a comma seperated step integer and/or preceeded by a ? which selects a random integer bounded by start and end

   for_loop = [ i | j | k ][ ? | = ] <start> - [ <end> ] | [ ,<step> ] 

Ring identifier r index=intensity or r number=intensity where index is i,j or k and intensity is 0-255

    ring_identifier = r [ i | j | k | <number 0-5> ] = <number 0-255>

Leg identifier l index=intensity or l number=intensity

    leg_identifier = l [ i | j | k | <number 0-2> ] = <number 0-255>

LED identifier r index l index=intensity where index is i,j or k, or can be a number.

   led_identifier = r [ i | j | k | <number 0-2> ] l [ i | j | k | <number 0-5> ] = <number0-255>


Delay: d milliseconds

Leg numbers are trucated modulo 3, and ring numbers modulo 6. This makes writing loops easier.

example:

i=0- j=0-5 rj=100 d100 rj=0 j=5-0 rj=100 d100 rj=0

This means for i from 0 to infinity, for j from 0 to 5 set all LEDs in the selected ring to intesity 100, delay 100 milliseconds and switch the ring off, and then do the same for j from 5 to 0 counting down. This causes concentric rings to be lit going inwards and then outwards, forever.

About

A daemon for PiGlow

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published