This is my code for a darkroom timer using:
- RaspberryPi
- IoT Relay (power switch)
- 8x8 x4 LED Matrix
- USB Numpad
The SPI and IoT device should be connected before the software is installed
The IOT device should be connected to GPIO 18 (aka PI Pin number 12). Check your relay device if uses ACTIVE HIGH mode or not and set ACTIVE_MODE_HIGH correctly.
- Enable SPI launch
sudo raspi-config
and into5 Interface Options
setP4 SPI
toYes
- Launch
sudo raspi-config
and into3 Boot Options
thenB1 Desktop / CLI
and setB2 Console Autologin
- Add user to proper groups
sudo usermod -a -G spi,gpio pi
- Install luma pre-reqs
sudo apt update && sudo apt install -y build-essential python3-dev python3-pip python3-venv libfreetype6-dev libjpeg-dev libopenjp2-7 libtiff5 git
- Checkout darkroom
cd ~ && git clone https://github.com/cdgriffith/darkroom && cd darkroom
- Create a virtual env
python3 -m venv venv
- Activate env
source venv/bin/activate
- Update pip
python -m pip install --upgrade --ignore-installed pip setuptools
- Install requirements
pip install -r requirements.txt
- Test the program
python -m darkroom
- Add it to bashrc
echo "PYTHONPATH=/home/pi/darkroom /home/pi/darkroom/venv/bin/python -m darkroom" > ~/.bashrc
Once added to the bashrc file, it will automatically launch when the user logs in. This will "take over" the console, even on SSH connections, so remember if you need to switch back to console to hit E or Ctrl+C first.
* Start key capture (to input time via number keys, hit "*" again to accept)
+ Add a tenth of a second or a fraction of stop (see STOP_INCREMENTS)
- Remove a tenth of a second or a fraction of stop (see STOP_INCREMENTS)
/ "Focus" - Turn the enlarger on
ENTER "Print" - Enlarger on, timer counts down to zero then turns the enlarger back off
e Pressing E or Ctrl+C Will exit the program
Using STOP_INCREMENTS=False, + and - will, respectively, add 0.1 o subtract 0.1 seconds. However I think is more useful to use f/stop increments. If you set STOP_INCREMENTS to 6 (values: 1,2,3,4,5,6,7,8,9,10,11,12 are accepted) when you press + or -, the timer will be adjusted by a 1/STOP_INCREMENTS of STOP. For example if current time is 10 seconds and STOP_INCREMENTS=1 (1 full stop) the first time you press + the timer will be adjusted to 20 seconds, the second time to 40 seconds and so on. If STOP_INCREMENTS is 6, the increments will be 11.2, 12.6, 14.1 and so on. If the timer is set to 14.1 and STOP_INCREMENTS is 6, you'll go in reverse: 12.6, 11.2, 10 and so on.
If you buy a HID USB footswitch, you can set the FOOTSWITCH_KEY to use it as an alias of Enter button. E.g. my footswitch works as "b" key out of the box, so I can set FOOTSWITCH_KEY=b and when I press the footswitch the timer starts.
It is possible to customize a few things with environment variables
- X_OFFSET (default 0)
- Y_OFFSET (default -2)
- BLOCK_DIR (default -90)
- ENLARGER_PIN = (default 18)
- STARTUP_MESSAGE = (default 'LOVE U')
- FONT_FILE = (default "darkroom/fonts/scoreboard.ttf")
- ACTIVE_MODE_HIGH = (default True)
- STOP_INCREMENTS = (default False)
- FOOTSWITCH_KEY = (default 'b')
This is MIT Licensed, view the LICENSE file for details.
This is using the Free for personal use Scoreboard font available at https://www.ffonts.net/Score-Board.font