summaryrefslogtreecommitdiff
path: root/libopie
authorsandman <sandman>2002-10-29 15:50:21 (UTC)
committer sandman <sandman>2002-10-29 15:50:21 (UTC)
commitbad66a2ea2aea8bec1c7895b0e1a461e2f4859c2 (patch) (unidiff)
tree6a39587f58ff01456fff0a6d17d5564d28bb4f4f /libopie
parent6224d462ef211b3b4cffa42d4a7f261caa92834b (diff)
downloadopie-bad66a2ea2aea8bec1c7895b0e1a461e2f4859c2.zip
opie-bad66a2ea2aea8bec1c7895b0e1a461e2f4859c2.tar.gz
opie-bad66a2ea2aea8bec1c7895b0e1a461e2f4859c2.tar.bz2
added lightSensorResolution() to get the hardware resolution of the light
sensor
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp12
-rw-r--r--libopie/odevice.h1
2 files changed, 11 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9f64fc0..4c49c4f 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -77,24 +77,25 @@ public:
77 virtual bool setDisplayBrightness ( int b ); 77 virtual bool setDisplayBrightness ( int b );
78 virtual int displayBrightnessResolution ( ) const; 78 virtual int displayBrightnessResolution ( ) const;
79 79
80 virtual void alarmSound ( ); 80 virtual void alarmSound ( );
81 81
82 virtual QValueList <OLed> ledList ( ) const; 82 virtual QValueList <OLed> ledList ( ) const;
83 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 83 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
84 virtual OLedState ledState ( OLed led ) const; 84 virtual OLedState ledState ( OLed led ) const;
85 virtual bool setLedState ( OLed led, OLedState st ); 85 virtual bool setLedState ( OLed led, OLedState st );
86 86
87 virtual bool hasLightSensor ( ) const; 87 virtual bool hasLightSensor ( ) const;
88 virtual int readLightSensor ( ); 88 virtual int readLightSensor ( );
89 virtual int lightSensorResolution ( ) const;
89 90
90 //virtual QValueList <int> keyList ( ) const; 91 //virtual QValueList <int> keyList ( ) const;
91 92
92protected: 93protected:
93 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 94 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
94 virtual void timerEvent ( QTimerEvent *te ); 95 virtual void timerEvent ( QTimerEvent *te );
95 96
96 int m_power_timer; 97 int m_power_timer;
97 98
98 OLedState m_leds [2]; 99 OLedState m_leds [2];
99}; 100};
100 101
@@ -360,24 +361,28 @@ bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
360} 361}
361 362
362bool ODevice::hasLightSensor ( ) const 363bool ODevice::hasLightSensor ( ) const
363{ 364{
364 return false; 365 return false;
365} 366}
366 367
367int ODevice::readLightSensor ( ) 368int ODevice::readLightSensor ( )
368{ 369{
369 return -1; 370 return -1;
370} 371}
371 372
373int ODevice::lightSensorResolution ( ) const
374{
375 return 0;
376}
372 377
373//QValueList <int> ODevice::keyList ( ) const 378//QValueList <int> ODevice::keyList ( ) const
374//{ 379//{
375 //return QValueList <int> ( ); 380 //return QValueList <int> ( );
376//} 381//}
377 382
378 383
379 384
380/************************************************** 385/**************************************************
381 * 386 *
382 * iPAQ 387 * iPAQ
383 * 388 *
@@ -673,49 +678,52 @@ bool iPAQ::setDisplayBrightness ( int bright )
673} 678}
674 679
675int iPAQ::displayBrightnessResolution ( ) const 680int iPAQ::displayBrightnessResolution ( ) const
676{ 681{
677 return 256; // really 128, but logarithmic control is smoother this way 682 return 256; // really 128, but logarithmic control is smoother this way
678} 683}
679 684
680 685
681bool iPAQ::hasLightSensor ( ) const 686bool iPAQ::hasLightSensor ( ) const
682{ 687{
683 return true; 688 return true;
684} 689}
685#include <errno.h> 690
686#include <string.h>
687int iPAQ::readLightSensor ( ) 691int iPAQ::readLightSensor ( )
688{ 692{
689 int fd; 693 int fd;
690 int val = -1; 694 int val = -1;
691 695
692 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 696 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
693 char buffer [8]; 697 char buffer [8];
694 698
695 if ( ::read ( fd, buffer, 5 ) == 5 ) { 699 if ( ::read ( fd, buffer, 5 ) == 5 ) {
696 char *endptr; 700 char *endptr;
697 701
698 buffer [4] = 0; 702 buffer [4] = 0;
699 val = ::strtol ( buffer + 2, &endptr, 16 ); 703 val = ::strtol ( buffer + 2, &endptr, 16 );
700 704
701 if ( *endptr != 0 ) 705 if ( *endptr != 0 )
702 val = -1; 706 val = -1;
703 } 707 }
704 ::close ( fd ); 708 ::close ( fd );
705 } 709 }
706 710
707 return val; 711 return val;
708} 712}
709 713
714int iPAQ::lightSensorResolution ( ) const
715{
716 return 256;
717}
710 718
711/************************************************** 719/**************************************************
712 * 720 *
713 * Zaurus 721 * Zaurus
714 * 722 *
715 **************************************************/ 723 **************************************************/
716 724
717 725
718 726
719void Zaurus::init ( ) 727void Zaurus::init ( )
720{ 728{
721 d-> m_modelstr = "Zaurus SL5000"; 729 d-> m_modelstr = "Zaurus SL5000";
diff --git a/libopie/odevice.h b/libopie/odevice.h
index be2a9c7..e07b91c 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -126,20 +126,21 @@ public:
126 126
127 virtual void alarmSound ( ); 127 virtual void alarmSound ( );
128 virtual void keySound ( ); 128 virtual void keySound ( );
129 virtual void touchSound ( ); 129 virtual void touchSound ( );
130 130
131 virtual QValueList <OLed> ledList ( ) const; 131 virtual QValueList <OLed> ledList ( ) const;
132 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 132 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
133 virtual OLedState ledState ( OLed led ) const; 133 virtual OLedState ledState ( OLed led ) const;
134 virtual bool setLedState ( OLed led, OLedState st ); 134 virtual bool setLedState ( OLed led, OLedState st );
135 135
136 virtual bool hasLightSensor ( ) const; 136 virtual bool hasLightSensor ( ) const;
137 virtual int readLightSensor ( ); 137 virtual int readLightSensor ( );
138 virtual int lightSensorResolution ( ) const;
138 139
139 //virtual QValueList <int> keyList ( ) const; 140 //virtual QValueList <int> keyList ( ) const;
140}; 141};
141 142
142} 143}
143 144
144#endif 145#endif
145 146