-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreen.cpp
127 lines (99 loc) · 2.09 KB
/
screen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include "screen.h"
int oldChannel;
int oldBrightness;
int oldContrast;
int oldVertical;
MainScreen main;
TuningScreen tuning;
SetupScreen setups;
StandbyScreen standby;
Screen* Screen::screens[SCREENS] = {
screens[SCREEN_STANDBY] = &standby,
screens[SCREEN_MAIN] = &main,
screens[SCREEN_TUNING] = &tuning,
screens[SCREEN_SETUP] = &setups
};
void StandbyScreen::handle(TV &tv, const int key) {
if (key != KEY_ONOFF) return;
tv.toggle();
Screen::index = SCREEN_MAIN;
}
void MainScreen::handle(TV &tv, const int key) {
switch (key) {
case KEY_ONOFF:
tv.toggle();
break;
case KEY_CHAN_UP:
++tv.channel;
tv.channel.write();
break;
case KEY_CHAN_DOWN:
--tv.channel;
tv.channel.write();
break;
case KEY_VOL_UP:
++tv.volume;
tv.volume.write();
break;
case KEY_VOL_DOWN:
--tv.volume;
tv.volume.write();
break;
case KEY_SETUP:
oldChannel = tv.channel.get();
oldBrightness = tv.brightness.get();
oldContrast = tv.contrast.get();
oldVertical = tv.vertical.get();
Screen::index = SCREEN_TUNING;
break;
}
}
void TuningScreen::handle(TV &tv, const int key) {
switch (key) {
case KEY_ONOFF:
tv.channel.write();
Screen::index = SCREEN_MAIN;
break;
case KEY_CHAN_UP:
++tv.channel;
break;
case KEY_CHAN_DOWN:
--tv.channel;
break;
case KEY_VOL_UP:
++tv.channel.tuning;
break;
case KEY_VOL_DOWN:
--tv.channel.tuning;
break;
case KEY_SETUP:
Screen::index = SCREEN_SETUP;
break;
}
}
void SetupScreen::handle(TV &tv, const int key) {
switch (key) {
case KEY_ONOFF:
tv.channel.set(oldChannel);
tv.brightness.write();
tv.contrast.write();
tv.vertical.write();
Screen::index = SCREEN_MAIN;
break;
case KEY_CHAN_UP:
break;
case KEY_CHAN_DOWN:
break;
case KEY_VOL_UP:
break;
case KEY_VOL_DOWN:
break;
case KEY_SETUP:
tv.channel.set(oldChannel);
tv.brightness.set(oldBrightness);
tv.contrast.set(oldContrast);
tv.vertical.set(oldVertical);
Screen::index = SCREEN_MAIN;
break;
}
}