summaryrefslogtreecommitdiff
path: root/noncore/multimedia/camera/zcameraio.cpp
Side-by-side diff
Diffstat (limited to 'noncore/multimedia/camera/zcameraio.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/camera/zcameraio.cpp42
1 files changed, 38 insertions, 4 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
@@ -62,2 +62,3 @@ void ZCameraIO::init()
{
+ _timer = new QTime();
setReadMode( STATUS );
@@ -85,4 +86,14 @@ bool ZCameraIO::isShutterPressed()
{
- return _status[0] == 'S';
+ if ( _timer->elapsed() < 1000 ) //TODO: make this customizable?
+ {
+ clearShutterLatch();
+ return false;
+ }
+ if ( _status[0] == 'S' )
+ {
+ _timer->restart();
clearShutterLatch();
+ return true;
+ }
+ else return false;
}
@@ -126,2 +137,8 @@ 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 )
@@ -131,4 +148,7 @@ void ZCameraIO::setReadMode( int 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();
+ }
}
@@ -138,4 +158,3 @@ void ZCameraIO::clearShutterLatch()
{
- char b = 'B';
- write( &b, 1 );
+ write( "B", 1 );
}
@@ -214,2 +233,3 @@ bool ZCameraIO::snapshot( QImage* image )
+
bool ZCameraIO::snapshot( unsigned char* buf )
@@ -230 +250,15 @@ bool ZCameraIO::snapshot( unsigned char* buf )
+
+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 );
+}
+
+