]> git.karo-electronics.de Git - oswald.git/blob - ui/LcdDisplay.c
Add MetaWatch Fonts package, LcdDisplay and start demo
[oswald.git] / ui / LcdDisplay.c
1 #include <time.h>
2 #include <stdio.h>
3 #include <string.h>
4
5 #include "oswald-ui.h"
6 #include "Fonts.h"
7 #include "LcdDisplay.h"
8
9 #define NUM_LCD_ROWS  96
10 #define NUM_LCD_COL_BYTES  ( 12 )
11 #define MAX_FONT_ROWS ( 19 )
12
13
14 gint WriteLcdCharacter(oswald_ui *ui, gint x, gint y, unsigned char Character)
15 {
16         gint CharacterHeight = GetCharacterHeight();
17         gint CharacterWidth = GetCharacterWidth(Character);
18         unsigned int bitmap[MAX_FONT_ROWS];
19         gint lx, ly;
20
21         GetCharacterBitmap(Character,(unsigned int*)&bitmap);
22
23         // printf("cw=%d ch=%d\n", CharacterWidth, CharacterHeight);
24         for (ly=0; ly<CharacterHeight; ly++) {
25                 for (lx=0; lx<CharacterWidth; lx++) {
26                         if (bitmap[ly] & (1<<lx)) {
27                                 set_pixel(ui, lx+x, ly+y, TRUE);
28                                 // printf(".");
29                         } else {
30                                 set_pixel(ui, lx+x, ly+y, FALSE);
31                                 // printf(" ");
32                         }
33                 }
34                 // printf("\n");
35         }
36
37         return CharacterWidth + GetFontSpacing();
38 }
39
40 void WriteLcdString(oswald_ui *ui, gint x, gint y, gchar *str)
41 {
42         gint lx, i;
43
44         if (str == NULL || strlen(str)==0)
45                 return;
46
47         lx = x;
48         for (i=0; i<strlen(str); i++) {
49                 lx += WriteLcdCharacter(ui, lx, y, str[i]);
50         }
51 }
52
53
54 void update_idle_time_date(oswald_ui *ui)
55 {
56         gint gRow = 3;
57         gint gColumn = 4;
58         static gchar secs = 0;
59
60         SetFont(MetaWatchTime);
61
62         //gRow += WriteLcdCharacter(ui, gRow, gColumn, TIME_CHARACTER_SPACE_INDEX);
63         gRow += WriteLcdCharacter(ui, gRow, gColumn, 2);
64         gRow += WriteLcdCharacter(ui, gRow, gColumn, 3);
65         gRow += WriteLcdCharacter(ui, gRow, gColumn, TIME_CHARACTER_COLON_INDEX);
66         gRow += WriteLcdCharacter(ui, gRow, gColumn, 1);
67         gRow += WriteLcdCharacter(ui, gRow, gColumn, 7);
68         gRow += WriteLcdCharacter(ui, gRow, gColumn, TIME_CHARACTER_COLON_INDEX);
69         gRow += WriteLcdCharacter(ui, gRow, gColumn, (secs / 10));
70         gRow += WriteLcdCharacter(ui, gRow, gColumn, (secs % 10));
71         secs = ++secs % 60;
72 }
73