Пример #1
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Function Header
void CStaticCounter::OnLButtonUp(UINT nFlags, CPoint point) 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
	ReleaseCapture();
	
	if (m_nLastAmount==0 && m_bAllowInteraction)	// ALLOW UNIT CHANGES WHEN IT'S HARD TO DRAG FOR SMALL NUMBERS
	{
		m_fPos-=(m_bFloat?0.01f:1);	// DECREMENT

		if (m_fPos<m_fMin) m_fPos = m_fMin;
		if (m_fPos>m_fMax) m_fPos = m_fMax;
		if (m_bFloat)
			DisplayFloat(m_fPos);
		else
			DisplayInt((int)m_fPos);
	}

	#ifdef WM_UPDATE_STATIC
		//#define WM_UPDATE_STATIC (WM_USER+0x411)		// user defined WM message
		::PostMessage(  GetParent()->m_hWnd,  WM_UPDATE_STATIC, (WPARAM)m_uID, (LPARAM)m_fPos );
	#endif

	m_nLastAmount = 0;
	m_bLDown = false;
}
Пример #2
0
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Function Header
void CStaticCounter::OnMouseMove(UINT nFlags, CPoint point) 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
{
	if (! m_bLDown && !m_bRDown)	return;		// If neither mouse buttons are down, don't come here thinking this is an off-license, ok!
	if (! m_bAllowInteraction)	return;					// "Sorry, I'm grounded and my dad says I'm not allowed visitors"

	m_nLastAmount = point.x-m_nMovement;
	m_nMovement = point.x;

	if (m_bLDown)
		m_fPos+=(float)m_nLastAmount;
	else
		m_fPos+=(float)((float)m_nLastAmount/(float)100);

	if (m_fPos<m_fMin) m_fPos = m_fMin;
	if (m_fPos>m_fMax) m_fPos = m_fMax;

	if (m_bFloat)
		DisplayFloat(m_fPos);
	else
		DisplayInt((int)m_fPos);
}
Пример #3
0
void main(void) {
	unsigned long delay;
	char exit = 'o';
	
  /* Initialization code */
    clock_init(BUS_CLK);
    sci_init(9600, BUS_CLK, SCI0);
    LIN_PHY_ENABLE;
    sci_init(9600, BUS_CLK, SCI1);
    gpio_init();
    LS_Module_Init();
    HS_Module_Init();
    HS0_On();
    PWM_init();
    ADC_init(BUS_CLK);
    
    /* Test serial communication */
    send_string("\n\rSerial Test, press any key\n\r", SCI1);
    echo(SCI1);
    send_string("\n\rTest successful\n\r",SCI1);

	/* Test Relay */
	send_string("\n\rPress u to activate the relay up and d to activate it down\n\r", SCI1);
	send_string("\n\rPres e to exit relay test\n\r", SCI1);
	
	while(exit != 'e'){
		exit = get_char(SCI1);
		put_char(exit, SCI1);
		if(exit == 'u'){
			send_string("\r\nRelay Low side driver 0 active\r\n", SCI1);
			LS0_On();
			for(delay = 0; delay < 30000; ++delay);
			send_string("\r\nRelay Low side driver 0 inactive\r\n", SCI1);
			LS0_Off();
			exit = 'a';	
		} else if (exit == 'd') {
			send_string("\r\nRelay Low side driver 1 active\r\n", SCI1);
			LS1_On();
			for(delay = 0; delay < 30000; ++delay);
			send_string("\r\nRelay Low side driver 1 inactive\r\n", SCI1);
			LS1_Off();
			exit = 'a';
		}		
	}
	
	put_char('\n', SCI1);
	EnableInterrupts;


  for(;;) {
    _FEED_COP(); /* feeds the dog */
    if(read_sw2){
    	LS0_On();
    	send_string("\r\nSwitch 2 pressed\r\n", SCI1);	
    } else {
    	LS0_Off();
    }
    if(read_sw3){
    	LS1_On();
    	send_string("\r\nSwitch 3 pressed\r\n", SCI1);	
    } else {
    	LS1_Off();
    }
    for(delay = 0; delay < 30000; ++delay);
    send_string("\rADC value:   ", SCI1);
    send_string("\b\b\b", SCI1);
    DisplayInt((unsigned char) ADC_read(POT), SCI1);
    put_char(0x55,SCI0);	/* Send stuff through LIN */
  } /* loop forever */
  /* please make sure that you never leave main */
}