Esempio n. 1
0
void movida::tick() {

    frames++;
    if(frames>=60) {
        frames=0;
        tickSecond();
    }

    gameWorld->tick();
    gameInterface->tick();

    // react to stat changes
    if(status::instance()->shutDown) gameExit = true;
    if(status::instance()->singelRender) {
        gameRedraw = true;
        status::instance()->singelRender=0;
    }

}
Esempio n. 2
0
void clockOps (void * p_context)
{
	uint16_t tickCount = tickSecond();
	char outbuf[20];
	
	initCoefficients();
	
	if (BLESessionActive == 1)
	{
/*	
		if (fd_check_motion_interrupt())
		{
			sprintf (outbuf, "Motion Interrupt");
			ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
		}
		
		if (fd_check_zero_g())
		{
			sprintf (outbuf, "ZeroG Interrupt");
			ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
		}

*/		

		
		if (sendRawData == 1) 
		{
			float p,r;
			
			rdg = rawDataPeek();
			
			sprintf (outbuf, "A: x%04xy%04xz%04x",rdg->val.x_ac,rdg->val.y_ac,rdg->val.z_ac);
			ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
//			sprintf (outbuf, "R: %04f",getR(rdg->val.x_ac,rdg->val.y_ac,rdg->val.z_ac));
//			ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
			
			accel_get_angles(&p,&r);
			sprintf (outbuf, "p: %04f, r: %04f",p,r);
			ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 20);
			
			if (checkOrientation() == ORIENTATION_STANDING)
			{
				sprintf (outbuf, "standing");
				ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 8);
			}
			else
			{	
				sprintf (outbuf, "not standing");
				ble_nus_send_string(&m_nus, (unsigned char*)outbuf, 12);
			}
			
			
		}
		
		return;
	}
	
#define INCLUDE_STEP_COUNTER

#ifdef INCLUDE_STEP_COUNTER
	// 5 minute backup, currently at 1sec
	#define DATA_SAVE_INTERVAL (120)
	if (tickCount % DATA_SAVE_INTERVAL == 0)
    {
			
			
			nrf_gpio_pin_set(LED_NO_FALL);
			nrf_delay_ms(40);
			nrf_gpio_pin_clear(LED_NO_FALL);
			
//			if (nSteps > 0) 
			{
				
				activityToSave = getActivityLevel();
				writeLog = 1; //writeLogEntry(nSteps);
				do_post_processing = true;
				updatePeakAverages();
			}
//			else
			{
				nrf_gpio_pin_set(LED_NO_FALL);
				nrf_gpio_pin_clear(LED_RESETTING);
				nrf_delay_ms(40);
				nrf_gpio_pin_clear(LED_NO_FALL);
				nrf_gpio_pin_set(LED_RESETTING);
				nrf_delay_ms(40);
				nrf_gpio_pin_clear(LED_RESETTING);
			}
    }
	#endif  //INCLUDE_STEP_COUNTER
}