/* * * A simple minute minder for presentations. Adjust the time and the number * of slides using the arrow keys; start the timing using the space key. * * Copyright (c) 2008, Diomidis Spinellis * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: minder.pde,v 1.2 2008/03/28 16:53:00 dds Exp $ * */ /** Number of slides in the presentation. */ int presSlides = 15; /** Duration of the presentation in presMinutes. */ int presMinutes = 30; /** Time of the presentation's start in milliseconds. */ int start; /** True if the presentation has started. */ boolean started; void setup() { size(250, 100); PFont fontA = loadFont("Arial-Black-32.vlw"); textFont(fontA); } void keyPressed() { if (key == ' ') { started = true; start = millis(); loop(); } else if (key == CODED) { switch (keyCode) { case UP: presSlides++; break; case DOWN: if (presSlides > 1) presSlides--; break; case RIGHT: presMinutes++; break; case LEFT: if (presMinutes > 1) presMinutes--; break; } loop(); } } void draw() { // Clear display area fill(255); rect(0, 0, width, height); // Current time in miliseconds int ml = (started ? millis() - start : 0); // Duration of presentation in milliseconds int presMillis = presMinutes * 60 * 1000; // Duration of each slide in milliseconds int slideTime = presMillis / presSlides; textAlign(LEFT); fill(0); // Display current time int minute = ml / 1000 / 60; int second = (ml - minute * 1000 * 60) / 1000; text("T " + (minute < 10 ? "0" : "") + minute + ":" + (second < 10 ? "0" : "") + second + "/" + presMinutes + ":00", 5, 40); // Display the slide we're should be in text("S " + (ml / slideTime + 1) + "/" + presSlides, 5, 80); if (started) delay(500); else noLoop(); }