void loop(){ DEBUG(("%i", isOn)); movementStart(); //This function is called once per second. Use it to control the satellite. if (game.getNextFlare() >= 4 && game.getMemoryFilled() > 0) { DEBUG(("[Mode: Flare upload]")); upload(); } else if (game.getNextFlare() < 4 && game.getNextFlare() != -1) { DEBUG(("[Mode: Flare turn off]")); game.turnOff(); isOn = false; } else { DEBUG(("[Mode: Normal]")); //turn on if off if (!isOn) { DEBUG(("[Sub-Mode: Turning on]")); game.turnOn(); isOn = true; } //normal loop stuff if (game.getMemoryFilled() == game.getMemorySize()) { DEBUG(("[Sub-Mode: Uploading]")); //upload photos if in photozone upload(); } else { DEBUG(("[Sub-Mode: Taking photo]")); //take photos takePhoto(); } } movementEnd(); }
void CameraMainWindow::takePhotoTimer() { PhotoTimerDialog* dialog = new PhotoTimerDialog( this ); if ( dialog->exec() == QDialog::Accepted ) { PhotoTimer* timer = new PhotoTimer( dialog->timeout(), dialog->number(), dialog->interval(), this ); connect( timer, SIGNAL(takePhoto()), this, SLOT(takePhotoNow()) ); timer->show(); } delete dialog; }
void PhotoTimer::timeout() { if ( mTimeout <= 0 ) { emit( takePhoto() ); if ( mNumber <= 1 ) { deleteLater(); } else { mTimeout = mInterval; --mNumber; } } else { --mTimeout; } mClock->display( QTime( 0, mTimeout, mTimeout ) ); }
int main() { wiringPiSetup(); pinMode(LED, OUTPUT); pinMode(Sensor, INPUT); digitalWrite(LED, LOW); while(1){ int sensor = digitalRead(Sensor); if(sensor){ digitalWrite(LED, HIGH); takePhoto(); }else { printf("No human\n"); digitalWrite(LED, LOW); } delay(500); } }
PhotoVideoWidget::PhotoVideoWidget( QWidget *parent /* = NULL */ ) : QWidget( parent ) { g_photoImage = NULL; photoPushButton = new QPushButton( tr( "拍照" ), this ); videoPushButton = new QPushButton( tr( "录像" ), this ); photoToolBar = new QToolBar; photoToolBar->setStyleSheet( "border: 4px solid blue; border-radius: 5px" ); for ( int i = 0; i < PHOTO_NUM; i++ ) { photoLabel[i] = new QLabel; photoLabel[i]->setFixedSize( 163, 140 ); photoLabel[i]->setStyleSheet( "border: 2px solid green; border-radius: 5px" ); photoToolBar->addSeparator(); photoToolBar->addWidget( photoLabel[i] ); } photoToolBar->addSeparator(); connect( photoPushButton, SIGNAL( clicked() ), this, SLOT( takePhoto() ) ); connect( videoPushButton, SIGNAL( clicked() ), this, SLOT( recordVideo() ) ); QHBoxLayout *topLayout = new QHBoxLayout; topLayout->addWidget( photoPushButton ); topLayout->addWidget( videoPushButton ); QVBoxLayout *mainLayout = new QVBoxLayout; mainLayout->addLayout( topLayout ); mainLayout->addWidget( photoToolBar ); setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); setLayout( mainLayout ); }
CameraMainWindow::CameraMainWindow(QWidget *parent, Qt::WFlags f): QMainWindow(parent, f), settings( NULL ), settingsDialog( NULL ), psize( -1 ), vsize( -1 ), snapRequest( 0 ), videoOnSecondary(false), m_photoContentSet( QContentSet::Asynchronous ), m_photoModel( 0 ), m_contextMenuActive(false) { setWindowTitle(tr("Camera")); QtopiaApplication::setPowerConstraint(QtopiaApplication::DisableLightOff); picfile = Qtopia::tempDir() + "image.jpg"; QWidget *cameraWidget = new QWidget(this); camera = new Ui::CameraBase(); camera->setupUi(cameraWidget); setCentralWidget(cameraWidget); camcat = QLatin1String("Camera"); // Ensure the Camera system categoy exists QCategoryManager catman("Documents"); // For new code a more unique id should be used instead of using the untranslated text // eg. ensureSystemCategory("com.mycompany.myapp.mycategory", "My Category"); catman.ensureSystemCategory(camcat, camcat); new CameraService(this); camera->photo->setFocus(); connect(camera->photo, SIGNAL(clicked()), this, SLOT(takePhoto())); connect(camera->video, SIGNAL(clicked()), this, SLOT(toggleVideo())); refocusTimer = new QTimer(this); refocusTimer->setSingleShot(true); connect(refocusTimer, SIGNAL(timeout()), this, SLOT(takePhotoNow())); thumb[0] = camera->thumb1; thumb[1] = camera->thumb2; thumb[2] = camera->thumb3; thumb[3] = camera->thumb4; thumb[4] = camera->thumb5; cur_thumb = -1; // Load the allowable sizes from the camera hardware. photo_size = camera->videocaptureview->photoSizes(); video_size = camera->videocaptureview->videoSizes(); namehint=0; recording = false; if ( !video_supported ) { // Room for longer text camera->photo->setText(tr("Take Photo")); camera->video->setEnabled(false); camera->video->hide(); } if (QApplication::desktop()->numScreens() > 1) { // We have a secondary display - watch for the clamshell open/close clamshellVsi = new QValueSpaceItem("/Hardware/Devices/ClamshellOpen", this); connect(clamshellVsi, SIGNAL(contentsChanged()), this, SLOT(clamshellChanged())); if (!clamshellVsi->value().toBool()) { videoToScreen(1); } } m_photoContentSet.setCriteria( QContentFilter( QContent::Document ) & QContentFilter::category( QLatin1String( "Camera" ) ) & QContentFilter::mimeType( QLatin1String( "image/jpeg" ) ) ); m_photoContentSet.setSortCriteria( QContentSortCriteria( QContentSortCriteria::LastUpdated, Qt::DescendingOrder ) ); m_photoModel = new QContentSetModel( &m_photoContentSet, this ); connect( m_photoModel, SIGNAL(updateFinished()), this, SLOT(loadThumbs()) ); m_wait = new QWaitWidget(camera->videocaptureview); m_iswaiting = false; QTimer::singleShot(1, this, SLOT(delayedInit())); m_currzoom = 0; zoomActive = false; zoomTimer.setSingleShot(true); zoomTimer.setInterval(5000); connect(&zoomTimer, SIGNAL(timeout()), this, SLOT(hideZoom())); }
bool CameraMainWindow::eventFilter(QObject* o, QEvent* e) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *ke = (QKeyEvent*)e; if (!ke->isAutoRepeat()) { if (ke->key() == Qt::Key_1) { takePhoto(); return true; } else if (ke->key() == Qt::Key_2) { toggleVideo(); return true; } } if (ke->key() == Qt::Key_4) { if(camera->videocaptureview->minZoom() < m_currzoom) { m_currzoom--; m_zoom->setValue(m_currzoom); showZoom(); } camera->videocaptureview->zoomOut(); } if (ke->key() == Qt::Key_6) { if(camera->videocaptureview->maxZoom() > m_currzoom) { m_currzoom++; m_zoom->setValue(m_currzoom); showZoom(); } camera->videocaptureview->zoomIn(); } if ( ke->key() == Qt::Key_Select ) for(int i = 0; i <nthumb-1; ++i) if( o == thumb[i]) return true; if ( ke->key() == Qt::Key_Up ) { camera->photo->setFocus(); return true; } else if ( ke->key() == Qt::Key_Down ) { thumb[0]->setFocus(); return true; } else if ( ke->key() == (QApplication::isLeftToRight() ? Qt::Key_Left : Qt::Key_Right) ) { if ( o == camera->video ) { camera->photo->setFocus(); return true; } else { if ( o == thumb[0] ) return true; for (int i=1; i<nthumb; ++i) { if ( o == thumb[i] ) { thumb[i-1]->setFocus(); return true; } } } } else if ( ke->key() == (QApplication::isLeftToRight() ? Qt::Key_Right : Qt::Key_Left) ) { if ( o == camera->photo ) { camera->video->setFocus(); return true; } else { if ( o == thumb[nthumb-1] ) return true; for (int i=0; i<nthumb-1; ++i) { if ( o == thumb[i] ) { thumb[i+1]->setFocus(); return true; } } } } } else if (!m_contextMenuActive) { if (e->type() == QEvent::FocusIn) { if (o == camera->photo) { QtopiaApplication::setPowerConstraint( QtopiaApplication::Disable ); } updateActions(); } else if (e->type() == QEvent::FocusOut) { if (o == camera->photo) { QtopiaApplication::setPowerConstraint( QtopiaApplication::Enable ); } } } return QWidget::eventFilter(o,e); }