示例#1
0
void ButtonPressed()
{   //Normally you would check to see what pin the GPIO interrupt is coming from but there are no other GPIO devices
    if(state ==1)//State 1
    {
        //Reset calendar
        day = 12;
        month = 7;
        year = 11;
        //Update LCD
        updateLCD();
    }
    else if(state ==2)//State 2
    {
        if(month >= 12)
        {
            month = 1;
        }
        else
        {
            month++;
        }
        updateLCD();
    }
    else if(state ==3)//State 3
    {
        if( day >= 30)
        {
            day = 1;
        }
        else
        {
            day++;
        }
        updateLCD();
    }
    else if(state ==4)//State 4
    {
        if(year >=99)
        {
            year = 0;
        }
        else
        {
            year++;
        }
        updateLCD();
    }
}
示例#2
0
void CalcScreen::timerEvent(QTimerEvent *e)
{
    if ( e->timerId() == m_lcdTimerId )
        updateLCD();
    else
        QQuickPaintedItem::timerEvent(e);
}
示例#3
0
void OneSecond()
{
    //Increase count
    seconds++;

    //Manage blinking - blink every second
    if(blinkState == 1)
    {
        blinkState = 0;
    }
    else
    {
        blinkState = 1;
    }

    //Handle changing of states
    if(seconds >= stateDelay)
    {
        //Move to next state
        if(state == 4)
        {
            state = 1;
        }
        else
        {
            state++;
        }

        //Reset second counter
        seconds = 0;
    }

    //Update LCD every second for blinking
    updateLCD();
}
示例#4
0
  /***********************************************************
   * 
   * checkBttnStatus
   * 
   ***********************************************************/
void TTUI::update()
{
	
	boolean keyDown = false;
	boolean hold = false; 
	int hitKeyVal = 0;
  
	    systemCheck(); //check for stop or reset
		updateLCD(); //updates the lcd if something needs to change in realtime

  	 	if(touch.hold() == true) //press and hold key pad
		{
			keyDown = true;
			hold = true;  
			hitKeyVal = touch.getKey();
		}

		
		if(touch.hit() == true) //just press key pad
		{ 
	   	 	keyDown = true;
		 	hitKeyVal = touch.readActiveKey(); //read which key was hit
		} 
	
	

		//call a specific function based on which key is pressed
	    if(keyDown == true)
		{ 
		  
		  previousMillis_UIPower = millis(); //time key was active
		  keyDown = false;
	      switch (hitKeyVal)
	      {		
	      	  case MODE_BTTN:
		        bttnMode();
		        break;
		      case SELECT_BTTN:
		        bttnOption();		
		        break;
		      case DOWN_BTTN:
		        bttnDown(hold); 
		        break;
		      case UP_BTTN:
		        bttnUp(hold);
		        break;
		      default: //no default option, just here for compiler
		        break;
	      }
		}
		
		if(batteryPower() == true)
		{
		 	uiPowerTimeOut(); //if there has been no activity turn off lcd power
		}	



}
示例#5
0
void CalcScreen::setLcd()
{
    if(m_lcdW == (int)width() && m_lcdH == (int)height())
        return;
    m_lcdW = (int)width();
    m_lcdH = (int)height();
    qDebug() << "setLcd: " << m_lcdW << "x" << m_lcdH;
    m_screen = QImage(m_lcdW,m_lcdH, QImage::Format_RGB32);
    updateLCD();
}
示例#6
0
void smartGoToGoal(float x, float y)
{
	xpos=x;
	ypos=y;
	while((roboxpos<=(x-.25)||roboxpos>=(x+.25))&&(roboypos<=(y-.25)||roboypos>=(y+.25)))
	{
		avoidObstacle(7,5,5,5);
		updateLCD();
	}
}
示例#7
0
文件: Menu.cpp 项目: JoyLabs/arduino
void Menu::leave(){
	if(_menuLevel > 0){
#if DEBUG
		char buf[128];
		snprintf(buf,128,"Leave Menu:%s", currentItem()->title);
		Serial.println(buf);
#endif
		_menuLevel--;
	}
	updateLCD(0);
}
示例#8
0
文件: Menu.cpp 项目: JoyLabs/arduino
void Menu::prev(){
	if(_menuIndex[_menuLevel] > 0){
		_menuIndex[_menuLevel] = _menuIndex[_menuLevel] - 1;
		updateLCD(0);
	}else{
#if DEBUG
		char buf[128];
		snprintf(buf,128,"reaches the first menu item, level:%d, index:%d",_menuLevel,_menuIndex[_menuLevel]);
		Serial.println(buf);
#endif
	}
}
示例#9
0
文件: Menu.cpp 项目: JoyLabs/arduino
void Menu::next(){
	if((_menuStack[_menuLevel] + _menuIndex[_menuLevel] + 1)->title != 0){
		_menuIndex[_menuLevel] = _menuIndex[_menuLevel] + 1;
		updateLCD(0);
	}else{
#if DEBUG
		char buf[128];
		snprintf(buf,128,"reaches the last menu item, level:%d, index:%d",_menuLevel,_menuIndex[_menuLevel]);
		Serial.println(buf);
#endif
	}
}
示例#10
0
void wander(char type)
{
	if(type == 'a')
	{
		while(1){
			char robostate='w';
			updateLCD();
			while (robostate=='w')
			{
				robostate = aggressiveKid(1,6,3);
				getIR();
				updateLCD();
				TMRSRVC_delay(100);
			}
			LCD_clear();
			LCD_printf("Reason for Stop: %c",robostate);
			if(ATTINY_get_SW_state(ATTINY_SW3))
			break;
		}
	}
	if(type=='s')
	{
		while(1){
			char robostate='w';
			updateLCD();
			while (robostate=='w')
			{
				robostate = shyGuy(1,7,4,4,6);
				getIR();
				updateLCD();
				TMRSRVC_delay(100);
			}
			LCD_clear();
			LCD_printf("Reason for Stop: %c",robostate);
			if(ATTINY_get_SW_state(ATTINY_SW3))
			break;
		}
	}
	
}
示例#11
0
/**************************************************************************//**
 * @brief  Main function
 *****************************************************************************/
