summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/screensaver.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/core/launcher/screensaver.cpp b/core/launcher/screensaver.cpp
index 088ed19..b9bb64c 100644
--- a/core/launcher/screensaver.cpp
+++ b/core/launcher/screensaver.cpp
@@ -129,17 +129,17 @@ void OpieScreenSaver::setIntervals ( int i1, int i2, int i3 )
129 } 129 }
130 else { 130 else {
131 m_enable_dim = ( i1 > 0 ); 131 m_enable_dim = ( i1 > 0 );
132 m_enable_lightoff = ( i2 > 0 ); 132 m_enable_lightoff = ( i2 > 0 );
133 m_enable_suspend = ( i3 > 0 ); 133 m_enable_suspend = ( i3 > 0 );
134 m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false ); 134 m_onlylcdoff = config.readBoolEntry ( "LcdOffOnly", false );
135 } 135 }
136 136
137 qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 137 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
138 138
139 v [ 0 ] = QMAX( 1000 * i1, 100 ); 139 v [ 0 ] = QMAX( 1000 * i1, 100 );
140 v [ 1 ] = QMAX( 1000 * i2, 100 ); 140 v [ 1 ] = QMAX( 1000 * i2, 100 );
141 v [ 2 ] = QMAX( 1000 * i3, 100 ); 141 v [ 2 ] = QMAX( 1000 * i3, 100 );
142 v [ 3 ] = 0; 142 v [ 3 ] = 0;
143 143
144 if ( !i1 && !i2 && !i3 ) 144 if ( !i1 && !i2 && !i3 )
145 QWSServer::setScreenSaverInterval( 0 ); 145 QWSServer::setScreenSaverInterval( 0 );
@@ -166,20 +166,20 @@ void OpieScreenSaver::setBacklight ( int bright )
166{ 166{
167 // Read from config 167 // Read from config
168 Config config ( "apm" ); 168 Config config ( "apm" );
169 config. setGroup ( m_on_ac ? "AC" : "Battery" ); 169 config. setGroup ( m_on_ac ? "AC" : "Battery" );
170 m_backlight_normal = config. readNumEntry ( "Brightness", m_on_ac ? 255 : 127 ); 170 m_backlight_normal = config. readNumEntry ( "Brightness", m_on_ac ? 255 : 127 );
171 171
172 m_use_light_sensor = config. readBoolEntry ( "LightSensor", false ); 172 m_use_light_sensor = config. readBoolEntry ( "LightSensor", false );
173 173
174 //qDebug ( "setBacklight: %d (ls: %d)", m_backlight_normal, m_use_light_sensor ? 1 : 0 ); 174 //qDebug ( "setBacklight: %d (norm: %d) (ls: %d)", bright, m_backlight_normal, m_use_light_sensor ? 1 : 0 );
175 175
176 killTimers ( ); 176 killTimers ( );
177 if ( m_use_light_sensor ) { 177 if (( bright < 0 ) && m_use_light_sensor ) {
178 QStringList sl = config. readListEntry ( "LightSensorData", ';' ); 178 QStringList sl = config. readListEntry ( "LightSensorData", ';' );
179 179
180 m_sensordata [LS_SensorMin] = 40; 180 m_sensordata [LS_SensorMin] = 40;
181 m_sensordata [LS_SensorMax] = 215; 181 m_sensordata [LS_SensorMax] = 215;
182 m_sensordata [LS_LightMin] = 1; 182 m_sensordata [LS_LightMin] = 1;
183 m_sensordata [LS_LightMax] = 255; 183 m_sensordata [LS_LightMax] = 255;
184 m_sensordata [LS_Steps] = 12; 184 m_sensordata [LS_Steps] = 12;
185 m_sensordata [LS_Interval] = 2000; 185 m_sensordata [LS_Interval] = 2000;
@@ -220,34 +220,32 @@ void OpieScreenSaver::setBacklightInternal ( int bright )
220 ODevice::inst ( )-> setDisplayBrightness ( bright ); 220 ODevice::inst ( )-> setDisplayBrightness ( bright );
221 m_backlight_current = bright; 221 m_backlight_current = bright;
222 } 222 }
223} 223}
224 224
225 225
226void OpieScreenSaver::timerEvent ( QTimerEvent * ) 226void OpieScreenSaver::timerEvent ( QTimerEvent * )
227{ 227{
228 int s = ODevice::inst ( )-> readLightSensor ( ); 228 int s = ODevice::inst ( )-> readLightSensor ( ) * 256 / ODevice::inst ( )-> lightSensorResolution ( );
229 229
230 if ( s < m_sensordata [LS_SensorMin] ) 230 if ( s < m_sensordata [LS_SensorMin] )
231 m_backlight_sensor = m_sensordata [LS_LightMax]; 231 m_backlight_sensor = m_sensordata [LS_LightMax];
232 else if ( s >= m_sensordata [LS_SensorMax] ) 232 else if ( s >= m_sensordata [LS_SensorMax] )
233 m_backlight_sensor = m_sensordata [LS_LightMin]; 233 m_backlight_sensor = m_sensordata [LS_LightMin];
234 else { 234 else {
235 int dx = m_sensordata [LS_SensorMax] - m_sensordata [LS_SensorMin]; 235 int dx = m_sensordata [LS_SensorMax] - m_sensordata [LS_SensorMin];
236 int dy = m_sensordata [LS_LightMax] - m_sensordata [LS_LightMin]; 236 int dy = m_sensordata [LS_LightMax] - m_sensordata [LS_LightMin];
237 237
238 int stepno = ( s - m_sensordata [LS_SensorMin] ) * m_sensordata [LS_Steps] / dx; // dx is never 0 238 int stepno = ( s - m_sensordata [LS_SensorMin] ) * m_sensordata [LS_Steps] / dx; // dx is never 0
239 239
240 m_backlight_sensor = m_sensordata [LS_LightMax] - dy * stepno / ( m_sensordata [LS_Steps] - 1 ); 240 m_backlight_sensor = m_sensordata [LS_LightMax] - dy * stepno / ( m_sensordata [LS_Steps] - 1 );
241 } 241 }
242 if ( !m_backlight_sensor )
243 m_backlight_sensor = 1;
244 242
245 // qDebug ( "f(%d) = %d [%d - %d] -> [%d - %d] / %d", s, m_backlight_sensor, m_sensordata [LS_SensorMin], m_sensordata [LS_SensorMax], m_sensordata [LS_LightMin], m_sensordata [LS_LightMax], m_sensordata [LS_Steps] ); 243 //qDebug ( "f(%d) = %d [%d - %d] -> [%d - %d] / %d", s, m_backlight_sensor, m_sensordata [LS_SensorMin], m_sensordata [LS_SensorMax], m_sensordata [LS_LightMin], m_sensordata [LS_LightMax], m_sensordata [LS_Steps] );
246 244
247 if ( m_level <= 0 ) 245 if ( m_level <= 0 )
248 setBacklightInternal ( -1 ); 246 setBacklightInternal ( -1 );
249} 247}
250 248
251 249
252void OpieScreenSaver::setDisplayState ( bool on ) 250void OpieScreenSaver::setDisplayState ( bool on )
253{ 251{