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

sensor.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the OPIE Project
00003                =.            Copyright (c)  2002 Maximilian Reiss <harlekin@handhelds.org>
00004              .=l.            Copyright (c)  2002 Robert Griebl <sandman@handhelds.org>
00005            .>+-=
00006  _;:,     .>    :=|.         This file is free software; you can
00007 .> <`_,   >  .   <=          redistribute it and/or modify it under
00008 :`=1 )Y*s>-.--   :           the terms of the GNU General Public
00009 .="- .-=="i,     .._         License as published by the Free Software
00010  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00011      ._= =}       :          or (at your option) any later version.
00012     .%`+i>       _;_.
00013     .i_,=:_.      -<s.       This file is distributed in the hope that
00014      +  .  -:.       =       it will be useful, but WITHOUT ANY WARRANTY;
00015     : ..    .:,     . . .    without even the implied warranty of
00016     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00017   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU General
00018 ..}^=.=       =       ;      Public License for more details.
00019 ++=   -.     .`     .:
00020  :     =  ...= . :.=-        You should have received a copy of the GNU
00021  -.   .:....=;==+<;          General Public License along with this file;
00022   -_. . .   )=.  =           see the file COPYING. If not, write to the
00023     --        :-=`           Free Software Foundation, Inc.,
00024                              59 Temple Place - Suite 330,
00025                              Boston, MA 02111-1307, USA.
00026 
00027 */
00028 
00029 #include "calibration.h"
00030 #include "sensor.h"
00031 
00032 #include <opie2/odevice.h>
00033 
00034 #include <qlayout.h>
00035 #include <qslider.h>
00036 #include <qspinbox.h>
00037 
00038 using namespace Opie::Core;
00039 
00040 Sensor::Sensor ( QStringList &params, QWidget *parent, const char *name )
00041         : SensorBase ( parent, name, true, WStyle_ContextHelp ), m_params ( params )
00042 {
00043         int steps = 12;
00044         int inter = 2;
00045 
00046         int smin = 40;
00047         int smax = 215;
00048         int lmin = 1;
00049         int lmax = 255;
00050 
00051         switch ( params. count ( )) {
00052                 case 6: lmax = params [5]. toInt ( );
00053                 case 5: lmin = params [4]. toInt ( );
00054                 case 4: smax = params [3]. toInt ( );
00055                 case 3: smin = params [2]. toInt ( );
00056                 case 2: steps = params [1]. toInt ( );
00057                 case 1: inter = params [0]. toInt ( ) / 1000;
00058         }
00059 
00060         int xscale = ODevice::inst ( )-> lightSensorResolution ( );
00061         int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
00062 
00063         QVBoxLayout *lay = new QVBoxLayout ( frame );
00064         lay-> setMargin ( 2 );
00065         m_calib = new Calibration ( frame );
00066         lay-> add ( m_calib );
00067 
00068         m_calib-> setScale ( QSize ( xscale, yscale ));
00069         m_calib-> setLineSteps ( steps );
00070         m_calib-> setInterval ( inter );
00071         m_calib-> setStartPoint ( QPoint ( smin * xscale / 256, lmax * yscale / 256 ));
00072         m_calib-> setEndPoint ( QPoint ( smax * xscale / 256, lmin * yscale / 256 ));
00073 
00074         interval-> setValue ( inter );
00075         linesteps-> setValue ( steps );
00076 
00077         connect ( interval, SIGNAL( valueChanged(int)), m_calib, SLOT( setInterval(int)));
00078         connect ( linesteps, SIGNAL( valueChanged(int)), m_calib, SLOT( setLineSteps(int)));
00079 
00080         connect ( m_calib, SIGNAL( startPointChanged(const QPoint&)), this, SLOT( pointDrag(const QPoint&)));
00081         connect ( m_calib, SIGNAL( endPointChanged(const QPoint&)), this, SLOT( pointDrag(const QPoint&)));
00082 }
00083 
00084 void Sensor::accept ( )
00085 {
00086         int xscale = ODevice::inst ( )-> lightSensorResolution ( );
00087         int yscale = ODevice::inst ( )-> displayBrightnessResolution ( );
00088 
00089         m_params. clear ( );
00090         m_params << QString::number ( m_calib-> interval ( ) * 1000 )
00091                  << QString::number ( m_calib-> lineSteps ( ))
00092                  << QString::number ( m_calib-> startPoint ( ). x ( ) * 256 / xscale )
00093                  << QString::number ( m_calib-> endPoint ( ). x ( ) * 256 / xscale )
00094                  << QString::number ( m_calib-> endPoint ( ). y ( ) * 256 / yscale )
00095                  << QString::number ( m_calib-> startPoint ( ). y ( ) * 256 / yscale );
00096 
00097         QDialog::accept ( );
00098 }
00099 
00100 void Sensor::pointDrag ( const QPoint &p )
00101 {
00102         emit viewBacklight ( p. y ( ));
00103 }

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