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 | |
| 22 | #include "clock.h" |
| 23 | #include "clock_draw.h" |
| 24 | #include "clock_draw_digital.h" |
| 25 | #include "clock_draw_analog.h" |
| 26 | #include "clock_draw_binary.h" |
| 27 | #include "clock_settings.h" |
| 28 | |
| 29 | void black_background(struct screen* display){ |
| 30 | #if (LCD_DEPTH > 1) || (defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH > 1)) |
| 31 | if(display->depth>1){ |
| 32 | display->set_background(LCD_BLACK); |
| 33 | display->clear_display(); |
| 34 | }else |
| 35 | #endif |
| 36 | { |
| 37 | display->clear_display(); |
| 38 | display->fillrect(0,0,display->width,display->height); |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | void white_background(struct screen* display){ |
| 43 | #if (LCD_DEPTH > 1) || (defined(LCD_REMOTE_DEPTH) && (LCD_REMOTE_DEPTH > 1)) |
| 44 | if(display->depth>1){ |
| 45 | #if defined(HAVE_LCD_COLOR) |
| 46 | if(display->is_color)/* restore to the bitmap's background */ |
| 47 | display->set_background(LCD_RGBPACK(180,200,230)); |
| 48 | else |
| 49 | #endif |
| 50 | display->set_background(LCD_WHITE); |
| 51 | } |
| 52 | #endif |
| 53 | display->clear_display(); |
| 54 | } |
| 55 | |
| 56 | bool skin_require_black_background(int mode, int skin){ |
| 57 | return((mode==BINARY && skin==2) || (mode==DIGITAL && skin==1 )); |
| 58 | } |
| 59 | |
| 60 | void skin_set_background(struct screen* display, int mode, int skin){ |
| 61 | if(skin_require_black_background(mode, skin) ) |
| 62 | black_background(display); |
| 63 | else |
| 64 | white_background(display); |
| 65 | } |
| 66 | |
| 67 | void skin_restore_background(struct screen* display, int mode, int skin){ |
| 68 | if(skin_require_black_background(mode, skin) ) |
| 69 | white_background(display); |
| 70 | } |
| 71 | |
| 72 | void clock_draw_set_colors(void){ |
| 73 | int i; |
| 74 | FOR_NB_SCREENS(i) |
| 75 | skin_set_background(rb->screens[i], |
| 76 | clock_settings.mode, |
| 77 | clock_settings.skin[clock_settings.mode]); |
| 78 | } |
| 79 | |
| 80 | void clock_draw_restore_colors(void){ |
| 81 | int i; |
| 82 | FOR_NB_SCREENS(i){ |
| 83 | skin_restore_background(rb->screens[i], |
| 84 | clock_settings.mode, |
| 85 | clock_settings.skin[clock_settings.mode]); |
| 86 | rb->screens[i]->update(); |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | void clock_draw(struct screen* display, struct time* time, |
| 91 | struct counter* counter){ |
| 92 | if(!clock_settings.general.show_counter) |
| 93 | counter=0; |
| 94 | int skin=clock_settings.skin[clock_settings.mode]; |
| 95 | skin_set_background(display, clock_settings.mode, skin); |
| 96 | if(clock_settings.mode == ANALOG) |
| 97 | analog_clock_draw(display, time, &clock_settings, counter, skin); |
| 98 | |
| 99 | else if(clock_settings.mode == DIGITAL) |
| 100 | digital_clock_draw(display, time, &clock_settings, counter, skin); |
| 101 | |
| 102 | else if(clock_settings.mode == BINARY) |
| 103 | binary_clock_draw(display, time, skin); |
| 104 | display->update(); |
| 105 | } |