author | sandman <sandman> | 2002-11-01 19:03:41 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-01 19:03:41 (UTC) |
commit | 0380a66a6edc8692668a24a49082881b13a4c5fc (patch) (side-by-side diff) | |
tree | 6e1fbfe4133d493c6380da26e38d29678b8c3622 /libopie/odevice.cpp | |
parent | 6860113387bbc86ee33e86327941cafc986e6481 (diff) | |
download | opie-0380a66a6edc8692668a24a49082881b13a4c5fc.zip opie-0380a66a6edc8692668a24a49082881b13a4c5fc.tar.gz opie-0380a66a6edc8692668a24a49082881b13a4c5fc.tar.bz2 |
setDisplayBrightness calculated the wrong backlight level for iPAQs
-rw-r--r-- | libopie/odevice.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 8f4e296..7d8cdbf 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -612,108 +612,106 @@ void iPAQ::alarmSound ( ) volalarm |= ( volalarm << 8 ); if (( volalarm & 0xff ) > ( vol & 0xff )) { if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) vol_reset = true; } } } snd. play ( ); while ( !snd. isFinished ( )) qApp-> processEvents ( ); if ( fd >= 0 ) { if ( vol_reset ) ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); ::close ( fd ); } #endif #endif } bool iPAQ::setSoftSuspend ( bool soft ) { bool res = false; int fd; if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) res = true; else ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); ::close ( fd ); } else ::perror ( "/proc/sys/ts/suspend_button_mode" ); return res; } bool iPAQ::setDisplayBrightness ( int bright ) { bool res = false; int fd; - int maxbright = displayBrightnessResolution ( ); - - if ( bright > maxbright ) - bright = maxbright; + if ( bright > 255 ) + bright = 255; if ( bright < 0 ) bright = 0; if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { FLITE_IN bl; bl. mode = 1; bl. pwr = bright ? 1 : 0; - bl. brightness = bright; + bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); ::close ( fd ); } return res; } int iPAQ::displayBrightnessResolution ( ) const { switch ( model ( )) { case Model_iPAQ_H31xx: case Model_iPAQ_H36xx: case Model_iPAQ_H37xx: return 128; // really 256, but >128 could damage the LCD case Model_iPAQ_H38xx: case Model_iPAQ_H39xx: return 64; default: return 2; } } bool iPAQ::hasLightSensor ( ) const { return true; } int iPAQ::readLightSensor ( ) { int fd; int val = -1; if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { char buffer [8]; if ( ::read ( fd, buffer, 5 ) == 5 ) { char *endptr; buffer [4] = 0; val = ::strtol ( buffer + 2, &endptr, 16 ); if ( *endptr != 0 ) val = -1; } ::close ( fd ); } |