Bump version numbers for 3.13
[maemo-rb.git] / apps / plugins / clock / clock_draw_binary.c
blob611ab1b3714b37d8815396e7ef04777eb903c9d8
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007 Copyright Kévin Ferrare
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
21 #include "clock_draw_binary.h"
22 #include "clock_bitmap_strings.h"
23 #include "clock_bitmaps.h"
24 #include "lib/picture.h"
26 const struct picture* binary_skin[]={binary,digits,segments};
28 static 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;
41 void binary_clock_draw(struct screen* display, struct time* time, int skin){
42 int lines_values[]={
43 time->hour,time->minute,time->second
45 char buffer[9];
46 int i;
47 const struct picture* binary_bitmaps = &(binary_skin[skin][display->screen_type]);
48 int y_offset=(display->getheight()-(binary_bitmaps->slide_height*3))/2;
49 int x_offset=(display->getwidth()-(binary_bitmaps->width*6))/2;
50 for(i=0;i<3;i++){
51 print_binary(buffer, lines_values[i], 6);
52 draw_string(display, binary_bitmaps, buffer, x_offset,
53 binary_bitmaps->slide_height*i+y_offset);