Root/tools/atspi-rssi/digit.c

Source at commit 0463bbea5d737f4385ed09997cff6f6ee9232640 created 8 years 11 months ago.
By Werner Almesberger, Added graphical display of RSSI scan results.
1/*
2 * atspi-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
22static 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
31void 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

Archive Download this file



interactive