blob: f50351f22651c3286658cd76476a668f8d4c953e [file] [log] [blame]
Kevin Ferrare93b2f9f2007-08-04 03:01:46 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $
9 *
Nicolas Pennequin357ffb32008-05-05 10:32:46 +000010 * Copyright (C) 2007 Copyright Kévin Ferrare
Kevin Ferrare93b2f9f2007-08-04 03:01:46 +000011 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
Kevin Ferrare93b2f9f2007-08-04 03:01:46 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21#include "clock_draw_binary.h"
22#include "clock_bitmap_strings.h"
23#include "clock_bitmaps.h"
24#include "picture.h"
25
26const struct picture* binary_skin[]={binary,digits,segments};
27
28void print_binary(char* buffer, int number, int nb_bits){
29 int i;
30 int mask=1;
31 buffer[nb_bits]='\0';
32 for(i=0; i<nb_bits; i++){
33 if((number & mask) !=0)
34 buffer[nb_bits-i-1]='1';
35 else
36 buffer[nb_bits-i-1]='0';
37 mask=mask<<1;
38 }
39}
40
41void binary_clock_draw(struct screen* display, struct time* time, int skin){
42 int lines_values[]={
43 time->hour,time->minute,time->second
44 };
45 char buffer[9];
46 int i;
47 const struct picture* binary_bitmaps = &(binary_skin[skin][display->screen_type]);
Kevin Ferrare14d27612007-08-04 14:50:28 +000048 int y_offset=(display->height-(binary_bitmaps->height*3))/2;
49 int x_offset=(display->width-(binary_bitmaps->width*6))/2;
Kevin Ferrare93b2f9f2007-08-04 03:01:46 +000050 for(i=0;i<3;i++){
51 print_binary(buffer, lines_values[i], 6);
Kevin Ferrare14d27612007-08-04 14:50:28 +000052 draw_string(display, binary_bitmaps, buffer, x_offset,
53 binary_bitmaps->height*i+y_offset);
Kevin Ferrare93b2f9f2007-08-04 03:01:46 +000054 }
55}