OVERVIEW
========

This project implements a countdown timer, to be used as i.e.
PCB exposure timer.

Resolution is 1 second. Maximum countdown time is 99:59 but can
be further limiteded by the MAXIMUM_TIME macro in main.c:

#define MAXIMUM_TIME 30*60  /* 30:00 min */

There are two more configurables at the begin of main.c:

#define DEFAULT_TIME 120    /*  2:00 min */
#define NUMBER_BEEPS 120    /* number alert beeps */


The rotary encoder used to set the time has an acceleration
characteristic that can be tuned by the following 3 macros:

#define ACCEL 24            /* acceleration */
#define SCALE 32            /* speed scale, power of 2 recommended */
#define VMAX  30            /* max speed */

The logic is like this:

Every 1ms the encoder is polled. If the encoder did a step, the
SPEED is increased by ACCEL. If there was no step, the SPEED is
decreased by 1 (note: every millisecond).
Maximum SPEED is SCALE * VMAX, minimum is SCALE. The increase and
decrease operations saturate at those boundaries. When an encoder
step is detected, the effective increment is SPEED/SCALE.


HOW TO BUILD
============

The firmware is shipped for the AT90S2312 MCU running at 8MHz.

The MCU type is set in the Makefile:

MCU = at90s2313
-or-
MCU = attiny2313

the code "knows" about AT90S2313 and ATtiny2313. For other devices
you will have to check the code and port some lines.

Once the MCU type is set, it's simply a matter of running "make all".
The Makefile also knows how to flash the controller with AVRDUDE.
Check the AVRDUDE options in the Makefile and use "make flash".
For the ATtiny2313 the lfuse has to be set to use an external xtal.
For that you can use "make fuse".

If you don't need ultimate precision, you can also run the Attiny2313
from the calibrated RC oscillator. The ATtiny2313 ships with 8MHz RC
oscillator and CLKDIV8 fuse set. You just had to unset the fuse.


USAGE
=====

In A Nutshell
-------------
The device will startup with the DEFAULT_TIME loaded from EEPROM.
By turning the rotary encoder the time can be changed. Pushing the
encoder button starts the countdown. The countdown can be interrupted
by pushing the button again. After completing the countdown, a sound
signal is given. Pushing the button once more returns to the begin.

Detailed
--------
There are 3 different states of the device, signaled by 3 LED.

READY: in this state you can modify the time by turning the encoder.
A time of 0:00 is special and can be used to check/set the alert signal.
A short button press will show the current setting as AL: 0/1. A long
button press (>1sec) will switch between 0 (disabled) and 1 (enabled)
and store the setting in EEPROM.

If the time is > 0:00 then a short button press will start the countdown.
A long button press will store the time as default in EEPROM.

RUNNING: the time counts down to 0:00. If the alert signal is enabled,
you will hear a "tick" noise each second. A button press (short or long)
will stop the countdown and jump to the DONE state.

DONE: this state is entered if the countdown was finished or stopped.
If enabled, an acoustic alert is given. Another button press brings you
back to the READY state. If the countdown was stopped, the time remains
unchanged. If the countdown was finished, the time is restored to the
value where the countdown was started.


LICENSE
=======

Everything in this packages is GPLv3 licensed.

