Wiki

Clone wiki

Pipsta / Advent Calendar

Difficulty Level

pipsta_mono.pngpipsta_mono_empty.pngpipsta_mono_empty.pngpipsta_mono_empty.pngpipsta_mono_empty.png

  • No Linux or Raspberry Pi knowledge is required
  • A fully assembled and set-up Pipsta and an internet connection are all that is required
  • Step-by-step instructions are provided

Time to Complete

pipsta_mono.pngpipsta_mono_empty.pngpipsta_mono_empty.pngpipsta_mono_empty.pngpipsta_mono_empty.png

  • The whole tutorial takes just a few minutes to complete.

Overview

This project prints out a different image each day from 1st to 25th December. Run it every day to get the full set of pictures and colour them in as you go!

Pre-requisites

This project assumes you have a fully working and configured Pipsta. There are wiki guides on how to assemble and set-up your Pipsta.

Step-by-Step Guide

1) Create a new directory under '/home/pi/pipsta/Examples' called 'christmas',

2) Download the file '1_AdventCalendar.zip' from here to the 'christmas' directory,

3) Right-click the file and select 'Extract Here'

4) You should now see:

• File: advent.py - the script that works-out which image to print

• Directory: image_print - the module that actually prints the image

• Files: 1.png … 25.png - the image that will be printed, one per day

• File: licence.txt - licence information for the 3rd party images used by this application

5) Once you have navigated to '/home/pi/pipsta/Examples/christmas/1_AdventCalendar', press F4 to bring up the terminal

6) In the terminal, type:

#!python

python advent.py

7) Today's advent calendar image will be printed. Note that you can only expect images to be printed for dates in the range 1st December to 25th December!

8) NB: Pipsta is not capable of printing chocolates.

How it Works

• The advent.py script reads the system date and check to ensure the month is 12.

• The script then checks that the day of the month is less than, or equal to 25.

• If all the above checks are passed, the day of the month is used to generate a filename to load. This is simply the day number followed by ".png" (for Portable Network Graphics, a standard image file type.) So, on day 1, the file that would be loaded is "1.png"

• This filename is passed to a command in the image_print module, namely send_to_printer().

• This module is actually really another Python script (albeit with some structure so it is seen as a module and can be called by other scripts.)

• The image_print module:

• Connects the Raspberry Pi to the Pipsta printer over USB

• Loads the image file

• Resizes the image file to fit the width of the Pipsta paper roll

• Converts the image to Pipsta printer graphics commands

• Sends the image data over USB to the Pipsta

New and Novel Aspects

• Pipsta users who have not experimented with examples_gui.py may not have considered using a Python module approach to image printing. advent.py can be seen to be a very short, very straightforward script. Clearly --if a user writes their own script and sets-up the module structure as outlined in this project-- this saves their own code from being 'cluttered' with the USB and printer-specific code image_print.py uses.

Feedback and Support

If you would like to get in touch, please feel free to contact us at support@pipsta.co.uk

Updated