summaryrefslogtreecommitdiff
authorschurig <schurig>2003-06-06 14:32:51 (UTC)
committer schurig <schurig>2003-06-06 14:32:51 (UTC)
commit802e9457b1bc158c61849755215fe2a5bad6231d (patch) (unidiff)
tree81b8a5cdb9d4b5beaee2f18eec6ca995ec8e77d2
parent225486a1c3714b4b0c0e60286df13d8ede029768 (diff)
downloadopie-802e9457b1bc158c61849755215fe2a5bad6231d.zip
opie-802e9457b1bc158c61849755215fe2a5bad6231d.tar.gz
opie-802e9457b1bc158c61849755215fe2a5bad6231d.tar.bz2
frequency change works now
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/light.cpp30
-rw-r--r--core/settings/light-and-power/light.h3
-rw-r--r--libopie/odevice.cpp49
-rw-r--r--libopie/odevice.h2
4 files changed, 61 insertions, 23 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index 8b98672..68c2929 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -1,257 +1,283 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "light.h" 29#include "light.h"
30 30
31#include <qpe/config.h> 31#include <qpe/config.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/power.h> 33#include <qpe/power.h>
34#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 34#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
35#include <qpe/qcopenvelope_qws.h> 35#include <qpe/qcopenvelope_qws.h>
36#endif 36#endif
37 37
38#include <qcheckbox.h> 38#include <qcheckbox.h>
39#include <qtabwidget.h> 39#include <qtabwidget.h>
40#include <qslider.h> 40#include <qslider.h>
41#include <qtimer.h> 41#include <qtimer.h>
42#include <qspinbox.h> 42#include <qspinbox.h>
43#include <qpushbutton.h> 43#include <qpushbutton.h>
44#include <qgroupbox.h> 44#include <qgroupbox.h>
45#include <qcombobox.h>
45 46
46#include <opie/odevice.h> 47#include <opie/odevice.h>
47 48
48#include "sensor.h" 49#include "sensor.h"
49 50
50using namespace Opie; 51using namespace Opie;
51 52
52LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 53LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
53 : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) 54 : LightSettingsBase( parent, name, false, WStyle_ContextHelp )
54{ 55{
55 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); 56 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( );
56 m_cres = ODevice::inst ( )-> displayContrastResolution ( ); 57 m_cres = ODevice::inst ( )-> displayContrastResolution ( );
57 58
58 if ( !ODevice::inst ( )-> hasLightSensor ( )) { 59 if ( !ODevice::inst ( )-> hasLightSensor ( )) {
59 auto_brightness-> hide ( ); 60 auto_brightness-> hide ( );
60 CalibrateLightSensor-> hide ( ); 61 CalibrateLightSensor-> hide ( );
61 auto_brightness_ac-> hide ( ); 62 auto_brightness_ac-> hide ( );
62 CalibrateLightSensor_ac-> hide ( ); 63 CalibrateLightSensor_ac-> hide ( );
63 } 64 }
64 if (m_cres) { 65 if (m_cres) {
65 GroupLight->setTitle(tr("Backlight & Contrast")); 66 GroupLight->setTitle(tr("Backlight && Contrast"));
67 GroupLight_ac->setTitle(GroupLight->title());
66 } else { 68 } else {
67 contrast->hide(); 69 contrast->hide();
68 contrast_ac->hide(); 70 contrast_ac->hide();
69 } 71 }
70 72
73 QStrList freq = ODevice::inst()->cpuFrequencies();
74 if ( freq.count() ) {
75 frequency->insertStrList( freq );
76 frequency_ac->insertStrList( freq );
77 } else {
78 frequency->hide();
79 frequency_ac->hide();
80 }
81
71 Config config ( "apm" ); 82 Config config ( "apm" );
72 config. setGroup ( "Battery" ); 83 config. setGroup ( "Battery" );
73 84
74 // battery spinboxes 85 // battery spinboxes
75 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); 86 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
76 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); 87 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
77 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 88 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
78 89
79 // battery check and slider 90 // battery check and slider
80 LcdOffOnly-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 91 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
92
93 // CPU frequency
94 frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
81 95
82 int bright = config. readNumEntry ( "Brightness", 127 ); 96 int bright = config. readNumEntry ( "Brightness", 127 );
83 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); 97 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
84 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres )); 98 brightness-> setTickInterval ( QMAX( 16, 256 / m_bres ));
85 brightness-> setLineStep ( QMAX( 1, 256 / m_bres )); 99 brightness-> setLineStep ( QMAX( 1, 256 / m_bres ));
86 brightness-> setPageStep ( QMAX( 1, 256 / m_bres )); 100 brightness-> setPageStep ( QMAX( 1, 256 / m_bres ));
87 brightness-> setValue ( bright ); 101 brightness-> setValue ( bright );
88 102
89 if (m_cres) { 103 if (m_cres) {
90 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres )); 104 contrast-> setTickInterval ( QMAX( 16, 256 / m_cres ));
91 contrast-> setLineStep ( QMAX( 1, 256 / m_cres )); 105 contrast-> setLineStep ( QMAX( 1, 256 / m_cres ));
92 contrast-> setPageStep ( QMAX( 1, 256 / m_cres )); 106 contrast-> setPageStep ( QMAX( 1, 256 / m_cres ));
93 contrast-> setValue ( contr ); 107 contrast-> setValue ( contr );
94 } 108 }
95 109
96 // light sensor 110 // light sensor
97 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 111 auto_brightness-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
98 m_sensordata = config. readListEntry ( "LightSensorData", ';' ); 112 m_sensordata = config. readListEntry ( "LightSensorData", ';' );
99 113
100 config. setGroup ( "AC" ); 114 config. setGroup ( "AC" );
101 115
102 // ac spinboxes 116 // ac spinboxes
103 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 )); 117 interval_dim_ac-> setValue ( config. readNumEntry ( "Dim", 60 ));
104 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 )); 118 interval_lightoff_ac-> setValue ( config. readNumEntry ( "LightOff", 120 ));
105 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 )); 119 interval_suspend_ac-> setValue ( config. readNumEntry ( "Suspend", 0 ));
106 120
107 // ac check and slider 121 // ac check and slider
108 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 122 LcdOffOnly_ac-> setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
109 123
124 // CPU frequency
125 frequency_ac->setCurrentItem( config.readNumEntry("Freq", 0) );
126
110 bright = config. readNumEntry ( "Brightness", 255 ); 127 bright = config. readNumEntry ( "Brightness", 255 );
111 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres )); 128 brightness_ac-> setTickInterval ( QMAX( 16, 256 / m_bres ));
112 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres )); 129 brightness_ac-> setLineStep ( QMAX( 1, 256 / m_bres ));
113 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres )); 130 brightness_ac-> setPageStep ( QMAX( 1, 256 / m_bres ));
114 brightness_ac-> setValue ( bright ); 131 brightness_ac-> setValue ( bright );
115 132
116 if (m_cres) { 133 if (m_cres) {
117 contr = config. readNumEntry ( "Contrast", 127); 134 contr = config. readNumEntry ( "Contrast", 127);
118 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres )); 135 contrast_ac-> setTickInterval ( QMAX( 16, 256 / m_cres ));
119 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres )); 136 contrast_ac-> setLineStep ( QMAX( 1, 256 / m_cres ));
120 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres )); 137 contrast_ac-> setPageStep ( QMAX( 1, 256 / m_cres ));
121 contrast_ac-> setValue ( contr ); 138 contrast_ac-> setValue ( contr );
122 } 139 }
123 140
124 // light sensor 141 // light sensor
125 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false )); 142 auto_brightness_ac-> setChecked ( config. readBoolEntry ( "LightSensor", false ));
126 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' ); 143 m_sensordata_ac = config. readListEntry ( "LightSensorData", ';' );
127 144
128 // advanced settings 145 // advanced settings
129 config. setGroup ( "Warnings" ); 146 config. setGroup ( "Warnings" );
130 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 ); 147 warnintervalBox-> setValue ( config. readNumEntry ( "checkinterval", 10000 ) / 1000 );
131 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) ); 148 lowSpinBox-> setValue ( config. readNumEntry ( "powerverylow", 10 ) );
132 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) ); 149 criticalSpinBox-> setValue ( config. readNumEntry ( "powercritical", 5 ) );
133 150
134 m_resettimer = new QTimer ( this ); 151 m_resettimer = new QTimer ( this );
135 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( ))); 152 connect ( m_resettimer, SIGNAL( timeout ( )), this, SLOT( resetBacklight ( )));
136 153
137 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) { 154 if ( PowerStatusManager::readStatus ( ). acStatus ( ) != PowerStatus::Online ) {
138 tabs-> setCurrentPage ( 0 ); 155 tabs-> setCurrentPage ( 0 );
139 } 156 }
140 else { 157 else {
141 tabs-> setCurrentPage ( 1 ); 158 tabs-> setCurrentPage ( 1 );
142 } 159 }
143 160
144 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 161 connect ( brightness, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
145 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int ))); 162 connect ( brightness_ac, SIGNAL( valueChanged ( int )), this, SLOT( setBacklight ( int )));
146 if (m_cres) { 163 if (m_cres) {
147 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 164 connect ( contrast, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
148 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int ))); 165 connect ( contrast_ac, SIGNAL( valueChanged ( int )), this, SLOT( setContrast ( int )));
149 } 166 }
167 connect( frequency, SIGNAL( activated(int) ), this, SLOT( setFrequency(int) ) );
150} 168}
151 169
152LightSettings::~LightSettings ( ) 170LightSettings::~LightSettings ( )
153{ 171{
154} 172}
155 173
156void LightSettings::calibrateSensor ( ) 174void LightSettings::calibrateSensor ( )
157{ 175{
158 Sensor *s = new Sensor ( m_sensordata, this ); 176 Sensor *s = new Sensor ( m_sensordata, this );
159 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 177 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
160 s-> showMaximized ( ); 178 s-> showMaximized ( );
161 s-> exec ( ); 179 s-> exec ( );
162 delete s; 180 delete s;
163} 181}
164 182
165void LightSettings::calibrateSensorAC ( ) 183void LightSettings::calibrateSensorAC ( )
166{ 184{
167 Sensor *s = new Sensor ( m_sensordata_ac, this ); 185 Sensor *s = new Sensor ( m_sensordata_ac, this );
168 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int ))); 186 connect ( s, SIGNAL( viewBacklight ( int )), this, SLOT( setBacklight ( int )));
169 s-> showMaximized ( ); 187 s-> showMaximized ( );
170 s-> exec ( ); 188 s-> exec ( );
171 delete s; 189 delete s;
172} 190}
173 191
174void LightSettings::setBacklight ( int bright ) 192void LightSettings::setBacklight ( int bright )
175{ 193{
176 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 194 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
177 e << bright; 195 e << bright;
178 196
179 if ( bright != -1 ) { 197 if ( bright != -1 ) {
180 m_resettimer-> stop ( ); 198 m_resettimer-> stop ( );
181 m_resettimer-> start ( 4000, true ); 199 m_resettimer-> start ( 4000, true );
182 } 200 }
183} 201}
184 202
185void LightSettings::setContrast ( int contr ) 203void LightSettings::setContrast ( int contr )
186{ 204{
187 if (contr == -1) contr = m_oldcontrast; 205 if (contr == -1) contr = m_oldcontrast;
188 206
189 ODevice::inst ( )-> setDisplayContrast(contr); 207 ODevice::inst ( )-> setDisplayContrast(contr);
190} 208}
191 209
210void LightSettings::setFrequency ( int index )
211{
212qWarning("LightSettings::setFrequency(%d)", index);
213 ODevice::inst ( )-> setCpuFrequency(index);
214}
215
192void LightSettings::resetBacklight ( ) 216void LightSettings::resetBacklight ( )
193{ 217{
194 setBacklight ( -1 ); 218 setBacklight ( -1 );
195 setContrast ( -1 ); 219 setContrast ( -1 );
196} 220}
197 221
198void LightSettings::accept ( ) 222void LightSettings::accept ( )
199{ 223{
200 Config config ( "apm" ); 224 Config config ( "apm" );
201 225
202 // bat 226 // bat
203 config. setGroup ( "Battery" ); 227 config. setGroup ( "Battery" );
204 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); 228 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
205 config. writeEntry ( "Dim", interval_dim-> value ( )); 229 config. writeEntry ( "Dim", interval_dim-> value ( ));
206 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 230 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
207 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 231 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
208 config. writeEntry ( "Brightness", brightness-> value () ); 232 config. writeEntry ( "Brightness", brightness-> value () );
209 if (m_cres) 233 if (m_cres)
210 config. writeEntry ( "Contrast", contrast-> value () ); 234 config. writeEntry ( "Contrast", contrast-> value () );
235 config. writeEntry ( "Freq", frequency->currentItem() );
211 236
212 // ac 237 // ac
213 config. setGroup ( "AC" ); 238 config. setGroup ( "AC" );
214 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( )); 239 config. writeEntry ( "LcdOffOnly", LcdOffOnly_ac-> isChecked ( ));
215 config. writeEntry ( "Dim", interval_dim_ac-> value ( )); 240 config. writeEntry ( "Dim", interval_dim_ac-> value ( ));
216 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( )); 241 config. writeEntry ( "LightOff", interval_lightoff_ac-> value ( ));
217 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( )); 242 config. writeEntry ( "Suspend", interval_suspend_ac-> value ( ));
218 config. writeEntry ( "Brightness", brightness_ac-> value () ); 243 config. writeEntry ( "Brightness", brightness_ac-> value () );
219 if (m_cres) 244 if (m_cres)
220 config. writeEntry ( "Contrast", contrast_ac-> value () ); 245 config. writeEntry ( "Contrast", contrast_ac-> value () );
246 config. writeEntry ( "Freq", frequency_ac->currentItem() );
221 247
222 // only make light sensor stuff appear if the unit has a sensor 248 // only make light sensor stuff appear if the unit has a sensor
223 if ( ODevice::inst ( )-> hasLightSensor ( )) { 249 if ( ODevice::inst ( )-> hasLightSensor ( )) {
224 config. setGroup ( "Battery" ); 250 config. setGroup ( "Battery" );
225 config. writeEntry ( "LightSensor", auto_brightness->isChecked() ); 251 config. writeEntry ( "LightSensor", auto_brightness->isChecked() );
226 config. writeEntry ( "LightSensorData", m_sensordata, ';' ); 252 config. writeEntry ( "LightSensorData", m_sensordata, ';' );
227 config. setGroup ( "AC" ); 253 config. setGroup ( "AC" );
228 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() ); 254 config. writeEntry ( "LightSensor", auto_brightness_ac->isChecked() );
229 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' ); 255 config. writeEntry ( "LightSensorData", m_sensordata_ac, ';' );
230 } 256 }
231 257
232 // advanced 258 // advanced
233 config. setGroup ( "Warnings" ); 259 config. setGroup ( "Warnings" );
234 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 ); 260 config. writeEntry ( "check_interval", warnintervalBox-> value ( ) * 1000 );
235 config. writeEntry ( "power_verylow", lowSpinBox-> value ( )); 261 config. writeEntry ( "power_verylow", lowSpinBox-> value ( ));
236 config. writeEntry ( "power_critical", criticalSpinBox-> value ( )); 262 config. writeEntry ( "power_critical", criticalSpinBox-> value ( ));
237 config. write ( ); 263 config. write ( );
238 264
239 // notify the launcher 265 // notify the launcher
240 { 266 {
241 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" ); 267 QCopEnvelope e ( "QPE/System", "reloadPowerWarnSettings()" );
242 } 268 }
243 { 269 {
244 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" ); 270 QCopEnvelope e ( "QPE/System", "setScreenSaverInterval(int)" );
245 e << -1; 271 e << -1;
246 } 272 }
247 LightSettingsBase::accept ( ); 273 LightSettingsBase::accept ( );
248} 274}
249 275
250void LightSettings::done ( int r ) 276void LightSettings::done ( int r )
251{ 277{
252 m_resettimer-> stop ( ); 278 m_resettimer-> stop ( );
253 resetBacklight ( ); 279 resetBacklight ( );
254 280
255 LightSettingsBase::done ( r ); 281 LightSettingsBase::done ( r );
256 close ( ); 282 close ( );
257} 283}
diff --git a/core/settings/light-and-power/light.h b/core/settings/light-and-power/light.h
index 4a8bf6b..c48e5f6 100644
--- a/core/settings/light-and-power/light.h
+++ b/core/settings/light-and-power/light.h
@@ -1,67 +1,70 @@
1/* 1/*
2 This file is part of the OPIE Project 2 This file is part of the OPIE Project
3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org> 3               =. Copyright (c) 2002 Maximilian Reiss <harlekin@handhelds.org>
4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 4             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can 6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public 8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that 13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details. 18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .: 19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU 20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file; 21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the 22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc., 23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330, 24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28#ifndef __LIGHT_H__ 28#ifndef __LIGHT_H__
29#define __LIGHT_H__ 29#define __LIGHT_H__
30 30
31 31
32#include <qstringlist.h> 32#include <qstringlist.h>
33#include <qlistbox.h>
33#include "lightsettingsbase.h" 34#include "lightsettingsbase.h"
34 35
35class QTimer; 36class QTimer;
36 37
37class LightSettings : public LightSettingsBase 38class LightSettings : public LightSettingsBase
38{ 39{
39 Q_OBJECT 40 Q_OBJECT
40 41
41public: 42public:
42 LightSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); 43 LightSettings( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
43 ~LightSettings(); 44 ~LightSettings();
44 45
45protected: 46protected:
46 virtual void accept(); 47 virtual void accept();
47 virtual void done ( int r ); 48 virtual void done ( int r );
48 49
49protected slots: 50protected slots:
50 virtual void calibrateSensor ( ); 51 virtual void calibrateSensor ( );
51 virtual void calibrateSensorAC ( ); 52 virtual void calibrateSensorAC ( );
52 void setBacklight ( int ); 53 void setBacklight ( int );
53 void setContrast ( int ); 54 void setContrast ( int );
55 void setFrequency ( int );
54 void resetBacklight ( ); 56 void resetBacklight ( );
55 57
56private: 58private:
57 int m_bres; 59 int m_bres;
58 int m_cres; 60 int m_cres;
59 int m_oldcontrast; 61 int m_oldcontrast;
62 int m_oldfreq;
60 QTimer *m_resettimer; 63 QTimer *m_resettimer;
61 QStringList m_sensordata; 64 QStringList m_sensordata;
62 QStringList m_sensordata_ac; 65 QStringList m_sensordata_ac;
63}; 66};
64 67
65 68
66#endif 69#endif
67 70
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 4b5a54e..4c33a0e 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -590,419 +590,415 @@ bool ODevice::setDisplayContrast ( int p)
590 590
591/** 591/**
592 * @return return the max value for the brightness settings slider 592 * @return return the max value for the brightness settings slider
593 * or 0 if the device doesn't support setting of a contrast 593 * or 0 if the device doesn't support setting of a contrast
594 */ 594 */
595int ODevice::displayContrastResolution ( ) const 595int ODevice::displayContrastResolution ( ) const
596{ 596{
597 return 0; 597 return 0;
598} 598}
599 599
600/** 600/**
601 * This returns the vendor as string 601 * This returns the vendor as string
602 * @return Vendor as QString 602 * @return Vendor as QString
603 */ 603 */
604QString ODevice::vendorString ( ) const 604QString ODevice::vendorString ( ) const
605{ 605{
606 return d-> m_vendorstr; 606 return d-> m_vendorstr;
607} 607}
608 608
609/** 609/**
610 * This returns the vendor as one of the values of OVendor 610 * This returns the vendor as one of the values of OVendor
611 * @return OVendor 611 * @return OVendor
612 */ 612 */
613OVendor ODevice::vendor ( ) const 613OVendor ODevice::vendor ( ) const
614{ 614{
615 return d-> m_vendor; 615 return d-> m_vendor;
616} 616}
617 617
618/** 618/**
619 * This returns the model as a string 619 * This returns the model as a string
620 * @return A string representing the model 620 * @return A string representing the model
621 */ 621 */
622QString ODevice::modelString ( ) const 622QString ODevice::modelString ( ) const
623{ 623{
624 return d-> m_modelstr; 624 return d-> m_modelstr;
625} 625}
626 626
627/** 627/**
628 * This does return the OModel used 628 * This does return the OModel used
629 */ 629 */
630OModel ODevice::model ( ) const 630OModel ODevice::model ( ) const
631{ 631{
632 return d-> m_model; 632 return d-> m_model;
633} 633}
634 634
635/** 635/**
636 * This does return the systen name 636 * This does return the systen name
637 */ 637 */
638QString ODevice::systemString ( ) const 638QString ODevice::systemString ( ) const
639{ 639{
640 return d-> m_systemstr; 640 return d-> m_systemstr;
641} 641}
642 642
643/** 643/**
644 * Return System as OSystem value 644 * Return System as OSystem value
645 */ 645 */
646OSystem ODevice::system ( ) const 646OSystem ODevice::system ( ) const
647{ 647{
648 return d-> m_system; 648 return d-> m_system;
649} 649}
650 650
651/** 651/**
652 * @return the version string of the base system 652 * @return the version string of the base system
653 */ 653 */
654QString ODevice::systemVersionString ( ) const 654QString ODevice::systemVersionString ( ) const
655{ 655{
656 return d-> m_sysverstr; 656 return d-> m_sysverstr;
657} 657}
658 658
659/** 659/**
660 * @return the current Transformation 660 * @return the current Transformation
661 */ 661 */
662Transformation ODevice::rotation ( ) const 662Transformation ODevice::rotation ( ) const
663{ 663{
664 return d-> m_rotation; 664 return d-> m_rotation;
665} 665}
666 666
667/** 667/**
668 * @return the current rotation direction 668 * @return the current rotation direction
669 */ 669 */
670ODirection ODevice::direction ( ) const 670ODirection ODevice::direction ( ) const
671{ 671{
672 return d-> m_direction; 672 return d-> m_direction;
673} 673}
674 674
675/** 675/**
676 * This plays an alarmSound 676 * This plays an alarmSound
677 */ 677 */
678void ODevice::alarmSound ( ) 678void ODevice::alarmSound ( )
679{ 679{
680#ifndef QT_NO_SOUND 680#ifndef QT_NO_SOUND
681 static Sound snd ( "alarm" ); 681 static Sound snd ( "alarm" );
682 682
683 if ( snd. isFinished ( )) 683 if ( snd. isFinished ( ))
684 snd. play ( ); 684 snd. play ( );
685#endif 685#endif
686} 686}
687 687
688/** 688/**
689 * This plays a key sound 689 * This plays a key sound
690 */ 690 */
691void ODevice::keySound ( ) 691void ODevice::keySound ( )
692{ 692{
693#ifndef QT_NO_SOUND 693#ifndef QT_NO_SOUND
694 static Sound snd ( "keysound" ); 694 static Sound snd ( "keysound" );
695 695
696 if ( snd. isFinished ( )) 696 if ( snd. isFinished ( ))
697 snd. play ( ); 697 snd. play ( );
698#endif 698#endif
699} 699}
700 700
701/** 701/**
702 * This plays a touch sound 702 * This plays a touch sound
703 */ 703 */
704void ODevice::touchSound ( ) 704void ODevice::touchSound ( )
705{ 705{
706#ifndef QT_NO_SOUND 706#ifndef QT_NO_SOUND
707 static Sound snd ( "touchsound" ); 707 static Sound snd ( "touchsound" );
708 708
709 if ( snd. isFinished ( )) 709 if ( snd. isFinished ( ))
710 snd. play ( ); 710 snd. play ( );
711#endif 711#endif
712} 712}
713 713
714/** 714/**
715 * This method will return a list of leds 715 * This method will return a list of leds
716 * available on this device 716 * available on this device
717 * @return a list of LEDs. 717 * @return a list of LEDs.
718 */ 718 */
719QValueList <OLed> ODevice::ledList ( ) const 719QValueList <OLed> ODevice::ledList ( ) const
720{ 720{
721 return QValueList <OLed> ( ); 721 return QValueList <OLed> ( );
722} 722}
723 723
724/** 724/**
725 * This does return the state of the LEDs 725 * This does return the state of the LEDs
726 */ 726 */
727QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 727QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
728{ 728{
729 return QValueList <OLedState> ( ); 729 return QValueList <OLedState> ( );
730} 730}
731 731
732/** 732/**
733 * @return the state for a given OLed 733 * @return the state for a given OLed
734 */ 734 */
735OLedState ODevice::ledState ( OLed /*which*/ ) const 735OLedState ODevice::ledState ( OLed /*which*/ ) const
736{ 736{
737 return Led_Off; 737 return Led_Off;
738} 738}
739 739
740/** 740/**
741 * Set the state for a LED 741 * Set the state for a LED
742 * @param which Which OLed to use 742 * @param which Which OLed to use
743 * @param st The state to set 743 * @param st The state to set
744 * @return success or failure 744 * @return success or failure
745 */ 745 */
746bool ODevice::setLedState ( OLed which, OLedState st ) 746bool ODevice::setLedState ( OLed which, OLedState st )
747{ 747{
748 Q_UNUSED( which ) 748 Q_UNUSED( which )
749 Q_UNUSED( st ) 749 Q_UNUSED( st )
750 return false; 750 return false;
751} 751}
752 752
753/** 753/**
754 * @return if the device has a light sensor 754 * @return if the device has a light sensor
755 */ 755 */
756bool ODevice::hasLightSensor ( ) const 756bool ODevice::hasLightSensor ( ) const
757{ 757{
758 return false; 758 return false;
759} 759}
760 760
761/** 761/**
762 * @return a value from the light senso 762 * @return a value from the light senso
763 */ 763 */
764int ODevice::readLightSensor ( ) 764int ODevice::readLightSensor ( )
765{ 765{
766 return -1; 766 return -1;
767} 767}
768 768
769/** 769/**
770 * @return the light sensor resolution whatever that is ;) 770 * @return the light sensor resolution whatever that is ;)
771 */ 771 */
772int ODevice::lightSensorResolution ( ) const 772int ODevice::lightSensorResolution ( ) const
773{ 773{
774 return 0; 774 return 0;
775} 775}
776 776
777/** 777/**
778 * @return a list with valid CPU frequency 778 * @return a list with valid CPU frequency
779 */ 779 */
780QStrList &ODevice::cpuFrequencies ( ) const 780QStrList &ODevice::cpuFrequencies ( ) const
781{ 781{
782qWarning("ODevice::cpuFrequencies: m_cpu_frequencies is %d", (int) d->m_cpu_frequencies);
783 return *d->m_cpu_frequencies; 782 return *d->m_cpu_frequencies;
784} 783}
785 784
786 785
787/** 786/**
788 * Set desired cpu frequency 787 * Set desired cpu frequency
789 * 788 *
790 * @param index index into d->m_cpu_frequencies of the frequency to be set 789 * @param index index into d->m_cpu_frequencies of the frequency to be set
791 */ 790 */
792bool ODevice::setCpuFrequency(uint index) 791bool ODevice::setCpuFrequency(uint index)
793{ 792{
794 if (index >= d->m_cpu_frequencies->count()) 793 if (index >= d->m_cpu_frequencies->count())
795 return false; 794 return false;
796 795
797 char *freq = d->m_cpu_frequencies->at(index); 796 char *freq = d->m_cpu_frequencies->at(index);
798 qWarning("set freq to %s", freq); 797 qWarning("set freq to %s", freq);
799 798
800 //TODO: do the change in /proc/sys/cpu/0/speed 799 int fd;
801
802 return false;
803}
804 800
805/** 801 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
806 * Returns current frequency index out of d->m_cpu_frequencies 802 char writeCommand[50];
807 */ 803 const int count = sprintf(writeCommand, "%s\n", freq);
808uint ODevice::cpuFrequency() const 804 int res = (::write(fd, writeCommand, count) != -1);
809{ 805 ::close(fd);
810 // TODO: get freq from /proc/sys/cpu/0/speed and return index 806 return res;
807 }
811 808
812 return 0; 809 return false;
813} 810}
814 811
815 812
816
817/** 813/**
818 * @return a list of hardware buttons 814 * @return a list of hardware buttons
819 */ 815 */
820const QValueList <ODeviceButton> &ODevice::buttons ( ) 816const QValueList <ODeviceButton> &ODevice::buttons ( )
821{ 817{
822 initButtons ( ); 818 initButtons ( );
823 819
824 return *d-> m_buttons; 820 return *d-> m_buttons;
825} 821}
826 822
827/** 823/**
828 * @return The amount of time that would count as a hold 824 * @return The amount of time that would count as a hold
829 */ 825 */
830uint ODevice::buttonHoldTime ( ) const 826uint ODevice::buttonHoldTime ( ) const
831{ 827{
832 return d-> m_holdtime; 828 return d-> m_holdtime;
833} 829}
834 830
835/** 831/**
836 * This method return a ODeviceButton for a key code 832 * This method return a ODeviceButton for a key code
837 * or 0 if no special hardware button is available for the device 833 * or 0 if no special hardware button is available for the device
838 * 834 *
839 * @return The devicebutton or 0l 835 * @return The devicebutton or 0l
840 * @see ODeviceButton 836 * @see ODeviceButton
841 */ 837 */
842const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 838const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
843{ 839{
844 initButtons ( ); 840 initButtons ( );
845 841
846 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 842 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
847 if ( (*it). keycode ( ) == code ) 843 if ( (*it). keycode ( ) == code )
848 return &(*it); 844 return &(*it);
849 } 845 }
850 return 0; 846 return 0;
851} 847}
852 848
853void ODevice::reloadButtonMapping ( ) 849void ODevice::reloadButtonMapping ( )
854{ 850{
855 initButtons ( ); 851 initButtons ( );
856 852
857 Config cfg ( "ButtonSettings" ); 853 Config cfg ( "ButtonSettings" );
858 854
859 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 855 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
860 ODeviceButton &b = ( *d-> m_buttons ) [i]; 856 ODeviceButton &b = ( *d-> m_buttons ) [i];
861 QString group = "Button" + QString::number ( i ); 857 QString group = "Button" + QString::number ( i );
862 858
863 QCString pch, hch; 859 QCString pch, hch;
864 QCString pm, hm; 860 QCString pm, hm;
865 QByteArray pdata, hdata; 861 QByteArray pdata, hdata;
866 862
867 if ( cfg. hasGroup ( group )) { 863 if ( cfg. hasGroup ( group )) {
868 cfg. setGroup ( group ); 864 cfg. setGroup ( group );
869 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 865 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
870 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 866 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
871 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 867 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
872 868
873 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 869 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
874 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 870 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
875 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 871 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
876 } 872 }
877 873
878 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 874 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
879 875
880 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 876 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
881 } 877 }
882} 878}
883 879
884void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 880void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
885{ 881{
886 initButtons ( ); 882 initButtons ( );
887 883
888 QString mb_chan; 884 QString mb_chan;
889 885
890 if ( button >= (int) d-> m_buttons-> count ( )) 886 if ( button >= (int) d-> m_buttons-> count ( ))
891 return; 887 return;
892 888
893 ODeviceButton &b = ( *d-> m_buttons ) [button]; 889 ODeviceButton &b = ( *d-> m_buttons ) [button];
894 b. setPressedAction ( action ); 890 b. setPressedAction ( action );
895 891
896 mb_chan=b. pressedAction ( ). channel ( ); 892 mb_chan=b. pressedAction ( ). channel ( );
897 893
898 Config buttonFile ( "ButtonSettings" ); 894 Config buttonFile ( "ButtonSettings" );
899 buttonFile. setGroup ( "Button" + QString::number ( button )); 895 buttonFile. setGroup ( "Button" + QString::number ( button ));
900 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 896 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
901 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 897 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
902 898
903 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 899 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
904 900
905 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 901 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
906} 902}
907 903
908void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 904void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
909{ 905{
910 initButtons ( ); 906 initButtons ( );
911 907
912 if ( button >= (int) d-> m_buttons-> count ( )) 908 if ( button >= (int) d-> m_buttons-> count ( ))
913 return; 909 return;
914 910
915 ODeviceButton &b = ( *d-> m_buttons ) [button]; 911 ODeviceButton &b = ( *d-> m_buttons ) [button];
916 b. setHeldAction ( action ); 912 b. setHeldAction ( action );
917 913
918 Config buttonFile ( "ButtonSettings" ); 914 Config buttonFile ( "ButtonSettings" );
919 buttonFile. setGroup ( "Button" + QString::number ( button )); 915 buttonFile. setGroup ( "Button" + QString::number ( button ));
920 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 916 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
921 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 917 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
922 918
923 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 919 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
924 920
925 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 921 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
926} 922}
927 923
928 924
929 925
930 926
931/************************************************** 927/**************************************************
932 * 928 *
933 * iPAQ 929 * iPAQ
934 * 930 *
935 **************************************************/ 931 **************************************************/
936 932
937void iPAQ::init ( ) 933void iPAQ::init ( )
938{ 934{
939 d-> m_vendorstr = "HP"; 935 d-> m_vendorstr = "HP";
940 d-> m_vendor = Vendor_HP; 936 d-> m_vendor = Vendor_HP;
941 937
942 QFile f ( "/proc/hal/model" ); 938 QFile f ( "/proc/hal/model" );
943 939
944 if ( f. open ( IO_ReadOnly )) { 940 if ( f. open ( IO_ReadOnly )) {
945 QTextStream ts ( &f ); 941 QTextStream ts ( &f );
946 942
947 d-> m_modelstr = "H" + ts. readLine ( ); 943 d-> m_modelstr = "H" + ts. readLine ( );
948 944
949 if ( d-> m_modelstr == "H3100" ) 945 if ( d-> m_modelstr == "H3100" )
950 d-> m_model = Model_iPAQ_H31xx; 946 d-> m_model = Model_iPAQ_H31xx;
951 else if ( d-> m_modelstr == "H3600" ) 947 else if ( d-> m_modelstr == "H3600" )
952 d-> m_model = Model_iPAQ_H36xx; 948 d-> m_model = Model_iPAQ_H36xx;
953 else if ( d-> m_modelstr == "H3700" ) 949 else if ( d-> m_modelstr == "H3700" )
954 d-> m_model = Model_iPAQ_H37xx; 950 d-> m_model = Model_iPAQ_H37xx;
955 else if ( d-> m_modelstr == "H3800" ) 951 else if ( d-> m_modelstr == "H3800" )
956 d-> m_model = Model_iPAQ_H38xx; 952 d-> m_model = Model_iPAQ_H38xx;
957 else if ( d-> m_modelstr == "H3900" ) 953 else if ( d-> m_modelstr == "H3900" )
958 d-> m_model = Model_iPAQ_H39xx; 954 d-> m_model = Model_iPAQ_H39xx;
959 else 955 else
960 d-> m_model = Model_Unknown; 956 d-> m_model = Model_Unknown;
961 957
962 f. close ( ); 958 f. close ( );
963 } 959 }
964 960
965 switch ( d-> m_model ) { 961 switch ( d-> m_model ) {
966 case Model_iPAQ_H31xx: 962 case Model_iPAQ_H31xx:
967 case Model_iPAQ_H38xx: 963 case Model_iPAQ_H38xx:
968 d-> m_rotation = Rot90; 964 d-> m_rotation = Rot90;
969 break; 965 break;
970 case Model_iPAQ_H36xx: 966 case Model_iPAQ_H36xx:
971 case Model_iPAQ_H37xx: 967 case Model_iPAQ_H37xx:
972 case Model_iPAQ_H39xx: 968 case Model_iPAQ_H39xx:
973 default: 969 default:
974 d-> m_rotation = Rot270; 970 d-> m_rotation = Rot270;
975 break; 971 break;
976 } 972 }
977 973
978 f. setName ( "/etc/familiar-version" ); 974 f. setName ( "/etc/familiar-version" );
979 if ( f. open ( IO_ReadOnly )) { 975 if ( f. open ( IO_ReadOnly )) {
980 d-> m_systemstr = "Familiar"; 976 d-> m_systemstr = "Familiar";
981 d-> m_system = System_Familiar; 977 d-> m_system = System_Familiar;
982 978
983 QTextStream ts ( &f ); 979 QTextStream ts ( &f );
984 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 980 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
985 981
986 f. close ( ); 982 f. close ( );
987 } else { 983 } else {
988 f. setName ( "/etc/oz_version" ); 984 f. setName ( "/etc/oz_version" );
989 985
990 if ( f. open ( IO_ReadOnly )) { 986 if ( f. open ( IO_ReadOnly )) {
991 d-> m_systemstr = "OpenEmbedded/iPaq"; 987 d-> m_systemstr = "OpenEmbedded/iPaq";
992 d-> m_system = System_Familiar; 988 d-> m_system = System_Familiar;
993 989
994 QTextStream ts ( &f ); 990 QTextStream ts ( &f );
995 ts.setDevice ( &f ); 991 ts.setDevice ( &f );
996 d-> m_sysverstr = ts. readLine ( ); 992 d-> m_sysverstr = ts. readLine ( );
997 f. close ( ); 993 f. close ( );
998 } 994 }
999 } 995 }
1000 996
1001 997
1002 998
1003 999
1004 1000
1005 m_leds [0] = m_leds [1] = Led_Off; 1001 m_leds [0] = m_leds [1] = Led_Off;
1006 1002
1007 m_power_timer = 0; 1003 m_power_timer = 0;
1008 1004
@@ -1803,355 +1799,368 @@ bool SIMpad::setLedState ( OLed l, OLedState st )
1803 leds. OnTime = 0; 1799 leds. OnTime = 0;
1804 leds. OffTime = 1; 1800 leds. OffTime = 1;
1805 leds. OffOnBlink = 2; 1801 leds. OffOnBlink = 2;
1806 1802
1807 switch ( st ) { 1803 switch ( st ) {
1808 case Led_Off : leds. OffOnBlink = 0; break; 1804 case Led_Off : leds. OffOnBlink = 0; break;
1809 case Led_On : leds. OffOnBlink = 1; break; 1805 case Led_On : leds. OffOnBlink = 1; break;
1810 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1806 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1811 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1807 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1812 } 1808 }
1813 1809
1814 { 1810 {
1815 /*TODO Implement this like that: 1811 /*TODO Implement this like that:
1816 read from cs3 1812 read from cs3
1817 && with SIMPAD_LED2_ON 1813 && with SIMPAD_LED2_ON
1818 write to cs3 */ 1814 write to cs3 */
1819 m_leds [0] = st; 1815 m_leds [0] = st;
1820 return true; 1816 return true;
1821 } 1817 }
1822 } 1818 }
1823 } 1819 }
1824 return false; 1820 return false;
1825} 1821}
1826 1822
1827 1823
1828bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1824bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1829{ 1825{
1830 //TODO 1826 //TODO
1831 return false; 1827 return false;
1832} 1828}
1833 1829
1834void SIMpad::timerEvent ( QTimerEvent * ) 1830void SIMpad::timerEvent ( QTimerEvent * )
1835{ 1831{
1836 killTimer ( m_power_timer ); 1832 killTimer ( m_power_timer );
1837 m_power_timer = 0; 1833 m_power_timer = 0;
1838 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1834 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1839 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1835 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1840} 1836}
1841 1837
1842 1838
1843void SIMpad::alarmSound ( ) 1839void SIMpad::alarmSound ( )
1844{ 1840{
1845#ifndef QT_NO_SOUND 1841#ifndef QT_NO_SOUND
1846 static Sound snd ( "alarm" ); 1842 static Sound snd ( "alarm" );
1847 int fd; 1843 int fd;
1848 int vol; 1844 int vol;
1849 bool vol_reset = false; 1845 bool vol_reset = false;
1850 1846
1851 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1847 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1852 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1848 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1853 Config cfg ( "qpe" ); 1849 Config cfg ( "qpe" );
1854 cfg. setGroup ( "Volume" ); 1850 cfg. setGroup ( "Volume" );
1855 1851
1856 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1852 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1857 if ( volalarm < 0 ) 1853 if ( volalarm < 0 )
1858 volalarm = 0; 1854 volalarm = 0;
1859 else if ( volalarm > 100 ) 1855 else if ( volalarm > 100 )
1860 volalarm = 100; 1856 volalarm = 100;
1861 volalarm |= ( volalarm << 8 ); 1857 volalarm |= ( volalarm << 8 );
1862 1858
1863 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1859 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1864 vol_reset = true; 1860 vol_reset = true;
1865 } 1861 }
1866 } 1862 }
1867 1863
1868 snd. play ( ); 1864 snd. play ( );
1869 while ( !snd. isFinished ( )) 1865 while ( !snd. isFinished ( ))
1870 qApp-> processEvents ( ); 1866 qApp-> processEvents ( );
1871 1867
1872 if ( fd >= 0 ) { 1868 if ( fd >= 0 ) {
1873 if ( vol_reset ) 1869 if ( vol_reset )
1874 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1870 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1875 ::close ( fd ); 1871 ::close ( fd );
1876 } 1872 }
1877#endif 1873#endif
1878} 1874}
1879 1875
1880 1876
1881bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm 1877bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
1882{ 1878{
1883 qDebug( "ODevice for SIMpad: suspend()" ); 1879 qDebug( "ODevice for SIMpad: suspend()" );
1884 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 1880 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1885 return false; 1881 return false;
1886 1882
1887 bool res = false; 1883 bool res = false;
1888 1884
1889 struct timeval tvs, tvn; 1885 struct timeval tvs, tvn;
1890 ::gettimeofday ( &tvs, 0 ); 1886 ::gettimeofday ( &tvs, 0 );
1891 1887
1892 ::sync ( ); // flush fs caches 1888 ::sync ( ); // flush fs caches
1893 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) 1889 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :)
1894 1890
1895 return res; 1891 return res;
1896} 1892}
1897 1893
1898 1894
1899bool SIMpad::setSoftSuspend ( bool soft ) 1895bool SIMpad::setSoftSuspend ( bool soft )
1900{ 1896{
1901 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 1897 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
1902 return false; 1898 return false;
1903} 1899}
1904 1900
1905 1901
1906bool SIMpad::setDisplayStatus ( bool on ) 1902bool SIMpad::setDisplayStatus ( bool on )
1907{ 1903{
1908 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 1904 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
1909 1905
1910 bool res = false; 1906 bool res = false;
1911 int fd; 1907 int fd;
1912 1908
1913 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 1909 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
1914 1910
1915 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 1911 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
1916 res = ( ::system( (const char*) cmdline ) == 0 ); 1912 res = ( ::system( (const char*) cmdline ) == 0 );
1917 ::close ( fd ); 1913 ::close ( fd );
1918 } 1914 }
1919 return res; 1915 return res;
1920} 1916}
1921 1917
1922 1918
1923bool SIMpad::setDisplayBrightness ( int bright ) 1919bool SIMpad::setDisplayBrightness ( int bright )
1924{ 1920{
1925 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 1921 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
1926 bool res = false; 1922 bool res = false;
1927 int fd; 1923 int fd;
1928 1924
1929 if ( bright > 255 ) 1925 if ( bright > 255 )
1930 bright = 255; 1926 bright = 255;
1931 if ( bright < 0 ) 1927 if ( bright < 0 )
1932 bright = 0; 1928 bright = 0;
1933 1929
1934 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 1930 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
1935 int value = 255 - bright; 1931 int value = 255 - bright;
1936 const int mask = SIMPAD_BACKLIGHT_MASK; 1932 const int mask = SIMPAD_BACKLIGHT_MASK;
1937 value = value << 8; 1933 value = value << 8;
1938 value += mask; 1934 value += mask;
1939 char writeCommand[100]; 1935 char writeCommand[100];
1940 const int count = sprintf( writeCommand, "0x%x\n", value ); 1936 const int count = sprintf( writeCommand, "0x%x\n", value );
1941 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1937 res = ( ::write ( fd, writeCommand, count ) != -1 );
1942 ::close ( fd ); 1938 ::close ( fd );
1943 } 1939 }
1944 return res; 1940 return res;
1945} 1941}
1946 1942
1947 1943
1948int SIMpad::displayBrightnessResolution ( ) const 1944int SIMpad::displayBrightnessResolution ( ) const
1949{ 1945{
1950 switch ( model ( )) { 1946 switch ( model ( )) {
1951 case Model_SIMpad_CL4: 1947 case Model_SIMpad_CL4:
1952 case Model_SIMpad_SL4: 1948 case Model_SIMpad_SL4:
1953 case Model_SIMpad_SLC: 1949 case Model_SIMpad_SLC:
1954 case Model_SIMpad_TSinus: 1950 case Model_SIMpad_TSinus:
1955 return 255; //TODO find out if this is save 1951 return 255; //TODO find out if this is save
1956 1952
1957 default: 1953 default:
1958 return 2; 1954 return 2;
1959 } 1955 }
1960} 1956}
1961 1957
1962/************************************************** 1958/**************************************************
1963 * 1959 *
1964 * Ramses 1960 * Ramses
1965 * 1961 *
1966 **************************************************/ 1962 **************************************************/
1967 1963
1968void Ramses::init() 1964void Ramses::init()
1969{ 1965{
1970 d->m_vendorstr = "M und N"; 1966 d->m_vendorstr = "M und N";
1971 d->m_vendor = Vendor_MundN; 1967 d->m_vendor = Vendor_MundN;
1972 1968
1973 QFile f("/proc/sys/board/ramses"); 1969 QFile f("/proc/sys/board/ramses");
1974 1970
1975 d->m_modelstr = "Ramses"; 1971 d->m_modelstr = "Ramses";
1976 d->m_model = Model_Ramses_MNCI; 1972 d->m_model = Model_Ramses_MNCI;
1977 1973
1978 d->m_rotation = Rot0; 1974 d->m_rotation = Rot0;
1979 d->m_holdtime = 1000; 1975 d->m_holdtime = 1000;
1980 1976
1981 f.setName("/etc/oz_version"); 1977 f.setName("/etc/oz_version");
1982 1978
1983 if (f.open(IO_ReadOnly)) { 1979 if (f.open(IO_ReadOnly)) {
1984 d->m_systemstr = "OpenEmbedded/Ramses"; 1980 d->m_systemstr = "OpenEmbedded/Ramses";
1985 d->m_system = System_OpenZaurus; 1981 d->m_system = System_OpenZaurus;
1986 1982
1987 QTextStream ts(&f); 1983 QTextStream ts(&f);
1988 ts.setDevice(&f); 1984 ts.setDevice(&f);
1989 d->m_sysverstr = ts.readLine(); 1985 d->m_sysverstr = ts.readLine();
1990 f.close(); 1986 f.close();
1991 } 1987 }
1992 1988
1993 m_power_timer = 0; 1989 m_power_timer = 0;
1994 1990
1995qWarning("adding freq"); 1991#ifdef QT_QWS_ALLOW_OVERCLOCK
1996 d->m_cpu_frequencies->append("100"); 1992#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
1997 d->m_cpu_frequencies->append("200"); 1993#define OC(x...) x
1998 d->m_cpu_frequencies->append("300"); 1994#else
1999 d->m_cpu_frequencies->append("400"); 1995#define OC(x...)
1996#endif
1997
1998
1999 // This table is true for a Intel XScale PXA 255
2000
2001 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
2002 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
2003 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
2004 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
2005 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
2006 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
2007 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
2008 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
2009 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
2010
2000} 2011}
2001 2012
2002bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) 2013bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
2003{ 2014{
2004 Q_UNUSED( keycode ); 2015 Q_UNUSED( keycode );
2005 Q_UNUSED( modifiers ); 2016 Q_UNUSED( modifiers );
2006 Q_UNUSED( isPress ); 2017 Q_UNUSED( isPress );
2007 Q_UNUSED( autoRepeat ); 2018 Q_UNUSED( autoRepeat );
2008 return false; 2019 return false;
2009} 2020}
2010 2021
2011void Ramses::timerEvent(QTimerEvent *) 2022void Ramses::timerEvent(QTimerEvent *)
2012{ 2023{
2013 killTimer(m_power_timer); 2024 killTimer(m_power_timer);
2014 m_power_timer = 0; 2025 m_power_timer = 0;
2015 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); 2026 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
2016 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); 2027 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
2017} 2028}
2018 2029
2019 2030
2020bool Ramses::setSoftSuspend(bool soft) 2031bool Ramses::setSoftSuspend(bool soft)
2021{ 2032{
2022 qDebug("Ramses::setSoftSuspend(%d)", soft); 2033 qDebug("Ramses::setSoftSuspend(%d)", soft);
2023#if 0 2034#if 0
2024 bool res = false; 2035 bool res = false;
2025 int fd; 2036 int fd;
2026 2037
2027 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || 2038 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
2028 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { 2039 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
2029 2040
2030 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources 2041 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
2031 2042
2032 if (sources >= 0) { 2043 if (sources >= 0) {
2033 if (soft) 2044 if (soft)
2034 sources &= ~APM_EVT_POWER_BUTTON; 2045 sources &= ~APM_EVT_POWER_BUTTON;
2035 else 2046 else
2036 sources |= APM_EVT_POWER_BUTTON; 2047 sources |= APM_EVT_POWER_BUTTON;
2037 2048
2038 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources 2049 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
2039 res = true; 2050 res = true;
2040 else 2051 else
2041 perror("APM_IOCGEVTSRC"); 2052 perror("APM_IOCGEVTSRC");
2042 } 2053 }
2043 else 2054 else
2044 perror("APM_IOCGEVTSRC"); 2055 perror("APM_IOCGEVTSRC");
2045 2056
2046 ::close(fd); 2057 ::close(fd);
2047 } 2058 }
2048 else 2059 else
2049 perror("/dev/apm_bios or /dev/misc/apm_bios"); 2060 perror("/dev/apm_bios or /dev/misc/apm_bios");
2050 2061
2051 return res; 2062 return res;
2052#else 2063#else
2053 return true; 2064 return true;
2054#endif 2065#endif
2055} 2066}
2056 2067
2057bool Ramses::suspend ( ) 2068bool Ramses::suspend ( )
2058{ 2069{
2059 qDebug("Ramses::suspend"); 2070 qDebug("Ramses::suspend");
2060 return false; 2071 return false;
2061} 2072}
2062 2073
2063/** 2074/**
2064 * This sets the display on or off 2075 * This sets the display on or off
2065 */ 2076 */
2066bool Ramses::setDisplayStatus(bool on) 2077bool Ramses::setDisplayStatus(bool on)
2067{ 2078{
2068 qDebug("Ramses::setDisplayStatus(%d)", on); 2079 qDebug("Ramses::setDisplayStatus(%d)", on);
2069#if 0 2080#if 0
2070 bool res = false; 2081 bool res = false;
2071 int fd; 2082 int fd;
2072 2083
2073 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { 2084 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
2074 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 2085 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
2075 ::close(fd); 2086 ::close(fd);
2076 } 2087 }
2077 return res; 2088 return res;
2078#else 2089#else
2079 return true; 2090 return true;
2080#endif 2091#endif
2081} 2092}
2082 2093
2083 2094
2084/* 2095/*
2085 * We get something between 0..255 into us 2096 * We get something between 0..255 into us
2086*/ 2097*/
2087bool Ramses::setDisplayBrightness(int bright) 2098bool Ramses::setDisplayBrightness(int bright)
2088{ 2099{
2089 qDebug("Ramses::setDisplayBrightness(%d)", bright); 2100 qDebug("Ramses::setDisplayBrightness(%d)", bright);
2090 bool res = false; 2101 bool res = false;
2091 int fd; 2102 int fd;
2092 2103
2093 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 2104 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
2094 2105
2095 if (bright > 255 ) 2106 if (bright > 255 )
2096 bright = 255; 2107 bright = 255;
2097 if (bright < 0) 2108 if (bright < 0)
2098 bright = 0; 2109 bright = 0;
2099 2110
2100 // Turn backlight completely off 2111 // Turn backlight completely off
2101 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 2112 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
2102 char writeCommand[10]; 2113 char writeCommand[10];
2103 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 2114 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
2104 res = (::write(fd, writeCommand, count) != -1); 2115 res = (::write(fd, writeCommand, count) != -1);
2105 ::close(fd); 2116 ::close(fd);
2106 } 2117 }
2107 2118
2108 // scale backlight brightness to hardware 2119 // scale backlight brightness to hardware
2109 bright = 500-(bright * 500 / 255); 2120 bright = 500-(bright * 500 / 255);
2110 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { 2121 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
2111 qDebug(" %d -> pwm1", bright); 2122 qDebug(" %d -> pwm1", bright);
2112 char writeCommand[100]; 2123 char writeCommand[100];
2113 const int count = sprintf(writeCommand, "%d\n", bright); 2124 const int count = sprintf(writeCommand, "%d\n", bright);
2114 res = (::write(fd, writeCommand, count) != -1); 2125 res = (::write(fd, writeCommand, count) != -1);
2115 ::close(fd); 2126 ::close(fd);
2116 } 2127 }
2117 return res; 2128 return res;
2118} 2129}
2119 2130
2120 2131
2121int Ramses::displayBrightnessResolution() const 2132int Ramses::displayBrightnessResolution() const
2122{ 2133{
2123 return 32; 2134 return 32;
2124} 2135}
2125 2136
2126bool Ramses::setDisplayContrast(int contr) 2137bool Ramses::setDisplayContrast(int contr)
2127{ 2138{
2128 qDebug("Ramses::setDisplayContrast(%d)", contr); 2139 qDebug("Ramses::setDisplayContrast(%d)", contr);
2129 bool res = false; 2140 bool res = false;
2130 int fd; 2141 int fd;
2131 2142
2132 // pwm0 contrast: 20 steps 79..90 (dunkel->hell) 2143 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
2133 2144
2134 if (contr > 255 ) 2145 if (contr > 255 )
2135 contr = 255; 2146 contr = 255;
2136 if (contr < 0) 2147 if (contr < 0)
2137 contr = 0; 2148 contr = 0;
2138 contr = 90 - (contr * 20 / 255); 2149 contr = 90 - (contr * 20 / 255);
2139 2150
2140 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { 2151 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
2141 qDebug(" %d -> pwm0", contr); 2152 qDebug(" %d -> pwm0", contr);
2142 char writeCommand[100]; 2153 char writeCommand[100];
2143 const int count = sprintf(writeCommand, "%d\n", contr); 2154 const int count = sprintf(writeCommand, "%d\n", contr);
2144 res = (::write(fd, writeCommand, count) != -1); 2155 res = (::write(fd, writeCommand, count) != -1);
2145 res = true; 2156 res = true;
2146 ::close(fd); 2157 ::close(fd);
2147 } else {
2148 qWarning("no write");
2149 } 2158 }
2150 return res; 2159 return res;
2151} 2160}
2152 2161
2153 2162
2154int Ramses::displayContrastResolution() const 2163int Ramses::displayContrastResolution() const
2155{ 2164{
2156 return 20; 2165 return 20;
2157} 2166}
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 7f6f856..18ff5f1 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -11,239 +11,239 @@
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _LIBOPIE_ODEVICE_H_ 20#ifndef _LIBOPIE_ODEVICE_H_
21#define _LIBOPIE_ODEVICE_H_ 21#define _LIBOPIE_ODEVICE_H_
22 22
23#include <qobject.h> 23#include <qobject.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qnamespace.h> 25#include <qnamespace.h>
26#include <qstrlist.h> 26#include <qstrlist.h>
27 27
28#include <opie/odevicebutton.h> 28#include <opie/odevicebutton.h>
29 29
30#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 30#include <qpe/qpeapplication.h> /* for Transformation enum.. */
31 31
32class ODeviceData; 32class ODeviceData;
33 33
34namespace Opie { 34namespace Opie {
35 35
36/** 36/**
37 * The available devices 37 * The available devices
38 */ 38 */
39enum OModel { 39enum OModel {
40 Model_Unknown, // = 0 40 Model_Unknown, // = 0
41 41
42 Model_Series_Mask = 0xff000000, 42 Model_Series_Mask = 0xff000000,
43 43
44 Model_iPAQ = ( 1 << 24 ), 44 Model_iPAQ = ( 1 << 24 ),
45 45
46 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 46 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
47 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 47 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
48 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 48 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
49 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 49 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
50 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 50 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
51 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 51 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
52 52
53 Model_Zaurus = ( 2 << 24 ), 53 Model_Zaurus = ( 2 << 24 ),
54 54
55 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 55 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
56 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 56 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
57 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 57 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
58 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 58 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
59 Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), 59 Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ),
60 60
61 Model_SIMpad = ( 3 << 24 ), 61 Model_SIMpad = ( 3 << 24 ),
62 62
63 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 63 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
64 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 64 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
65 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 65 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
66 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 66 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
67 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 67 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
68 68
69 Model_Ramses = ( 4 << 24 ), 69 Model_Ramses = ( 4 << 24 ),
70 70
71 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 71 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
72 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 72 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
73}; 73};
74 74
75/** 75/**
76 * The vendor of the device 76 * The vendor of the device
77 */ 77 */
78enum OVendor { 78enum OVendor {
79 Vendor_Unknown, 79 Vendor_Unknown,
80 80
81 Vendor_HP, 81 Vendor_HP,
82 Vendor_Sharp, 82 Vendor_Sharp,
83 Vendor_SIEMENS, 83 Vendor_SIEMENS,
84 Vendor_MundN, 84 Vendor_MundN,
85}; 85};
86 86
87/** 87/**
88 * The System used 88 * The System used
89 */ 89 */
90enum OSystem { 90enum OSystem {
91 System_Unknown, 91 System_Unknown,
92 92
93 System_Familiar, 93 System_Familiar,
94 System_Zaurus, 94 System_Zaurus,
95 System_OpenZaurus 95 System_OpenZaurus
96}; 96};
97 97
98enum OLedState { 98enum OLedState {
99 Led_Off, 99 Led_Off,
100 Led_On, 100 Led_On,
101 Led_BlinkSlow, 101 Led_BlinkSlow,
102 Led_BlinkFast 102 Led_BlinkFast
103}; 103};
104 104
105enum OLed { 105enum OLed {
106 Led_Mail, 106 Led_Mail,
107 Led_Power, 107 Led_Power,
108 Led_BlueTooth 108 Led_BlueTooth
109}; 109};
110 110
111enum OHardKey { 111enum OHardKey {
112 HardKey_Datebook = Qt::Key_F9, 112 HardKey_Datebook = Qt::Key_F9,
113 HardKey_Contacts = Qt::Key_F10, 113 HardKey_Contacts = Qt::Key_F10,
114 HardKey_Menu = Qt::Key_F11, 114 HardKey_Menu = Qt::Key_F11,
115 HardKey_Home = Qt::Key_F12, 115 HardKey_Home = Qt::Key_F12,
116 HardKey_Mail = Qt::Key_F13, 116 HardKey_Mail = Qt::Key_F13,
117 HardKey_Record = Qt::Key_F24, 117 HardKey_Record = Qt::Key_F24,
118 HardKey_Suspend = Qt::Key_F34, 118 HardKey_Suspend = Qt::Key_F34,
119 HardKey_Backlight = Qt::Key_F35, 119 HardKey_Backlight = Qt::Key_F35,
120}; 120};
121 121
122enum ODirection { 122enum ODirection {
123 CW = 0, 123 CW = 0,
124 CCW = 1, 124 CCW = 1,
125 Flip = 2, 125 Flip = 2,
126}; 126};
127 127
128/** 128/**
129 * A singleton which gives informations about device specefic option 129 * A singleton which gives informations about device specefic option
130 * like the Hardware used, LEDs, the Base Distribution and 130 * like the Hardware used, LEDs, the Base Distribution and
131 * hardware key mappings. 131 * hardware key mappings.
132 * 132 *
133 * @short A small class for device specefic options 133 * @short A small class for device specefic options
134 * @see QObject 134 * @see QObject
135 * @author Robert Griebl 135 * @author Robert Griebl
136 * @version 1.0 136 * @version 1.0
137 */ 137 */
138class ODevice : public QObject { 138class ODevice : public QObject {
139 Q_OBJECT 139 Q_OBJECT
140 140
141private: 141private:
142 /* disable copy */ 142 /* disable copy */
143 ODevice ( const ODevice & ); 143 ODevice ( const ODevice & );
144 144
145protected: 145protected:
146 ODevice ( ); 146 ODevice ( );
147 virtual void init ( ); 147 virtual void init ( );
148 virtual void initButtons ( ); 148 virtual void initButtons ( );
149 149
150 ODeviceData *d; 150 ODeviceData *d;
151 151
152public: 152public:
153 // sandman do we want to allow destructions? -zecke? 153 // sandman do we want to allow destructions? -zecke?
154 virtual ~ODevice ( ); 154 virtual ~ODevice ( );
155 155
156 static ODevice *inst ( ); 156 static ODevice *inst ( );
157 157
158 // information 158 // information
159 159
160 QString modelString ( ) const; 160 QString modelString ( ) const;
161 OModel model ( ) const; 161 OModel model ( ) const;
162 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 162 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
163 163
164 QString vendorString ( ) const; 164 QString vendorString ( ) const;
165 OVendor vendor ( ) const; 165 OVendor vendor ( ) const;
166 166
167 QString systemString ( ) const; 167 QString systemString ( ) const;
168 OSystem system ( ) const; 168 OSystem system ( ) const;
169 169
170 QString systemVersionString ( ) const; 170 QString systemVersionString ( ) const;
171 171
172 Transformation rotation ( ) const; 172 Transformation rotation ( ) const;
173 ODirection direction ( ) const; 173 ODirection direction ( ) const;
174 174
175// system 175// system
176 176
177 virtual bool setSoftSuspend ( bool on ); 177 virtual bool setSoftSuspend ( bool on );
178 virtual bool suspend ( ); 178 virtual bool suspend ( );
179 179
180 virtual bool setDisplayStatus ( bool on ); 180 virtual bool setDisplayStatus ( bool on );
181 virtual bool setDisplayBrightness ( int brightness ); 181 virtual bool setDisplayBrightness ( int brightness );
182 virtual int displayBrightnessResolution ( ) const; 182 virtual int displayBrightnessResolution ( ) const;
183 virtual bool setDisplayContrast ( int contrast ); 183 virtual bool setDisplayContrast ( int contrast );
184 virtual int displayContrastResolution ( ) const; 184 virtual int displayContrastResolution ( ) const;
185 185
186// input / output 186// input / output
187 //FIXME playAlarmSound and al might be better -zecke 187 //FIXME playAlarmSound and al might be better -zecke
188 virtual void alarmSound ( ); 188 virtual void alarmSound ( );
189 virtual void keySound ( ); 189 virtual void keySound ( );
190 virtual void touchSound ( ); 190 virtual void touchSound ( );
191 191
192 virtual QValueList <OLed> ledList ( ) const; 192 virtual QValueList <OLed> ledList ( ) const;
193 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 193 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
194 virtual OLedState ledState ( OLed led ) const; 194 virtual OLedState ledState ( OLed led ) const;
195 virtual bool setLedState ( OLed led, OLedState st ); 195 virtual bool setLedState ( OLed led, OLedState st );
196 196
197 virtual bool hasLightSensor ( ) const; 197 virtual bool hasLightSensor ( ) const;
198 virtual int readLightSensor ( ); 198 virtual int readLightSensor ( );
199 virtual int lightSensorResolution ( ) const; 199 virtual int lightSensorResolution ( ) const;
200 200
201 QStrList &cpuFrequencies() const; 201 QStrList &cpuFrequencies() const;
202 bool setCpuFrequency(uint index); 202 bool setCpuFrequency(uint index);
203 uint cpuFrequency() const; 203 int cpuFrequency() const;
204 204
205 /** 205 /**
206 * Returns the available buttons on this device. The number and location 206 * Returns the available buttons on this device. The number and location
207 * of buttons will vary depending on the device. Button numbers will be assigned 207 * of buttons will vary depending on the device. Button numbers will be assigned
208 * by the device manufacturer and will be from most preferred button to least preffered 208 * by the device manufacturer and will be from most preferred button to least preffered
209 * button. Note that this list only contains "user mappable" buttons. 209 * button. Note that this list only contains "user mappable" buttons.
210 */ 210 */
211 const QValueList<ODeviceButton> &buttons ( ); 211 const QValueList<ODeviceButton> &buttons ( );
212 212
213 /** 213 /**
214 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 214 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
215 * returns 0L 215 * returns 0L
216 */ 216 */
217 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 217 const ODeviceButton *buttonForKeycode ( ushort keyCode );
218 218
219 /** 219 /**
220 * Reassigns the pressed action for \a button. To return to the factory 220 * Reassigns the pressed action for \a button. To return to the factory
221 * default pass an empty string as \a qcopMessage. 221 * default pass an empty string as \a qcopMessage.
222 */ 222 */
223 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 223 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
224 224
225 /** 225 /**
226 * Reassigns the held action for \a button. To return to the factory 226 * Reassigns the held action for \a button. To return to the factory
227 * default pass an empty string as \a qcopMessage. 227 * default pass an empty string as \a qcopMessage.
228 */ 228 */
229 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 229 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
230 230
231 /** 231 /**
232 * How long (in ms) you have to press a button for a "hold" action 232 * How long (in ms) you have to press a button for a "hold" action
233 */ 233 */
234 uint buttonHoldTime ( ) const; 234 uint buttonHoldTime ( ) const;
235 235
236signals: 236signals:
237 void buttonMappingChanged ( ); 237 void buttonMappingChanged ( );
238 238
239private slots: 239private slots:
240 void systemMessage ( const QCString &, const QByteArray & ); 240 void systemMessage ( const QCString &, const QByteArray & );
241 241
242protected: 242protected:
243 void reloadButtonMapping ( ); 243 void reloadButtonMapping ( );
244}; 244};
245 245
246} 246}
247 247
248#endif 248#endif
249 249