IEEE 802.15.4 subsystem
Sign in or create your account | Project List | Help
IEEE 802.15.4 subsystem Git Source Tree
Root/
Source at commit 33926475741878e548c670f24284ed1b87a24954 created 13 years 2 months ago. By Werner Almesberger, great atusd -> atben renaming: changed the directory name | |
---|---|
1 | /* |
2 | * atrf-rssi/digit.c - Draw 7 segment style digits |
3 | * |
4 | * Written 2010 by Werner Almesberger |
5 | * Copyright 2010 Werner Almesberger |
6 | * |
7 | * This program is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as published by |
9 | * the Free Software Foundation; either version 2 of the License, or |
10 | * (at your option) any later version. |
11 | */ |
12 | |
13 | |
14 | #include <stdint.h> |
15 | |
16 | #include "SDL.h" |
17 | #include "SDL_gfxPrimitives.h" |
18 | |
19 | #include "digit.h" |
20 | |
21 | |
22 | static void hlines_3(SDL_Surface *s, int x0, int x1, int y0, int ym, int y1, |
23 | uint32_t fg) |
24 | { |
25 | hlineColor(s, x0, x1, y0, fg); |
26 | hlineColor(s, x0, x1, ym, fg); |
27 | hlineColor(s, x0, x1, y1, fg); |
28 | } |
29 | |
30 | |
31 | void digit(SDL_Surface *s, int n, int x0, int x1, int y0, int ym, int y1, |
32 | uint32_t fg) |
33 | { |
34 | switch (n) { |
35 | case 8: |
36 | hlineColor(s, x0, x1, ym, fg); |
37 | /* fall through */ |
38 | case 0: |
39 | hlineColor(s, x0, x1, y0, fg); |
40 | vlineColor(s, x0, y0, y1, fg); |
41 | /* fall through */ |
42 | case 7: |
43 | hlineColor(s, x0, x1, y1, fg); |
44 | vlineColor(s, x1, y0, y1, fg); |
45 | break; |
46 | |
47 | case 1: |
48 | lineColor(s, x0, ym, x1, y1, fg); |
49 | vlineColor(s, x1, y0, y1, fg); |
50 | break; |
51 | |
52 | case 2: |
53 | hlines_3(s, x0, x1, y0, ym, y1, fg); |
54 | vlineColor(s, x0, y0, ym, fg); |
55 | vlineColor(s, x1, ym, y1, fg); |
56 | break; |
57 | |
58 | case 9: |
59 | vlineColor(s, x0, ym, y1, fg); |
60 | /* fall through */ |
61 | case 3: |
62 | hlines_3(s, x0, x1, y0, ym, y1, fg); |
63 | vlineColor(s, x1, y0, y1, fg); |
64 | break; |
65 | |
66 | case 4: |
67 | hlineColor(s, x0, x1, ym, fg); |
68 | vlineColor(s, x0, ym, y1, fg); |
69 | vlineColor(s, x1, y0, y1, fg); |
70 | break; |
71 | |
72 | case 6: |
73 | hlines_3(s, x0, x1, y0, ym, y1, fg); |
74 | vlineColor(s, x0, y0, y1, fg); |
75 | vlineColor(s, x1, y0, ym, fg); |
76 | break; |
77 | |
78 | case 5: |
79 | hlines_3(s, x0, x1, y0, ym, y1, fg); |
80 | vlineColor(s, x0, ym, y1, fg); |
81 | vlineColor(s, x1, y0, ym, fg); |
82 | break; |
83 | |
84 | default: |
85 | abort(); |
86 | } |
87 | } |
88 |