/* * bigbin.c - display big binary time * * Copyright (C) 2003 Nathan Laredo (laredo@gnu.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include #include static char *digits[2] = { " 000000 " "00000000" "00 00" "00 00" "00 00" "00 00" "00000000" " 000000 ", " 11 " " 1111 " " 11 " " 11 " " 11 " " 11 " " 111111 " " 111111 ", }; static void paintchar(char *ch, int x, int y) { int i; char line[9]; line[8] = '\0'; for (i = 0; i < 8; i++) { fprintf(stderr, "\E[%d;%dH", y + i + 1, x + 1); strncpy(line, ch + i * 8, 8); fprintf(stderr, line); } } int main(int argc, char **argv) { time_t now; struct tm *tmp; int val[6 * 3], oldval[6 * 3]; int i; fprintf(stderr, "\E[H\E[2J"); for (i = 0; i < 6 * 3; i++) { oldval[i] = 117; } while (1) { now = time(NULL); tmp = localtime(&now); for (i = 0; i < 6; i++) { val[i] = ((tmp->tm_hour & (1<<(5-i))) != 0); val[i + 6] = ((tmp->tm_min & (1<<(5-i))) != 0); val[i + 12] = ((tmp->tm_sec & (1<<(5-i))) != 0); } for (i = 0; i < 6 * 3; i++) { if (val[i] != oldval[i]) { paintchar(digits[val[i]], (i % 6) * 9, 9 * (i / 6)); } } sleep(1); memcpy(oldval, val, sizeof(val)); } exit(0); }