summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authorsandman <sandman>2002-10-29 18:43:23 (UTC)
committer sandman <sandman>2002-10-29 18:43:23 (UTC)
commit5ac67b8aece5aca20419f8953f88a36fd729adfc (patch) (unidiff)
tree3ce57c7a938d36ce40ff0dfe4b114233febf7b08 /libopie/odevice.cpp
parent45d9a30ec17b5146ffdac8e776003752fe2deeea (diff)
downloadopie-5ac67b8aece5aca20419f8953f88a36fd729adfc.zip
opie-5ac67b8aece5aca20419f8953f88a36fd729adfc.tar.gz
opie-5ac67b8aece5aca20419f8953f88a36fd729adfc.tar.bz2
- redone the Model enum to make it easy to check for series (like: is this an
iPAQ - and not is this a 31xx or 36xx or ...) - fixed the disply brightness resolution bug on H38xx
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 4c49c4f..8f4e296 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -379,64 +379,66 @@ int ODevice::lightSensorResolution ( ) const
379//{ 379//{
380 //return QValueList <int> ( ); 380 //return QValueList <int> ( );
381//} 381//}
382 382
383 383
384 384
385/************************************************** 385/**************************************************
386 * 386 *
387 * iPAQ 387 * iPAQ
388 * 388 *
389 **************************************************/ 389 **************************************************/
390 390
391void iPAQ::init ( ) 391void iPAQ::init ( )
392{ 392{
393 d-> m_vendorstr = "HP"; 393 d-> m_vendorstr = "HP";
394 d-> m_vendor = Vendor_HP; 394 d-> m_vendor = Vendor_HP;
395 395
396 QFile f ( "/proc/hal/model" ); 396 QFile f ( "/proc/hal/model" );
397 397
398 if ( f. open ( IO_ReadOnly )) { 398 if ( f. open ( IO_ReadOnly )) {
399 QTextStream ts ( &f ); 399 QTextStream ts ( &f );
400 400
401 d-> m_modelstr = "H" + ts. readLine ( ); 401 d-> m_modelstr = "H" + ts. readLine ( );
402 402
403 if ( d-> m_modelstr == "H3100" ) 403 if ( d-> m_modelstr == "H3100" )
404 d-> m_model = Model_iPAQ_H31xx; 404 d-> m_model = Model_iPAQ_H31xx;
405 else if ( d-> m_modelstr == "H3600" ) 405 else if ( d-> m_modelstr == "H3600" )
406 d-> m_model = Model_iPAQ_H36xx; 406 d-> m_model = Model_iPAQ_H36xx;
407 else if ( d-> m_modelstr == "H3700" ) 407 else if ( d-> m_modelstr == "H3700" )
408 d-> m_model = Model_iPAQ_H37xx; 408 d-> m_model = Model_iPAQ_H37xx;
409 else if ( d-> m_modelstr == "H3800" ) 409 else if ( d-> m_modelstr == "H3800" )
410 d-> m_model = Model_iPAQ_H38xx; 410 d-> m_model = Model_iPAQ_H38xx;
411 else if ( d-> m_modelstr == "H3900" )
412 d-> m_model = Model_iPAQ_H39xx;
411 else 413 else
412 d-> m_model = Model_Unknown; 414 d-> m_model = Model_Unknown;
413 415
414 f. close ( ); 416 f. close ( );
415 } 417 }
416 418
417 f. setName ( "/etc/familiar-version" ); 419 f. setName ( "/etc/familiar-version" );
418 if ( f. open ( IO_ReadOnly )) { 420 if ( f. open ( IO_ReadOnly )) {
419 d-> m_systemstr = "Familiar"; 421 d-> m_systemstr = "Familiar";
420 d-> m_system = System_Familiar; 422 d-> m_system = System_Familiar;
421 423
422 QTextStream ts ( &f ); 424 QTextStream ts ( &f );
423 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 425 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
424 426
425 f. close ( ); 427 f. close ( );
426 } 428 }
427 429
428 m_leds [0] = m_leds [1] = Led_Off; 430 m_leds [0] = m_leds [1] = Led_Off;
429 431
430 m_power_timer = 0; 432 m_power_timer = 0;
431 433
432 if ( d-> m_qwsserver ) 434 if ( d-> m_qwsserver )
433 QWSServer::setKeyboardFilter ( this ); 435 QWSServer::setKeyboardFilter ( this );
434} 436}
435 437
436//#include <linux/h3600_ts.h> // including kernel headers is evil ... 438//#include <linux/h3600_ts.h> // including kernel headers is evil ...
437 439
438typedef struct { 440typedef struct {
439 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 441 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
440 unsigned char TotalTime; /* Units of 5 seconds */ 442 unsigned char TotalTime; /* Units of 5 seconds */
441 unsigned char OnTime; /* units of 100m/s */ 443 unsigned char OnTime; /* units of 100m/s */
442 unsigned char OffTime; /* units of 100m/s */ 444 unsigned char OffTime; /* units of 100m/s */
@@ -626,89 +628,97 @@ void iPAQ::alarmSound ( )
626 ::close ( fd ); 628 ::close ( fd );
627 } 629 }
628#endif 630#endif
629#endif 631#endif
630} 632}
631 633
632 634
633bool iPAQ::setSoftSuspend ( bool soft ) 635bool iPAQ::setSoftSuspend ( bool soft )
634{ 636{
635 bool res = false; 637 bool res = false;
636 int fd; 638 int fd;
637 639
638 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 640 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
639 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 641 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
640 res = true; 642 res = true;
641 else 643 else
642 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 644 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
643 645
644 ::close ( fd ); 646 ::close ( fd );
645 } 647 }
646 else 648 else
647 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 649 ::perror ( "/proc/sys/ts/suspend_button_mode" );
648 650
649 return res; 651 return res;
650} 652}
651 653
652 654
653bool iPAQ::setDisplayBrightness ( int bright ) 655bool iPAQ::setDisplayBrightness ( int bright )
654{ 656{
655 bool res = false; 657 bool res = false;
656 int fd; 658 int fd;
657 659
658 if ( bright > 255 ) 660 int maxbright = displayBrightnessResolution ( );
659 bright = 255; 661
662 if ( bright > maxbright )
663 bright = maxbright;
660 if ( bright < 0 ) 664 if ( bright < 0 )
661 bright = 0; 665 bright = 0;
662 666
663 // 128 is the maximum if you want a decent lifetime for the LCD
664
665 if ( bright > 1 )
666 bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic
667 //bright = ( bright + 1 ) / 2;
668
669 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 667 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
670 FLITE_IN bl; 668 FLITE_IN bl;
671 bl. mode = 1; 669 bl. mode = 1;
672 bl. pwr = bright ? 1 : 0; 670 bl. pwr = bright ? 1 : 0;
673 bl. brightness = bright; 671 bl. brightness = bright;
674 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 672 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
675 ::close ( fd ); 673 ::close ( fd );
676 } 674 }
677 return res; 675 return res;
678} 676}
679 677
680int iPAQ::displayBrightnessResolution ( ) const 678int iPAQ::displayBrightnessResolution ( ) const
681{ 679{
682 return 256; // really 128, but logarithmic control is smoother this way 680 switch ( model ( )) {
681 case Model_iPAQ_H31xx:
682 case Model_iPAQ_H36xx:
683 case Model_iPAQ_H37xx:
684 return 128; // really 256, but >128 could damage the LCD
685
686 case Model_iPAQ_H38xx:
687 case Model_iPAQ_H39xx:
688 return 64;
689
690 default:
691 return 2;
692 }
683} 693}
684 694
685 695
686bool iPAQ::hasLightSensor ( ) const 696bool iPAQ::hasLightSensor ( ) const
687{ 697{
688 return true; 698 return true;
689} 699}
690 700
691int iPAQ::readLightSensor ( ) 701int iPAQ::readLightSensor ( )
692{ 702{
693 int fd; 703 int fd;
694 int val = -1; 704 int val = -1;
695 705
696 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 706 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
697 char buffer [8]; 707 char buffer [8];
698 708
699 if ( ::read ( fd, buffer, 5 ) == 5 ) { 709 if ( ::read ( fd, buffer, 5 ) == 5 ) {
700 char *endptr; 710 char *endptr;
701 711
702 buffer [4] = 0; 712 buffer [4] = 0;
703 val = ::strtol ( buffer + 2, &endptr, 16 ); 713 val = ::strtol ( buffer + 2, &endptr, 16 );
704 714
705 if ( *endptr != 0 ) 715 if ( *endptr != 0 )
706 val = -1; 716 val = -1;
707 } 717 }
708 ::close ( fd ); 718 ::close ( fd );
709 } 719 }
710 720
711 return val; 721 return val;
712} 722}
713 723
714int iPAQ::lightSensorResolution ( ) const 724int iPAQ::lightSensorResolution ( ) const
@@ -928,39 +938,33 @@ bool Zaurus::setSoftSuspend ( bool soft )
928 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 938 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
929 939
930 return res; 940 return res;
931} 941}
932 942
933 943
934bool Zaurus::setDisplayBrightness ( int bright ) 944bool Zaurus::setDisplayBrightness ( int bright )
935{ 945{
936 bool res = false; 946 bool res = false;
937 int fd; 947 int fd;
938 948
939 if ( bright > 255 ) 949 if ( bright > 255 )
940 bright = 255; 950 bright = 255;
941 if ( bright < 0 ) 951 if ( bright < 0 )
942 bright = 0; 952 bright = 0;
943 953
944 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 954 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
945 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 955 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
946 if ( bright && !bl ) 956 if ( bright && !bl )
947 bl = 1; 957 bl = 1;
948 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 958 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
949 ::close ( fd ); 959 ::close ( fd );
950 } 960 }
951 return res; 961 return res;
952} 962}
953 963
954 964
955int Zaurus::displayBrightnessResolution ( ) const 965int Zaurus::displayBrightnessResolution ( ) const
956{ 966{
957 return 5; 967 return 5;
958} 968}
959 969
960//QValueList <int> Zaurus::keyList ( ) const
961//{
962 //QValueList <int> vl;
963 //vl << HardKey_Datebook << HardKey_Contacts << HardKey_Mail << HardKey_Menu << HardKey_Home << HardKey_Suspend << HardKey_Backlight;
964 //return vl;
965//}
966 970