author | schurig <schurig> | 2003-06-06 07:43:08 (UTC) |
---|---|---|
committer | schurig <schurig> | 2003-06-06 07:43:08 (UTC) |
commit | e7d5436f3379f45d9c165a2826b1f4ae5adaeea4 (patch) (side-by-side diff) | |
tree | c05f10f573167fd2a0289715a6e7272cfa45fad4 | |
parent | 4f987e0199430d04a4ac86007f0a79c631c2e611 (diff) | |
download | opie-e7d5436f3379f45d9c165a2826b1f4ae5adaeea4.zip opie-e7d5436f3379f45d9c165a2826b1f4ae5adaeea4.tar.gz opie-e7d5436f3379f45d9c165a2826b1f4ae5adaeea4.tar.bz2 |
ramses stuff
better doc-strings setDisplayBrightness(), setDisplayContrast() and their
...Resolution() friends
-rw-r--r-- | libopie/odevice.cpp | 12 | ||||
-rw-r--r-- | libopie/odevice.h | 1 |
2 files changed, 8 insertions, 5 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 160568b..f808960 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -367,402 +367,406 @@ struct r_button { static QCString makeChannel ( const char *str ) { if ( str && !::strchr ( str, '/' )) return QCString ( "QPE/Application/" ) + str; else return str; } static inline bool isQWS() { return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; } ODevice *ODevice::inst ( ) { static ODevice *dev = 0; if ( !dev ) { if ( QFile::exists ( "/proc/hal/model" )) dev = new iPAQ ( ); else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) dev = new Zaurus ( ); else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) dev = new SIMpad ( ); else if ( QFile::exists ( "/proc/sys/board/name" )) dev = new Ramses ( ); else dev = new ODevice ( ); dev-> init ( ); } return dev; } /************************************************** * * common * **************************************************/ ODevice::ODevice ( ) { d = new ODeviceData; d-> m_modelstr = "Unknown"; d-> m_model = Model_Unknown; d-> m_vendorstr = "Unknown"; d-> m_vendor = Vendor_Unknown; d-> m_systemstr = "Unknown"; d-> m_system = System_Unknown; d-> m_sysverstr = "0.0"; d-> m_rotation = Rot0; d-> m_direction = CW; d-> m_holdtime = 1000; // 1000ms d-> m_buttons = 0; } void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) { if ( msg == "deviceButtonMappingChanged()" ) { reloadButtonMapping ( ); } } void ODevice::init ( ) { } /** * This method initialises the button mapping */ void ODevice::initButtons ( ) { if ( d-> m_buttons ) return; // Simulation uses iPAQ 3660 device buttons qDebug ( "init Buttons" ); d-> m_buttons = new QValueList <ODeviceButton>; for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { i_button *ib = ipaq_buttons + i; ODeviceButton b; if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { b. setKeycode ( ib-> code ); b. setUserText ( QObject::tr ( "Button", ib-> utext )); b. setPixmap ( Resource::loadPixmap ( ib-> pix )); b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); d-> m_buttons-> append ( b ); } } reloadButtonMapping ( ); QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); } ODevice::~ODevice ( ) { delete d; } bool ODevice::setSoftSuspend ( bool /*soft*/ ) { return false; } //#include <linux/apm_bios.h> #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) /** * This method will try to suspend the device * It only works if the user is the QWS Server and the apm application * is installed. * It tries to suspend and then waits some time cause some distributions * do have asynchronus apm implementations. * This method will either fail and return false or it'll suspend the * device and return once the device got woken up * * @return if the device got suspended */ bool ODevice::suspend ( ) { qDebug("ODevice::suspend"); if ( !isQWS( ) ) // only qwsserver is allowed to suspend return false; if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices return false; bool res = false; struct timeval tvs, tvn; ::gettimeofday ( &tvs, 0 ); ::sync ( ); // flush fs caches res = ( ::system ( "apm --suspend" ) == 0 ); // This is needed because the iPAQ apm implementation is asynchronous and we // can not be sure when exactly the device is really suspended // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. if ( res ) { do { // wait at most 1.5 sec: either suspend didn't work or the device resumed ::usleep ( 200 * 1000 ); ::gettimeofday ( &tvn, 0 ); } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); } return res; } //#include <linux/fb.h> better not rely on kernel headers in userspace ... #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 /* VESA Blanking Levels */ #define VESA_NO_BLANKING 0 #define VESA_VSYNC_SUSPEND 1 #define VESA_HSYNC_SUSPEND 2 #define VESA_POWERDOWN 3 /** * This sets the display on or off */ bool ODevice::setDisplayStatus ( bool on ) { qDebug("ODevice::setDisplayStatus(%d)", on); if ( d-> m_model == Model_Unknown ) return false; bool res = false; int fd; if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); ::close ( fd ); } return res; } /** * This sets the display brightness + * + * @param p The brightness to be set on a scale from 0 to 255 * @return success or failure */ bool ODevice::setDisplayBrightness ( int p) { Q_UNUSED( p ) return false; } /** - * @return return the max value for the brightness settings slider + * @return returns the number of steppings on the brightness slider + * in the Light-'n-Power settings. */ int ODevice::displayBrightnessResolution ( ) const { return 16; } /** * This sets the display contrast + * @param p The contrast to be set on a scale from 0 to 255 * @return success or failure */ bool ODevice::setDisplayContrast ( int p) { Q_UNUSED( p ) return false; } /** * @return return the max value for the brightness settings slider * or 0 if the device doesn't support setting of a contrast */ int ODevice::displayContrastResolution ( ) const { return 0; } /** * This returns the vendor as string * @return Vendor as QString */ QString ODevice::vendorString ( ) const { return d-> m_vendorstr; } /** * This returns the vendor as one of the values of OVendor * @return OVendor */ OVendor ODevice::vendor ( ) const { return d-> m_vendor; } /** * This returns the model as a string * @return A string representing the model */ QString ODevice::modelString ( ) const { return d-> m_modelstr; } /** * This does return the OModel used */ OModel ODevice::model ( ) const { return d-> m_model; } /** * This does return the systen name */ QString ODevice::systemString ( ) const { return d-> m_systemstr; } /** * Return System as OSystem value */ OSystem ODevice::system ( ) const { return d-> m_system; } /** * @return the version string of the base system */ QString ODevice::systemVersionString ( ) const { return d-> m_sysverstr; } /** * @return the current Transformation */ Transformation ODevice::rotation ( ) const { return d-> m_rotation; } /** * @return the current rotation direction */ ODirection ODevice::direction ( ) const { return d-> m_direction; } /** * This plays an alarmSound */ void ODevice::alarmSound ( ) { #ifndef QT_NO_SOUND static Sound snd ( "alarm" ); if ( snd. isFinished ( )) snd. play ( ); #endif } /** * This plays a key sound */ void ODevice::keySound ( ) { #ifndef QT_NO_SOUND static Sound snd ( "keysound" ); if ( snd. isFinished ( )) snd. play ( ); #endif } /** * This plays a touch sound */ void ODevice::touchSound ( ) { #ifndef QT_NO_SOUND static Sound snd ( "touchsound" ); if ( snd. isFinished ( )) snd. play ( ); #endif } /** * This method will return a list of leds * available on this device * @return a list of LEDs. */ QValueList <OLed> ODevice::ledList ( ) const { return QValueList <OLed> ( ); } /** * This does return the state of the LEDs */ QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const { return QValueList <OLedState> ( ); } /** * @return the state for a given OLed */ OLedState ODevice::ledState ( OLed /*which*/ ) const { return Led_Off; } /** * Set the state for a LED * @param which Which OLed to use * @param st The state to set * @return success or failure */ bool ODevice::setLedState ( OLed which, OLedState st ) { Q_UNUSED( which ) Q_UNUSED( st ) return false; } /** * @return if the device has a light sensor */ bool ODevice::hasLightSensor ( ) const { return false; } /** * @return a value from the light senso */ int ODevice::readLightSensor ( ) { return -1; } /** * @return the light sensor resolution whatever that is ;) */ int ODevice::lightSensorResolution ( ) const { return 0; @@ -1881,218 +1885,218 @@ bool SIMpad::setDisplayBrightness ( int bright ) int fd; if ( bright > 255 ) bright = 255; if ( bright < 0 ) bright = 0; if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { int value = 255 - bright; const int mask = SIMPAD_BACKLIGHT_MASK; value = value << 8; value += mask; char writeCommand[100]; const int count = sprintf( writeCommand, "0x%x\n", value ); res = ( ::write ( fd, writeCommand, count ) != -1 ); ::close ( fd ); } return res; } int SIMpad::displayBrightnessResolution ( ) const { switch ( model ( )) { case Model_SIMpad_CL4: case Model_SIMpad_SL4: case Model_SIMpad_SLC: case Model_SIMpad_TSinus: return 255; //TODO find out if this is save default: return 2; } } /************************************************** * * Ramses * **************************************************/ void Ramses::init() { d->m_vendorstr = "M und N"; d->m_vendor = Vendor_MundN; QFile f("/proc/sys/board/ramses"); d->m_modelstr = "Ramses"; d->m_model = Model_Ramses_MNCI; d->m_rotation = Rot0; d->m_holdtime = 1000; f.setName("/etc/oz_version"); if (f.open(IO_ReadOnly)) { d->m_systemstr = "OpenEmbedded/Ramses"; d->m_system = System_OpenZaurus; QTextStream ts(&f); ts.setDevice(&f); d->m_sysverstr = ts.readLine(); f.close(); } m_power_timer = 0; } bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) { Q_UNUSED( keycode ); Q_UNUSED( modifiers ); Q_UNUSED( isPress ); Q_UNUSED( autoRepeat ); return false; } void Ramses::timerEvent(QTimerEvent *) { killTimer(m_power_timer); m_power_timer = 0; QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); } bool Ramses::setSoftSuspend(bool soft) { qDebug("Ramses::setSoftSuspend(%d)", soft); #if 0 bool res = false; int fd; if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources if (sources >= 0) { if (soft) sources &= ~APM_EVT_POWER_BUTTON; else sources |= APM_EVT_POWER_BUTTON; if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources res = true; else perror("APM_IOCGEVTSRC"); } else perror("APM_IOCGEVTSRC"); ::close(fd); } else perror("/dev/apm_bios or /dev/misc/apm_bios"); return res; #else return true; #endif } bool Ramses::suspend ( ) { qDebug("Ramses::suspend"); } /** * This sets the display on or off */ bool Ramses::setDisplayStatus(bool on) { qDebug("Ramses::setDisplayStatus(%d)", on); #if 0 bool res = false; int fd; if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); ::close(fd); } return res; #else return true; #endif } /* * We get something between 0..255 into us */ bool Ramses::setDisplayBrightness(int bright) { qDebug("Ramses::setDisplayBrightness(%d)", bright); bool res = false; int fd; // pwm1 brighness: 20 steps 500..0 (dunkel->hell) if (bright > 255 ) bright = 255; if (bright < 0) bright = 0; bright = 500-(bright * 500 / 255); if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { qDebug(" %d -> pwm1", bright); char writeCommand[100]; const int count = sprintf(writeCommand, "%d\n", bright); res = (::write(fd, writeCommand, count) != -1); ::close(fd); } else { qWarning("no write"); } return res; } int Ramses::displayBrightnessResolution() const { return 32; } bool Ramses::setDisplayContrast(int contr) { qDebug("Ramses::setDisplayContrast(%d)", contr); bool res = false; int fd; - // pwm0 contrast: 35 steps 65..100 (dunkel->hell) + // pwm0 contrast: 20 steps 79..90 (dunkel->hell) if (contr > 255 ) contr = 255; if (contr < 0) contr = 0; - contr = 65 + (contr * 350 / 255); + contr = 90 - (contr * 20 / 255); if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { qDebug(" %d -> pwm0", contr); char writeCommand[100]; const int count = sprintf(writeCommand, "%d\n", contr); res = (::write(fd, writeCommand, count) != -1); res = true; ::close(fd); } else { qWarning("no write"); } return res; } int Ramses::displayContrastResolution() const { - return 32; + return 20; } diff --git a/libopie/odevice.h b/libopie/odevice.h index 6c4830e..0974e8d 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h @@ -1,246 +1,245 @@ /* This file is part of the OPIE libraries Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef _LIBOPIE_ODEVICE_H_ #define _LIBOPIE_ODEVICE_H_ #include <qobject.h> #include <qstring.h> #include <qnamespace.h> #include <opie/odevicebutton.h> #include <qpe/qpeapplication.h> /* for Transformation enum.. */ class ODeviceData; namespace Opie { /** * The available devices */ enum OModel { Model_Unknown, // = 0 Model_Series_Mask = 0xff000000, Model_iPAQ = ( 1 << 24 ), Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), Model_Zaurus = ( 2 << 24 ), Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), Model_SIMpad = ( 3 << 24 ), Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), Model_Ramses = ( 4 << 24 ), Model_Ramses_All = ( Model_Ramses | 0xffffff ), Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), }; /** * The vendor of the device */ enum OVendor { Vendor_Unknown, Vendor_HP, Vendor_Sharp, Vendor_SIEMENS, Vendor_MundN, }; /** * The System used */ enum OSystem { System_Unknown, System_Familiar, System_Zaurus, System_OpenZaurus }; enum OLedState { Led_Off, Led_On, Led_BlinkSlow, Led_BlinkFast }; enum OLed { Led_Mail, Led_Power, Led_BlueTooth }; enum OHardKey { HardKey_Datebook = Qt::Key_F9, HardKey_Contacts = Qt::Key_F10, HardKey_Menu = Qt::Key_F11, HardKey_Home = Qt::Key_F12, HardKey_Mail = Qt::Key_F13, HardKey_Record = Qt::Key_F24, HardKey_Suspend = Qt::Key_F34, HardKey_Backlight = Qt::Key_F35, }; enum ODirection { CW = 0, CCW = 1, Flip = 2, }; /** * A singleton which gives informations about device specefic option * like the Hardware used, LEDs, the Base Distribution and * hardware key mappings. * - * * @short A small class for device specefic options * @see QObject * @author Robert Griebl * @version 1.0 */ class ODevice : public QObject { Q_OBJECT private: /* disable copy */ ODevice ( const ODevice & ); protected: ODevice ( ); virtual void init ( ); virtual void initButtons ( ); ODeviceData *d; public: // sandman do we want to allow destructions? -zecke? virtual ~ODevice ( ); static ODevice *inst ( ); // information QString modelString ( ) const; OModel model ( ) const; inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } QString vendorString ( ) const; OVendor vendor ( ) const; QString systemString ( ) const; OSystem system ( ) const; QString systemVersionString ( ) const; Transformation rotation ( ) const; ODirection direction ( ) const; // system virtual bool setSoftSuspend ( bool on ); virtual bool suspend ( ); virtual bool setDisplayStatus ( bool on ); virtual bool setDisplayBrightness ( int brightness ); virtual int displayBrightnessResolution ( ) const; virtual bool setDisplayContrast ( int contrast ); virtual int displayContrastResolution ( ) const; // input / output //FIXME playAlarmSound and al might be better -zecke virtual void alarmSound ( ); virtual void keySound ( ); virtual void touchSound ( ); virtual QValueList <OLed> ledList ( ) const; virtual QValueList <OLedState> ledStateList ( OLed led ) const; virtual OLedState ledState ( OLed led ) const; virtual bool setLedState ( OLed led, OLedState st ); virtual bool hasLightSensor ( ) const; virtual int readLightSensor ( ); virtual int lightSensorResolution ( ) const; /** * Returns the available buttons on this device. The number and location * of buttons will vary depending on the device. Button numbers will be assigned * by the device manufacturer and will be from most preferred button to least preffered * button. Note that this list only contains "user mappable" buttons. */ const QValueList<ODeviceButton> &buttons ( ); /** * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it * returns 0L */ const ODeviceButton *buttonForKeycode ( ushort keyCode ); /** * Reassigns the pressed action for \a button. To return to the factory * default pass an empty string as \a qcopMessage. */ void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); /** * Reassigns the held action for \a button. To return to the factory * default pass an empty string as \a qcopMessage. */ void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); /** * How long (in ms) you have to press a button for a "hold" action */ uint buttonHoldTime ( ) const; signals: void buttonMappingChanged ( ); private slots: void systemMessage ( const QCString &, const QByteArray & ); protected: void reloadButtonMapping ( ); }; } #endif |