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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
|
#include "osdmenu.h"
#include "lightpack.h"
myOsdMenu::myOsdMenu() : cOsdMenu("Lightpack", 32)
{
Gamma = LastGamma = LightpackGamma;
Brightness = LastBrightness = LightpackBrightness;
Smooth = LastSmooth = LightpackSmooth;
ProfileIndex = LastProfileIndex = LightpackProfileIndex;
if( libLightpack.isConnected() ) {
Add(new cOsdItem(tr("Appearance"), osUnknown, false));
Add(new cMenuEditIntItem(tr("Gamma"), &Gamma, 0, 100));
Add(new cMenuEditIntItem(tr("Brightness"), &Brightness));
Add(new cMenuEditIntItem(tr("Smooth"), &Smooth));
if( libLightpack.GetProfiles( Profiles ) ) {
cString Profile;
libLightpack.GetProfile( Profile );
ProfileIndex = LastProfileIndex = Profiles.Find( *Profile );
if( ProfileIndex < 0 || ProfileIndex > Profiles.Size() )
ProfileIndex = 0;
Add(new cMenuEditStraItem(tr("Profile"), &ProfileIndex, Profiles.Size(), &Profiles[0]));
}
else
Add(new cOsdItem(tr("can't get profiles list"), osUnknown, false));
MySetHelp();
} else {
Add(new cOsdItem(tr("Lightpack not available"), osUnknown, false));
cString Error = libLightpack.GetLastError();
Add(new cOsdItem(*Error, osUnknown, false));
}
Display();
}
void myOsdMenu::MySetHelp()
{
LastStatus = libLightpack.GetStatus();
LastMode = libLightpack.GetMode();
if( LastStatus == 1 ) {
if( LastMode == 1 )
SetHelp(tr("Stop"), tr("Lamp"), NULL, NULL);
else if( LastMode == 2 )
SetHelp(tr("Stop"), tr("Ambilight"), NULL, NULL);
else
Skins.Message(mtError, libLightpack.GetLastError() );
} else if( LastStatus == 2 ) {
if( LastMode == 1 )
SetHelp(tr("Start"), tr("Lamp"), NULL, NULL);
else if( LastMode == 2 )
SetHelp(tr("Start"), tr("Ambilight"), NULL, NULL);
else
Skins.Message(mtError, libLightpack.GetLastError() );
} else
Skins.Message(mtError, libLightpack.GetLastError() );
}
myOsdMenu::~myOsdMenu()
{
libLightpack.Disconnect();
}
eOSState myOsdMenu::ProcessKey(eKeys Key)
{
eOSState state = cOsdMenu::ProcessKey(Key);
if( !libLightpack.isConnected() )
return state;
if( LastGamma != Gamma )
{
if( libLightpack.SetGamma( (double) Gamma / 10.0) )
LastGamma = Gamma;
else {
Gamma = LastGamma;
Skins.Message(mtError, libLightpack.GetLastError() );
}
}
if( LastBrightness != Brightness )
{
if( libLightpack.SetBrightness(Brightness) )
LastBrightness = Brightness;
else {
Brightness = LastBrightness;
Skins.Message(mtError, libLightpack.GetLastError() );
}
}
if( LastSmooth != Smooth )
{
if( libLightpack.SetSmooth(Smooth) )
LastSmooth = Smooth;
else {
Smooth = LastSmooth;
Skins.Message(mtError, libLightpack.GetLastError() );
}
}
if( LastProfileIndex != ProfileIndex )
{
cStringList Profiles;
if( libLightpack.GetProfiles( Profiles ) ) {
if( ProfileIndex < 0 || ProfileIndex > Profiles.Size() )
ProfileIndex = 0;
if( libLightpack.SetProfile( Profiles[ProfileIndex] ) )
LastProfileIndex = ProfileIndex;
else {
ProfileIndex = LastProfileIndex;
Skins.Message(mtError, libLightpack.GetLastError() );
}
}
else
Skins.Message(mtError, libLightpack.GetLastError() );
}
switch(Key)
{
case kRed:
LastStatus = libLightpack.GetStatus();
if( LastStatus == 1 ) {
if( !libLightpack.SetStatus( false ) )
Skins.Message(mtError, libLightpack.GetLastError() );
} else if( LastStatus == 2 ) {
if( !libLightpack.SetStatus( true ) )
Skins.Message(mtError, libLightpack.GetLastError() );
}
MySetHelp();
break;
case kGreen:
LastMode = libLightpack.GetMode();
if( LastMode == 1 ) {
if( !libLightpack.SetMode( 2 ) )
Skins.Message(mtError, libLightpack.GetLastError() );
} else if( LastMode == 2 ) {
if( !libLightpack.SetMode( 1 ) )
Skins.Message(mtError, libLightpack.GetLastError() );
}
MySetHelp();
break;
case kYellow:
break;
case kBlue:
break;
default:
break;
}
return state;
}
|