author | sandman <sandman> | 2002-10-29 15:50:21 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-29 15:50:21 (UTC) |
commit | bad66a2ea2aea8bec1c7895b0e1a461e2f4859c2 (patch) (unidiff) | |
tree | 6a39587f58ff01456fff0a6d17d5564d28bb4f4f | |
parent | 6224d462ef211b3b4cffa42d4a7f261caa92834b (diff) | |
download | opie-bad66a2ea2aea8bec1c7895b0e1a461e2f4859c2.zip opie-bad66a2ea2aea8bec1c7895b0e1a461e2f4859c2.tar.gz opie-bad66a2ea2aea8bec1c7895b0e1a461e2f4859c2.tar.bz2 |
added lightSensorResolution() to get the hardware resolution of the light
sensor
-rw-r--r-- | libopie/odevice.cpp | 12 | ||||
-rw-r--r-- | libopie/odevice.h | 1 |
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 | |||
@@ -73,32 +73,33 @@ protected: | |||
73 | 73 | ||
74 | public: | 74 | public: |
75 | virtual bool setSoftSuspend ( bool soft ); | 75 | virtual bool setSoftSuspend ( bool soft ); |
76 | 76 | ||
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 | ||
92 | protected: | 93 | protected: |
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 | ||
101 | class Zaurus : public ODevice { | 102 | class Zaurus : public ODevice { |
102 | protected: | 103 | protected: |
103 | virtual void init ( ); | 104 | virtual void init ( ); |
104 | 105 | ||
@@ -356,32 +357,36 @@ OLedState ODevice::ledState ( OLed /*which*/ ) const | |||
356 | 357 | ||
357 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | 358 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) |
358 | { | 359 | { |
359 | return false; | 360 | return false; |
360 | } | 361 | } |
361 | 362 | ||
362 | bool ODevice::hasLightSensor ( ) const | 363 | bool ODevice::hasLightSensor ( ) const |
363 | { | 364 | { |
364 | return false; | 365 | return false; |
365 | } | 366 | } |
366 | 367 | ||
367 | int ODevice::readLightSensor ( ) | 368 | int ODevice::readLightSensor ( ) |
368 | { | 369 | { |
369 | return -1; | 370 | return -1; |
370 | } | 371 | } |
371 | 372 | ||
373 | int 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 | * |
384 | **************************************************/ | 389 | **************************************************/ |
385 | 390 | ||
386 | void iPAQ::init ( ) | 391 | void iPAQ::init ( ) |
387 | { | 392 | { |
@@ -669,57 +674,60 @@ bool iPAQ::setDisplayBrightness ( int bright ) | |||
669 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 674 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
670 | ::close ( fd ); | 675 | ::close ( fd ); |
671 | } | 676 | } |
672 | return res; | 677 | return res; |
673 | } | 678 | } |
674 | 679 | ||
675 | int iPAQ::displayBrightnessResolution ( ) const | 680 | int 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 | ||
681 | bool iPAQ::hasLightSensor ( ) const | 686 | bool iPAQ::hasLightSensor ( ) const |
682 | { | 687 | { |
683 | return true; | 688 | return true; |
684 | } | 689 | } |
685 | #include <errno.h> | 690 | |
686 | #include <string.h> | ||
687 | int iPAQ::readLightSensor ( ) | 691 | int 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 | ||
714 | int 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 | ||
719 | void Zaurus::init ( ) | 727 | void Zaurus::init ( ) |
720 | { | 728 | { |
721 | d-> m_modelstr = "Zaurus SL5000"; | 729 | d-> m_modelstr = "Zaurus SL5000"; |
722 | d-> m_model = Model_Zaurus_SL5000; | 730 | d-> m_model = Model_Zaurus_SL5000; |
723 | d-> m_vendorstr = "Sharp"; | 731 | d-> m_vendorstr = "Sharp"; |
724 | d-> m_vendor = Vendor_Sharp; | 732 | d-> m_vendor = Vendor_Sharp; |
725 | 733 | ||
diff --git a/libopie/odevice.h b/libopie/odevice.h index be2a9c7..e07b91c 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -122,24 +122,25 @@ public: | |||
122 | virtual bool setDisplayBrightness ( int brightness ); | 122 | virtual bool setDisplayBrightness ( int brightness ); |
123 | virtual int displayBrightnessResolution ( ) const; | 123 | virtual int displayBrightnessResolution ( ) const; |
124 | 124 | ||
125 | // input / output | 125 | // input / output |
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 | ||