Exemplo n.º 1
0
static void prvButtonPollTask( void *pvParameters )
{
    unsigned char ucLastState = pdFALSE, ucState;
    xQueueMessage xMessage;

    /* This tasks performs the button polling functionality as described at the
    top of this file. */
    for( ;; )
    {
        /* Check the button state. */
        ucState = ( halButtonsPressed() & BUTTON_UP );

        if( ucState != 0 )
        {
            /* The button was pressed. */
            ucState = pdTRUE;
        }

        if( ucState != ucLastState )
        {
            /* The state has changed, send a message to the LCD task. */
            xMessage.cMessageID = mainMESSAGE_BUTTON_UP;
            xMessage.ulMessageValue = ( unsigned long ) ucState;
            ucLastState = ucState;
            xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY );
        }

        /* Block for 10 milliseconds so this task does not utilise all the CPU
        time and debouncing of the button is not necessary. */
        vTaskDelay( 10 / portTICK_RATE_MS );
    }
}
uint8_t uifPollFunc(EHIF_CMD_RC_SET_DATA_PARAM_T* pParam) {
    static uint8_t prevButtonState = 0x00;

    // Update remote control commands if the button state has changed
    uint8_t buttonState = halButtonsPressed();
    if (buttonState != prevButtonState) {
        prevButtonState = buttonState;
        
        uint8_t rcCmdCount = 0;
        if (buttonState & BUTTON_LEFT) {
            pParam->pRcCmds[rcCmdCount++] = EHIF_RC_CMD_SCAN_PREV_TRACK;
        }
        if (buttonState & BUTTON_RIGHT) {
            pParam->pRcCmds[rcCmdCount++] = EHIF_RC_CMD_SCAN_NEXT_TRACK;
        }
        if (buttonState & BUTTON_UP) {
            pParam->pRcCmds[rcCmdCount++] = EHIF_RC_CMD_OUT_VOL_INCR;
        }
        if (buttonState & BUTTON_DOWN) {
            pParam->pRcCmds[rcCmdCount++] = EHIF_RC_CMD_OUT_VOL_DECR;
        }
        if (buttonState & BUTTON_SELECT) {
            pParam->pRcCmds[rcCmdCount++] = EHIF_RC_CMD_PLAY_PAUSE_TOGGLE;
        }
        pParam->rcCmdCount = rcCmdCount;
        return 1;
    } else { 
        return 0;
    }
    
} // uifPollFunc
Exemplo n.º 3
0
uint8_t uifPollFunc(EHIF_CMD_RC_SET_DATA_PARAM_T* pParam) {

    // Update mouse position and button state and send if changed
    uint8_t doRcSetData = 0;
    uint8_t buttonState = halButtonsPressed();
    if (buttonState & BUTTON_LEFT) { 
        pParam->mousePosX -= 1 + ((++xMouseMoveDuration) >> 5);
        doRcSetData = 1; 
    } else if (buttonState & BUTTON_RIGHT) {
Exemplo n.º 4
0
uint8_t pollButtons(void) {
    static uint32_t lastButtonDuration = 0;
    static uint8_t lastButton = 0x00;
    uint8_t currButton = halButtonsPressed();
    if (currButton == lastButton) {
        lastButtonDuration++;
    } else {
        lastButton = currButton;
        lastButtonDuration = 0;
    }
    if (lastButtonDuration == 10) {
        return lastButton & BUTTON_ALL;
    } else {
        return 0x00;
    }
} // pollButtons
Exemplo n.º 5
0
void main( void )
{
	unsigned int ucState=0xffff;
	unsigned char test[10];
	memset(test,'\0',10);
	int i=0;
	halBoardInit();
	hal430SetSystemClock();
	halButtonsInit();
	Init_Uart(115200);
	Init_Lcd();
	Msp430_ADC12_Init();
	Write_NByte((unsigned char *)eeprom,10,0);
	Read_NByte_Randomaddress(test,10,0);
	printf("main %s\r\n",test);
	 while(1)
	{
		if(flag==1)
		{
			//WDTCTL = WDTPW + WDTNMI + WDTTMSEL + WDTSSEL + WDTCNTCL;             // Start watchdog timer
			//IE1 |= WDTIE;                         // Enable WDT interrupt
			printf("we are in active state\r\n");
			//这里写自己的程序,把程序做在一个有限的循环里,这样做完之后就可以自动结束并关机。
			for(i=0;i<1000;i++){
			ucState = halButtonsPressed();
			
			if(ucState!=0xffff)
			{
			    i=0;
			    send_wave();
			    hal_buzzer(2);
			    Get_Power();
				//printf("%x is pressed\r\n",ucState);
				switch(ucState)
					{
					case BUTTON_MATL:
						printf("matl is pressed\r\n");
						break;
					case BUTTON_HARD:
						printf("hard is pressed\r\n");
						break;
					case BUTTON_DIREC:
						printf("direc is pressed\r\n");
						break;
					case BUTTON_TIMES:
						printf("times is pressed\r\n");
						break;						
					case BUTTON_SAVE:
						printf("save is pressed\r\n");
						break;
					case BUTTON_UP:
						printf("up is pressed\r\n");
						break;
					case BUTTON_DEL:
						printf("del is pressed\r\n");
						break;
					case BUTTON_AVE:
						printf("ave is pressed\r\n");
						break;
					case BUTTON_LEFT:
						printf("left is pressed\r\n");
						break;
					case BUTTON_MENU:
						printf("menu is pressed\r\n");
						break;
					case BUTTON_RIGHT:
						printf("right is pressed\r\n");
						break;
					case BUTTON_BACKLIGHT:
						printf("backlight is pressed\r\n");
						break;
					case BUTTON_ESC:
						printf("esc is pressed\r\n");
						break;
					case BUTTON_DOWN:
						printf("down is pressed\r\n");
						break;
					case BUTTON_ENTER:
						printf("enter is pressed\r\n");
						break;
					default:
						break;
					}
			}			
			//LPM3;
			Delay(100);
			}
			//如需定时,上边这个LPM3要被包括在那个有循环的循环体中,这样才能实现类似便携式仪表5分钟自动关机的效果。如果不使用定时也可以不要LPM3这句话。
			//WDTCTL = WDTPW + WDTHOLD + WDTNMI;             // Stop watchdog timer
			flag=0;
		}
		else
		{
			//如果周边设备在关机时有需要复位的或是关闭的在这里处理
			printf("we are in power off state\r\n");
		}
		hal_buzzer(0);
		printf("we going to LPM4\r\n");
		LPM4;
	}
}