Date:2011-06-25 03:29:17 (8 years 2 months ago)
Author:Werner Almesberger
Commit:5392401c0acbabadccf1e47abe59f05e25db9a7f
Message:tools/atrf-rssi/: added menu for regulation area selection

- gui.c (area_off, gui): don't show a regulation area by default
- letter.h, letter.c: drawing of limited character set
- Makefile (OBJS_host, OBJS_ben_jlime): added letter.o
- gui.c (print, area_selector, gui): show regulation area selector
Files: tools/atrf-rssi/Makefile (1 diff)
tools/atrf-rssi/gui.c (6 diffs)
tools/atrf-rssi/letter.c (1 diff)
tools/atrf-rssi/letter.h (1 diff)

Change Details

tools/atrf-rssi/Makefile
1818CFLAGS_host += $(shell sdl-config --cflags)
1919MACROS_host += -DHAVE_GFX
2020LDLIBS_host += $(shell sdl-config --libs) -lSDL_gfx
21OBJS_host = gui.o zgrid.o digit.o
21OBJS_host = gui.o zgrid.o digit.o letter.o
2222
2323CFLAGS_ben_jlime += $(shell sdl-config --cflags)
2424MACROS_ben_jlime += -DHAVE_GFX
2525LDLIBS_ben_jlime += -lSDL -lSDL_gfx
26OBJS_ben_jlime = gui.o zgrid.o digit.o
26OBJS_ben_jlime = gui.o zgrid.o digit.o letter.o
2727
2828$(MAIN): $(OBJS_$(TARGET))
tools/atrf-rssi/gui.c
2626
2727#include "zgrid.h"
2828#include "digit.h"
29#include "letter.h"
2930#include "gui.h"
3031
3132
...... 
4243#define FREQ_RGBA 0x20ff00ff /* frequency color */
4344#define WCHAN_RGBA 0xffff00e0 /* WLAN channel number color */
4445#define WLAN_RGBA 0x8080ffff /* WLAN channel occupancy color */
46#define SEL_RGBA WLAN_RGBA /* WLAN area selector */
4547
4648#define X_STEP 17 /* grid x step */
4749#define Y_STEP 2 /* grid y step */
...... 
5658#define WLAN_XR (X_STEP*9.5/5)
5759#define WLAN_YH 6
5860
61#define X_SEL (XRES-20)
62#define Y_SEL (YRES-50)
63
5964
6065static enum {
66    area_off,
6167    area_us,
6268    area_eu,
6369    area_jp,
64} wlan_area = area_us;
70} wlan_area = area_off;
6571
6672
6773static struct timeval t0;
...... 
112118    x-7+(pos)*4, x-5+(pos)*4, y+15, y+13, y+11, FREQ_RGBA
113119#define CWLAN(pos) \
114120    x-4+(pos)*5, x-1+(pos)*5, y+6, y+3, y, WCHAN_RGBA
121#define CSEL(pos) \
122    x-4+(pos)*5, x-1+(pos)*5, y+6, y+3, y, SEL_RGBA
115123
116124
117125static void label_channels(SDL_Surface *s, int sx, int x0, int y0)
...... 
138146}
139147
140148
149static void print(SDL_Surface *s, int x, int y, const char *t)
150{
151    int i = 0;
152
153    while (*t) {
154        letter(s, *t, CSEL(i));
155        t++;
156        i++;
157    }
158}
159
160
161static void area_selector(SDL_Surface *s, int x0, int y0)
162{
163    int x, y, r;
164
165    print(s, x0, y0, "EU");
166    print(s, x0, y0+9, "JP");
167    print(s, x0, y0+18, "US");
168    switch (wlan_area) {
169    case area_off:
170        return;
171    case area_eu:
172        y = 0;
173        break;
174    case area_jp:
175        y = 1;
176        break;
177    case area_us:
178        y = 2;
179        break;
180    default:
181        abort();
182    }
183    y = y0+9*y+3;
184    x = x0-8;
185    r = 6;
186    filledTrigonColor(s, x, y, x-r, y+r/2, x-r, y-r/2, SEL_RGBA);
187}
188
189
141190static int wlan_channels(void)
142191{
143192    switch (wlan_area) {
...... 
257306            X_OFFSET, Y_OFFSET,
258307            FG_RGBA, BG_RGBA);
259308        label_channels(surf, X_STEP, X_OFFSET, Y_OFFSET);
260        label_wlan_channels(surf, X_STEP, X_WLAN_OFFSET, Y_WLAN_OFFSET);
309        area_selector(surf, X_SEL, Y_SEL);
310        if (wlan_area != area_off)
311            label_wlan_channels(surf, X_STEP, X_WLAN_OFFSET,
312                Y_WLAN_OFFSET);
261313
262314        SDL_UnlockSurface(surf);
263315        SDL_UpdateRect(surf, 0, 0, 0, 0);
tools/atrf-rssi/letter.c
1/*
2 * atrf-rssi/letter.c - Draw 7 segment style letters
3 *
4 * Written 2011 by Werner Almesberger
5 * Copyright 2011 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 "letter.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 letter(SDL_Surface *s, char c, int x0, int x1, int y0, int ym, int y1,
32    uint32_t fg)
33{
34    switch (c) {
35    case 'E':
36        hlines_3(s, x0, x1, y0, ym, y1, fg);
37        vlineColor(s, x0, y0, y1, fg);
38        break;
39    case 'U':
40        vlineColor(s, x0, ym, y1, fg);
41        /* fall through */
42    case 'J':
43        hlineColor(s, x0, x1, y0, fg);
44        vlineColor(s, x1, y0, y1, fg);
45        vlineColor(s, x0, y0, ym, fg);
46        break;
47    case 'P':
48        hlineColor(s, x0, x1, y1, fg);
49        hlineColor(s, x0, x1, ym, fg);
50        vlineColor(s, x1, ym, y1, fg);
51        vlineColor(s, x0, y0, y1, fg);
52        break;
53    case 'S':
54        hlines_3(s, x0, x1, y0, ym, y1, fg);
55        vlineColor(s, x0, ym, y1, fg);
56        vlineColor(s, x1, y0, ym, fg);
57        break;
58        hlineColor(s, x0, x1, y0, fg);
59        vlineColor(s, x0, y0, y1, fg);
60    default:
61        abort();
62    }
63}
tools/atrf-rssi/letter.h
1/*
2 * atrf-rssi/letter.h - Draw 7 segment style letters
3 *
4 * Written 2011 by Werner Almesberger
5 * Copyright 2011 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#ifndef LETTER_H
15#define LETTER_H
16
17#include <stdint.h>
18
19#include "SDL.h"
20
21
22void letter(SDL_Surface *s, char c, int x0, int x1, int y0, int ym, int y1,
23    uint32_t fg);
24
25#endif /* !LETTER_H */

Archive Download the corresponding diff file



interactive