static void ICACHE_FLASH_ATTR eventTimerCb(void *arg) {
	static int apledCnt = 0;
        static bool apledState = 0;
	static int resetCnt=0;
	static bool button1 = 1;
	static bool button2 = 1;
	apledCnt ++;
	if (apledCnt > 2) {
		apledState = ~apledState;
		apledCnt = 0;
	}
	if ((!GPIO_INPUT_GET(GPIO_BUTTON1))&&(!GPIO_INPUT_GET(GPIO_BUTTON2))) {
		resetCnt++;
		os_printf("Both buttons pressed (reset) (%d/30)\n", resetCnt);
		if (apledState) {
			ioSetLed(1);
		} else {
			ioSetLed(0);
		}
		if (resetCnt>=30) { //3 sec pressed
			restoreFactorySettings();
		}
	} else {
		resetCnt=0;
		//Button 1
		if (!GPIO_INPUT_GET(GPIO_BUTTON1)) {
			if (!button1) {
				os_printf("Button 1 pressed!\n");
				toggleOutput1();
			}
			button1 = 1;
		} else {
			button1 = 0;
		}
		//Button 2
		if (!GPIO_INPUT_GET(GPIO_BUTTON2)) {
			if (!button2) {
				os_printf("Button 2 pressed!\n");
				toggleOutput2();
			}
			button2 = 1;
		} else {
			button2 = 0;
		}
		//Leds
		if (wifi_get_opmode()==1) { //Client mode
			if (wifi_station_get_connect_status()==STATION_GOT_IP) {
				ioSetLed(1);
			} else {
				if (apledState) {
					ioSetLed(1);
				} else {
					ioSetLed(0);
				}
			}
		}
		if ((wifi_get_opmode()==2)) { //AP mode
			ioSetLed(1);
		}
		if (wifi_get_opmode()==3) { //Client + AP mode
			if (wifi_station_get_connect_status()==STATION_GOT_IP) {
				ioSetLed(1);
			} else {
				if (apledState) {
					ioSetLed(1);
				} else {
					ioSetLed(0);
				}
			}
		}
	}
}
Beispiel #2
0
QWidget *  QCamVesta::buildGUI(QWidget * parent) {
   QWidget * remoteCTRL=QCamV4L2::buildGUI(parent);

   //QHGroupBox* vestaCtrl=new QHGroupBox("Vesta controls",remoteCTRL);
   QGridBox * sliders= new QGridBox(/*vestaCtrl*/VctrlBox,Qt::Vertical,3);
   /*
   QHBox * sliders=new QHBox(remoteCTRL);
   QVBox * left = new QVBox(sliders);
   QVBox * right = new QVBox(sliders);
   */
   if (QCamUtilities::expertMode()) {
      QCheckBox * backLight = new QCheckBox(tr("Back Light"),sliders);
      connect(backLight,SIGNAL(toggled(bool)),this,SLOT(setBackLight(bool)));
      backLight->setToolTip(tr("In case the object you are viewing with the camera is\n"
                       "in front of a bright background (for example, a window\n"
                       "or some bright lights), the automatic exposure unit may\n"
                       "make the image too dark. In that case you can turn the\n"
                       "backlight compensation mode off"));
      QCheckBox * flicker = new QCheckBox(tr("Anti-flicker"),sliders);
      connect(flicker,SIGNAL(toggled(bool)),this,SLOT(setFlicker(bool)));
      flicker->setToolTip(tr("Suppress 'flickering' of the image when light with a fluo tube"));
   }
   remoteCTRLgama_=new QCamSlider(tr("Gamma"),false,sliders);
   // not very clean...but works
   remoteCTRLgama_->setMinValue(0);
   remoteCTRLgama_->setMaxValue(32);
   remoteCTRLgama_->setToolTip(tr("Low gamma implies less contrasts"));
   remoteCTRLgain_=new QCamSlider(tr("Gain"),true,sliders);
   remoteCTRLgain_->setToolTip(tr("More Gain implies more noise in the images"));
   remoteCTRLexposure_=new QCamSlider(tr("Exp."),true,sliders,0,65535,true);
   remoteCTRLexposure_->setToolTip(tr("More exposure reduce noise in images.\n"
                 "(manual exposure setting don't work on type 740\n"
                 "if automatic gain is activated).")
      );
   if (QCamUtilities::expertMode()) {
      remoteCTRLcompression_=new QCamSlider(tr("Comp."),false,sliders,0,3);
      remoteCTRLnoiseRemoval_=new QCamSlider(tr("Noise"),false,sliders,0,3);
      remoteCTRLsharpness_=new QCamSlider(tr("Sharp."),false,sliders,0,65535);

      connect(this,SIGNAL(compressionChange(int)),remoteCTRLcompression_,SLOT(setValue(int)));
      connect(remoteCTRLcompression_,SIGNAL(valueChange(int)),this,SLOT(setCompression(int)));
      connect(this,SIGNAL(noiseRemovalChange(int)),remoteCTRLnoiseRemoval_,SLOT(setValue(int)));
      connect(remoteCTRLnoiseRemoval_,SIGNAL(valueChange(int)),this,SLOT(setNoiseRemoval(int)));

      remoteCTRLnoiseRemoval_->setToolTip(tr("Dynamic Noise removal (0=none, 3=high) (0 give brighter image)"));

      connect(this,SIGNAL(sharpnessChange(int)),remoteCTRLsharpness_,SLOT(setValue(int)));
      connect(remoteCTRLsharpness_,SIGNAL(valueChange(int)),this,SLOT(setSharpness(int)));
      remoteCTRLsharpness_->setToolTip(tr("Shaprness enhancement (0=none, 65536=high) (low value blurs image)"));
   }

   int wbValue[]={PWC_WB_AUTO, PWC_WB_INDOOR, PWC_WB_OUTDOOR, PWC_WB_FL, PWC_WB_MANUAL};
   const char *wbLabel[]={"Auto", "In","Out","Neon","Manual"};
   remoteCTRLWhiteBalance_=new QCamRadioBox("White Balance",VctrlBox,5,wbValue,wbLabel,5);

   QWidget* whiteBalanceGroup=new QWidget();
   QHBoxLayout* whiteBalanceGroup_layout= new QHBoxLayout();
   whiteBalanceGroup->setLayout(whiteBalanceGroup_layout);

   connect(remoteCTRLWhiteBalance_,SIGNAL(change(int)),this,SLOT(setWhiteBalanceMode(int)));
   connect(this,SIGNAL(whiteBalanceModeChange(int)),remoteCTRLWhiteBalance_,SLOT(update(int)));

   QCheckBox * liveWBupdateB = new QCheckBox(tr("live"),whiteBalanceGroup);
   connect(liveWBupdateB,SIGNAL(toggled(bool)),this,SLOT(setLiveWhiteBalance(bool)));
   liveWBupdateB->setToolTip(tr("Live Update of red/blue value in automatic mode"));
   whiteBalanceGroup_layout->addWidget(liveWBupdateB);

   remoteCTRLWBred_ = new QCamSlider(tr("red bal."),false,whiteBalanceGroup,0,65535);
   whiteBalanceGroup_layout->addWidget(remoteCTRLWBred_);
   connect(this,SIGNAL(whiteBalanceRedChange(int)),remoteCTRLWBred_,SLOT(setValue(int)));
   connect(remoteCTRLWBred_,SIGNAL(valueChange(int)),this,SLOT(setWhiteBalanceRed(int)));

   remoteCTRLWBblue_ = new QCamSlider(tr("blue bal."),false,whiteBalanceGroup,0,65535);
   whiteBalanceGroup_layout->addWidget(remoteCTRLWBblue_);
   connect(this,SIGNAL(whiteBalanceBlueChange(int)),remoteCTRLWBblue_,SLOT(setValue(int)));
   connect(remoteCTRLWBblue_,SIGNAL(valueChange(int)),this,SLOT(setWhiteBalanceBlue(int)));

   remoteCTRLWhiteBalance_->layout()->addWidget(whiteBalanceGroup);

   remoteCTRLWBred_->setEnabled(false);
   remoteCTRLWBblue_->setEnabled(false);
   remoteCTRLWhiteBalance_->show();

   exposureTimeLeft_=NULL;
   connect(this,SIGNAL(gainChange(int)),remoteCTRLgain_,SLOT(setValue(int)));
   connect(remoteCTRLgain_,SIGNAL(valueChange(int)),this,SLOT(setGain(int)));

   /*
     connect(this,SIGNAL(exposureChange(int)),remoteCTRLexposure_,
     SLOT(setValue(int)));
   */
   connect(remoteCTRLexposure_,SIGNAL(valueChange(int)),this,SLOT(setExposure(int)));
   connect(this,SIGNAL(gamaChange(int)),remoteCTRLgama_,SLOT(setValue(int)));
   connect(remoteCTRLgama_,SIGNAL(valueChange(int)),this,SLOT(setGama(int)));

   QCamHBox* settings=new QCamHBox(VctrlBox);
   settings->setToolTip(tr("save/restore settings of gain,exposure & white balance"));

   QPushButton* saveSettingsB =new QPushButton(tr("save"),settings);
   saveSettingsB->setToolTip(tr("Save User settings (gain,exposure & white balance)"));
   connect(saveSettingsB,SIGNAL(released()),this,SLOT(saveSettings()));

   QPushButton* restoreSettingsB =new QPushButton(tr("restore"),settings);
   restoreSettingsB->setToolTip(tr("Restore User settings"));
   connect(restoreSettingsB,SIGNAL(released()),this,SLOT(restoreSettings()));

   QPushButton* restoreFactorySettingsB =new QPushButton(tr("factory"),settings);
   restoreFactorySettingsB->setToolTip(tr("Restore factory default settings"));
   connect(restoreFactorySettingsB,SIGNAL(released()),this,SLOT(restoreFactorySettings()));

   remoteCTRLframeRate_ =new QCamHGroupBox(tr("fps / long exposure"),remoteCTRL);
   int frameRate[]={5,10,15,20,25,30};
   remoteCTRLframeRate2_=new QCamComboBox("fps",remoteCTRLframeRate_,6,frameRate,NULL);
   remoteCTRLframeRate2_->setToolTip(tr("Camera frame rate"));
   connect(this,SIGNAL(frameRateChange(int)),remoteCTRLframeRate2_,SLOT(update(int)));
   connect(remoteCTRLframeRate2_,SIGNAL(change(int)),this,SLOT(setFrameRate(int)));
   remoteCTRLframeRate2_->show();

   int scModeTable[]={SCmodNone,SCmodPPort2,SCmodLed,SCmodSerial};
   const char* scModeLabel[]={"SC mod : None","SC mod : // port","SC mod : TUC led","SC mod : serial"};
   SCmodSelector_ = new QCamComboBox("SC mod",remoteCTRLframeRate_,4,scModeTable,scModeLabel);
   SCmodSelector_->setToolTip(tr("Long exposure device"));
   connect(SCmodSelector_,SIGNAL(change(int)),this,SLOT(setSCmod(int)));

   initRemoteControlLongExposure(remoteCTRLframeRate_);

   setBestQuality();
   refreshPictureSettings();

   remoteCTRL->show();

   return remoteCTRL;
}