author | mickeyl <mickeyl> | 2003-04-13 22:27:57 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-04-13 22:27:57 (UTC) |
commit | f47258125bac368987a90ca49a118721ecbc3a8b (patch) (side-by-side diff) | |
tree | 04d137fce8890a311d0cc1c3ab2853acc64ccb45 /noncore/multimedia/camera/zcameraio.cpp | |
parent | 053c38bb48ae8e7563293bc029f3c9d029b947f7 (diff) | |
download | opie-f47258125bac368987a90ca49a118721ecbc3a8b.zip opie-f47258125bac368987a90ca49a118721ecbc3a8b.tar.gz opie-f47258125bac368987a90ca49a118721ecbc3a8b.tar.bz2 |
make opiecam work!
Diffstat (limited to 'noncore/multimedia/camera/zcameraio.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/camera/zcameraio.cpp | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp index b37ae8c..9af0c25 100644 --- a/noncore/multimedia/camera/zcameraio.cpp +++ b/noncore/multimedia/camera/zcameraio.cpp @@ -60,6 +60,7 @@ void ZCameraIO::init() ofatal << "Don't create more than one ZCameraIO instances." << oendl; else { + _timer = new QTime(); setReadMode( STATUS ); } } @@ -83,8 +84,18 @@ bool ZCameraIO::isOpen() const bool ZCameraIO::isShutterPressed() { - return _status[0] == 'S'; - clearShutterLatch(); + if ( _timer->elapsed() < 1000 ) //TODO: make this customizable? + { + clearShutterLatch(); + return false; + } + if ( _status[0] == 'S' ) + { + _timer->restart(); + clearShutterLatch(); + return true; + } + else return false; } @@ -124,20 +135,28 @@ bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot ) } +bool ZCameraIO::setZoom( int zoom ) +{ + return setCaptureFrame( _width, _height, zoom*256, _rot ); +} + + void ZCameraIO::setReadMode( int mode ) { char b[10]; sprintf( b, "M=%d", mode ); write( b, mode <= 9 ? 3 : 4 ); - if ( mode & 1 ) // STATUS bit is set + if ( mode & STATUS ) // STATUS bit is set + { read( _status, 4 ); + if ( isShutterPressed() ) emit shutterClicked(); + } } void ZCameraIO::clearShutterLatch() { - char b = 'B'; - write( &b, 1 ); + write( "B", 1 ); } @@ -212,6 +231,7 @@ bool ZCameraIO::snapshot( QImage* image ) return true; } + bool ZCameraIO::snapshot( unsigned char* buf ) { setReadMode( IMAGE | XFLIP | YFLIP ); @@ -228,3 +248,17 @@ bool ZCameraIO::snapshot( unsigned char* buf ) return true; } + +void ZCameraIO::captureFrame( int w, int h, int zoom, QImage* image ) +{ + int pw = _width; + int ph = _height; + if ( _rot ) + setCaptureFrame( h, w, zoom*256, true ); + else + setCaptureFrame( w, h, zoom*256, false ); + snapshot( image ); + setCaptureFrame( pw, ph, _zoom, _rot ); +} + + |