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.cpp58
1 files changed, 34 insertions, 24 deletions
diff --git a/noncore/multimedia/camera/zcameraio.cpp b/noncore/multimedia/camera/zcameraio.cpp
index 7343dca..56b2e13 100644
--- a/noncore/multimedia/camera/zcameraio.cpp
+++ b/noncore/multimedia/camera/zcameraio.cpp
@@ -26,2 +26,3 @@
#include <qimage.h>
+#include <qdatetime.h>
@@ -29,2 +30,4 @@
+#define SHARPZDC "/dev/sharp_zdc"
+
ZCameraIO* ZCameraIO::_instance = 0;
@@ -45,3 +48,3 @@ ZCameraIO::ZCameraIO()
{
- _driver = ::open( "/dev/sharp_zdc", O_RDWR );
+ _driver = ::open( SHARPZDC, O_RDWR );
if ( _driver == -1 )
@@ -67,4 +70,7 @@ ZCameraIO::~ZCameraIO()
if ( _driver != -1 )
+ {
+ setReadMode( 0 );
::close( _driver );
}
+}
@@ -109,3 +115,3 @@ bool ZCameraIO::setCaptureFrame( int width, int height, int zoom, bool rot )
_width = width;
- _height = _height;
+ _height = height;
_zoom = zoom;
@@ -121,3 +127,3 @@ void ZCameraIO::setReadMode( int mode )
{
- char b[4];
+ char b[10];
sprintf( b, "M=%d", mode );
@@ -138,4 +144,16 @@ bool ZCameraIO::read( char* b, int len )
{
+ #ifndef NO_TIMING
+ QTime t;
+ t.start();
+ #endif
int rlen = ::read( _driver, b, len );
- odebug << "read " << rlen << " from driver." << oendl;
+ #ifndef NO_TIMING
+ int time = t.elapsed();
+ #else
+ int time = -1;
+ #endif
+ if ( rlen )
+ odebug << "read " << rlen << " ('" << b[0] << b[1] << b[2] << b[3] << "') [" << time << " ms] from driver." << oendl;
+ else
+ odebug << "read nothing from driver." << oendl;
return rlen == len;
@@ -157,23 +175,8 @@ bool ZCameraIO::snapshot( QImage* image )
{
- /*
-
+ setReadMode( IMAGE | XFLIP | YFLIP );
char buf[76800];
-
- write( _driver, "M=13", 4 );
- write( _driver, "R=240,160,256,480", 17 );
- write( _driver, "M=12", 4 );
-
- int result = read( _driver, &buf, sizeof buf );
-
- return result == sizeof buf;
-
- */
-
- unsigned char buf[76800];
- unsigned char* bp = buf;
+ char* bp = buf;
unsigned char* p;
- int fd = open( "/tmp/cam", O_RDONLY );
- if ( ::read( fd, buf, sizeof buf ) != sizeof buf )
- owarn << "Couldn't read image from /dev/sharp_zdc" << oendl;
+ read( bp, _readlen );
@@ -197,7 +200,14 @@ bool ZCameraIO::snapshot( QImage* image )
-bool ZCameraIO::snapshot( uchar* buf )
+bool ZCameraIO::snapshot( unsigned char* buf )
{
+ setReadMode( IMAGE | XFLIP | YFLIP );
+
+ read( (char*) buf, _readlen );
+
+ /* //TESTCODE
int fd = open( "/tmp/cam", O_RDONLY );
- if ( ::read( fd, buf, 76800 ) != 76800 )
+ if ( ::read( fd, (char*) buf, 76800 ) != 76800 )
owarn << "Couldn't read image from /dev/sharp_zdc" << oendl;
+ // TESTCODE */
+