Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

odevice_jornada.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003 
00004                              Copyright (C)2002-2005 The Opie Team <opie-devel@handhelds.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022 :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 */
00030 
00031 #include "odevice_jornada.h"
00032 
00033 /* QT */
00034 #include <qapplication.h>
00035 #include <qfile.h>
00036 #include <qtextstream.h>
00037 #include <qwindowsystem_qws.h>
00038 
00039 /* OPIE */
00040 #include <qpe/config.h>
00041 #include <qpe/sound.h>
00042 #include <qpe/qcopenvelope_qws.h>
00043 
00044 #include <opie2/oresource.h>
00045 
00046 /* STD */
00047 #include <fcntl.h>
00048 #include <math.h>
00049 #include <stdlib.h>
00050 #include <signal.h>
00051 #include <sys/ioctl.h>
00052 #include <sys/time.h>
00053 #include <unistd.h>
00054 #ifndef QT_NO_SOUND
00055 #include <linux/soundcard.h>
00056 #endif
00057 
00058 /* KERNEL */
00059 #define OD_IOC(dir,type,number,size)    (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
00060 
00061 #define OD_IO(type,number)              OD_IOC(0,type,number,0)
00062 #define OD_IOW(type,number,size)        OD_IOC(1,type,number,sizeof(size))
00063 #define OD_IOR(type,number,size)        OD_IOC(2,type,number,sizeof(size))
00064 #define OD_IORW(type,number,size)       OD_IOC(3,type,number,sizeof(size))
00065 
00066 typedef struct {
00067   unsigned char OffOnBlink;       /* 0=off 1=on 2=Blink */
00068   unsigned char TotalTime;        /* Units of 5 seconds */
00069   unsigned char OnTime;           /* units of 100m/s */
00070   unsigned char OffTime;          /* units of 100m/s */
00071 } LED_IN;
00072 
00073 typedef struct {
00074         unsigned char mode;
00075         unsigned char pwr;
00076         unsigned char brightness;
00077 } FLITE_IN;
00078 
00079 #define LED_ON    OD_IOW( 'f', 5, LED_IN )
00080 #define FLITE_ON  OD_IOW( 'f', 7, FLITE_IN )
00081 
00082 using namespace Opie::Core;
00083 using namespace Opie::Core::Internal;
00084 
00085 struct j_button jornada56x_buttons [] = {
00086     { Model_Jornada_56x,
00087     Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
00088     "devicebuttons/jornada56x_calendar",
00089     "datebook", "nextView()",
00090     "today", "raise()" },
00091     { Model_Jornada_56x,
00092     Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
00093     "devicebuttons/jornada56x_contact",
00094     "addressbook", "raise()",
00095     "addressbook", "beamBusinessCard()" },
00096     { Model_Jornada_56x,
00097     Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Todo Button"),
00098     "devicebuttons/jornada56x_todo",
00099     "todolist", "raise()",
00100     "todolist", "create()" },
00101     { Model_Jornada_56x,
00102     Qt::Key_F8, QT_TRANSLATE_NOOP("Button", "Home Button"),
00103     "devicebuttons/jornada56x_home",
00104     "QPE/Launcher", "home()",
00105     "buttonsettings", "raise()" },
00106     { Model_Jornada_56x,
00107     Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Record Button"),
00108     "devicebuttons/jornada56x_record",
00109     "QPE/VMemo", "toggleRecord()",
00110     "sound", "raise()" },
00111 };
00112 
00113 void Jornada::init(const QString& cpu_info)
00114 {
00115     d->m_vendorstr = "HP";
00116     d->m_vendor = Vendor_HP;
00117 
00118     QString model;
00119     int loc = cpu_info.find( ":" );
00120     if ( loc != -1 )
00121         model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
00122     else
00123         model = cpu_info;
00124 
00125     if ( model == "HP Jornada 56x" ) {
00126         d->m_modelstr = "Jornada 56x";
00127         d->m_model = Model_Jornada_56x;
00128     } else if ( model == "HP Jornada 720" ) {
00129         d->m_modelstr = "Jornada 720";
00130         d->m_model = Model_Jornada_720;
00131     }
00132 
00133     d->m_rotation = Rot0; //all Jornadas need this rotation
00134     //Distribution detecting code is now in base class
00135 }
00136 
00137 void Jornada::initButtons()
00138 {
00139     if ( d->m_buttons )
00140         return;
00141 
00142     d->m_buttons = new QValueList <ODeviceButton>;
00143 
00144     for ( uint i = 0; i < ( sizeof( jornada56x_buttons ) / sizeof( j_button )); i++ ) {
00145         j_button *ib = jornada56x_buttons + i;
00146         ODeviceButton b;
00147 
00148         if (( ib->model & d->m_model ) == d->m_model ) {
00149             b. setKeycode ( ib->code );
00150             b. setUserText ( QObject::tr ( "Button", ib->utext ));
00151             b. setPixmap ( OResource::loadPixmap ( ib->pix ));
00152             b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
00153             b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
00154 
00155             d->m_buttons->append ( b );
00156         }
00157     }
00158     reloadButtonMapping();
00159 }
00160 
00161 int Jornada::displayBrightnessResolution() const
00162 {
00163     if ( d->m_model == Model_Jornada_56x )
00164         return 190;
00165     else if (d->m_model == Model_Jornada_720 )
00166         return 255;
00167     else
00168         return 0;
00169 }
00170 
00171 
00172 bool Jornada::setDisplayBrightness( int bright )
00173 {
00174     bool res = false;
00175 
00176     if ( bright > 255 )
00177         bright = 255;
00178     if ( bright < 0 )
00179         bright = 0;
00180 
00181     QString cmdline;
00182 
00183     if ( d->m_model == Model_Jornada_56x ) {
00184         if ( !bright )
00185             cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/sa1100fb/power");
00186         else
00187             cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/sa1100fb/power; echo %1 > /sys/class/backlight/sa1100fb/brightness" ).arg( bright );
00188     } else if ( d->m_model == Model_Jornada_720 ) {
00189         cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/e1356fb/brightness" ).arg( bright );
00190     }
00191 
00192     // No Global::shellQuote as we gurantee it to be sane
00193     res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
00194 
00195     return res;
00196 }
00197 
00198 
00199 bool Jornada::setDisplayStatus ( bool on )
00200 {
00201     bool res = false;
00202 
00203     QString cmdline;
00204 
00205     if ( d->m_model == Model_Jornada_56x ) {
00206         cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/sa1100fb/power; echo %2 > /sys/class/backlight/sa1100fb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
00207     } else if ( d->m_model == Model_Jornada_720 ) {
00208         cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/e1356fb/power").arg( on ? "0" : "4" );
00209     }
00210 
00211     res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
00212 
00213     return res;
00214 }
00215 

Generated on Sat Nov 5 16:16:05 2005 for OPIE by  doxygen 1.4.2