int main(void)
{
  CHIP_Init();

  // initializations
  initGPIO();
  /* Enable LCD without voltage boost */
  SegmentLCD_Init(false);
  setupSWOForPrint();

  updateLCD(getCapsenseCurrent());

  while (1)
  {
    updateGPIO();
    if (getCapsensePrevious() != getCapsenseCurrent())
    {
      updateLCD(getCapsenseCurrent());
      updateSWO();
    }
  }
}
示例#12
0
void levelZero(char type,float frontDist)
{
	if(type == 'a')
	{
		while(1){
			char robostate='w';
			updateLCD();
			while (robostate=='w')
			{
				robostate = aggressiveKid(0,6,3);
				getIR();
				updateLCD();
				TMRSRVC_delay(100);
			}
			LCD_clear();
			LCD_printf("Reason for Stop: %c",robostate);
			if(ATTINY_get_SW_state(ATTINY_SW3))
			break;
		}
		
	}
}
示例#13
0
// ------------------------------------------------------------------
void appBase::logSamples() { // log one set of samples to the serial port
  float t1 = 0.0; // first two active channels
  float t2 = 0.0;
  float rx;
  float RoR = 0.0;
  float t;
  boolean frst = false;
  boolean scnd = false;

  // print timestamp from when samples were taken
  Serial.print( timestamp, _DP );

  // print ambient
  Serial.print(",");
  if( celsius )
    Serial.print( amb.getAmbC(), _DP );
  else
    Serial.print( amb.getAmbF(), _DP );

  // print temperature, rate for each active channel
  for( uint8_t i = 0; i < _NCHAN; i++ ) {
    uint8_t k = chan.getChan( i );
    if( k != 0 ) {  // if zero, then channel not active
      --k; // now k will contain the physical ADC channel ID, 0 to 3
      Serial.print(",");
      Serial.print( t = _D_MULT*temps[k], _DP ); // temp on logical channel i
      Serial.print(",");
      // rx = rise rate of current channel
      rx = calcRise( flast[k], ftemps[k], lasttimes[k], ftimes[k] );
      // perform post-filtering on RoR values
      rx = fRoR[k].doFilter( rx /  _D_MULT ) * _D_MULT;
      Serial.print( rx , _DP ); // print post-filtered RoR for logical channel i
      // capture the values from the first two active channels
      if( !frst ) {
        frst = true;
        t1 = t;
        RoR = rx;
      }
      else if( frst && !scnd ) {
        scnd = true;
        t2 = t;
      }
    }
  }
  Serial.println();

  // display the values from the first two active channels
  if( lcd != NULL )
    updateLCD( timestamp, t1, t2, RoR );
}
示例#14
0
main(void)
{
	/**********INITIALIZATIONS AND CONFIGURATIONS****************/
	/* Initialize communications */
	interface_init();
	lcd_init();

	/*********** RUNNING ****************************************/
	welcome();	

	while (1) {
		if (updateFlag())	updateLCD();
	}

}
示例#15
0
文件: Menu.cpp 项目: JoyLabs/arduino
void Menu::enter(){
	MenuItem *current = currentItem();
	if(current->children != 0){
		// has children, can enter
		_menuLevel++;
		_menuStack[_menuLevel] = current->children;
		updateLCD(0);
#if DEBUG
		char buf[128];
		snprintf(buf,128,"Enter Menu:%s",current->title);
		Serial.println(buf);
#endif
	}else{
#if DEBUG
		char buf[128];
		snprintf(buf,128,"Choosed Menu %s, level:%d, index:%d",current->title, _menuLevel,_menuIndex[_menuLevel]);
		Serial.println(buf);
#endif
		if(current->callback){
			// call the menu callbacks.
			current->callback((void*)current);
		}
	}
}
示例#16
0
void setOnOff(boolean bool, byte address){
	 if (bool) updateLCD(address, " ON");
	 else      updateLCD(address, "OFF");
示例#17
0
文件: Menu.cpp 项目: JoyLabs/arduino
void Menu::updateLCD(void){
	updateLCD(NULL);
}
示例#18
0
/***************************************************************************//**
 *   @brief      Runs the main routine
 *
 *               This function covers the main application code.
 *
 *   @note 		 Depending on the application, you can use either one or several
 *   			 calls from the following functions from the SIGFOX Library:
 *
 *	 @note 		\li SfxSendFrame(message, length, NULL, NULL) : Send an Uplink frame
 *   @note 		\li SfxSendFrame(message, length, ReceivedPayload, TRUE) : Downlink with ack
 *   @note 		\li SfxSendBit( 0, NULL, NULL) : Send a bit
 *   @note 		\li SfxSendOutOfBand() : Send OOB frame
 *   @note 		\li SfxTxTestMode(nb_frames, channel_number) : Tx TestModeFrame activation
 ******************************************************************************/
void
main(void)
{
	SFX_error_t volatile err;		// error returned from sigfox api functions. (For debug purpose)
#if defined(AT_CMD)
	host_cmd_status_t hostCmdStatus;
	char cmd[40];
	unsigned char length;
#endif
#if defined(PB_KEY)
	unsigned char buttonPressed;
#endif

	//Initialize the memory
	dynamic_memory_init();

	// Initialize MCU and Peripherals
	initMCU();

#ifdef __MSP430F5438A__

	// Display welcome screen on LCD
	welcomeLCD();
#endif

	// Write the uplink and downlink frequencies if device is programmed for first time
	resetCF();

	// SIGFOX library init
	err = SfxInit();
	assert(SFX_ERR_NONE == err);

	// Infinite loop
	for(;;)
	{

	GPIO_setAsOutputPin(GPIO_PORT_P4, GPIO_PIN7);
//	GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN7);

//	P4OUT |= 0x00;
	P4OUT &= ~BIT7;
#if defined(AT_CMD)
		// Detect Carriage Return in the string
		if(uartGetRxEndOfStr() == END_OF_LINE_DETECTED)
		{
			// Reset end of string detection
			uartResetRxEndOfStr();

			// Get the input string and its length
			length = uartGetRxStrLength();
			uartGetStr(cmd, length);

			// Parse the string to find AT commands
			hostCmdStatus = parseHostCmd((unsigned char *)cmd, length);
			assert(HOST_CMD_NOT_FOUND != hostCmdStatus);
		}
#endif
#if defined(PB_KEY)
		buttonPressed = bspKeyPushed(BSP_KEY_ALL);

		// Detect button push to send the message
		if((buttonPressed == BSP_KEY_SELECT) || (buttonPressed == BSP_KEY_UP))
		{
#if defined(__MSP430F5438A__)

			// Update LCD
			updateLCD();

			// Toggle LED indicators
			bspLedClear(BSP_LED_3);
			bspLedClear(BSP_LED_4);
#endif
			bspLedClear(BSP_LED_2);
			bspLedSet(BSP_LED_1);


			if(buttonPressed == BSP_KEY_UP)
			{
				// Send uplink only frame
				err = SfxSendFrame(message, sizeof(message), NULL, NULL);
			}
			else if(buttonPressed == BSP_KEY_SELECT)
			{
				// Send a bi-directional frame
				err = SfxSendFrame(message, sizeof(message), ReceivedPayload, TRUE);
			}

			// Reset button status
			buttonPressed = 0;

#if defined (__MSP430F5438A__)

			// Clear LED1
			bspLedClear(BSP_LED_1);

			// LED indicator for sigfox API error status
			if (err == SFX_ERR_NONE) {
				bspLedSet(BSP_LED_3);
			}
			else {
				bspLedSet(BSP_LED_4);
			}

			// Update LCD
			updateLCD();

#elif defined (__MSP430F5529__)

			if (err == SFX_ERR_NONE) {
				bspLedSet(BSP_LED_2);
			}
			else {
				bspLedClear(BSP_LED_2);
			}
#endif

			// Increment in message
			message[11]++;
		}
		else
		{
#if defined (__MSP430F5438A__)

			// Set LED2
			bspLedSet(BSP_LED_2);
#elif defined (__MSP430F5529__)

			// Clear LED1
			bspLedClear(BSP_LED_1);
#endif	//MSP
		}
#endif //INTERFACE
	}
}