Exemplo n.º 1
0
/*virtual*/ void CMainWnd::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
    if ( pSender == &m_wndToolBar )
    {
        if ( code == ToWord('L', 'D') && data )	// Layout disable
        {
            CWnd* pLayout = (CWnd*)data;
            SendMessage( pLayout, code, 0 );
            pLayout->ShowWindow( SwHide );
        }
        if ( code == ToWord('L', 'E') && data )	// Layout enable
        {
            CWnd* pLayout = (CWnd*)data;
            SendMessage( pLayout, code, 0 );
            pLayout->ShowWindow( SwShow );
        }
        if ( code == ToWord('L', 'R') )	// Layout reset
        {
            Invalidate();
        }
    }
    /*
    	if ( pSender == NULL && code == WmBroadcast && data == ToWord('d', 'g') )
    	{
    		if ( m_wndGraph.m_dwFlags & WsVisible )
    			m_wndGraph.Invalidate();
    		else if ( m_wndSpectrumGraph.m_dwFlags & WsVisible )
    			m_wndSpectrumGraph.Invalidate();
    		else if ( GetFocus() != this )
    			SendMessage( GetFocus(), code, data );
    	}
    	*/
}
Exemplo n.º 2
0
/*virtual*/ void CMainWnd::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
    if ( pSender == &m_wndToolBar )
    {
        if ( code == ToWord('f', 'c') )	// focus changed
        {
            m_wndMenuInput.ShowWindow( ( data == 0 ) ? SwShow : SwHide );
            m_wndMenuCursor.ShowWindow( ( data == 1 ) ? SwShow : SwHide );
            m_wndMenuMeas.ShowWindow( ( data == 2 ) ? SwShow : SwHide );
            m_wndMenuMath.ShowWindow( ( data == 3 ) ? SwShow : SwHide );
            m_wndMenuDisplay.ShowWindow( ( data == 4 ) ? SwShow : SwHide );
            m_wndMenuGenerator.ShowWindow( ( data == 5 ) ? SwShow : SwHide );
            m_wndMenuSettings.ShowWindow( ( data == 6 ) ? SwShow : SwHide );
            m_wndMenuTools.ShowWindow( ( data == 7 ) ? SwShow : SwHide );

            m_wndGraph.ShowWindow( ( data != 5 ) ? SwShow : SwHide );
            m_wndZoomBar.ShowWindow( ( data != 5 ) ? SwShow : SwHide );
            m_wndLReferences.ShowWindow( ( data != 5 ) ? SwShow : SwHide );
            m_wndTReferences.ShowWindow( ( data != 5 ) ? SwShow : SwHide );
            m_wndSignalGraph.ShowWindow( ( data == 5 ) ? SwShow : SwHide );
            Invalidate();
        }
    }
    if (code == ToWord('d', 'g'))
    {
        if ( m_wndGraph.m_dwFlags & WsVisible )
            m_wndGraph.Invalidate();
    }
}
Exemplo n.º 3
0
/*virtual*/ void CWndTuner::OnMessage(CWnd *pSender, ui16 code, ui32 data) {
  static int nOldResolution, nOldSync;

  if (pSender == NULL && code == WmBroadcast && data == ToWord('d', 'g')) {
    m_bWave = true;
    Invalidate();
    m_bWave = false;
    return;
  }

  // LAYOUT ENABLE/DISABLE FROM TOP MENU BAR
  if (code == ToWord('L', 'D')) {
    Settings.Time.Resolution = (CSettings::TimeBase::EResolution)nOldResolution;
    Settings.Trig.Sync = (CSettings::Trigger::ESync)nOldSync;
    CCoreOscilloscope::ConfigureAdc();
    return;
  }

  if (code == ToWord('L', 'E')) {
    nOldResolution = Settings.Time.Resolution;
    nOldSync = Settings.Trig.Sync;
    Settings.Time.Resolution = CSettings::TimeBase::_5ms;
    Settings.Trig.Sync = CSettings::Trigger::_Scan;
    CCoreOscilloscope::ConfigureAdc();
    return;
  }
}
Exemplo n.º 4
0
/*virtual*/ void CWndToolBar::ChangeFocus(ui8 oldFocus)
{
	const CWndToolBar::CBarItem* pItems = GetMenuItems();
	SendMessage( GetParent(), ToWord('L', 'D'), (NATIVEPTR)pItems[oldFocus].m_pWndMenu );
	SendMessage( GetParent(), ToWord('L', 'E'), (NATIVEPTR)pItems[m_nFocus].m_pWndMenu );
	SendMessage( GetParent(), ToWord('L', 'R'), 0 );
	Settings.Runtime.m_nMenuItem = m_nFocus;
}
Exemplo n.º 5
0
void CMainWnd::Create()
{
    m_pInstance = this;

    // image correctly uploaded in ROM ?
    _ASSERT(
        CSettings::TimeBase::ppszTextResolution[CSettings::TimeBase::_1s][0] == '1' &&
        CSettings::TimeBase::ppszTextResolution[CSettings::TimeBase::_1s][1] == 's' &&
        CSettings::TimeBase::ppszTextResolution[CSettings::TimeBase::_1s][2] == 0 );

    //Settings.Save();
    //Settings.SaveCalibration();

    Settings.Load();
    Settings.LoadCalibration();

    CWnd::Create("CMainWnd", WsVisible, CRect(0, 0, BIOS::LCD::LcdWidth, BIOS::LCD::LcdHeight), NULL );

    m_wndToolBar.Create( this );
    m_wndGraph.Create( this, WsHidden | WsNoActivate );
    m_wndSignalGraph.Create( this, WsNoActivate );
    m_wndSpectrumGraph.Create( this, WsNoActivate );

    m_wndMenuInput.Create( this, WsHidden );
    m_wndMenuCursor.Create( this, WsHidden );
    m_wndMenuMeas.Create( this, WsHidden );
    m_wndMenuMath.Create( this, WsHidden );
    m_wndMenuSettings.Create( this, WsHidden );
    m_wndMenuDisplay.Create( this, WsHidden );
    m_wndMenuGenerator.Create( this, WsHidden );
    m_wndMenuTools.Create( this, WsHidden );
    m_wndZoomBar.Create( this, WsHidden, &m_wndGraph );
    m_wndLReferences.Create( this, WsHidden );
    m_wndTReferences.Create( this, WsHidden );
    m_wndSpectrumMain.Create( this, WsHidden );
    m_wndScreenSaver.Create( this, WsHidden );
    m_wndUserGame.Create( this, WsHidden );
    m_wndUserBalls.Create( this, WsHidden );
    m_wndUserMeter.Create( this, WsHidden );
    m_wndModuleSel.Create(this, WsHidden );
    m_wndUserCalibration.Create( this, WsHidden );

    m_wndToolbox.Create(this);

    if ( Settings.Runtime.m_nMenuItem != -1 )
        SendMessage( &m_wndToolBar, ToWord('g', 'i'), Settings.Runtime.m_nMenuItem);
    else
        SendMessage( &m_wndToolBar, ToWord('g', 'i'), 1);

    //m_wndToolBar.SetFocus();
    //SendMessage( &m_wndToolBar, ToWord('g', 'o'), (ui32)"Meter");
    //m_wndMenuInput.m_itmCH1.SetFocus();
    //m_wndMenuGenerator.m_itmBpm.SetFocus();
    //OnMessage( &m_wndToolBar, ToWord('f', 'c'), 0 ); // force update

    SetTimer(1000);
}
Exemplo n.º 6
0
/*virtual*/ void CWndListCalDac::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	if ( pSender == &m_itmANumber && code == ToWord('u', 'p') )	
	{
		if ( m_nValueA < 100 )
		{
			m_nValueA = 100;
			m_itmANumber.Invalidate();
		}
		if ( m_nValueA > 8000 )
		{
			m_nValueA = 8000;
			m_itmANumber.Invalidate();
		}
		BIOS::GEN::ConfigureDc( m_nValueA );
	}
	if ( pSender == &m_itmBNumber && code == ToWord('u', 'p') )	
	{
		if ( m_nValueB < 100 )
		{
			m_nValueB = 100;
			m_itmBNumber.Invalidate();
		}
		if ( m_nValueB > 8000 )
		{
			m_nValueB = 8000;
			m_itmBNumber.Invalidate();
		}
		BIOS::GEN::ConfigureDc( m_nValueB );
	}

	// Selector
	if ( pSender == &m_itmExecute && code == ToWord('l', 'e') )	// provider selector combo box
	{
		Save();
		StopModal();
		//MainWnd.m_wndConfirm.Show( this, "Message", "Do you really want to\nsave these settings?", RGB565(ffff00), "Yes", "No");
	}
	/*
	if ( pSender == &MainWnd.m_wndConfirm && code == ToWord('e', 'd') && data == (ui32)"Yes" )
	{
		MainWnd.m_wndConfirm.Hide();
		StopModal();
		Save();
		Settings.SaveCalibration();
		MainWnd.m_wndMessage.Show( this, "Message", "Values saved", RGB565(ffff00));
	}
	if ( pSender == &MainWnd.m_wndConfirm && code == ToWord('e', 'd') && data == (ui32)"No" )
	{
		MainWnd.m_wndConfirm.Hide();
		StopModal(); // hide this list
	}*/
}
Exemplo n.º 7
0
/*virtual*/ void CWndMenuSpectMain::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	// LAYOUT ENABLE/DISABLE FROM TOP MENU BAR
	if (code == ToWord('L', 'D') )
	{
		MainWnd.m_wndSpectrumGraph.ShowWindow( SwHide );
	}

	if (code == ToWord('L', 'E') )
	{
		MainWnd.m_wndSpectrumGraph.ShowWindow( SwShow );
	}
}
Exemplo n.º 8
0
void CMainWnd::CallShortcut(int nShortcut)
{
	static int nOldFocus = -1;
	if ( nShortcut >= 0 )
	{
		// +1 => first submenu in section
		if ( nShortcut == MainWnd.m_wndToolBar.m_nFocus )
		{
			if ( nOldFocus != -1 )
				SendMessage( &MainWnd.m_wndToolBar, ToWord('g', '2'), nOldFocus );
		} else {
			nOldFocus = MainWnd.m_wndToolBar.m_nFocus;
			SendMessage( &MainWnd.m_wndToolBar, ToWord('g', '2'), nShortcut );
		}
		return;
	}
	switch ( nShortcut )
	{
		case CSettings::CRuntime::None:
			break;
		case CSettings::CRuntime::StartStop:
			m_wndToolbox.ToggleAdc();
			break;
		case CSettings::CRuntime::Toolbox:
			if ( !m_wndToolbox.IsVisible() && !m_wndManager.IsVisible() )
			{
				m_wndToolbox.DoModal();
				if ( m_wndToolbox.GetResult() == CWndToolbox::MenuManager)
				{
					m_wndManager.Create(this);
					m_wndManager.DoModal();
				}
			}
			break;
		case CSettings::CRuntime::WaveManager:
			if ( m_wndManager.IsVisible() )
				m_wndManager.Cancel();
			else
			{
				m_wndManager.Create(this);
				m_wndManager.DoModal();
			}
			break;
		case CSettings::CRuntime::Screenshot:
			m_wndToolbox.SaveScreenshot16();
			break;
	default:
		_ASSERT( !!!"Unknown shortcut" );
	}
}
Exemplo n.º 9
0
void CWnd::ShowWindow(ui8 sh)
{
	if ( sh == SwShow )
	{
		if ( !(m_dwFlags & WsVisible) )
			OnMessage( this, ToWord('S', 'H'), 1 ); 
		m_dwFlags |= WsVisible;
	}
	else
	{
		if ( m_dwFlags & WsVisible )
			OnMessage( this, ToWord('S', 'H'), 0 ); 
		m_dwFlags &= ~WsVisible;
	}
}
Exemplo n.º 10
0
/*virtual*/ void CWndModuleSelector::OnKey(ui16 nKey)
{
	if ( nKey & BIOS::KEY::KeyEnter )
	{
		const char* strTarget = NULL;
		if ( GetFocus() == &m_itmOscilloscope )
			strTarget = "Oscilloscope"; 
		if ( GetFocus() == &m_itmSpectrum )
			strTarget = "Spectrum";
		if ( GetFocus() == &m_itmGenerator )
			strTarget = "Generator"; 
		if ( GetFocus() == &m_itmSettings )
			strTarget = "Settings"; 
		if ( GetFocus() == &m_itmAbout )
			strTarget = "About";
		if ( GetFocus() == &m_itmUser )
			strTarget = "User app";
		
		if (strTarget)
		{
			SendMessage( &MainWnd.m_wndToolBar, ToWord('g', 'o'), (NATIVEPTR)strTarget);
		} else {
			MainWnd.m_wndMessage.Show(this, "Info", "Sorry, not implemented", RGB565(FFFF00));
		}
		return;
	}
	CWnd::OnKey( nKey );
}
Exemplo n.º 11
0
/*virtual*/ void CWnd::WindowMessage(int nMsg, int nParam /*=0*/)
{
	switch (nMsg)
	{
		case WmPaint:
		{
			OnPaint();

			CWnd *pChild = m_pFirst;
			while (pChild)
			{
				if ( pChild->m_dwFlags & WsVisible )
					pChild->WindowMessage( WmPaint );
				pChild = pChild->m_pNext;
			}
		}	
		break;
		case WmKey:
		{
			if ( GetActiveWindow() )
				GetActiveWindow()->OnKey( nParam );
		}
		break;
		case WmTick:
		{
			if ( m_pParent == NULL )
				_UpdateTimers();

			if ( m_dwFlags & WsTick )
				SendMessage( this, ToWord('t', 'i'), 0 );

			CWnd *pChild = m_pFirst;
			while (pChild)
			{
				if ( pChild->m_dwFlags & WsVisible )
					pChild->WindowMessage( WmTick );
				pChild = pChild->m_pNext;
			}
		}
		break;
		case WmBroadcast:
		{
			if ( m_dwFlags & WsListener )
				OnMessage( NULL, WmBroadcast, nParam );

			CWnd *pChild = m_pFirst;
			while (pChild)
			{
				if ( pChild->m_dwFlags & WsVisible )
					pChild->WindowMessage( WmBroadcast, nParam );
				pChild = pChild->m_pNext;
			}
		}
		break;
	}	
}
Exemplo n.º 12
0
void CWndUserMonitor::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	if ( code == ToWord('t', 'i') )
	{
		OnTick();
		return;
	}

	// LAYOUT ENABLE/DISABLE FROM TOP MENU BAR
	if (code == ToWord('L', 'D') )
	{
		KillTimer();
		return;
	}

	if (code == ToWord('L', 'E') )
	{
		m_x = 0;
		m_y = 0;
		SetTimer(500);
		return;
	}
	
	if ( pSender == &m_itmBaud && code == ToWord('u', 'p') )
	{
		int nBaudrate = m_pnValueBaud[m_nBaud];
		BIOS::SERIAL::Configure( nBaudrate );
	}

	if ( pSender == &m_btnClear && code == CWnd::WmKey && data == BIOS::KEY::KeyEnter )
	{
		m_x = 0;
		m_y = 0;
		BIOS::LCD::Bar( 4, 24, 4+32*8, 24 + 12*16, RGB565(000000) );
	}
	/*
	if ( pSender == &m_btnSend && code == CWnd::WmKey && data == BIOS::KEY::KeyEnter )
	{
		BIOS::SERIAL::Send("Hello");
	}
	*/
}
Exemplo n.º 13
0
/*virtual*/ void CWndListCalSimple::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{	
	if ( pSender == NULL && code == WmBroadcast && data == ToWord('d', 'g') )
	{
		OnWave();
		return;
	}

	if ( pSender == &m_itmReset && code == ToWord('l', 'e') )
	{
		MainWnd.m_wndConfirm.Show( this, "Message", "Connect probe to ground\nReady?", RGB565(ffff00), "Yes", "No");
		return;
	}
	if ( pSender == &MainWnd.m_wndConfirm && code == ToWord('e', 'd') && data == (ui32)"Yes" )
	{
		m_proReset.m_pName = "Wait...";
		m_itmReset.Invalidate();

		m_nResetPhase = 0;
		MainWnd.m_wndConfirm.Hide();
		return;
	}
	if ( pSender == &MainWnd.m_wndConfirm && code == ToWord('e', 'd') && data == (ui32)"No" )
	{
		MainWnd.m_wndConfirm.Hide();
		return;
	}

	if ( pSender == &m_itmSave && code == ToWord('l', 'e') )
	{
		SaveCalib();
		StopModal();
		return;
	}

	if ( pSender == &m_itmNumber && code == ToWord('u', 'p') )
	{
		int nNewVal = m_nValue;
		UTILS.Clamp<int>(m_nValue, 256, 4096);
		if ( nNewVal != m_nValue )
			m_itmNumber.Invalidate();

		_UpdateCalib( m_nValue, V_LEVEL );
		UpdateZero();  // TODO: neni treba!
	}

	if ( ( pSender == &m_itmSource || pSender == &m_itmResolution ) && code == ToWord('u', 'p') )
	{
		LoadCalib();
		UpdateZero();
		return;
	}

	CListBox::OnMessage( pSender, code, data );
}
Exemplo n.º 14
0
Arquivo: Dmm.cpp Projeto: fredzo/DS203
/* virtual */ void CWndDmm::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	// LAYOUT ENABLE/DISABLE FROM TOP MENU BAR
	if ((code == ToWord('L', 'D') )||(code == ToWord('S', 'H') && data == 0))
	{	// TODO restore channel settings
		bTimer = false;
		KillTimer();
		return;
	}

	if ((code == ToWord('L', 'E') )||(code == ToWord('S', 'H') && data == 1 ))
	{	// TODO backup channel settings
		// Configure ADC accrding to DMM settings
		MainWnd.m_wndDmmMeas.ConfigureAdc();
		bRefresh = true;
		return;
	}

	if ( pSender == NULL && code == WmBroadcast && data == ToWord('d', 'g') )
	{
		OnPaint(false);
		return;
	}

	if (code == ToWord('t', 'i') )
	{
		// OnTick
		OnTick(false);
		return;
	}
}
Exemplo n.º 15
0
void CMainWnd::OnMouseClick()
{
	CWnd* pTopDialog = GetFocus();
	while ( pTopDialog->m_pParent )
	{
		if ( pTopDialog->m_dwFlags & CWnd::WsModal )
			break;
		pTopDialog = pTopDialog->m_pParent;
	}

	CWnd* pWnd = GetWindowByPoint( pTopDialog, m_Mouse.GetX(), m_Mouse.GetY() );
	if ( pWnd )
	{
		if ( pWnd == pTopDialog )
		{
		} else
		if ( pWnd == GetFocus() )
		{
			if ( !(pWnd->m_dwFlags & CWnd::WsNoActivate) )
			{
				bool bProcess = true;
				pTopDialog->SendMessage( pWnd, ToWord('M', 'D'), (NATIVEPTR)&bProcess );
				if ( bProcess )
					pWnd->WindowMessage( CWnd::WmKey, BIOS::KEY::KeyEnter );
			}
		} else if ( !(pWnd->m_dwFlags & CWnd::WsNoActivate) )
		{
			CWnd* pPrevFocus = GetFocus();
			pWnd->SetFocus();
			pPrevFocus->Invalidate();
			bool bProcess = false;
			pTopDialog->SendMessage( pWnd, ToWord('M', 'C'), (NATIVEPTR)&bProcess );
			pWnd->Invalidate();
		}
	} else
	{
		GetFocus()->WindowMessage( CWnd::WmKey, BIOS::KEY::KeyEscape );
	}
}
Exemplo n.º 16
0
void CWndManager::DoModal()
{
	m_bRunning = true;
	
	OnMessage( &m_itmTabs, ToWord('u', 'p'), 0 );
	StartModal( &m_itmValue );
	
	while ( IsRunning() )
	{
		Sleep(20);
	}
	StopModal();
}
Exemplo n.º 17
0
/*virtual*/ void CMainWnd::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	if ( pSender == &m_wndToolBar )
	{
		if ( code == ToWord('L', 'D') && data )	// Layout disable
		{
			CWnd* pLayout = (CWnd*)data;
			SendMessage( pLayout, code, 0 );
			pLayout->ShowWindow( SwHide );
		}
		if ( code == ToWord('L', 'E') && data )	// Layout enable
		{
			CWnd* pLayout = (CWnd*)data;
			SendMessage( pLayout, code, 0 );
			pLayout->ShowWindow( SwShow );
		}
		if ( code == ToWord('L', 'R') )	// Layout reset
		{
			Invalidate();
		}
		return;
	}
}
Exemplo n.º 18
0
/*virtual*/ void CMainWnd::OnTimer()
{
	// every 200ms
	static int nSubCounter = 0;

	if ( ++nSubCounter == 5 )
	{
		nSubCounter = 0;
		static ui32 nChecksum = -1;
		static int nSeconds = 0;
		nSeconds++;

		if ( Settings.Runtime.m_nStandby != 0 )
		{
			if ( (int)BIOS::SYS::GetTick() > m_nLastKey + Settings.Runtime.m_nStandby*60000 )
			{
				// enter sleep mode
				BIOS::SYS::SetVolume(0);
				m_wndMessage.Show(this, "Information", "Entering sleep mode", RGB565(ffff00));
				BIOS::ADC::Enable( FALSE );
				for ( int i = Settings.Runtime.m_nBacklight; i > 0; i--)
				{
					BIOS::SYS::SetBacklight( i );
					BIOS::SYS::DelayMs(10);
				}
				BIOS::SYS::Standby( TRUE );
				m_bSleeping = TRUE;
				KillTimer();
			}
		}

 		if ( nChecksum == (ui32)-1 )
		{
			int nUptime = Settings.Runtime.m_nUptime;
			Settings.Runtime.m_nUptime = 0;
			nChecksum = Settings.GetChecksum();
			Settings.Runtime.m_nUptime = nUptime;
		}
		if ( Settings.m_lLastChange != 0 )
		{
			// save settings in 20 seconds
			nSeconds = 120 - 20;
			Settings.m_lLastChange = 0;
		}
		if ( nSeconds >= 120 )
		{
			nSeconds = 0;
	
			ui32 nNewChecksum = Settings.GetStaticChecksum();
			if ( nNewChecksum != nChecksum )
			{
				//m_wndMessage.Show(this, "Information", "Saving settings...", RGB565(ffff00));
				Settings.Save();
				nChecksum = nNewChecksum;
			}
		}

		if ( Settings.Runtime.m_bUartTest )
		{
			char test[32];
			static int nCounter=0;
			BIOS::DBG::sprintf(test, "Ready.(%d)\n", nCounter++);
			BIOS::SERIAL::Send("TEST!");
			BIOS::SERIAL::Send(test);
		}
	}

	if ( BIOS::ADC::Enabled() && Settings.Trig.Sync == CSettings::Trigger::_Auto )
	{
		if ( m_lLastAcquired != -1 && BIOS::SYS::GetTick() - m_lLastAcquired > 150 )
		{
			bool bScreenReady = BIOS::ADC::GetPointer() > (300 + Settings.Time.InvalidFirst);
			BIOS::ADC::Copy( BIOS::ADC::GetCount() );

			// redraw the screen even when the sampler is not full
			//BIOS::LCD::Print(0, 0, RGB565(ff0000), 0, "U");
			WindowMessage( CWnd::WmBroadcast, ToWord('d', 'g') );
			//BIOS::LCD::Print(0, 0, RGB565(808080), 0, "u");
		
			// force restart if the write pointer is behind current window
			// TODO: the FPGA program is unreliable and stupid!, the restart wont reset the WPTR to begin of buffer
			if ( bScreenReady )
			{
				//BIOS::LCD::Print(0, 0, RGB565(ff0000), 0, "R");
				BIOS::ADC::Restart();
			} 
		}
	}
}
Exemplo n.º 19
0
void CMainWnd::Create()
{
	m_pInstance = this;

	// image correctly uploaded in ROM ?
	_ASSERT( 
		CSettings::TimeBase::ppszTextResolution[CSettings::TimeBase::_1s][0] == '1' &&
		CSettings::TimeBase::ppszTextResolution[CSettings::TimeBase::_1s][1] == 's' &&
		CSettings::TimeBase::ppszTextResolution[CSettings::TimeBase::_1s][2] == 0 );

	Settings.Load();
	Settings.LoadCalibration();
	CCoreOscilloscope::ConfigureAdc();
	CCoreGenerator::Update();
	CCoreSettings::Update();

	m_nLastKey = BIOS::SYS::GetTick();
	m_bSleeping = FALSE;
	
	CWnd::Create("CMainWnd", WsVisible | WsListener, CRect(0, 0, BIOS::LCD::LcdWidth, BIOS::LCD::LcdHeight), NULL );

	m_wndToolBar.Create( this );
	m_wndGraph.Create( this, WsHidden | WsNoActivate );
	m_wndSignalGraph.Create( this, WsNoActivate );
	m_wndSpectrumGraph.Create( this, WsNoActivate );
	m_wndSpectrumMiniFD.Create( this, WsNoActivate );
	m_wndSpectrumMiniTD.Create( this, WsNoActivate );
	m_wndSpectrumMiniSG.Create( this, WsNoActivate );

	m_wndMenuInput.Create( this, WsHidden );
	m_wndMenuCursor.Create( this, WsHidden );
	m_wndMenuMeas.Create( this, WsHidden );
	m_wndMenuMath.Create( this, WsHidden );
	m_wndMenuSettings.Create( this, WsHidden );
	m_wndMenuKeySettings.Create( this, WsHidden );
	m_wndMenuDisplay.Create( this, WsHidden );
	m_wndMenuMask.Create( this, WsHidden );
	m_wndMenuGenerator.Create( this, WsHidden );
//	m_wndMenuGeneratorMod.Create( this, WsHidden );
	m_wndMenuGeneratorEdit.Create( this, WsHidden );
	m_wndZoomBar.Create( this, WsHidden, &m_wndGraph );
	m_wndInfoBar.Create( this, WsHidden, &m_wndGraph );
	m_wndLReferences.Create( this, WsHidden );
	m_wndLReferencesM.Create( this, WsHidden );
	m_wndTReferences.Create( this, WsHidden );
	m_wndSpectrumMain.Create( this, WsHidden );
	m_wndSpectrumMarker.Create( this, WsHidden );
	m_wndSpectrumAnnot.Create( this, WsHidden );
	m_wndAboutFirmware.Create( this, WsHidden );
	m_wndAboutDevice.Create( this, WsHidden );
	m_wndAboutStatus.Create( this, WsHidden );
	m_wndAboutModules.Create( this, WsHidden );
	m_wndModuleSel.Create(this, WsHidden );
	m_wndCalibration.Create( this, WsHidden );

#	define ADD_MODULE( strName, type ) m_wndUser##type.Create( this, WsHidden );
#	include <Source/User/_Modules.h>
#	undef ADD_MODULE

	m_wndToolbox.Create(this);

	if ( Settings.Runtime.m_nMenuItem == -1 )
		Settings.Runtime.m_nMenuItem = 1;
	
	SendMessage( &m_wndToolBar, ToWord('g', 'i'), Settings.Runtime.m_nMenuItem);

	m_lLastAcquired = 0;
	SetTimer(200);
}
Exemplo n.º 20
0
/*virtual*/ void CWndToolBar::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	if ( code == ToWord('g', 'i') )
	{
		const CBarItem *pItems = GetMenuItems();
		m_nFocus = (ui8)data;
		CWnd* pFocus = GetFocus();
		SendMessage( GetParent(), ToWord('L', 'E'), (NATIVEPTR)pItems[m_nFocus].m_pWndMenu );
		if ( GetFocus() == pFocus )
		{
			// else the focus was stolen by the current wnd
			SetFocus();
		}
	}

	if ( code == ToWord('g', 'o') )
	{
		const char* strId = (const char*)data;
		int nItem = Find( strId );
		
		code = ToWord('g', '2');
		data = nItem;
	}

	if ( ( code == ToWord('M', 'C') || code == ToWord('M', 'D') ) && data )
	{
		// select menu item by mouse position
		bool* pProcess = (bool*)data;
		*pProcess = false;

		int nOldFocus = m_nFocus;
		int nNewFocus = _FindItemByPoint( BIOS::MOUSE::GetX() );
		if ( nNewFocus != -1 && nNewFocus != nOldFocus )
		{
			m_nFocus = nNewFocus;
			SetFocus();
			ChangeFocus(nOldFocus);
			Invalidate();
		}
	}

	if ( code == ToWord('g', '2') )
	{
		const CBarItem *pItems = GetMenuItems();

		int nItem = data;
		if ( nItem == -1 )
			return;

		SendMessage( GetParent(), ToWord('L', 'D'), (NATIVEPTR)pItems[m_nFocus].m_pWndMenu );

		if ( pItems[nItem].m_eType == CBarItem::IMain ) 
			m_nFocus = nItem+1;
		else
			m_nFocus = nItem;

		SendMessage( GetParent(), ToWord('L', 'E'), (NATIVEPTR)pItems[m_nFocus].m_pWndMenu );
		SetFocus();
		SendMessage( GetParent(), ToWord('L', 'R'), 0 );
		Settings.Runtime.m_nMenuItem = m_nFocus;
	}
}
Exemplo n.º 21
0
/*virtual*/ void CMainWnd::WindowMessage(int nMsg, int nParam /*=0*/)
{
//	BIOS::LCD::Printf( 0, 0, RGB565(ff0000), RGB565(ffffff), "%d", BIOS::ADC::GetState() );
	if ( nMsg == WmTick )
	{
		if ( m_bSleeping )
			return;

		m_Mouse.Hide();
		if ( m_Mouse.Clicked() )
			OnMouseClick();

		// timers update
		CWnd::WindowMessage( nMsg, nParam );
		bool bEnableSdk = Settings.Runtime.m_bUartSdk ? true : false;

#ifdef ENABLE_MONITOR
		// When the user is in UART monitor screen, do not intercept UART traffic
		if ( MainWnd.m_wndToolBar.GetCurrentLayout() == &MainWnd.m_wndUserCWndUserMonitor )
			bEnableSdk = false;
#endif

#ifdef ENABLE_MODULE_GPIOTEST
		if ( MainWnd.m_wndToolBar.GetCurrentLayout() == &MainWnd.m_wndUserCWndGpioTest )
			bEnableSdk = false;
#endif

		if ( bEnableSdk )
			SdkUartProc();

		if ( (Settings.Trig.Sync != CSettings::Trigger::_None) && BIOS::ADC::Enabled() && BIOS::ADC::Ready() )
		{
			// ADC::Ready means that the write pointer is at the end of buffer, we can restart sampler
			BIOS::ADC::Copy( BIOS::ADC::GetCount() );
			BIOS::ADC::Restart();
			Resample();

			// trig stuff
			m_lLastAcquired = BIOS::SYS::GetTick();
			if ( BIOS::ADC::Enabled() && Settings.Trig.Sync == CSettings::Trigger::_Single )
			{
				BIOS::ADC::Enable( false );
				Settings.Trig.State = CSettings::Trigger::_Stop;
				if ( m_wndMenuInput.m_itmTrig.IsVisible() )
					m_wndMenuInput.m_itmTrig.Invalidate();
			}

			// broadcast message for windows that process waveform data
			WindowMessage( CWnd::WmBroadcast, ToWord('d', 'g') );
		}
		m_Mouse.Show();
		return;
	}

	if ( nMsg == WmKey )
	{
		if ( m_bSleeping )
		{
			SetTimer( 200 );
			m_bSleeping = false;
			BIOS::SYS::Standby( FALSE );

			CCoreOscilloscope::ConfigureAdc();
			CCoreGenerator::Update();
			m_wndMessage.Hide();
			Invalidate();

			for ( int i = 0; i < Settings.Runtime.m_nBacklight; i++)
			{
				BIOS::SYS::SetBacklight( i );
				BIOS::SYS::DelayMs(10);
			}

			m_nLastKey = BIOS::SYS::GetTick();
			CCoreSettings::Update();	// display backlight
			return;
		}

		m_nLastKey = BIOS::SYS::GetTick();

		if ( nParam & ( BIOS::KEY::KeyFunction | BIOS::KEY::KeyFunction2 | BIOS::KEY::KeyS2 | BIOS::KEY::KeyS1 ) )
		{
			m_Mouse.Hide();
			if ( nParam == BIOS::KEY::KeyFunction )
				CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutCircle);

			if ( nParam == BIOS::KEY::KeyFunction2 )
				CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutTriangle);

			if ( nParam == BIOS::KEY::KeyS2 )
				CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutS2);

			if ( nParam == BIOS::KEY::KeyS1 )
				CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutS1);
			m_Mouse.Show();
			return;
		}
	}

	m_Mouse.Hide();
	CWnd::WindowMessage( nMsg, nParam );
	m_Mouse.Show();
}
Exemplo n.º 22
0
/*virtual*/ void CWndMenuMask::OnMessage(CWnd *pSender, CodeParam code,
                                         DataParam data) {
  if (pSender == NULL && code == WmBroadcast && data == ToWord('d', 'g')) {
    if (m_btnCollect.m_pszId != m_strStart) {
      CSettings::Calibrator::FastCalc Ch1fast;
      Settings.CH1Calib.Prepare(&Settings.CH1, Ch1fast);

      for (int i = 0; i < CWndGraph::DivsX * CWndGraph::BlkX; i++) {
        ui8 *bLow = NULL;
        ui8 *bHigh = NULL;
        CCoreOscilloscope::GetMaskAt(i, &bLow, &bHigh);

        BIOS::ADC::SSample Sample;
        Sample.nValue = BIOS::ADC::GetAt(Settings.Time.Shift + i);

        si16 ch1 = Sample.CH1;
        ch1 = Settings.CH1Calib.Correct(Ch1fast, ch1);
        UTILS.Clamp<si16>(ch1, 0, 255);

        *bLow = min(*bLow, (ui8)ch1);
        *bHigh = max(*bHigh, (ui8)ch1);
      }
    }
    if (m_Action != ActionNone || m_Display != DisplayNo) {
      bool bFailure = false;
      CSettings::Calibrator::FastCalc Ch1fast;
      Settings.CH1Calib.Prepare(&Settings.CH1, Ch1fast);

      for (int i = 0; i < CWndGraph::DivsX * CWndGraph::BlkX; i++) {
        ui8 *bLow = NULL;
        ui8 *bHigh = NULL;
        CCoreOscilloscope::GetMaskAt(i, &bLow, &bHigh);

        BIOS::ADC::SSample Sample;
        Sample.nValue = BIOS::ADC::GetAt(Settings.Time.Shift + i);

        si16 ch1 = Sample.CH1;
        ch1 = Settings.CH1Calib.Correct(Ch1fast, ch1);
        UTILS.Clamp<si16>(ch1, 0, 255);

        if (ch1 < *bLow || ch1 > *bHigh) {
          bFailure = true;
          break;
        }
      }

      int *nPass = NULL;
      int *nFail = NULL;
      CCoreOscilloscope::GetMaskStats(&nPass, &nFail);

      if (!bFailure)
        (*nPass)++;
      else {
        (*nFail)++;
        switch (m_Action) {
          case ActionNone:
            break;

          case ActionBeep:
            BIOS::SYS::Beep(100);
            break;

          case ActionBeepStop:
            BIOS::SYS::Beep(100);
            Settings.Trig.State = CSettings::Trigger::_Stop;
            BIOS::ADC::Enable(false);
            MainWnd.m_wndMessage.Show(&MainWnd, "Information",
                                      "Trigger was paused", RGB565(ffff00));
            break;

          case ActionStop:
            Settings.Trig.State = CSettings::Trigger::_Stop;
            BIOS::ADC::Enable(false);
            MainWnd.m_wndMessage.Show(&MainWnd, "Information",
                                      "Trigger was paused", RGB565(ffff00));
            break;
        }
      }
    }
    return;
  }

  // LAYOUT ENABLE/DISABLE FROM TOP MENU BAR
  if (code == ToWord('L', 'D')) {
    MainWnd.m_wndGraph.ShowWindow(SwHide);
    MainWnd.m_wndInfoBar.ShowWindow(SwHide);
  }

  if (code == ToWord('L', 'E')) {
    m_Action = ActionNone;
    MainWnd.m_wndGraph.ShowWindow(SwShow);
    MainWnd.m_wndInfoBar.ShowWindow(SwShow);
    for (int i = 0; i < CWndGraph::DivsX * CWndGraph::BlkX; i++) {
      ui8 *bLow = NULL;
      ui8 *bHigh = NULL;
      CCoreOscilloscope::GetMaskAt(i, &bLow, &bHigh);
      *bLow = 32;
      *bHigh = 255 - 32;
    }
  }

  if (pSender == &m_btnReset && code == CWnd::WmKey &&
      data == BIOS::KEY::KeyEnter) {
    CSettings::Calibrator::FastCalc Ch1fast;
    Settings.CH1Calib.Prepare(&Settings.CH1, Ch1fast);

    for (int i = 0; i < CWndGraph::DivsX * CWndGraph::BlkX; i++) {
      ui8 *bLow = NULL;
      ui8 *bHigh = NULL;
      CCoreOscilloscope::GetMaskAt(i, &bLow, &bHigh);

      BIOS::ADC::SSample Sample;
      Sample.nValue = BIOS::ADC::GetAt(Settings.Time.Shift + i);

      si16 ch1 = Sample.CH1;
      ch1 = Settings.CH1Calib.Correct(Ch1fast, ch1);
      UTILS.Clamp<si16>(ch1, 0, 255);
      *bLow = (ui8)ch1;
      *bHigh = (ui8)ch1;
    }
  }

  if (pSender == &m_btnExpand && code == CWnd::WmKey &&
      data == BIOS::KEY::KeyRight) {
    for (int i = 0; i < CWndGraph::DivsX * CWndGraph::BlkX; i++) {
      ui8 *bLow = NULL;
      ui8 *bHigh = NULL;
      CCoreOscilloscope::GetMaskAt(i, &bLow, &bHigh);

      if (*bLow > 0) (*bLow)--;
      if (*bHigh < 255) (*bHigh)++;
    }
  }

  if (pSender == &m_btnExpand && code == CWnd::WmKey &&
      data == BIOS::KEY::KeyLeft) {
    for (int i = 0; i < CWndGraph::DivsX * CWndGraph::BlkX; i++) {
      ui8 *bLow = NULL;
      ui8 *bHigh = NULL;
      CCoreOscilloscope::GetMaskAt(i, &bLow, &bHigh);

      if (*bLow < 255 && *bLow < *bHigh) (*bLow)++;
      if (*bHigh > 0 && *bHigh > *bLow) (*bHigh)--;
    }
  }

  if (pSender == &m_btnCollect && code == CWnd::WmKey &&
      data == BIOS::KEY::KeyEnter) {
    if (m_btnCollect.m_pszId == m_strStart) {
      // m_dwFlags |= CWnd::WsListener;
      m_btnCollect.m_pszId = m_strStop;
      m_btnCollect.Invalidate();
    } else if (m_btnCollect.m_pszId == m_strStop) {
      // m_dwFlags &= ~CWnd::WsListener;
      m_btnCollect.m_pszId = m_strStart;
      m_btnCollect.Invalidate();
    }
  }

  if (pSender == &m_btnBlur && code == CWnd::WmKey &&
      data == BIOS::KEY::KeyRight) {
    ui8 arrLow[3] = {0, 0, 0};
    ui8 arrHigh[3] = {255, 255, 25};
    for (int i = 0; i < CWndGraph::DivsX * CWndGraph::BlkX; i++) {
      ui8 *bLow = NULL;
      ui8 *bHigh = NULL;

      CCoreOscilloscope::GetMaskAt(i, &bLow, &bHigh);
      arrLow[0] = arrLow[1];
      arrLow[1] = arrLow[2];
      arrLow[2] = *bLow;

      arrHigh[0] = arrHigh[1];
      arrHigh[1] = arrHigh[2];
      arrHigh[2] = *bHigh;

      if (i >= 2) {
        CCoreOscilloscope::GetMaskAt(i - 1, &bLow, &bHigh);
        *bLow = BlurFilter(arrLow[0], arrLow[1], arrLow[2]);
        *bHigh = BlurFilterInv(arrHigh[0], arrHigh[1], arrHigh[2]);
      }
    }
  }

  if (pSender == &m_btnBlur && code == CWnd::WmKey &&
      data == BIOS::KEY::KeyLeft) {
    ui8 arrLow[3] = {0, 0, 0};
    ui8 arrHigh[3] = {255, 255, 25};
    for (int i = 0; i < CWndGraph::DivsX * CWndGraph::BlkX; i++) {
      ui8 *bLow = NULL;
      ui8 *bHigh = NULL;

      CCoreOscilloscope::GetMaskAt(i, &bLow, &bHigh);
      arrLow[0] = arrLow[1];
      arrLow[1] = arrLow[2];
      arrLow[2] = *bLow;

      arrHigh[0] = arrHigh[1];
      arrHigh[1] = arrHigh[2];
      arrHigh[2] = *bHigh;

      if (i >= 2) {
        CCoreOscilloscope::GetMaskAt(i - 1, &bLow, &bHigh);
        *bLow = BlurFilterInv(arrLow[0], arrLow[1], arrLow[2]);
        *bHigh = BlurFilter(arrHigh[0], arrHigh[1], arrHigh[2]);
      }
    }
  }
  if (pSender == &m_itmDisplay && code == ToWord('l', 'e')) {
    int *nPass = NULL;
    int *nFail = NULL;
    CCoreOscilloscope::GetMaskStats(&nPass, &nFail);
    *nPass = 0;
    *nFail = 0;
  }
}
Exemplo n.º 23
0
/*virtual*/ void CWndMenuSpectMain::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	// LAYOUT ENABLE/DISABLE FROM TOP MENU BAR
	if (code == ToWord('L', 'D') )
	{
		MainWnd.m_wndSpectrumMiniTD.ShowWindow( SwHide );
		MainWnd.m_wndSpectrumMiniFD.ShowWindow( SwHide );
		MainWnd.m_wndSpectrumMiniSG.ShowWindow( SwHide );
		MainWnd.m_wndSpectrumGraph.ShowWindow( SwHide );
		MainWnd.m_wndSpectrumAnnot.ShowWindow( SwHide );
		return;
	}

	if (code == ToWord('L', 'E') )
	{
		MainWnd.m_wndSpectrumMiniTD.ShowWindow( 
			( Settings.Spec.Display == CSettings::Spectrum::_FftTime || 
			Settings.Spec.Display == CSettings::Spectrum::_Spectrograph ) ? SwShow : SwHide );
		MainWnd.m_wndSpectrumMiniFD.ShowWindow( Settings.Spec.Display == CSettings::Spectrum::_FftTime ? SwShow : SwHide );
		MainWnd.m_wndSpectrumGraph.ShowWindow( Settings.Spec.Display == CSettings::Spectrum::_Fft ? SwShow : SwHide );
		MainWnd.m_wndSpectrumMiniSG.ShowWindow( Settings.Spec.Display == CSettings::Spectrum::_Spectrograph ? SwShow : SwHide );
		MainWnd.m_wndSpectrumAnnot.ShowWindow( SwShow );
		return;
	}

	if ( code == ToWord('i', 'u') && 
		( pSender == &m_itmCH1 || pSender == &m_itmCH2 || pSender == &m_itmTime ) )
	{
		CCoreOscilloscope::ConfigureAdc();
		MainWnd.m_wndSpectrumAnnot.Invalidate();
		return;
	}
	if ( code == ToWord('m', 'a') && pSender == &m_itmCH1 )
	{
		if ( Settings.CH1.Enabled == CSettings::AnalogChannel::_NO )
			Settings.CH1.Enabled = CSettings::AnalogChannel::_YES;
		else
			Settings.CH1.Enabled = CSettings::AnalogChannel::_NO;
		m_itmCH1.Invalidate();
		return;
	}
	if ( code == ToWord('m', 'a') && pSender == &m_itmCH2 )
	{
		if ( Settings.CH2.Enabled == CSettings::AnalogChannel::_NO )
			Settings.CH2.Enabled = CSettings::AnalogChannel::_YES;
		else
			Settings.CH2.Enabled = CSettings::AnalogChannel::_NO;
		m_itmCH2.Invalidate();
		return;
	}
	if ( code == ToWord('u', 'p') && pSender == &m_itmDisplay )
	{
		MainWnd.m_wndSpectrumMiniTD.ShowWindow( 
			( Settings.Spec.Display == CSettings::Spectrum::_FftTime || 
			Settings.Spec.Display == CSettings::Spectrum::_Spectrograph ) ? SwShow : SwHide );
		MainWnd.m_wndSpectrumMiniFD.ShowWindow( Settings.Spec.Display == CSettings::Spectrum::_FftTime ? SwShow : SwHide );
		MainWnd.m_wndSpectrumGraph.ShowWindow( Settings.Spec.Display == CSettings::Spectrum::_Fft ? SwShow : SwHide );
		MainWnd.m_wndSpectrumMiniSG.ShowWindow( Settings.Spec.Display == CSettings::Spectrum::_Spectrograph ? SwShow : SwHide );
		MainWnd.m_wndSpectrumAnnot.ShowWindow( SwShow );
		MainWnd.Invalidate();
	}
}
Exemplo n.º 24
0
/*virtual*/ void CWndMenuGeneratorEdit::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	if (code == ToWord('L', 'D') )
	{
		MainWnd.m_wndSignalGraph.ShowWindow( SwHide );
		return;
	}

	if (code == ToWord('L', 'E') )
	{
		MainWnd.m_wndSignalGraph.ShowWindow( SwShow );
		return;
	}

	// copy from oscilloscope
	if ( code == ToWord('m', 'o') && pSender == &m_itmCopy )
	{
		int nBegin, nEnd;

		if ( Settings.MarkT1.Mode != CSettings::Marker::_On || 
			 Settings.MarkT2.Mode != CSettings::Marker::_On ||
			 Settings.MarkT2.nValue <= Settings.MarkT1.nValue )
		{
			MainWnd.m_wndGraph.GetCurrentRange( nBegin, nEnd );
		} else
		{
			nBegin = Settings.MarkT1.nValue;
			nEnd = Settings.MarkT2.nValue;
		}

		int nTargetLen = nEnd - nBegin;
		nTargetLen = min(256, nTargetLen);
		CCoreGenerator::GetVolatileLen() = nTargetLen;
		ui8* pVolatile = CCoreGenerator::GetVolatile();
		for ( int i = 0; i < nTargetLen; i++ )
		{
			int nIndex = nBegin + i*(nEnd - nBegin)/nTargetLen;
			BIOS::ADC::SSample Sample;
			Sample.nValue = BIOS::ADC::GetAt( nIndex );
			*pVolatile++ = Sample.CH1;
		}
		Settings.Gen.Wave = CSettings::Generator::_Volatile;
		CCoreGenerator::Update();
		MainWnd.m_wndSignalGraph.Setup( CCoreGenerator::GetRamDac(), CCoreGenerator::GetRamLen() );
		MainWnd.m_wndSignalGraph.Invalidate();
	}

	// normalize
	if ( code == ToWord('m', 'o') && pSender == &m_itmNormalize )
	{
		int nLength = CCoreGenerator::GetVolatileLen();
		ui8* pVolatile = CCoreGenerator::GetVolatile();
		int nMin = 0, nMax = 0;
		for ( int i = 0; i < nLength; i++ )
		{
			int nValue = *pVolatile++;
			if ( i == 0 )
			{
				nMin = nMax = nValue;
			} else
			{
				nMin = min(nMin, nValue);
				nMax = max(nMax, nValue);
			}
		}

		pVolatile = CCoreGenerator::GetVolatile();
		for ( int i = 0; i < nLength; i++ )
		{
			int nValue = *pVolatile;
			nValue = (nValue - nMin) * 255 / (nMax - nMin);
			_ASSERT( nValue >= 0 && nValue <= 255 );
			*pVolatile++ = nValue;
		}
		CCoreGenerator::Update();
		MainWnd.m_wndSignalGraph.Invalidate();
	}

	// invert
	if ( code == ToWord('m', 'o') && pSender == &m_itmInvert )
	{
		int nLength = CCoreGenerator::GetVolatileLen();
		ui8* pVolatile = CCoreGenerator::GetVolatile();
		for ( int i = 0; i < nLength; i++, pVolatile++ )
			*pVolatile = 255-*pVolatile;

		CCoreGenerator::Update();
		MainWnd.m_wndSignalGraph.Invalidate();
	}

	// edit
	if ( code == ToWord('m', 'o') && pSender == &m_itmEdit )
	{
		Settings.Gen.Wave = CSettings::Generator::_Volatile;
		CCoreGenerator::Update();
		MainWnd.m_wndSignalGraph.Setup( CCoreGenerator::GetRamDac(), CCoreGenerator::GetRamLen() );
		MainWnd.m_wndSignalGraph.m_dwFlags &= ~CWnd::WsNoActivate;
		MainWnd.m_wndSignalGraph.SetFocus();
		MainWnd.m_wndSignalGraph.Invalidate();
		MainWnd.m_wndSignalGraph.ExitHandler( this );
		m_itmEdit.Invalidate();
	}
	if ( code == ToWord('e', 'x') && pSender == &MainWnd.m_wndSignalGraph )
	{
		m_itmEdit.SetFocus();
		m_itmEdit.Invalidate();
		MainWnd.m_wndSignalGraph.m_dwFlags |= CWnd::WsNoActivate;
		MainWnd.m_wndSignalGraph.Invalidate();
	}
}
Exemplo n.º 25
0
/*virtual*/ void CWndManager::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	char strName[13];

	if ( pSender == &m_itmTabs && code == ToWord('u', 'p') )
	{
		// redirect to next function for redrawing the listbox
		pSender = &m_itmValue;
		// find nearest non used file
		for ( int i=0; i<10; i++ )
		{
			BIOS::DBG::sprintf( strName, strTemplateFile[m_itmTabs.GetFocus()], i );
			if ( !Exists(strName) )
			{
				m_nValue = i;
				break;
			}
		}
	}

	if ( pSender == &m_itmValue && code == ToWord('u', 'p') )
	{
		BIOS::DBG::sprintf( m_strCurrent, strTemplateDisplay[m_itmTabs.GetFocus()], m_nValue );
		m_itmFile.m_pszId = m_strCurrent;
		m_itmFile.Invalidate();
		
		BIOS::DBG::sprintf( strName, strTemplateFile[m_itmTabs.GetFocus()], m_nValue );
		bool bExists = Exists(strName);
		// set the flag even when the window is not displayed yet (instead of .IsVisible())
		if ( bExists != (m_itmLoad.m_dwFlags & CWnd::WsVisible) )
		{
			m_itmLoad.ShowWindow( bExists ? CWnd::SwShow : CWnd::SwHide );
			Invalidate();
		} 
	}
	if ( code == ToWord('l', 'e') && data == (NATIVEPTR)&m_proLoad )
	{
		// load
		BIOS::DBG::sprintf( strName, strTemplateFile[m_itmTabs.GetFocus()], m_nValue );

		switch ( m_itmTabs.GetFocus() )
		{
			case 0:	// Wave
				if ( !CImport::LoadWave( strName ) )
					MainWnd.m_wndMessage.Show(&MainWnd, "Sorry...", "Import failed!", RGB565(ffff00));
				else
				{
					CWnd::PushOverlay();
					MainWnd.Invalidate(); // to redraw the graph
					CWnd::PopOverlay();
				}
				//Invalidate(); // Why it forgets to redraw current window!?
				break;
			case 1: // Bmp
			case 2: // Csv
			case 3: // Svg
			case 4: // Dat
				MainWnd.m_wndMessage.Show(&MainWnd, "Sorry...", "This feature is not\nimplemented yet", RGB565(ffff00));
				break;
		}
		// load
	}
	if ( code == ToWord('l', 'e') && data == (NATIVEPTR)&m_proSave )
	{
		// save
		BIOS::DBG::sprintf( strName, strTemplateFile[m_itmTabs.GetFocus()], m_nValue );
		CRect rcSafe;

		switch ( m_itmTabs.GetFocus() )
		{
			case 0:	// Wave
				CExport::SaveWav( strName );
				MainWnd.m_wndMessage.Show(&MainWnd, "Information", "Successfully saved", RGB565(ffff00));
				break;
			case 1: // Bmp
				ShowWindow(CWnd::SwHide);
				CWnd::PushOverlay();
				MainWnd.Invalidate();
				CWnd::PopOverlay();

				CExport::SaveScreenshot16( strName );
				ShowWindow(CWnd::SwShow);
				MainWnd.Invalidate();
				MainWnd.m_wndMessage.Show(&MainWnd, "Information", "Successfully saved", RGB565(ffff00));
				break;
			case 2: // Csv
				CExport::SaveCsv( strName );
				MainWnd.m_wndMessage.Show(&MainWnd, "Information", "Successfully saved", RGB565(ffff00));
				break;
			case 3: // Svg
				CExport::SaveSvg( strName );
				MainWnd.m_wndMessage.Show(&MainWnd, "Information", "Successfully saved", RGB565(ffff00));
//				MainWnd.m_wndMessage.Show(&MainWnd, "Sorry...", "This feature is not implemented yet", RGB565(ffff00));
				break;
			case 4: // Dat
				CExport::SaveBinary( strName );
				MainWnd.m_wndMessage.Show(&MainWnd, "Information", "Successfully saved", RGB565(ffff00));
				break;
		}
	}
	if ( code == ToWord('o', 'k') )
	{
		m_bRunning = false;
	}
	if ( code == ToWord('e', 'x') )
	{
		m_bRunning = false;
	}
}
Exemplo n.º 26
0
void unban(char *source, char *ch, char *list)
{
  register aban *bans;
  register aluser *luser;
  register achannel *chan;
  char channel[CHANNELNAME_LENGTH];
  char buffer[512];
  char one[200];
  register int found;
  register int i, exact;

  if (*list == '#')
  {
    GetWord(0, list, channel);
    list = ToWord(1, list);
  }
  else
  {
    strcpy(channel, ch);
    GuessChannel(source, channel);
  }

  chan = ToChannel(channel);
  if (chan == NULL || !chan->on)
  {
    notice(source, "I am NOT on that channel!");
    return;
  }

  if (!chan->AmChanOp)
  {
    notice(source, "I am not channel operator!");
    return;
  }

  if (*source && Access(channel, source) < BAN_LEVEL)
  {
    notice(source, "You're Access on this channel is too low");
    return;
  }

  if (!*list)
  {
    notice(source, "SYNTAX: unban [#channel] <nick1|addr1> [<nick2|addr2>] [...]");
    return;
  }

  i = 0;
  GetWord(0, list, one);
  while (*one)
  {
    found = 0;
    luser = ToLuser(one);
    if (luser != NULL)
    {
      sprintf(one, "%s!%s@%s", luser->nick, luser->username,
	luser->site);
      exact = 0;
    }
    else
    {
      exact = 1;
    }
    bans = chan->bans;
    while (bans != NULL)
    {
      if ((!exact && match(one, bans->pattern)) ||
	(exact && !strcasecmp(one, bans->pattern)))
      {
	sprintf(buffer, "I UNBAN %s ON %s",
	  bans->pattern, chan->name);
	log(buffer);
	changemode(channel, "-b", bans->pattern, 0);
	RemBan(channel, bans->pattern);
	bans = chan->bans;
	found = 1;
	if (exact)
	  break;
      }
      else
	bans = bans->next;
    }
    if (*source && !found)
    {
      sprintf(buffer, "%s is not in %s's banlist!",
	one, channel);
      notice(source, buffer);
    }
    GetWord(++i, list, one);
  }
  flushmode(channel);
}
Exemplo n.º 27
0
void mban(char *source, char *ch, char *args)
{
  char buffer[200];
  char channel[80];
  register int found = 0;
  register achannel *chan;
  register auser *user;

  if (*args == '#')
  {
    GetWord(0, args, channel);
    args = ToWord(1, args);
  }
  else
  {
    strcpy(channel, ch);
    GuessChannel(source, channel);
  }

  if (!strcmp(channel, "*"))
  {
    notice(source, "SYNTAX: mban <channel> <nick!username@hostname>");
    return;
  }

  if ((chan = ToChannel(channel)) == NULL || !chan->on)
  {
    if (*source)
      notice(source, "I'm NOT on that channel!");
    return;
  }

  if (!chan->AmChanOp)
  {
    if (*source)
      notice(source, "I am NOT channel operator!");
    return;
  }

  if (*source && Access(channel, source) < MASS_BAN_LEVEL)
  {
    notice(source, "Your Access on this channel is too low!");
    return;
  }

  if (!*args)
  {
    notice(source, "SYNTAX: mban <channel> <nick!username@hostname>");
    return;
  }

  user = chan->users;

  while (user)
  {
    sprintf(buffer, "%s!%s@%s",
      user->N->nick, user->N->username, user->N->site);
    if (match(buffer, args))
    {
      sprintf(buffer, "I BAN %s!%s@%s on %s (%s)", user->N->nick,
	user->N->username, user->N->site, channel, args);
      log(buffer);

      if (user->chanop)
      {
	changemode(channel, "-o", user->N->nick, 0);
	user->chanop = 0;
      }

      /*MakeBanMask(user->N,buffer); */
      if (!found)
	changemode(channel, "+b", args, 0);
      found = 1;
    }
    user = user->next;
  }
  if (found)
    flushmode(channel);
  else if (*source)
  {
    notice(source, "No match.");
  }
}
Exemplo n.º 28
0
/*virtual*/ void CWndMenuCursor::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
    // LAYOUT ENABLE/DISABLE FROM TOP MENU BAR
    if (code == ToWord('L', 'D') )
    {
        MainWnd.m_wndGraph.ShowWindow( SwHide );
        MainWnd.m_wndLReferences.ShowWindow( SwHide );
        MainWnd.m_wndTReferences.ShowWindow( SwHide );
        MainWnd.m_wndInfoBar.ShowWindow( SwHide );
        return;
    }

    if (code == ToWord('L', 'E') )
    {
        MainWnd.m_wndGraph.ShowWindow( SwShow );
        MainWnd.m_wndLReferences.ShowWindow( SwShow );
        MainWnd.m_wndTReferences.ShowWindow( SwShow );
        MainWnd.m_wndInfoBar.ShowWindow( SwShow );
        return;
    }

    // update, called when the user changes the cursor position
    if (code == ToWord('u', 'p') )
    {
        if ( data == (NATIVEPTR)&m_itmX1 ||
                data == (NATIVEPTR)&m_itmX2 )
        {
            m_itmDeltaX.Invalidate();
        }
        if ( data == (NATIVEPTR)&m_itmY1 ||
                data == (NATIVEPTR)&m_itmY2 )
        {
            m_itmDeltaY.Invalidate();
        }
        if ( !BIOS::ADC::Enabled() )
        {
            // we should redraw the graph, but not immediatelly for keeping
            // keyboard response quick
            MainWnd.m_wndGraph.Invalidate();
        }
        return;
    }

    // new waveform acquired, update the Y values
    if ( pSender == NULL && code == WmBroadcast && data == ToWord('d', 'g') )
    {
        if ( Settings.MarkY1.Mode == CSettings::Marker::_Auto )
            m_itmY1.Invalidate();
        if ( Settings.MarkY2.Mode == CSettings::Marker::_Auto )
            m_itmY2.Invalidate();
        if ( Settings.MarkY1.Mode == CSettings::Marker::_Auto ||
                Settings.MarkY1.Mode == CSettings::Marker::_Auto )
        {
            m_itmDeltaY.Invalidate();
        }
        return;
    }

    // Show listbox - cursor details
    if (code == ToWord('m', 'c') )
    {
        m_wndListCursor.Create( (CSettings::Marker*)(NATIVEPTR)data, this );
        m_wndListCursor.StartModal( &m_wndListCursor.m_itmMode );
        return;
    }
    if ( code == ToWord('o', 'k') && pSender == &m_wndListCursor )
    {
        // done
        m_wndListCursor.StopModal();
        return;
    }
    if ( code == ToWord('e', 'x') && pSender == &m_wndListCursor )
    {
        // done
        m_wndListCursor.StopModal();
        return;
    }

    // Clicked on Find
    if ( code == ToWord('l', 'e') && data == (NATIVEPTR)&m_wndListCursor.m_proFind )
    {
        Find( m_wndListCursor.m_pMarker, m_wndListCursor.m_modeFind );
        return;
    }
}
Exemplo n.º 29
0
void ban(char *source, char *chan, char *nicklist)
{
  char buffer[300];
  char OneNick[NICK_LENGTH];
  char channel[CHANNELNAME_LENGTH];
  register auser *user;
  register aluser *luser;
  register achannel *ch;
  register int i = 0;

  if (*nicklist == '#')
  {
    GetWord(0, nicklist, channel);
    nicklist = ToWord(1, nicklist);
  }
  else
  {
    strcpy(channel, chan);
    GuessChannel(source, channel);
  }

  if (!strcmp(channel, "*"))
  {
    notice(source, "SYNTAX: ban <channel> <nick1|addr1> [nick2|addr2] [...]");
    return;
  }

#ifdef DEBUG
  printf("BAN REQUEST FOR %s\nON CHANNEL %s\nBY %s (%d)\n",
    nicklist, channel, source, Access(channel, source));
#endif

  if (*source && Access(channel, source) < BAN_LEVEL)
  {
    notice(source, "Your Access on this channel is too low");
    return;
  }

  ch = ToChannel(channel);

  /* I'm not on this channel.. so screw it! */
  if (ch == NULL || !ch->on)
  {
    notice(source, "I'm NOT on that channel!");
    return;
  }

  if (!ch->AmChanOp)
  {
    notice(source, "I'm not channel operator!");
    return;
  }

  if (!*nicklist)
  {
    notice(source, "SYNTAX: ban <channel> <nick1|addr1> [nick2|addr2] [...]");
    return;
  }

  GetWord(0, nicklist, OneNick);

  while (*OneNick)
  {
    luser = ToLuser(OneNick);
    if (luser)
      sprintf(buffer, "%s!%s@%s", luser->nick,
	luser->username, luser->site);
    if (luser)
    {
      sprintf(buffer, "I BAN %s!%s@%s ON %s", luser->nick,
	luser->username, luser->site, channel);
      log(buffer);

      user = ToUser(channel, OneNick);
      if (user && user->chanop)
      {
	changemode(channel, "-o", user->N->nick, 0);
      }

      MakeBanMask(luser, buffer);
      changemode(channel, "+b", buffer, 0);
    }
    GetWord(++i, nicklist, OneNick);
  }
  flushmode(channel);
}
Exemplo n.º 30
0
/*virtual*/ void CWndMenuMeas::OnMessage(CWnd* pSender, ui16 code, ui32 data)
{
	// LAYOUT ENABLE/DISABLE FROM TOP MENU BAR
	if (code == ToWord('L', 'D') )
	{
		MainWnd.m_wndGraph.ShowWindow( SwHide );
		MainWnd.m_wndInfoBar.ShowWindow( SwHide );
		MainWnd.m_wndLReferences.ShowWindow( SwHide );
		MainWnd.m_wndTReferences.ShowWindow( SwHide );
		return;
	}

	if (code == ToWord('L', 'E') )
	{
		MainWnd.m_wndGraph.ShowWindow( SwShow );
		MainWnd.m_wndInfoBar.ShowWindow( SwShow );
		MainWnd.m_wndLReferences.ShowWindow( SwShow );
		MainWnd.m_wndTReferences.ShowWindow( SwShow );
		return;
	}

	// new waveform acquired, update the Y values 	
	if ( pSender == NULL && code == WmBroadcast && data == ToWord('d', 'g') )
	{
		_UpdateAll();
		return;
	}

	// something was changed in listbox
	if (code == ToWord('u', 'p') )
	{
		_UpdateAll();
		if ( m_wndListMeas.m_pMeas == m_itmMeas[0].m_pMeas )
			m_itmMeas[0].Invalidate();
		if ( m_wndListMeas.m_pMeas == m_itmMeas[1].m_pMeas )
			m_itmMeas[1].Invalidate();
		if ( m_wndListMeas.m_pMeas == m_itmMeas[2].m_pMeas )
			m_itmMeas[2].Invalidate();
		if ( m_wndListMeas.m_pMeas == m_itmMeas[3].m_pMeas )
			m_itmMeas[3].Invalidate();
		if ( m_wndListMeas.m_pMeas == m_itmMeas[4].m_pMeas )
			m_itmMeas[4].Invalidate();
		if ( m_wndListMeas.m_pMeas == m_itmMeas[5].m_pMeas )
			m_itmMeas[5].Invalidate();
		return;
	}

	// Show listbox - cursor details
	if (code == ToWord('m', 'c') )	
	{
		m_wndListMeas.Create( (CSettings::Measure*)(NATIVEPTR)data, this );
		m_wndListMeas.StartModal( &m_wndListMeas.m_itmEnabled );
		return;
	}
	if ( (code == ToWord('o', 'k') || code == ToWord('e', 'x') || code == ToWord('l', 'e')) )
	{
		// done
		m_wndListMeas.StopModal();
		return;
	}
}