void CAtmoColorPicker::outputColor(int red,int green,int blue) 
{
	CAtmoConnection *pAtmoConnection = this->m_pAtmoDynData->getAtmoConnection();
	CAtmoConfig *pAtmoConfig = this->m_pAtmoDynData->getAtmoConfig();

	if((pAtmoConnection==NULL) || (pAtmoConnection->isOpen()==ATMO_FALSE)) return;

	pColorPacket packet;

	AllocColorPacket(packet, pAtmoConfig->getZoneCount());

	for(int i=0;i<packet->numColors;i++) 
	{
		packet->zone[i].r  = red;
		packet->zone[i].g  = green;
		packet->zone[i].b  = blue;
	}

	if(pAtmoConfig->isUseSoftwareWhiteAdj()) 
		packet = CAtmoTools::WhiteCalibration(pAtmoConfig, packet);

	packet = CAtmoTools::ApplyGamma(pAtmoConfig, packet);

	pAtmoConnection->SendData( packet );

	delete (char *)packet;
}
예제 #2
0
ATMO_BOOL CAtmoLiveSettings::UpdateLiveViewValues(ATMO_BOOL showPreview) {
     HWND hwndCtrl;
     CAtmoDisplays *pAtmoDisplays = this->m_pDynData->getAtmoDisplays();
     CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();

     pAtmoDisplays->ReloadList(); // auf nummer sicher!

     hwndCtrl = getDlgItem(IDC_DISPLAYS);
     int i = ComboBox_GetCurSel(hwndCtrl);
     if(i>=pAtmoDisplays->getCount()) {
         pAtmoConfig->setLiveView_DisplayNr(0);
         LoadDisplayList();
         MessageBox(this->m_hDialog,"Ausgewähltes Display nicht mehr in der Liste ;-)","Fehler",MB_ICONERROR | MB_OK);
         return ATMO_FALSE;
     }
     pAtmoConfig->setLiveView_DisplayNr(i);

     if(showPreview == ATMO_TRUE) {
        CAtmoConnection *pAtmoConnection = m_pDynData->getAtmoConnection();
        if((pAtmoConnection!=NULL) && pAtmoConnection->isOpen()) {
            CAtmoTools::SwitchEffect(m_pDynData, emLivePicture);
         }
     }
     return ATMO_TRUE;
}
STDMETHODIMP CAtmoRemoteControlImplEx::setStaticColor(BYTE red, BYTE green, BYTE blue) {
    m_pAtmoDynData->LockCriticalSection();

    CAtmoConnection *connection = this->m_pAtmoDynData->getAtmoConnection();
    if((connection!=NULL) && (connection->isOpen())) {

        CAtmoConfig *pConfig = m_pAtmoDynData->getAtmoConfig();
        pColorPacket newColors;
        int zoneCount = pConfig->getZoneCount();

        AllocColorPacket(newColors, zoneCount);

        for(int i=0;i<zoneCount;i++) {
            newColors->zone[i].r = red;
            newColors->zone[i].g = green;
            newColors->zone[i].b = blue;
        }

        newColors = CAtmoTools::ApplyGamma(pConfig, newColors);

        if(pConfig->isUseSoftwareWhiteAdj()) 
            newColors = CAtmoTools::WhiteCalibration(pConfig, newColors);

        connection->SendData(newColors);

        delete (char *)newColors;
    }

    this->m_pAtmoDynData->UnLockCriticalSection();
    return S_OK;
}
DWORD CAtmoGdiDisplayCaptureInput::Execute(void) {
    // process Screen Capturing... every x ms ...
    DWORD tickCount;
    DWORD sleepMs; 
    CAtmoConfig *pAtmoConfig = m_pAtmoDynData->getAtmoConfig();
    int fps = pAtmoConfig->getLiveView_GDI_FrameRate();
    if (fps < 1) fps = 1;
    if (fps > 100) fps = 100;

    sleepMs = DWORD(1000 / fps);

    // in this loop the picture is read and the colors are calculated
    while (this->m_bTerminated == ATMO_FALSE)
	{
		tickCount = GetTickCount();

		// [TF] if new parameter "rowsPerFrame" is set, use new method for getting colors
		// if (m_rowsPerFrame > 0)
		//	CalcColorsNew();
		//else
   	    
        CalcColors(); // read picture and calculate colors

        tickCount = GetTickCount() - tickCount;

        if (tickCount < sleepMs) // ensure that this loop takes at least 50ms! so we will get 20 Frames per Second
        {
            if(this->ThreadSleep(sleepMs - tickCount) == ATMO_FALSE)  // sleep at least 10ms!
               break;// thread was terminated durring waiting... oops
        }
    }

    return 0;
}
예제 #5
0
파일: AtmoTools.cpp 프로젝트: CSRedRat/vlc
int CAtmoTools::SetChannelAssignment(CAtmoDynData *pDynData, int index)
{
    CAtmoConfig *pAtmoConfig = pDynData->getAtmoConfig();
    CAtmoConnection *pAtmoConnection = pDynData->getAtmoConnection();
    int oldIndex = pAtmoConfig->getCurrentChannelAssignment();

    CAtmoChannelAssignment *ca = pAtmoConfig->getChannelAssignment(index);
    if((ca!=NULL) && (pAtmoConnection!=NULL)) {
        pAtmoConnection->SetChannelAssignment(ca);
        pAtmoConfig->setCurrentChannelAssignment(index);
    }
    return oldIndex;
}
STDMETHODIMP CAtmoRemoteControlImplEx::getEffect(enum ComEffectMode *dwEffect) {
    m_pAtmoDynData->LockCriticalSection();

    CAtmoConfig *atmoConfig = this->m_pAtmoDynData->getAtmoConfig();
    if(atmoConfig!=NULL)
       *dwEffect = ConvertEffectAtmo2Com(atmoConfig->getEffectMode());

    m_pAtmoDynData->UnLockCriticalSection();

    if(atmoConfig == NULL)
        return S_FALSE;
      else
        return S_OK;
}
예제 #7
0
void CAtmoTools::ShowShutdownColor(CAtmoDynData *pDynData)
{
	pDynData->LockCriticalSection();


	CAtmoConnection *atmoConnection = pDynData->getAtmoConnection();
	CAtmoConfig *atmoConfig = pDynData->getAtmoConfig();
	if((atmoConnection != NULL) && (atmoConfig!=NULL) && atmoConfig->isSetShutdownColor()) 
	{
		int i;
		pColorPacket packet;
		AllocColorPacket(packet, atmoConfig->getZoneCount());

		// set a special color? on shutdown of the software? mostly may use black or so ...
		// if this function ist disabled ... atmo will continuing to show the last color...
		for(i = 0; i < packet->numColors; i++) 
		{
			packet->zone[i].r = atmoConfig->getShutdownColor_Red();
			packet->zone[i].g = atmoConfig->getShutdownColor_Green();
			packet->zone[i].b = atmoConfig->getShutdownColor_Blue();
		}

		packet = CAtmoTools::ApplyGamma(atmoConfig, packet);

		if(atmoConfig->isUseSoftwareWhiteAdj())
			packet = CAtmoTools::WhiteCalibration(atmoConfig, packet);

		atmoConnection->SendData(packet);

		delete (char *)packet;

	}

	pDynData->UnLockCriticalSection();
}
ATMO_BOOL CAtmoGradients::Execute(HINSTANCE hInst, HWND parent, CAtmoDynData *pAtmoDynData)
{
	CAtmoConnection *pAtmoConnection = pAtmoDynData->getAtmoConnection();
	CAtmoConfig *pAtmoConfig = pAtmoDynData->getAtmoConfig();

	EffectMode backupEffectMode = CAtmoTools::SwitchEffect(pAtmoDynData, emDisabled);

	CAtmoGradients *pAtmoGradients = new CAtmoGradients(hInst, parent, pAtmoDynData);

	ATMO_BOOL result (pAtmoGradients->ShowModal() == IDOK);
	if(result == ATMO_TRUE) 
	{  
		pAtmoConfig->setLiveView_EdgeWeighting( pAtmoGradients->m_edge_weight );
	} 
	else 
	{
		// altes Setup wieder Temporär in Controller laden!
		// flackert vermutlich furchtbar...aber wenns dann wirkt... ;-)
	}
	delete pAtmoGradients;

	CAtmoTools::SwitchEffect(pAtmoDynData, backupEffectMode);
	return result;
}
DWORD CAtmoLiveView::Execute(void)
{
#if defined(_ATMO_VLC_PLUGIN_)
	vlc_object_t *m_pLog = m_pAtmoDynData->getAtmoFilter();
	mtime_t ticks;
	mtime_t t;
	mtime_t packet_time;
#else
	DWORD ticks;
	DWORD t;
	DWORD packet_time;
#endif
	int i_frame_counter = -1;

	pColorPacket ColorPacket;
	pColorPacket PreviousPacket = NULL;

	CAtmoConnection *pAtmoConnection = this->m_pAtmoDynData->getAtmoConnection();
	if((pAtmoConnection == NULL) || (pAtmoConnection->isOpen() == ATMO_FALSE)) return 0;

	CAtmoConfig *pAtmoConfig = this->m_pAtmoDynData->getAtmoConfig();

	/*
	this object does post processing of the pixel data
	like jump /scenechange detection fading over the colors
	*/
	CAtmoOutputFilter *filter = new CAtmoOutputFilter( this->m_pAtmoDynData->getAtmoConfig() );
	CAtmoPacketQueue *pPacketQueue = this->m_pAtmoDynData->getLivePacketQueue();

	int frameDelay = pAtmoConfig->getLiveView_FrameDelay();

#if defined(_ATMO_VLC_PLUGIN_)
	/*
	because time function of vlc are working with us values instead of ms
	*/
	frameDelay = frameDelay * 1000;
#endif

	/*
	wait for the first frame to go in sync with the other thread
	*/
	t = get_time1;

	if( pPacketQueue->WaitForNextPacket(3000) )
	{
		if( frameDelay > 0 )
			do_sleep( frameDelay );
#if defined(_ATMO_VLC_PLUGIN_)
		msg_Dbg( m_pLog, "First Packet got %"PRId64" ms", (get_time1 - t) / 1000  );
#endif
	}

	while(this->m_bTerminated == ATMO_FALSE)
	{
		i_frame_counter++;
		if(i_frame_counter == 50) i_frame_counter = 0;

		/* grab current Packet from InputQueue (working as FIFO)! */
#if defined(_ATMO_VLC_PLUGIN_)
		ColorPacket = pPacketQueue->GetNextPacket(get_time1 - frameDelay, (i_frame_counter == 0), m_pLog, packet_time);
#else
		ColorPacket = pPacketQueue->GetNextPacket(get_time1 - frameDelay, (i_frame_counter == 0), packet_time);
#endif
		if(ColorPacket)
		{
			/*
			create a packet copy - for later reuse if the input is slower than 25fps
			*/
			if(PreviousPacket && (PreviousPacket->numColors == ColorPacket->numColors))
				CopyColorPacket(ColorPacket, PreviousPacket)
			else 
			{
				delete (char *)PreviousPacket;
				DupColorPacket(PreviousPacket, ColorPacket )
			}
		} 
		else 
		{
			/*
			packet queue was empty for the given point of time
			*/
			if(i_frame_counter == 0)
			{
#if defined(_ATMO_VLC_PLUGIN_)
				msg_Dbg( m_pLog, "wait for delayed packet..." );
#endif
				t = get_time1;
				if( pPacketQueue->WaitForNextPacket(200) )
				{
					if( frameDelay > 0 )
						do_sleep( frameDelay );
#if defined(_ATMO_VLC_PLUGIN_)
					msg_Dbg( m_pLog, "got delayed packet %"PRId64" ms", (mdate() - t) / 1000  );
#endif
					continue;
				}
			}
			/*
			reuse previous color packet
			*/
			DupColorPacket(ColorPacket, PreviousPacket)
		}

		ticks = get_time1;

		if(ColorPacket)
		{
			/* pass it through the outputfilters! */
			// Info Filtering will possible free the colorpacket and alloc a new one!
			ColorPacket = filter->Filtering(ColorPacket);

			// invert colors
			if(pAtmoConfig->isUseinvert())
				ColorPacket = CAtmoTools::Applyinvert(pAtmoConfig, ColorPacket);

			/* apply gamma correction - only if the hardware isnt capable doing this */
			ColorPacket = CAtmoTools::ApplyGamma(pAtmoConfig, ColorPacket);

			// load color correction from Kodak 3D-Lut file
			if(pAtmoConfig->isUse3dlut() && pAtmoConfig->m_3dlut)
				ColorPacket = CAtmoTools::Apply3dlut(pAtmoConfig, ColorPacket);

			// our own trilinear CMS
			if(pAtmoConfig->isUseColorKWhiteAdj())
				ColorPacket = CAtmoTools::ApplyColorK(pAtmoConfig, ColorPacket);

			// apply white calibration - only if it is not done by the hardware
			if((pAtmoConfig->isUseSoftwareWhiteAdj()))//&&(!pAtmoConfig->isUseColorKWhiteAdj()))
				ColorPacket = CAtmoTools::WhiteCalibration(pAtmoConfig, ColorPacket);

			//Sensitivity
			ColorPacket = CAtmoTools::ApplySens(pAtmoConfig, ColorPacket);
			/* send color data to the the hardware... */
			try
			{
				pAtmoConnection->SendData(ColorPacket);
				delete (char *)ColorPacket;
			}
			catch(...)
			{
				delete (char *)ColorPacket;
			}
		}

		/*
		calculate RunTime of thread abbove (doesn't work well - so
		this threads comes out of sync with Image producer and the
		framerate (25fps) drifts away
		*/
#if defined(_ATMO_VLC_PLUGIN_)
		ticks = ((mdate() - ticks) + 999)/1000;
#else
		ticks = GetTickCount() - ticks;
#endif
		if(ticks < 40)
		{
			if( ThreadSleep( 40 - ticks ) == ATMO_FALSE )
				break;
		}
	}
예제 #10
0
EffectMode CAtmoTools::SwitchEffect(CAtmoDynData *pDynData, EffectMode newEffectMode)
{
	// may need a critical section??
	if(pDynData == NULL) 
	{
		return emUndefined;
	}
	pDynData->LockCriticalSection();

	CAtmoConfig *atmoConfig = pDynData->getAtmoConfig();
	if(atmoConfig == NULL) 
	{
		pDynData->UnLockCriticalSection();
		return emUndefined;
	}
	CAtmoConnection *atmoConnection = pDynData->getAtmoConnection();

	EffectMode oldEffectMode = atmoConfig->getEffectMode();
	CThread *currentEffect = pDynData->getEffectThread();
	CAtmoInput *currentInput = pDynData->getLiveInput();
	CAtmoPacketQueue *currentPacketQueue = pDynData->getLivePacketQueue();


	if(oldEffectMode == emLivePicture)
	{
		/* in case of disabling the live mode
		first we have to stop the input
		then the effect thread!
		*/
		if(currentInput != NULL) 
		{
			pDynData->setLiveInput( NULL );
			currentInput->Close();
			delete currentInput;
			currentInput = NULL;
		}
	}

	// stop and delete/cleanup current Effect Thread...
	pDynData->setEffectThread( NULL );
	if(currentEffect != NULL)
	{
		currentEffect->Terminate();
		delete currentEffect;
		currentEffect = NULL;
	}

	if(oldEffectMode == emLivePicture) 
	{
		/*
		and last we kill the PacketQueue used for communication between the threads
		*/
		pDynData->setLivePacketQueue( NULL );
		delete currentPacketQueue;
		currentPacketQueue = NULL;
	}

	if((atmoConnection!=NULL) && (atmoConnection->isOpen()==ATMO_TRUE))
	{
		// neuen EffectThread nur mit aktiver Connection starten...

		switch(newEffectMode) 
		{
		case emUndefined: // do nothing also in that case (avoid compiler warning)
			break;
		case emDisabled:
			{
				// get values from config - and put them to all channels?
				pColorPacket packet;
				AllocColorPacket(packet, atmoConfig->getZoneCount());

				for(int i=0; i < packet->numColors; i++)
				{
					packet->zone[i].r = 0;
					packet->zone[i].g = 0;
					packet->zone[i].b = 0;
				}

				atmoConnection->SendData( packet );
				atmoConnection->SendData( packet );

				delete (char *)packet;

				break;
			}


		case emStaticColor: 
			{
				// get values from config - and put them to all channels?
				pColorPacket packet;
				AllocColorPacket(packet, atmoConfig->getZoneCount());
				for(int i=0; i < packet->numColors; i++){
					packet->zone[i].r = atmoConfig->getStaticColor_Red();
					packet->zone[i].g = atmoConfig->getStaticColor_Green();
					packet->zone[i].b = atmoConfig->getStaticColor_Blue();
				}

				packet = CAtmoTools::ApplyGamma( atmoConfig, packet );

				if(atmoConfig->isUseSoftwareWhiteAdj())
					packet = CAtmoTools::WhiteCalibration(atmoConfig, packet);

				atmoConnection->SendData( packet );
				atmoConnection->SendData( packet );

				delete (char *)packet;

				break;
			}

		case emLivePicture: 
			{
				currentEffect = new CAtmoLiveView(pDynData);

#if !defined(_ATMO_VLC_PLUGIN_)
				CAtmoPacketQueueStatus *packetMon = NULL;
				if(atmoConfig->getShow_statistics())
				{
					packetMon = new CAtmoPacketQueueStatus(pDynData->getAppHinstance(), (HWND)NULL);
					packetMon->createWindow();
					packetMon->showWindow(SW_SHOW);
				}
				currentPacketQueue = new CAtmoPacketQueue(packetMon);
				pDynData->setLivePictureSource(lpsScreenCapture);
				//Atmo liveview option GDi <Win7 / DekstopDuplication >Win8
				int AtmoSetup_Mode = atmoConfig->getLiveView_Mode();
				if (AtmoSetup_Mode == 1)
				{
					 currentInput = new CAtmoDesktopDuplicationCaptureInput( pDynData );
				}
				else
				{
					 currentInput = new CAtmoGdiDisplayCaptureInput( pDynData );
				}

#else
				currentPacketQueue = new CAtmoPacketQueue();
				pDynData->setLivePictureSource(lpsExtern);
				currentInput = new CAtmoExternalCaptureInput( pDynData );
#endif
				break;
			}

#if !defined(_ATMO_VLC_PLUGIN_)
		case emColorChange:
			currentEffect = new CAtmoColorChanger(atmoConnection, atmoConfig);
			break;

		case emLrColorChange:
			currentEffect = new CAtmoLeftRightColorChanger(atmoConnection, atmoConfig);
			break;
#endif
		}

	}

	atmoConfig->setEffectMode( newEffectMode );

	pDynData->setLivePacketQueue( currentPacketQueue );
	pDynData->setEffectThread( currentEffect );
	pDynData->setLiveInput( currentInput );

	if(currentEffect != NULL)
		currentEffect->Run();
	if(currentInput != NULL)
		currentInput->Open();

	pDynData->UnLockCriticalSection();
	return oldEffectMode;
}
예제 #11
0
ATMO_BOOL CAtmoTools::RecreateConnection(CAtmoDynData *pDynData)
{
	pDynData->LockCriticalSection();
	CLanguage *Lng = new CLanguage;

	CAtmoConnection *current = pDynData->getAtmoConnection();
	CAtmoConfig *atmoConfig = pDynData->getAtmoConfig();
	AtmoConnectionType act = atmoConfig->getConnectionType();
	pDynData->setAtmoConnection(NULL);
	if(current != NULL) 
	{
		current->CloseConnection();
		delete current;
	}

	switch(act)
	{
	case actClassicAtmo:
		{
			CAtmoClassicConnection *tempConnection = new CAtmoClassicConnection( atmoConfig );
			if(tempConnection->OpenConnection() == ATMO_FALSE)
			{
#if !defined(_ATMO_VLC_PLUGIN_)
				if(atmoConfig->getIgnoreConnectionErrorOnStartup() == ATMO_FALSE)
				{
					char errorMsgBuf[200];
					sprintf(errorMsgBuf,Lng->sMessagesText[26] + "com%d" + Lng->sMessagesText[26] + "%d (0x%x)",
						pDynData->getAtmoConfig()->getArduComport(),
						tempConnection->getLastError(),
						tempConnection->getLastError()
						);
					MessageBox(0,errorMsgBuf,Lng->sMessagesText[3] ,MB_ICONERROR | MB_OK);
				}
#endif
				pDynData->setAtmoConnection(tempConnection);

				pDynData->UnLockCriticalSection();
				return ATMO_FALSE;
			}
			pDynData->setAtmoConnection(tempConnection);
			pDynData->ReloadZoneDefinitionBitmaps();

			tempConnection->CreateDefaultMapping(atmoConfig->getChannelAssignment(0));

			CAtmoTools::SetChannelAssignment(pDynData,
				atmoConfig->getCurrentChannelAssignment());

			pDynData->UnLockCriticalSection();
			return ATMO_TRUE;
		}

#if !defined(_ATMO_VLC_PLUGIN_)
	case actDummy:
		{
			// actDummy8,actDummy12,actDummy16
			CAtmoDummyConnection *tempConnection = new CAtmoDummyConnection(pDynData->getResHinstance(),
				atmoConfig);
			if(tempConnection->OpenConnection() == ATMO_FALSE) 
			{
				pDynData->setAtmoConnection(tempConnection);
				pDynData->UnLockCriticalSection();
				return ATMO_FALSE;
			}
			pDynData->setAtmoConnection(tempConnection);
			pDynData->ReloadZoneDefinitionBitmaps();

			tempConnection->CreateDefaultMapping(atmoConfig->getChannelAssignment(0));

			CAtmoTools::SetChannelAssignment(pDynData, pDynData->getAtmoConfig()->getCurrentChannelAssignment());

			pDynData->UnLockCriticalSection();
			return ATMO_TRUE;
		}
#endif

	case actDMX: 
		{
			// create here your DMX connections... instead of the dummy....
			CAtmoDmxSerialConnection *tempConnection = new CAtmoDmxSerialConnection( atmoConfig );
			if(tempConnection->OpenConnection() == ATMO_FALSE)
			{
				pDynData->setAtmoConnection(tempConnection);

				pDynData->UnLockCriticalSection();
				return ATMO_FALSE;
			}
			pDynData->setAtmoConnection(tempConnection);
			pDynData->ReloadZoneDefinitionBitmaps();

			tempConnection->CreateDefaultMapping(atmoConfig->getChannelAssignment(0));

			CAtmoTools::SetChannelAssignment(pDynData, atmoConfig->getCurrentChannelAssignment());

			pDynData->UnLockCriticalSection();
			return ATMO_TRUE;
		}

#if !defined(_ATMO_VLC_PLUGIN_)
	case actNUL: 
		{
			CAtmoNulConnection *tempConnection = new CAtmoNulConnection( atmoConfig );
			if(tempConnection->OpenConnection() == ATMO_FALSE) 
			{
				pDynData->setAtmoConnection(tempConnection);
				pDynData->UnLockCriticalSection();
				return ATMO_FALSE;
			}
			pDynData->setAtmoConnection(tempConnection);
			pDynData->ReloadZoneDefinitionBitmaps();

			tempConnection->CreateDefaultMapping(atmoConfig->getChannelAssignment(0));

			CAtmoTools::SetChannelAssignment(pDynData, atmoConfig->getCurrentChannelAssignment());

			pDynData->UnLockCriticalSection();
			return ATMO_TRUE;
		}
#endif

	case actMultiAtmo: 
		{
			CAtmoMultiConnection *tempConnection = new CAtmoMultiConnection( atmoConfig );
			if(tempConnection->OpenConnection() == ATMO_FALSE) 
			{
				pDynData->setAtmoConnection(tempConnection);
				pDynData->UnLockCriticalSection();
				return ATMO_FALSE;
			}
			pDynData->setAtmoConnection(tempConnection);
			pDynData->ReloadZoneDefinitionBitmaps();

			tempConnection->CreateDefaultMapping(atmoConfig->getChannelAssignment(0));

			CAtmoTools::SetChannelAssignment(pDynData, atmoConfig->getCurrentChannelAssignment());

			pDynData->UnLockCriticalSection();
			return ATMO_TRUE;
		}

#if !defined(_ATMO_VLC_PLUGIN_)
	case actMondolight: 
		{
			CMondolightConnection *tempConnection = new CMondolightConnection( atmoConfig );
			if(tempConnection->OpenConnection() == ATMO_FALSE)
			{
				pDynData->setAtmoConnection(tempConnection);
				pDynData->UnLockCriticalSection();
				return ATMO_FALSE;
			}
			pDynData->setAtmoConnection(tempConnection);
			pDynData->ReloadZoneDefinitionBitmaps();

			tempConnection->CreateDefaultMapping(atmoConfig->getChannelAssignment(0));

			CAtmoTools::SetChannelAssignment(pDynData, atmoConfig->getCurrentChannelAssignment());

			pDynData->UnLockCriticalSection();
			return ATMO_TRUE;
		}
#endif
	case actMoMoLight: 
		{
			CMoMoConnection *tempConnection = new CMoMoConnection( atmoConfig );
			if(tempConnection->OpenConnection() == ATMO_FALSE)
			{
				pDynData->setAtmoConnection(tempConnection);
				pDynData->UnLockCriticalSection();
				return ATMO_FALSE;
			}
			pDynData->setAtmoConnection(tempConnection);
			pDynData->ReloadZoneDefinitionBitmaps();

			tempConnection->CreateDefaultMapping( atmoConfig->getChannelAssignment(0) );

			CAtmoTools::SetChannelAssignment(pDynData, atmoConfig->getCurrentChannelAssignment() );

			pDynData->UnLockCriticalSection();
			return ATMO_TRUE;
		}

	case actFnordlicht: 
		{
			CFnordlichtConnection *tempConnection = new CFnordlichtConnection( atmoConfig );
			if(tempConnection->OpenConnection() == ATMO_FALSE)
			{
				pDynData->setAtmoConnection(tempConnection);
				pDynData->UnLockCriticalSection();
				return ATMO_FALSE;
			}
			pDynData->setAtmoConnection(tempConnection);
			pDynData->ReloadZoneDefinitionBitmaps();

			tempConnection->CreateDefaultMapping( atmoConfig->getChannelAssignment(0) );

			CAtmoTools::SetChannelAssignment(pDynData, atmoConfig->getCurrentChannelAssignment() );

			pDynData->UnLockCriticalSection();
			return ATMO_TRUE;
		}

	case actEnttecDMX: 
		{
			CAtmoEntecSerialConnection *tempConnection = new CAtmoEntecSerialConnection( atmoConfig );
			if(tempConnection->OpenConnection() == ATMO_FALSE) 
			{
				pDynData->setAtmoConnection(tempConnection);
				pDynData->UnLockCriticalSection();
				return ATMO_FALSE;
			}
			pDynData->setAtmoConnection(tempConnection);
			pDynData->ReloadZoneDefinitionBitmaps();

			tempConnection->CreateDefaultMapping( atmoConfig->getChannelAssignment(0) );

			CAtmoTools::SetChannelAssignment(pDynData, atmoConfig->getCurrentChannelAssignment() );

			pDynData->UnLockCriticalSection();
			return ATMO_TRUE;
		}

  case actAtmoDuinoV2: {
    CAtmoDuinoV2Connection *tempConnection = new CAtmoDuinoV2Connection(atmoConfig);
    if (tempConnection->OpenConnection() == ATMO_FALSE) {
#if !defined(_ATMO_VLC_PLUGIN_)
      if (atmoConfig->getIgnoreConnectionErrorOnStartup() == ATMO_FALSE)
      {
        char errorMsgBuf[200];
        sprintf(errorMsgBuf, "Failed to open serial port com%d with errorcode: %d (0x%x)",
          pDynData->getAtmoConfig()->getComport(),
          tempConnection->getLastError(),
          tempConnection->getLastError()
          );
        MessageBox(0, errorMsgBuf, "Error", MB_ICONERROR | MB_OK);
      }
#endif
      pDynData->setAtmoConnection(tempConnection);

      pDynData->UnLockCriticalSection();
      return ATMO_FALSE;
    }
    pDynData->setAtmoConnection(tempConnection);
    pDynData->ReloadZoneDefinitionBitmaps();

    tempConnection->CreateDefaultMapping(atmoConfig->getChannelAssignment(0));

    CAtmoTools::SetChannelAssignment(pDynData,
      atmoConfig->getCurrentChannelAssignment());

    pDynData->UnLockCriticalSection();
    return ATMO_TRUE;
  }


	default: 
		{
			pDynData->UnLockCriticalSection();
			return ATMO_FALSE;
		}
	}
}
예제 #12
0
ATMO_BOOL CAtmoLiveSettings::InitDialog(WPARAM wParam) 
{
        CAtmoConfig *config = m_pDynData->getAtmoConfig();
        char buffer[256];
        HWND hwndCtrl;

        hwndCtrl = this->getDlgItem(IDC_GDI_CAPURE_RATE);
        sprintf(buffer,"%d",config->getLiveView_GDI_FrameRate());
        Edit_SetText(hwndCtrl, buffer);
        Edit_LimitText(hwndCtrl,2);

        LoadDisplayList();

        hwndCtrl = getDlgItem(IDC_FILTERMODE);
        ComboBox_AddString(hwndCtrl, "No Filter");
        ComboBox_AddString(hwndCtrl, "Combined");
        ComboBox_AddString(hwndCtrl, "Percent");
        ComboBox_SetCurSel(hwndCtrl, (int)config->getLiveViewFilterMode());

        hwndCtrl = getDlgItem(IDC_WIDESCREEN);
        Button_SetCheck(hwndCtrl, config->getLiveView_WidescreenMode());

        SetupSliderControl(IDC_EdgeWeighting,1,30,config->getLiveView_EdgeWeighting(),5);
        SendMessage(getDlgItem(IDC_EdgeWeighting),TBM_SETPAGESIZE,0,2);
        sprintf(buffer,"Edge weighting [%d]",config->getLiveView_EdgeWeighting());
        SetStaticText(IDC_TXT_EDGEWEIGHTNING, buffer);

        SetupSliderControl(IDC_BrightCorrect,50,300,config->getLiveView_BrightCorrect(),15);
        SendMessage(getDlgItem(IDC_BrightCorrect),TBM_SETPAGESIZE,0,10);
        sprintf(buffer,"Brightness [%d%%]",config->getLiveView_BrightCorrect());
        SetStaticText(IDC_TXT_BRIGHTCORRECT, buffer);

        SetupSliderControl(IDC_DarknessLimit,0,10,config->getLiveView_DarknessLimit(),1);
        SendMessage(getDlgItem(IDC_DarknessLimit),TBM_SETPAGESIZE,0,1);
        sprintf(buffer,"Darkness Limit [%d]",config->getLiveView_DarknessLimit());
        SetStaticText(IDC_TXT_DARKNESSLIMIT, buffer);

        SetupSliderControl(IDC_HueWinSize,0,5,config->getLiveView_HueWinSize(),1);
        SendMessage(getDlgItem(IDC_HueWinSize),TBM_SETPAGESIZE,0,1);
        sprintf(buffer,"Hue windowing [%d]",config->getLiveView_HueWinSize());
        SetStaticText(IDC_TXT_HUEWINSIZE, buffer);

        SetupSliderControl(IDC_SatWinSize,0,5,config->getLiveView_SatWinSize(),1);
        SendMessage(getDlgItem(IDC_SatWinSize),TBM_SETPAGESIZE,0,1);
        sprintf(buffer,"Sat windowing [%d]",config->getLiveView_SatWinSize());
        SetStaticText(IDC_TXT_SATWINSIZE, buffer);

        SetupSliderControl(IDC_Filter_MeanLength,300,5000,config->getLiveViewFilter_MeanLength(),0);
        SendMessage(getDlgItem(IDC_Filter_MeanLength),TBM_SETPAGESIZE,0,100);
        sprintf(buffer,"Filter length [%d ms]",config->getLiveViewFilter_MeanLength());
        SetStaticText(IDC_TXT_Filter_MeanLength, buffer);

        SetupSliderControl(IDC_Filter_MeanThreshold,1,100,config->getLiveViewFilter_MeanThreshold(),0);
        SendMessage(getDlgItem(IDC_Filter_MeanThreshold),TBM_SETPAGESIZE,0,5);
        sprintf(buffer,"Filter threshold [%d%%]",config->getLiveViewFilter_MeanThreshold());
        SetStaticText(IDC_TXT_Filter_MeanThreshold, buffer);

        SetupSliderControl(IDC_Filter_PercentNew,1,100,config->getLiveViewFilter_PercentNew(),0);
        SendMessage(getDlgItem(IDC_Filter_PercentNew),TBM_SETPAGESIZE,0,5);
        sprintf(buffer,"Filter smoothness [%d%%]",config->getLiveViewFilter_PercentNew());
        SetStaticText(IDC_TXT_Filter_PercentNew, buffer);

        return ATMO_FALSE;
}
예제 #13
0
ATMO_BOOL CAtmoLiveSettings::ExecuteCommand(HWND hControl,int wmId, int wmEvent) {

    switch(wmId) {
        case IDOK: {
           CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();

           if(UpdateLiveViewValues(ATMO_FALSE) == ATMO_FALSE) return 0;

           EndDialog(this->m_hDialog, wmId);
           break;
        }

        case IDCANCEL: {
            // m_pBackupConfig --> wieder herstellen...
            CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
            pAtmoConfig->Assign(this->m_pBackupConfig);

            EndDialog(this->m_hDialog, wmId);
            break;
        }

        case IDC_WIDESCREEN: {
            CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
            if(Button_GetCheck(hControl) == BST_CHECKED)
               pAtmoConfig->setLiveView_WidescreenMode(1);
            else
               pAtmoConfig->setLiveView_WidescreenMode(0);
            break;
        }

        case IDC_FILTERMODE: {
             /// CBN_SELCHANGE
            if(wmEvent == CBN_SELCHANGE) {
               CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
               int i = ComboBox_GetCurSel(hControl);
               pAtmoConfig->setLiveViewFilterMode((AtmoFilterMode)i);
            }
            break;
        }

        case IDC_DISPLAYS: {
            if(wmEvent == CBN_SELCHANGE) {
               CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
               int i = ComboBox_GetCurSel(hControl);
               if(i != pAtmoConfig->getLiveView_DisplayNr()) {
                  UpdateLiveViewValues( pAtmoConfig->getEffectMode() == emLivePicture );
               }
            }
            break;
        }

        case IDC_GDI_CAPURE_RATE: {
            if(wmEvent == EN_CHANGE) {
                char buffer[20];
                if(Edit_GetText(hControl,buffer,sizeof(buffer))>0) {
                    int value = atoi(buffer);
                    if((value>=1) && (value<=50)) {
                        CAtmoConfig *pAtmoConfig = this->m_pDynData->getAtmoConfig();
                        pAtmoConfig->setLiveView_GDI_FrameRate(value);
                    } else {
                        MessageBeep(MB_ICONEXCLAMATION);
                    }
                }
            }
            break;
        }

       default:
           return ATMO_FALSE;

    }

    return ATMO_TRUE;
}
// Opens the input-device. Parameters (e.g. the device-name) can be given in 'param'.
// Returns true if the input-device was opened successfully.
ATMO_BOOL CAtmoGdiDisplayCaptureInput::Open() {

     CAtmoConfig *pAtmoConfig = m_pAtmoDynData->getAtmoConfig();
     CAtmoDisplays *pAtmoDisplays = m_pAtmoDynData->getAtmoDisplays();
     
	 m_rowsPerFrame = pAtmoConfig->getLiveView_RowsPerFrame();
     if(m_rowsPerFrame < 1) m_rowsPerFrame = 1;
     if(m_rowsPerFrame >= CAP_HEIGHT) m_rowsPerFrame = CAP_HEIGHT - 1;
     m_CurrentFrame = 0; // halbbild counter
     
     // clear temp hsv image 
     memset(&HSV_Img, 0, IMAGE_SIZE * sizeof(tHSVColor) );

#ifndef UseGdiDesktopGetPixel
     // setup handles and stuff for screen copy ...
     m_hdcScreen      = GetDC(NULL);

     // used as device context for temporary screenshot bitmap
     m_hTempBitmapDC  = CreateCompatibleDC(m_hdcScreen);
#endif

     int displayNr = pAtmoConfig->getLiveView_DisplayNr();
     if(displayNr >= pAtmoDisplays->getCount())
        displayNr = 0; // drop back to display 0 ;-)
     TAtmoDisplayInfo dislayInfo = pAtmoDisplays->getDisplayInfo(displayNr);


     // here TODO insert Screen! - in the config we have the display number to use
     // get resolution of this display and its position in the world of the current
     // windows desktop device context....!!! todo!
     m_ScreenSourceRect.left   = dislayInfo.horz_ScreenPos + pAtmoConfig->getLiveView_HOverscanBorder();
     m_ScreenSourceRect.top    = dislayInfo.vert_ScreenPos + pAtmoConfig->getLiveView_VOverscanBorder();
     m_ScreenSourceRect.right  = m_ScreenSourceRect.left + dislayInfo.horz_res - (2 * pAtmoConfig->getLiveView_HOverscanBorder());
     m_ScreenSourceRect.bottom = m_ScreenSourceRect.top  + dislayInfo.vert_res - (2 * pAtmoConfig->getLiveView_VOverscanBorder());

     // calculate lShift and tShift?
     /*
       for what?
       ok ... lets do some basics... our temp picutre has 64 columns?
       our source (my desktop) is 1600 columns wide?
       ... so i Have to grab every 64th Pixel?
       a simple calculation would result into
       destination column 0:   --> source column 0
       destincation column 63: --> source column 1575 ... so we will lose 25 pixel to the right?
       so m_lShift is the value we have to move the "Grab Raster to right" so that
       destination column 0:   --> source column 12
       destincation column 63: --> source column 1587 ... so we will lose 12 pixel to the right and 12 to the left.. a nice small ignored Border around...

       that same happens to the row position...
     */

     // precalculate Pixel Coordinates for Capture to save some cpu time?
     int capture_area_width  = m_ScreenSourceRect.right - m_ScreenSourceRect.left;
     int capture_area_height = m_ScreenSourceRect.bottom - m_ScreenSourceRect.top;
     for(int y=1;y<=CAP_HEIGHT;y++) {
         m_iSrcRows[y-1] = ((y * capture_area_height) / (CAP_HEIGHT+1) );
     }
     for(int x=1;x<=CAP_WIDTH;x++) {
         m_iSrcCols[x-1] = ((x * capture_area_width) / (CAP_WIDTH+1) );
     }
     // 25.09.2007 Igor: + m_ScreenSourceRect.left +m_ScreenSourceRect.top --> ist falsch
     // weil die Koordinaten in m_iSrcCols und m_iSrcRows - beziehen sich ja schon auf die mittels m_ScreenSourceRect erzeugte
     // Kopie des Desktops Device Contexts ... thanks to MacGyver for debugging.

#ifndef UseGdiGetPixel
     // should be enough memory for one row of pixels! in each Color Depth?
     m_PixelBuffer = (unsigned char *)malloc((capture_area_width+1) * 4);
#endif

     // run this thread
     this->Run();
     return true;
}