summaryrefslogtreecommitdiff
authorschurig <schurig>2003-06-10 16:35:43 (UTC)
committer schurig <schurig>2003-06-10 16:35:43 (UTC)
commitd2f78d2aba17a491739d10bd73f6fce033849537 (patch) (unidiff)
tree0d8e5683afaa6da476001e00fc6db2ebc5c1a0df
parent8ffea5d37080bd173d55a458296c1fc461a54d13 (diff)
downloadopie-d2f78d2aba17a491739d10bd73f6fce033849537.zip
opie-d2f78d2aba17a491739d10bd73f6fce033849537.tar.gz
opie-d2f78d2aba17a491739d10bd73f6fce033849537.tar.bz2
renamed frequency access methods
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/settings/light-and-power/light.cpp4
-rw-r--r--libopie/odevice.cpp8
-rw-r--r--libopie/odevice.h5
3 files changed, 8 insertions, 9 deletions
diff --git a/core/settings/light-and-power/light.cpp b/core/settings/light-and-power/light.cpp
index 68c2929..eda0c1f 100644
--- a/core/settings/light-and-power/light.cpp
+++ b/core/settings/light-and-power/light.cpp
@@ -49,49 +49,49 @@
49#include "sensor.h" 49#include "sensor.h"
50 50
51using namespace Opie; 51using namespace Opie;
52 52
53LightSettings::LightSettings( QWidget* parent, const char* name, WFlags ) 53LightSettings::LightSettings( QWidget* parent, const char* name, WFlags )
54 : LightSettingsBase( parent, name, false, WStyle_ContextHelp ) 54 : LightSettingsBase( parent, name, false, WStyle_ContextHelp )
55{ 55{
56 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( ); 56 m_bres = ODevice::inst ( )-> displayBrightnessResolution ( );
57 m_cres = ODevice::inst ( )-> displayContrastResolution ( ); 57 m_cres = ODevice::inst ( )-> displayContrastResolution ( );
58 58
59 if ( !ODevice::inst ( )-> hasLightSensor ( )) { 59 if ( !ODevice::inst ( )-> hasLightSensor ( )) {
60 auto_brightness-> hide ( ); 60 auto_brightness-> hide ( );
61 CalibrateLightSensor-> hide ( ); 61 CalibrateLightSensor-> hide ( );
62 auto_brightness_ac-> hide ( ); 62 auto_brightness_ac-> hide ( );
63 CalibrateLightSensor_ac-> hide ( ); 63 CalibrateLightSensor_ac-> hide ( );
64 } 64 }
65 if (m_cres) { 65 if (m_cres) {
66 GroupLight->setTitle(tr("Backlight && Contrast")); 66 GroupLight->setTitle(tr("Backlight && Contrast"));
67 GroupLight_ac->setTitle(GroupLight->title()); 67 GroupLight_ac->setTitle(GroupLight->title());
68 } else { 68 } else {
69 contrast->hide(); 69 contrast->hide();
70 contrast_ac->hide(); 70 contrast_ac->hide();
71 } 71 }
72 72
73 QStrList freq = ODevice::inst()->cpuFrequencies(); 73 QStrList freq = ODevice::inst()->allowedCpuFrequencies();
74 if ( freq.count() ) { 74 if ( freq.count() ) {
75 frequency->insertStrList( freq ); 75 frequency->insertStrList( freq );
76 frequency_ac->insertStrList( freq ); 76 frequency_ac->insertStrList( freq );
77 } else { 77 } else {
78 frequency->hide(); 78 frequency->hide();
79 frequency_ac->hide(); 79 frequency_ac->hide();
80 } 80 }
81 81
82 Config config ( "apm" ); 82 Config config ( "apm" );
83 config. setGroup ( "Battery" ); 83 config. setGroup ( "Battery" );
84 84
85 // battery spinboxes 85 // battery spinboxes
86 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 )); 86 interval_dim-> setValue ( config. readNumEntry ( "Dim", 30 ));
87 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 )); 87 interval_lightoff-> setValue ( config. readNumEntry ( "LightOff", 20 ));
88 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 )); 88 interval_suspend-> setValue ( config. readNumEntry ( "Suspend", 60 ));
89 89
90 // battery check and slider 90 // battery check and slider
91 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false )); 91 LcdOffOnly->setChecked ( config. readBoolEntry ( "LcdOffOnly", false ));
92 92
93 // CPU frequency 93 // CPU frequency
94 frequency->setCurrentItem( config.readNumEntry("Freq", 0) ); 94 frequency->setCurrentItem( config.readNumEntry("Freq", 0) );
95 95
96 int bright = config. readNumEntry ( "Brightness", 127 ); 96 int bright = config. readNumEntry ( "Brightness", 127 );
97 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 ); 97 int contr = m_oldcontrast = config. readNumEntry ( "Contrast", 127 );
@@ -189,49 +189,49 @@ void LightSettings::calibrateSensorAC ( )
189 delete s; 189 delete s;
190} 190}
191 191
192void LightSettings::setBacklight ( int bright ) 192void LightSettings::setBacklight ( int bright )
193{ 193{
194 QCopEnvelope e ( "QPE/System", "setBacklight(int)" ); 194 QCopEnvelope e ( "QPE/System", "setBacklight(int)" );
195 e << bright; 195 e << bright;
196 196
197 if ( bright != -1 ) { 197 if ( bright != -1 ) {
198 m_resettimer-> stop ( ); 198 m_resettimer-> stop ( );
199 m_resettimer-> start ( 4000, true ); 199 m_resettimer-> start ( 4000, true );
200 } 200 }
201} 201}
202 202
203void LightSettings::setContrast ( int contr ) 203void LightSettings::setContrast ( int contr )
204{ 204{
205 if (contr == -1) contr = m_oldcontrast; 205 if (contr == -1) contr = m_oldcontrast;
206 206
207 ODevice::inst ( )-> setDisplayContrast(contr); 207 ODevice::inst ( )-> setDisplayContrast(contr);
208} 208}
209 209
210void LightSettings::setFrequency ( int index ) 210void LightSettings::setFrequency ( int index )
211{ 211{
212qWarning("LightSettings::setFrequency(%d)", index); 212qWarning("LightSettings::setFrequency(%d)", index);
213 ODevice::inst ( )-> setCpuFrequency(index); 213 ODevice::inst ( )-> setCurrentCpuFrequency(index);
214} 214}
215 215
216void LightSettings::resetBacklight ( ) 216void LightSettings::resetBacklight ( )
217{ 217{
218 setBacklight ( -1 ); 218 setBacklight ( -1 );
219 setContrast ( -1 ); 219 setContrast ( -1 );
220} 220}
221 221
222void LightSettings::accept ( ) 222void LightSettings::accept ( )
223{ 223{
224 Config config ( "apm" ); 224 Config config ( "apm" );
225 225
226 // bat 226 // bat
227 config. setGroup ( "Battery" ); 227 config. setGroup ( "Battery" );
228 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( )); 228 config. writeEntry ( "LcdOffOnly", LcdOffOnly-> isChecked ( ));
229 config. writeEntry ( "Dim", interval_dim-> value ( )); 229 config. writeEntry ( "Dim", interval_dim-> value ( ));
230 config. writeEntry ( "LightOff", interval_lightoff-> value ( )); 230 config. writeEntry ( "LightOff", interval_lightoff-> value ( ));
231 config. writeEntry ( "Suspend", interval_suspend-> value ( )); 231 config. writeEntry ( "Suspend", interval_suspend-> value ( ));
232 config. writeEntry ( "Brightness", brightness-> value () ); 232 config. writeEntry ( "Brightness", brightness-> value () );
233 if (m_cres) 233 if (m_cres)
234 config. writeEntry ( "Contrast", contrast-> value () ); 234 config. writeEntry ( "Contrast", contrast-> value () );
235 config. writeEntry ( "Freq", frequency->currentItem() ); 235 config. writeEntry ( "Freq", frequency->currentItem() );
236 236
237 // ac 237 // ac
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 4c33a0e..d6e6892 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -754,62 +754,62 @@ bool ODevice::setLedState ( OLed which, OLedState st )
754 * @return if the device has a light sensor 754 * @return if the device has a light sensor
755 */ 755 */
756bool ODevice::hasLightSensor ( ) const 756bool ODevice::hasLightSensor ( ) const
757{ 757{
758 return false; 758 return false;
759} 759}
760 760
761/** 761/**
762 * @return a value from the light senso 762 * @return a value from the light senso
763 */ 763 */
764int ODevice::readLightSensor ( ) 764int ODevice::readLightSensor ( )
765{ 765{
766 return -1; 766 return -1;
767} 767}
768 768
769/** 769/**
770 * @return the light sensor resolution whatever that is ;) 770 * @return the light sensor resolution whatever that is ;)
771 */ 771 */
772int ODevice::lightSensorResolution ( ) const 772int ODevice::lightSensorResolution ( ) const
773{ 773{
774 return 0; 774 return 0;
775} 775}
776 776
777/** 777/**
778 * @return a list with valid CPU frequency 778 * @return a list with CPU frequencies supported by the hardware
779 */ 779 */
780QStrList &ODevice::cpuFrequencies ( ) const 780const QStrList &ODevice::allowedCpuFrequencies ( ) const
781{ 781{
782 return *d->m_cpu_frequencies; 782 return *d->m_cpu_frequencies;
783} 783}
784 784
785 785
786/** 786/**
787 * Set desired cpu frequency 787 * Set desired CPU frequency
788 * 788 *
789 * @param index index into d->m_cpu_frequencies of the frequency to be set 789 * @param index index into d->m_cpu_frequencies of the frequency to be set
790 */ 790 */
791bool ODevice::setCpuFrequency(uint index) 791bool ODevice::setCurrentCpuFrequency(uint index)
792{ 792{
793 if (index >= d->m_cpu_frequencies->count()) 793 if (index >= d->m_cpu_frequencies->count())
794 return false; 794 return false;
795 795
796 char *freq = d->m_cpu_frequencies->at(index); 796 char *freq = d->m_cpu_frequencies->at(index);
797 qWarning("set freq to %s", freq); 797 qWarning("set freq to %s", freq);
798 798
799 int fd; 799 int fd;
800 800
801 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 801 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
802 char writeCommand[50]; 802 char writeCommand[50];
803 const int count = sprintf(writeCommand, "%s\n", freq); 803 const int count = sprintf(writeCommand, "%s\n", freq);
804 int res = (::write(fd, writeCommand, count) != -1); 804 int res = (::write(fd, writeCommand, count) != -1);
805 ::close(fd); 805 ::close(fd);
806 return res; 806 return res;
807 } 807 }
808 808
809 return false; 809 return false;
810} 810}
811 811
812 812
813/** 813/**
814 * @return a list of hardware buttons 814 * @return a list of hardware buttons
815 */ 815 */
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 18ff5f1..f2f6467 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -177,51 +177,50 @@ public:
177 virtual bool setSoftSuspend ( bool on ); 177 virtual bool setSoftSuspend ( bool on );
178 virtual bool suspend ( ); 178 virtual bool suspend ( );
179 179
180 virtual bool setDisplayStatus ( bool on ); 180 virtual bool setDisplayStatus ( bool on );
181 virtual bool setDisplayBrightness ( int brightness ); 181 virtual bool setDisplayBrightness ( int brightness );
182 virtual int displayBrightnessResolution ( ) const; 182 virtual int displayBrightnessResolution ( ) const;
183 virtual bool setDisplayContrast ( int contrast ); 183 virtual bool setDisplayContrast ( int contrast );
184 virtual int displayContrastResolution ( ) const; 184 virtual int displayContrastResolution ( ) const;
185 185
186// input / output 186// input / output
187 //FIXME playAlarmSound and al might be better -zecke 187 //FIXME playAlarmSound and al might be better -zecke
188 virtual void alarmSound ( ); 188 virtual void alarmSound ( );
189 virtual void keySound ( ); 189 virtual void keySound ( );
190 virtual void touchSound ( ); 190 virtual void touchSound ( );
191 191
192 virtual QValueList <OLed> ledList ( ) const; 192 virtual QValueList <OLed> ledList ( ) const;
193 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 193 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
194 virtual OLedState ledState ( OLed led ) const; 194 virtual OLedState ledState ( OLed led ) const;
195 virtual bool setLedState ( OLed led, OLedState st ); 195 virtual bool setLedState ( OLed led, OLedState st );
196 196
197 virtual bool hasLightSensor ( ) const; 197 virtual bool hasLightSensor ( ) const;
198 virtual int readLightSensor ( ); 198 virtual int readLightSensor ( );
199 virtual int lightSensorResolution ( ) const; 199 virtual int lightSensorResolution ( ) const;
200 200
201 QStrList &cpuFrequencies() const; 201 const QStrList &allowedCpuFrequencies() const;
202 bool setCpuFrequency(uint index); 202 bool setCurrentCpuFrequency(uint index);
203 int cpuFrequency() const;
204 203
205 /** 204 /**
206 * Returns the available buttons on this device. The number and location 205 * Returns the available buttons on this device. The number and location
207 * of buttons will vary depending on the device. Button numbers will be assigned 206 * of buttons will vary depending on the device. Button numbers will be assigned
208 * by the device manufacturer and will be from most preferred button to least preffered 207 * by the device manufacturer and will be from most preferred button to least preffered
209 * button. Note that this list only contains "user mappable" buttons. 208 * button. Note that this list only contains "user mappable" buttons.
210 */ 209 */
211 const QValueList<ODeviceButton> &buttons ( ); 210 const QValueList<ODeviceButton> &buttons ( );
212 211
213 /** 212 /**
214 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 213 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
215 * returns 0L 214 * returns 0L
216 */ 215 */
217 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 216 const ODeviceButton *buttonForKeycode ( ushort keyCode );
218 217
219 /** 218 /**
220 * Reassigns the pressed action for \a button. To return to the factory 219 * Reassigns the pressed action for \a button. To return to the factory
221 * default pass an empty string as \a qcopMessage. 220 * default pass an empty string as \a qcopMessage.
222 */ 221 */
223 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 222 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
224 223
225 /** 224 /**
226 * Reassigns the held action for \a button. To return to the factory 225 * Reassigns the held action for \a button. To return to the factory
227 * default pass an empty string as \a qcopMessage. 226 * default pass an empty string as \a qcopMessage.