Kevin Ferrare | 93b2f9f | 2007-08-04 03:01:46 +0000 | [diff] [blame] | 1 | /*************************************************************************** |
| 2 | * __________ __ ___. |
| 3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ |
| 4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / |
| 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
| 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
| 7 | * \/ \/ \/ \/ \/ |
| 8 | * $Id: jackpot.c 14034 2007-07-28 05:42:55Z kevin $ |
| 9 | * |
Nicolas Pennequin | 357ffb3 | 2008-05-05 10:32:46 +0000 | [diff] [blame] | 10 | * Copyright (C) 2007 Copyright Kévin Ferrare |
Kevin Ferrare | 93b2f9f | 2007-08-04 03:01:46 +0000 | [diff] [blame] | 11 | * |
Daniel Stenberg | 2acc0ac | 2008-06-28 18:10:04 +0000 | [diff] [blame^] | 12 | * 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 Ferrare | 93b2f9f | 2007-08-04 03:01:46 +0000 | [diff] [blame] | 16 | * |
| 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 | |
| 26 | const struct picture* binary_skin[]={binary,digits,segments}; |
| 27 | |
| 28 | void 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 | |
| 41 | void 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 Ferrare | 14d2761 | 2007-08-04 14:50:28 +0000 | [diff] [blame] | 48 | int y_offset=(display->height-(binary_bitmaps->height*3))/2; |
| 49 | int x_offset=(display->width-(binary_bitmaps->width*6))/2; |
Kevin Ferrare | 93b2f9f | 2007-08-04 03:01:46 +0000 | [diff] [blame] | 50 | for(i=0;i<3;i++){ |
| 51 | print_binary(buffer, lines_values[i], 6); |
Kevin Ferrare | 14d2761 | 2007-08-04 14:50:28 +0000 | [diff] [blame] | 52 | draw_string(display, binary_bitmaps, buffer, x_offset, |
| 53 | binary_bitmaps->height*i+y_offset); |
Kevin Ferrare | 93b2f9f | 2007-08-04 03:01:46 +0000 | [diff] [blame] | 54 | } |
| 55 | } |