Skip to content
Browse files

clock: clean up printTime()

  • Loading branch information...
1 parent 940bb8e commit aeff9050fc9c99cb59bdb119de8a5808c865a3af @lynxeye-dev lynxeye-dev committed Apr 13, 2011
Showing with 28 additions and 7 deletions.
  1. +15 −5 clock/clock.c
  2. +11 −1 clock/clock.h
  3. +2 −1 main.c
View
20 clock/clock.c
@@ -166,11 +166,21 @@ inline uint8_t getMode() {
return currentMode;
}
-void printTime(bitmap_t destination) {
- //simpleBinary(destination, time.hours, time.minutes, time.seconds, currentMode);
- raisingBars(destination, time.hours, time.minutes, time.seconds, currentMode);
- //analogClock(destination, time.hours, time.minutes, time.seconds, currentMode);
- //dices(destination, time.hours, time.minutes, time.seconds, currentMode);
+void printTime(bitmap_t destination, const enum CLOCK_THEME theme) {
+ switch(theme) {
+ case THEME_ANALOG:
+ analogClock(destination, time.hours, time.minutes, time.seconds, currentMode);
+ break;
+ case THEME_BARS:
+ raisingBars(destination, time.hours, time.minutes, time.seconds, currentMode);
+ break;
+ case THEME_BINARY:
+ simpleBinary(destination, time.hours, time.minutes, time.seconds, currentMode);
+ break;
+ case THEME_DICES:
+ dices(destination, time.hours, time.minutes, time.seconds, currentMode);
+ break;
+ }
}
// Interupt service routine for clock overflow
View
12 clock/clock.h
@@ -30,6 +30,16 @@ enum CLOCK_MODE {
};
/**
+ * enum CLOCK_THEME specifies the printTime() design
+ */
+enum CLOCK_THEME {
+ THEME_ANALOG,
+ THEME_DICES,
+ THEME_BARS,
+ THEME_BINARY
+};
+
+/**
* struct timeval_t holds all time related values
*/
struct timeval_t {
@@ -70,6 +80,6 @@ uint8_t getMode();
/**
* Used to generate a bitmap based on the given time.
*/
-void printTime(bitmap_t destination);
+void printTime(bitmap_t destination, const enum CLOCK_THEME theme);
#endif // CLOCK_H_INCLUDED
View
3 main.c
@@ -34,7 +34,8 @@ int main(void)
while(1) {
handleKeyInput();
- printTime(bitmap);
+ // XXX: this should only be called if there is actually something new
+ printTime(bitmap, THEME_BARS);
scanout(bitmap);
}

0 comments on commit aeff905

Please sign in to comment.
Something went wrong with that request. Please try again.