summaryrefslogtreecommitdiff
Unidiff
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
@@ -13,240 +13,266 @@
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 ( );
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
@@ -750,99 +750,95 @@ bool ODevice::setLedState ( OLed which, OLedState 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);
@@ -1963,69 +1959,84 @@ int SIMpad::displayBrightnessResolution ( ) const
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
@@ -2115,43 +2126,41 @@ bool Ramses::setDisplayBrightness(int bright)
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
@@ -171,65 +171,65 @@ public:
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