コード例 #1
0
void Bling::Execute()
{
	ClearStrip();
	switch (pattern){
	case OFF:
		break;
	case BLUE_SOLID:
		SetColor(0,0,127);
		break;
	case BLUE_BLINKING:
		Blink(0,0,127);
		break;
	case GREEN_SOLID:
		SetColor(0,127,0);
		break;
	case GREEN_BLINKING:
		Blink(0,127,0);
		break;
	case RAINBOW_EXPLOSION:
		RainbowExplosion();
		break;
	case RED_BLINKING:
		Blink(127,0,0);
		break;
	case PURPLE_SOLID:
		SetColor(127,0,127);
		break;
	case PURPLE_BLINKING:
		Blink(127,0,127);
		break;
	default:
		printf("ERROR: in Bling.cpp execute switch\n");
	}
}
コード例 #2
0
ファイル: caret.cpp プロジェクト: BackupTheBerlios/wxbeos-svn
void wxCaret::DoMove()
{
    if ( IsVisible() )
    {
        if ( !m_blinkedOut )
        {
            // hide it right now and it will be shown the next time it blinks
            Blink();

            // but if the caret is not blinking, we should blink it back into
            // visibility manually
            if ( !m_timer.IsRunning() )
                Blink();
        }
    }
    //else: will be shown at the correct location when it is shown
}
コード例 #3
0
int main()
{
    initLED();
    while(1) //infinite loop
    {
        Blink();
    }
    return 0;
}
コード例 #4
0
ファイル: caret.cpp プロジェクト: BackupTheBerlios/wxbeos-svn
void wxCaret::OnKillFocus()
{
    m_hasFocus = false;

    if ( IsVisible() )
    {
        // the caret must be shown - otherwise, if it is hidden now, it will
        // stay so until the focus doesn't return because it won't blink any
        // more

        // hide it first if it isn't hidden ...
        if ( !m_blinkedOut )
            Blink();

        // .. and show it in the new style
        Blink();
    }
}
コード例 #5
0
ファイル: caret.cpp プロジェクト: BackupTheBerlios/wxbeos-svn
void wxCaret::DoShow()
{
    int blinkTime = GetBlinkTime();
    if ( blinkTime )
        m_timer.Start(blinkTime);

    if ( m_blinkedOut )
        Blink();
}
コード例 #6
0
ファイル: caret.cpp プロジェクト: BackupTheBerlios/wxbeos-svn
void wxCaret::DoHide()
{
    m_timer.Stop();

    if ( !m_blinkedOut )
    {
        Blink();
    }
}
コード例 #7
0
ファイル: main.c プロジェクト: 21rcc/ioio
int main() {
  log_init();

  // If bootloader mode not requested, go immediately to app.
  if (!ShouldEnterBootloader()) {
    OscCalibrateCached();
    log_printf("Running app...");
    __asm__("goto __APP_RESET");
  }

  // We need to enter bootloader mode, wait for the boot pin to be released.
  while (!led_read());

  // Now we can start!
  led_init();
#ifdef SIGNAL_AFTER_BAD_RESET
  if (RCON & 0b1100001001000000) {
    SignalRcon();
  }
#endif

  log_printf("Hello from Bootloader!!!");
  if (IsPin1Grounded()) {
    log_printf("Erasing config.");
    EraseConfig();
  }
  OscCalibrateCached();
  Blink(5);
  USBInitialize();

  while (1) {
    // Wait for connection
    while (!(USBGetDeviceState() == CONFIGURED_STATE
      && CDCIsDtePresent())) USBTasks();

    log_printf("Connected!");
    BootProtocolInit();

    while (USBGetDeviceState() == CONFIGURED_STATE && CDCIsDtePresent()) {
      static char in_buf[64];
      USBTasks();

      BYTE size = getsUSBUSART(in_buf, sizeof(in_buf));
      if (!BootProtocolProcess(in_buf, size)) {
        log_printf("Protocol error. Will detach / re-attach.");
        USBSoftDetach();
        __delay_ms(2000);
        USBDeviceAttach();
        break;
      }
      BootProtocolTasks();
    }
    log_printf("Disconnected!");
  }
  return 0;
}
コード例 #8
0
ファイル: raspberrylib.cpp プロジェクト: Mr-Ntic/rpi-kernel
	void PiFault( const char* msg ) {
		
		// This is the generic "raspberry pi is busted
		// and there is no screen to write to yet" 
		// error function. The message variable is just 
		// in the hopes that I can someday write to the 
		// sd card. But until I get there, it won't be used.
		Blink( 4, 200 );
		return;		
	}
コード例 #9
0
ファイル: caret.cpp プロジェクト: beanhome/dev
void wxCaret::DoMove()
{
#ifdef wxHAS_CARET_USING_OVERLAYS
    m_overlay.Reset();
#endif
    if ( IsVisible() )
    {
        if ( !m_blinkedOut )
        {
            // hide it right now and it will be shown the next time it blinks
            Blink();

            // but if the caret is not blinking, we should blink it back into
            // visibility manually
            if ( !m_timer.IsRunning() )
                Blink();
        }
    }
    //else: will be shown at the correct location when it is shown
}
コード例 #10
0
void main(void) {
    byte pattern=0;
    initSquareWear();
    initBlink();
    // open button interrupt
    openOnBoardButtonInterrupt(button_callback);
    while(1) {
        switch(pattern) {
            case 0:
                Blink(500); // blink at 500ms interval
                break;
            case 1:
                Blink(250); // blink at 250ms interval
                break;
            case 2:
                Blink(1000); // blink at 100ms interval
                break;
            case 3:
                Fade(15);   // fade at 50ms interval
                break;
            case 4:
                Fade(50);    // fade at 1ms interval
                break;
            case 5:
                Fade(4);    // fade at 2ms interval
                break;
        }
        if(change) {
            pattern=(pattern+1)%6;  // change pattern
            // call corresponding initialization function
            if(pattern==0 || pattern==1 || pattern==2)  {
                initBlink();
            } else {
                initFade();
            }
            change=0;
        }

    }

}
コード例 #11
0
ファイル: prosper.CPP プロジェクト: IAmAnubhavSaini/templeos
U0 DrawIt(CTask *task,CDC *dc)
{
  F64 dt=tMBeat-t0;
  dc->flags|=DCF_TRANSFORMATION;
  GrRotZEqu(dc->r,0.25*Sin(2*ã*tM));
  GrScaleMatEqu(dc->r,1.5+0.5*Sin(tM));
  GrSetRotMat(dc,dc->r);
  if (Blink(0.5))
    SpritePlot3b(dc,12.0*dt%task->win_pixel_width,20,0,$IB,"<1>",1$);
  else
    SpritePlot3b(dc,12.0*dt%task->win_pixel_width,20,0,$IB,"<2>",2$);
}
コード例 #12
0
ファイル: main.cpp プロジェクト: Donny3000/auto-garden
void loop()
{
  delay(1000);  // Wait 1 second between transmits, could also 'sleep' here!

  // Create and pack the heartbeat data
  mavlink_msg_heartbeat_pack(NODEID, NODEID, &data_pkt, 78.3, 45.1, 83.6, 75.4, 10234);
  uint16_t buf_len = mavlink_msg_to_send_buffer(mavlink_buf, &data_pkt);

  radio.send(RECEIVER, mavlink_buf, buf_len, false);
  Blink(LED_BUILTIN, 50, 3);
  /*if(radio.sendWithRetry(RECEIVER, radiopacket, strlen(radiopacket)))
  {
    Serial.println("OK");
    Blink(LED_BUILTIN, 50, 3); //blink LED 3 times, 50ms between blinks
  }*/

  radio.receiveDone(); // Put radio in RX mode
  Serial.flush(); // Make sure all serial data is clocked out before sleeping the MCU
}
コード例 #13
0
ファイル: Artefact.cpp プロジェクト: AntonioModer/xray-16
void SArtefactDetectorsSupport::UpdateOnFrame()
{
	if(m_currPatrolPath && !m_parent->getVisible())
	{
		if(m_parent->Position().distance_to(m_destPoint) < 2.0f)
		{
			CPatrolPath::const_iterator b,e;
			m_currPatrolPath->begin(m_currPatrolVertex,b,e);
			if(b!=e)
			{
				std::advance(b, ::Random.randI(s32(e-b)));
				m_currPatrolVertex	= m_currPatrolPath->vertex((*b).vertex_id());
				m_destPoint			= m_currPatrolVertex->data().position();
			}	
		}
		float		cos_et	= _cos(deg2rad(45.f));
		Fvector		dir;
		dir.sub		(m_destPoint, m_parent->Position()).normalize_safe();

		Fvector v;
		m_parent->PHGetLinearVell(v);
		float	cosa		= v.dotproduct(dir);
		if(v.square_magnitude() < (0.7f*0.7f) || (cosa<cos_et) )
		{
			Fvector			power = dir;
			power.y			+= 1.0f;
			power.mul		(m_path_moving_force);
			m_parent->m_pPhysicsShell->applyGravityAccel(power);
		}
	}

	if(m_parent->getVisible() && m_parent->GetAfRank()!=0 && m_switchVisTime+5000 < Device.dwTimeGlobal)
		SetVisible(false);

	u32 dwDt = 2*3600*1000/10; //2 hour of game time
	if(!m_parent->getVisible() && m_switchVisTime+dwDt < Device.dwTimeGlobal)
	{
		m_switchVisTime		= Device.dwTimeGlobal;
		if(m_parent->Position().distance_to(Device.vCameraPosition)>40.0f)
			Blink			();
	}
}
コード例 #14
0
ファイル: main_blink2.c プロジェクト: 3spds/stm32f4
int main(void)
{

//init:
    DAC_DeInit();
    init_DMA_GPIO_ADC();
    /* Start ADC3 Software Conversion */
    ADC_SoftwareStartConv(ADC3);

//say hello:
    Blink(1000000L);

    while (1)
    {
        DAC1ConvertedValue = ADC3ConvertedValue;
        //Blink((uint32_t)ADC3ConvertedValue*1000L);
        //Pulse();
        Blink2((u)
    }
}
コード例 #15
0
ファイル: main.c プロジェクト: spookymelonhead/Tuna_fish
int main()
{
	SerialDebug(250000);			//PrintString() and PrintFloat() using UART
	BeginBasics();
	Blink();
	Enable_PeriphClock();
	
	/*Roll-0 Pitch-1 Yaw-2..Roll rotation around X axis.Pitch rotation around Y axis and Yaw rotation around Z axis
	note: It does not mean rotation along the X Y or Z axis*/
	
	float RPY_c[3],RPY_k[3];					//RPY_c and RPY_k..Roll pitch and yaw obtained from complemntary filter and kalman filter													
	float Accel[3],Gyro[3],Tempreature;			//raw values
	float Accel_RealWorld[3];					//Real World Acceleration

	while(Init_I2C(400)){PrintString("\nI2C Connection Error");}	
	while(MPU6050_Init()){PrintString("MPU6050 Initialization Error");}
	MPU6050_UpdateOffsets(&MPU6050_Offsets[0]);
	//MPU6050_ConfirmOffsets(&MPU6050_Offsets[0]);
	
	while(0)						//to play around with quaternions and vector rotation
	{
		float vector[3]= {1,0,0};
		float axis_vector[3]= {0,1,0};		//rotate around Y axis
		float rot_angle=90;					//with 90 degrees
		
		Quaternion q;
		
		q=RotateVectorY(vector,rot_angle);	//Rotates vector around Y axis with rot_angle

		PrintString("\nRotated Vector's Quaternion\t");
		DisplayQ(q);
		
		PrintString("\n");
	}
	
	while(1)
	{
		MPU6050_GetRaw(&Accel[0],&Gyro[0],&Tempreature);	//Reads MPU6050 Raw Data Buffer..i.e Accel Gyro and Tempreature values

		if(Gyro[2]<0.3 && Gyro[2]>-0.3) Gyro[2]=0;			//this actually reduces Yaw drift..will add magnetometer soon

		spudnut=tics();										//tics() return current timing info..using SysTick running at CPU_Core_Frequency/8..Counter Runs from 0xFFFFFF to 0 therefore overflows every 1.864135 secs
		delt=spudnut-donut;									//small time dt
		donut=spudnut;											
		
		//Display_Raw(Accel,Gyro,Tempreature);
		
		Attitude_k(Accel,Gyro,RPY_k,delt);	//Estimates YPR using Kalman
		
		
		PrintString("\nYPR\t");
		PrintFloat(RPY_k[2]);
		PrintString("\t");
		PrintFloat(RPY_k[1]);
		PrintString("\t");
		PrintFloat(RPY_k[0]);
		
		RemoveGravity(RPY_k,Accel,Accel_RealWorld);
		PrintString("\tReal World Accel with Gravity\t");			//still glitchish..working on it
		DisplayVector(Accel_RealWorld);
		
		PrintString("\t");
		PrintFloat(1/delt);
	}
}
コード例 #16
0
ファイル: TstStdio2.c プロジェクト: jjmcd/Elmer160
void main()
{
  byte nCaseNumber;
  int nLEDnumber;

  // Turn off AN3, 4 and 5
  ADCON1 = 0x34;
  // Set all pins output for now
  TRISA = 0x00;
  TRISB = 0x00;		// LEDs only outputs

  // Initialize LCD display
  LCDinit();

  // Use user code rather than serial port
  stdout = STREAM_USER;

  // Signon Banner
  printf("\014TstStdio2.c  ");
  Delay4();
  printf("\014$Revision: 0.10 $");
  Delay4();
  printf("\014%s  ",__DATE__);
  Delay4();

  // Flash RB1 - LED1
  nLEDnumber = 1;
  printf("\014");
  printf("LED #%d",nLEDnumber);
  LCDaddr(20);
  Blink(LED1);
  Blink(LED1);

  // Flash RB0 - LED2
  nLEDnumber = 2;
  printf("\014LED %d",nLEDnumber);
  LCDaddr(20);
  Blink(LED2);
  Blink(LED2);

  // Flash RA3 - LED3
  printf("\014LED 0x%x_012345678",3);
  LCDaddr(20);
  Blink(LED3);
  Blink(LED3);

  printf("\014");

  // Now loop through pattern
  while ( 1 )  // And do this for quite a long time
    {
      for ( nCaseNumber=0; nCaseNumber<5; nCaseNumber++ )
	{
	  printf("\014");
	  if ( nCaseNumber )
	    {
	      printf("%s",pMs[nCaseNumber-1]);
	    }
	  LCDaddr(0x40);
	  printf("%s",pMs[nCaseNumber]);
	  LCDaddr(20);
	  Delay4();
	  Delay4();
	  //Delay();
	}
      printf("\014");
      for ( nCaseNumber=0; nCaseNumber<4; nCaseNumber++ )
        {
	  switch ( nCaseNumber )
	  {
	    case 0:
              printf( Message1 );  // Display the message
	      Blink( LED1 );        // Blink the LED
	      break;
	    case 1:
	      printf( Message2, nCaseNumber );
	      Blink( LED2 );
	      break;
	    case 2:
	      printf( Message3, nCaseNumber );
	      Blink(LED3);
	      break;
	    default:
	      printf( Message4 );
	      Delay();
	  }
	  printf("\014");
	}
      for ( nCaseNumber=0; nCaseNumber<4; nCaseNumber++ )
        {
	  switch ( nCaseNumber )
	  {
	    case 0:
              printf( Message1 );  // Display the message
	      LCDaddr(66);
	      Blink( LED1 );        // Blink the LED
	      LCDaddr(70);
	      Blink( LED2 );
	      LCDaddr(74);
	      Blink( LED3 );
	      break;
	    case 1:
	      printf( Message2, nCaseNumber );
	      LCDaddr(70);
	      Blink( LED2 );
	      LCDaddr(74);
	      Blink( LED3 );
	      LCDaddr(66);
	      Blink( LED1 );
	      break;
	    case 2:
	      printf( Message3, nCaseNumber );
	      LCDaddr(74);
	      Blink( LED3 );
	      LCDaddr(66);
	      Blink( LED1 );
	      LCDaddr(70);
	      Blink( LED2 );
	      break;
	    default:
	      printf( Message4 );
	      LCDaddr(20);
	      Delay();
	  }
	  printf("\014");
	}
      for ( nCaseNumber=0; nCaseNumber<4; nCaseNumber++ )
        {
	  switch ( nCaseNumber )
	  {
	    case 0:
              printf( Ms1 );  // Display the message
	      Blink( LED1 );        // Blink the LED
	      Blink( LED2 );
	      Blink( LED3 );
	      break;
	    case 1:
	      printf( Ms2 );
	      Blink( LED1 );
	      Blink( LED2 );
	      Blink( LED3 );
	      break;
	    case 2:
	      printf( Ms3 );
	      Blink( LED1 );
	      Blink( LED2 );
	      Blink( LED3 );
	      break;
	    default:
	      printf( Ms4 );
	      Delay();
	      Delay();
	      Delay();
	  }
	  printf("\014");
	}
      for ( nCaseNumber=0; nCaseNumber<4; nCaseNumber++ )
        {
	  switch ( nCaseNumber )
	  {
	    case 0:
              printf( Message1 );  // Display the message
	      Blink( LED1 );        // Blink the LED
	      Blink( LED2 );
	      Blink( LED3 );
	      Blink( LED1 );        // Blink the LED
	      Blink( LED2 );
	      Blink( LED3 );
	      break;
	    case 1:
	      printf( Message2, nCaseNumber );
	      Blink( LED1 );
	      Blink( LED2 );
	      Blink( LED3 );
	      Blink( LED1 );        // Blink the LED
	      Blink( LED2 );
	      Blink( LED3 );
	      break;
	    case 2:
	      printf( Message3, nCaseNumber );
	      Blink( LED1 );
	      Blink( LED2 );
	      Blink( LED3 );
	      Blink( LED1 );        // Blink the LED
	      Blink( LED2 );
	      Blink( LED3 );
	      break;
	    default:
	      printf( Message4 );
	      Delay();
	  }
	  printf("\014");
	}
      for ( nCaseNumber=0; nCaseNumber<4; nCaseNumber++ )
        {
	  switch ( nCaseNumber )
	  {
	    case 0:
              printf( Ms1 );  // Display the message
	      LCDaddr(0x50);
	      Blink( LED1 );        // Blink the LED
	      Blink( LED2 );
	      Blink( LED3 );
	      Blink( LED1 );        // Blink the LED
	      Blink( LED2 );
	      Blink( LED3 );
	      break;
	    case 1:
	      printf( Ms1 );
	      LCDaddr(40);
	      printf( Ms2 );
	      LCDaddr(0x50);
	      Blink( LED1 );
	      Blink( LED2 );
	      Blink( LED3 );
	      Blink( LED1 );        // Blink the LED
	      Blink( LED2 );
	      Blink( LED3 );
	      break;
	    case 2:
	      printf( Ms2 );
	      LCDaddr( 40 );
	      printf( Ms3 );
	      LCDaddr(0x50);
	      Blink( LED1 );
	      Blink( LED2 );
	      Blink( LED3 );
	      Blink( LED1 );        // Blink the LED
	      Blink( LED2 );
	      Blink( LED3 );
	      break;
	    default:
	      printf( Ms3 );
	      LCDaddr( 40 );
	      printf( Ms4 );
	      LCDaddr(0x50);
	      Delay4();
	      Delay4();
	      //Delay();
	  }
	  printf("\014");
	}
      LED1 = LED2 = LED3 = 0;    // All LEDs on
      Delay();                   // Wait a bit
      LED1 = LED2 = LED3 = 1;    // All LEDs off
    }
}
コード例 #17
0
ファイル: sendCmd.cpp プロジェクト: BackupGGCode/motenet
void loop() {

  //check for any received packets
  if (radio.receiveDone()) {
    Serial.print('[');Serial.print(radio.SENDERID, DEC);Serial.print("] ");
    for (byte i = 0; i < radio.DATALEN; i++)
      Serial.print((char)radio.DATA[i]);
    Serial.print("   [RX_RSSI:");Serial.print(radio.readRSSI());Serial.print("]");

    if (radio.ACK_REQUESTED)
    {
      radio.sendACK();
      Serial.print(" - ACK sent");
      delay(10);
    }
    Blink(LED,5);
    Serial.println();
  }

  // 
  int currPeriod = millis()/TRANSMITPERIOD;
  //Serial.print("lastPeriod: ");
  //Serial.print(lastPeriod);
  //Serial.print(" currPeriod: ");
  //Serial.println(currPeriod);  

  if (currPeriod != lastPeriod) {
    //fill in the struct with new values
    theData.msgID = millis();
    theData.pkgType = 1;
    //theData.count = currPeriod;
    
    thePackage.a = 9;
    thePackage.b = 19;
    thePackage.c = 29;
    thePackage.d = 39;

    //theData.pkg = (const void*)(&thePackage);
    memcpy(theData.pkg, &thePackage, sizeof(thePackage));

    Serial.print("Sending struct (");
    Serial.print(sizeof(theData));
    Serial.print(" bytes) ... ");
    
    /* TEST - Delete 
    if (currPeriod % 2) { 
    if (radio.sendWithRetry(TARGETID, (const void*)(&theData), sizeof(theData)))
      Serial.print(" ok!");
    else Serial.print(" nothing...");
    } else {
    if (radio.sendWithRetry(TARGETID_2, (const void*)(&theData), sizeof(theData)))
      Serial.print(" ok!");
    else Serial.print(" nothing...");
    }
    */


    if (radio.sendWithRetry(TARGETID, (const void*)(&theData), sizeof(theData)))
      Serial.print(" ok!");
    else Serial.print(" nothing...");
    

    Serial.println();
    Blink(LED,3);
    lastPeriod=currPeriod;
  }
}
コード例 #18
0
ファイル: SceneObject.cpp プロジェクト: OLR-xray/OLR-3.0
//----------------------------------------------------
void CSceneObject::Select(BOOL flag)
{
	inherited::Select(flag);
    if (flag) Blink();
}
コード例 #19
0
ファイル: main.cpp プロジェクト: Kreyl/WitcherGlove
static void Hold(PwmPin_t *PLed) {
    Blink(PLed);
}
コード例 #20
0
ファイル: main.cpp プロジェクト: Kreyl/WitcherGlove
static void Exec(PwmPin_t *PLed) {
    Vibro.On(VIBRO_EXEC);
    Blink(PLed);
    Blink(PLed);
    Vibro.Off();
}
コード例 #21
0
/**
	 * @brief Worker thread main superloop that defines how the thread will always display values 
	 * depending on the relevant mode of operation
	 * @param void*
   * @retval void
   */
void Thread_DISP(void const *argument){
	
	double temp2;
	int disp[] = {0, 0, 0, 0}; 
	int* temp3;
	float roll_temp, pitch_temp;
	int final_col = 0; 
	int sample_col;
	interrupt7 = 0;
	
	while(1){
		
		sample_col = Get_Column();
		if(sample_col != NULL){ 
			if(interrupt7 > 50){ 
				// printf("column= %d\n", sample_col);
				final_col = sample_col;
				interrupt7 = 0;
			}					
		}
		
		if(final_col != 0){ 
			
			// printf("col= %d\n", final_col);
			if(final_col == 4){
				mode = 0;
			}
			else if(final_col == 5){
				mode = 1;
				mode1 = 0;
			}
			else{
				mode = 1;
				mode1 = 1;
			}
		}
		
		if(mode == 0){
		
			// osDelay(2);
			osMutexWait(temp_mutex_id, osWaitForever);
			temp2 = output;
			osMutexRelease(temp_mutex_id);
			// printf("disp: temp2= %f\n", temp2);		
			Parse_Temp(temp2, disp);
			// printf("%d %d %d %d\n", disp[3], disp[2], disp[1], disp[0]);
			
			if(interrupt5 == 1){
				temp3 = disp;
			}
			
			if(interrupt4 <= 2){
				if(temp3[3] == 4 && temp3[2] > 0 && interrupt5 > 600) Blink();
				else Display(temp3[3], 4);
			}
			
			else if(interrupt4 <= 4){
				if(temp3[3] == 4 && temp3[2] > 0 && interrupt5 > 600) Blink();
				else Display(temp3[2], 3);
			}
			
			else if(interrupt4 <= 6){
				if(temp3[3] == 4 && temp3[2] > 0 && interrupt5 > 600) Blink();
				else Display(temp3[0], 1);
			}
			
			else if(interrupt4 <= 8){
				if(temp3[3] == 4 && temp3[2] > 0 && interrupt5 > 600) Blink();
				else Display(11, 0);
			}
			
			else{
				if(temp3[3] == 4 && temp3[2] > 0 && interrupt5 > 600) Blink();
				else Display(temp3[1], 2);
			}

			/* Reset loop counter after 90 cycles */
			if(interrupt5 > 1200){
				HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);
				HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_RESET);
				HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3, GPIO_PIN_RESET);
				interrupt5 = 0;					
			}
			
			/* Reset loop counter after 4 cycles */
			if(interrupt4 > 10){
				interrupt4 = 0;
			}
		}
		
		else{
		
			if(mode1 == 0){
				
				// osDelay(2);
				osMutexWait(mems_mutex_id, osWaitForever);
				roll_temp = roll;
				osMutexRelease(mems_mutex_id);
				// printf("mems: roll= %f\n", roll_temp);
				// printf("mems: temp= %f\n", output);
						
				if(roll_temp < 100){
					Parse_Mems(parsed, roll_temp);								
					// printf("disp2: %d %d %d %d %d\n", parsed[3], parsed[2], parsed[1], parsed[0], parsed[4]);
				}
				
				else{
					parsed[0] = (int) roll_temp % 10;
					parsed[2] = ((int) roll_temp / 10) % 10;
					parsed[3] = ((int) roll_temp / 100) % 10;
					parsed[1] = 0;
					parsed[4] = 0;				
					// printf("disp2: %d %d %d %d %d\n", parsed[3], parsed[2], parsed[1], parsed[0], parsed[4]);
				}
			}
			
			else{
			
				// osDelay(2);
				osMutexWait(mems_mutex_id, osWaitForever);
				pitch_temp = pitch;
				osMutexRelease(mems_mutex_id);
				// printf("mems: roll= %f\n", pitch_temp);
				// printf("mems: temp= %f\n", output);
				
				if(pitch_temp < 100){
					Parse_Mems(parsed, pitch_temp);								
					// printf("disp2: %d %d %d %d %d\n", parsed[3], parsed[2], parsed[1], parsed[0], parsed[4]);
				}
				
				else{
					parsed[0] = (int) pitch_temp % 10;
					parsed[2] = ((int) pitch_temp / 10) % 10;
					parsed[3] = ((int) pitch_temp / 100) % 10;
					parsed[1] = 0;
					parsed[4] = 0;				
					// printf("disp2: %d %d %d %d %d\n", parsed[3], parsed[2], parsed[1], parsed[0], parsed[4]);
				}
			}
			
			if(parsed[4] < 0 || parsed[3] < 0 || parsed[2] < 0 || parsed[1] < 0 || parsed[0] < 0) Show_Negative();
			else Show();
		}
	}
}
コード例 #22
0
ファイル: caret.cpp プロジェクト: BackupTheBerlios/wxbeos-svn
void wxCaret::OnTimer()
{
    // don't blink the caret when we don't have the focus
    if ( m_hasFocus )
        Blink();
}
コード例 #23
0
ファイル: main.c プロジェクト: buihaduong/tismartbin_hardware
int main(void) {
	unsigned char button_val;
	unsigned char Delta;
	unsigned char Rawstate;

	//
	// Setup the system clock to run at 80 Mhz from PLL with crystal reference
	//
	SysCtlClockSet(
			SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN
					| SYSCTL_XTAL_16MHZ);

	//
	// Enable and configure the GPIO port for the LED operation.
	//
	SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
	GPIOPinTypeGPIOOutput(LED, RED_LED | BLUE_LED | GREEN_LED);
	GPIOPinWrite(LED, RED_LED | BLUE_LED | GREEN_LED, 0x00);

	Blink(GREEN_LED | BLUE_LED, 5, 50);

	ButtonsInit();
	UARTInit();

	while (1) {
		SysCtlDelay(100000);

		button_val = ButtonsPoll(&Delta, &Rawstate);

		if (BUTTON_PRESSED(LEFT_BUTTON,button_val,Delta)) {
			if (SendAndCheck("AT", 1)) {
				Blink(BLUE_LED, 1, 300);
			} else {
				Blink(RED_LED, 1, 300);
			}
		}

		if (BUTTON_PRESSED(RIGHT_BUTTON,button_val,Delta)) {
			break;
		}
	}

	Blink(GREEN_LED, 1, 1000);

	ADCInit();
	InitSonar();
	SimInit();

	Blink(BLUE_LED, 1, 1000);

	//
	// Loop Forever
	//
	while (1) {
		SysCtlDelay(100000);

		button_val = ButtonsPoll(&Delta, &Rawstate);

		if (BUTTON_PRESSED(LEFT_BUTTON,button_val,Delta)) {
			GPIOPinWrite(LED, RED_LED | BLUE_LED | GREEN_LED, GREEN_LED);
			max_distance = GetDistanceSonar();
			GPIOPinWrite(LED, RED_LED | BLUE_LED | GREEN_LED, 0x00);

			if (SendAndCheck("AT", 1)) {
				Blink(BLUE_LED, 1, 300);
			} else {
				Blink(RED_LED, 1, 300);
			}
		}

		if (BUTTON_PRESSED(RIGHT_BUTTON,button_val,Delta)) {
			isRunning = !isRunning;
		}

		if (isRunning) {
			tempC = GetTemperature();
			if (tempC > 70) {
				SendData(DATA_TEMP, tempC);
				Blink(RED_LED, 3, 100);
			}

			distance = GetDistanceSonar();
			percentage = (int) floor(
					((max_distance - distance) * 100.0) / max_distance);
			if ((percentage >= 0) && (percentage <= 100)
					&& abs(percentage - oldPercentage) > 10) {
				SendData(DATA_TRASH, percentage);
				oldPercentage = percentage;
			}

			Blink(GREEN_LED, 1, 10);
		}
	}
}
コード例 #24
0
void Show(void){
		
	// printf("%d %d %d %d\n", displaying[3], displaying[2], displaying[1], displaying[0]);
	
	if(interrupt3 == 1){
		displaying[3] = parsed[3];
		displaying[2] = parsed[2];
		displaying[1] = parsed[1];
		displaying[0] = parsed[0];
		displaying[4] = parsed[4];
	}
	
	if(interrupt2 < 2){
		if(displaying[3] != 0){
			if(output > 32 && interrupt3 > 600) Blink();
			else Display(displaying[3], 4);
		}
		else{
			if(output > 32 && interrupt3 > 600) Blink();
			else Display(displaying[2], 4);
		}
	}
	
	else if(interrupt2 < 4){
		if(displaying[3] != 0){
			if(output > 32 && interrupt3 > 600) Blink();
			else Display(displaying[2], 3);
		}
		else{
			if(output > 32 && interrupt3 > 600) Blink();
			else Display(displaying[1], 4);
		}
	}
	
	else if(interrupt2 < 6){
		if(displaying[3] != 0){
			if(displaying[1] != 0){
				if(output > 32 && interrupt3 > 600) Blink();
				else Display(displaying[1], 3);
			}
		}
		else{
			if(output > 32 && interrupt3 > 600) Blink();
			else Display(displaying[0], 3);
		}
	}
	
	else if (interrupt2 < 8){	
		if(displaying[3] != 0){		
			if(output > 32 && interrupt3 > 600) Blink();
			else Display(displaying[0], 1);					
		}
		else{
			if(output > 32 && interrupt3 > 600) Blink();
			else Display(displaying[4], 1);
		}
	}
	
	else{
		if(output > 32 && interrupt3 > 600) Blink();
		else Display(11, 0);
	}

	if(interrupt3 > 1200){
		HAL_GPIO_WritePin(GPIOA, GPIO_PIN_1, GPIO_PIN_RESET);
		HAL_GPIO_WritePin(GPIOA, GPIO_PIN_2, GPIO_PIN_RESET);
		HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3, GPIO_PIN_RESET);
		interrupt3 = 0;					
	}
	
	if(interrupt2 > 10){
		interrupt2 = 0;
	}	
}
コード例 #25
0
void Cf3MapObjectfunya::OnMove()
{
	if (!IsValid()) return;
	if (!m_pParent->IsPlayable()) return;
	if (m_bFirst) { HitCheck(); m_bFirst = false; }
	float Wind = m_pParent->GetWind(floor(m_X/32),floor(m_Y/32));
	float Friction = m_pParent->GetFriction(floor(m_X/32),floor((m_Y+14)/32));
	float Gravity = GetGravity();
	if (m_pParent->ItemCompleted()) Smile();
	if (theSetting->m_Hyper) m_nPower=4;
	// 動かしま〜す
	if (m_State==STANDING||m_State==SLEEPING||m_State==BLINKING) {
		// 立ってるとき
		m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
		BringClose(m_DX,0.0f,Friction);
		if (m_DX==0) m_Direction = DIR_FRONT;
		if (m_State==STANDING && ++m_Sleepy>=30*40/3) Sleep();
		if (m_State==BLINKING && --m_PoseCounter==0) m_State = STANDING;
		if (m_State==STANDING && CApp::random(120)==0) Blink();
		if (m_PowerY<=0 && m_pInput->GetKeyPressed(F3KEY_JUMP)) StartJump();
		if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) Run(DIR_LEFT);
		if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) Run(DIR_RIGHT);
		if (m_pInput->GetKeyPressed(F3KEY_DOWN)) Sit();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_HitBottom) {
			Fall();
		}
	}ef(m_State==RUNNING) {
		// 走ってるとき
		int AXL = 0, AXR = 0;
		if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) AXL = 1;
		if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) AXR = 1;
		m_DX -= Friction*(m_DX-Wind)*RUNFRICTION;
		m_DX += Friction*2.0f*(AXR-AXL);
		if (AXL&&!AXR) m_Direction = DIR_LEFT;
		if (AXR&&!AXL) m_Direction = DIR_RIGHT;
		if (!AXL&&!AXR) Stop();
		if (m_PowerY<=0 && m_pInput->GetKeyPressed(F3KEY_JUMP)) StartJump();
		if (m_pInput->GetKeyPressed(F3KEY_DOWN)) Sit();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_HitBottom) {
			Fall();
		}
	}ef(m_State==WALKING) {
		// 歩いてるとき
		int AXL = 0, AXR = 0;
		if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) AXL = 1;
		if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) AXR = 1;
		m_DX += WALKACCEL*(AXR-AXL);
		m_DX -= m_DX*WALKFRICTION;
		if (AXL&!AXR) m_Direction = DIR_LEFT;
		if (AXR&!AXL) m_Direction = DIR_RIGHT;
		if (!AXL&!AXR) m_Direction = DIR_FRONT;
		if (!m_pInput->GetKeyPressed(F3KEY_DOWN)) Stop();
		if (m_PowerY<=0 && m_pInput->GetKeyPushed(F3KEY_JUMP)) StartJump();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_HitBottom) Fall();
	}ef(m_State==CHARGING) {
		// パワー充填中
		if (m_ChargePower>0) {
			m_ChargePower -= m_ChargeDec;
			if (m_ChargePower<0) m_ChargePower = 0;
		}
		m_X -= m_DX;
		if (m_pInput->GetKeyPushed(F3KEY_DOWN)) Sit();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_pInput->GetKeyPressed(F3KEY_JUMP)) Jump();
		if (!m_HitBottom) Fall();
	}ef(m_State==JUMPING) {
		// 空中
		if (m_DY>=0) {
			int AXL = 0, AXR = 0;
			if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) AXL = 1;
			if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) AXR = 1;
			m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			m_DX += JUMPACCEL*(AXR-AXL);
			if (AXL&!AXR) m_Direction = DIR_LEFT;
			if (AXR&!AXL) m_Direction = DIR_RIGHT;
		}
		if (m_HitLeft||m_HitRight) m_Direction = DIR_FRONT;
		m_DY += Gravity;
		if (m_DY>=0) {
			if (m_PowerY>=0 && m_pInput->GetKeyPressed(F3KEY_DOWN)) m_DY += Gravity*ADDGRAVITY;
			m_DY -= m_DY*JUMPFRICTIONY;
			if (m_pInput->GetKeyPressed(F3KEY_UP)) {
				m_DY += Gravity;
				m_DY -= m_DY*JUMPFRICTIONY;
			}
		}
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (m_HitBottom) Land();
	}ef(m_State==BREATHEIN) {
		// 冷気充填中
		m_ChargePower+=1.0f;
		if (m_pInput->GetKeyPushed(F3KEY_LEFT)) m_Direction = DIR_LEFT;
		if (m_pInput->GetKeyPushed(F3KEY_RIGHT)) m_Direction = DIR_RIGHT;
		if (m_pInput->GetKeyPushed(F3KEY_UP)) m_Direction = DIR_FRONT;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
			BringClose(m_DX,0.0f,Friction);
			if (m_pInput->GetKeyPushed(F3KEY_DOWN)) Sit();
		}else {
			m_ChargePower+=1.0f;
			if (m_DY>=0) {
				m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			}
			m_DY += Gravity;
			if (m_DY>=0) {
				m_DY -= m_DY*JUMPFRICTIONY;
			}
		}
		if (!m_pInput->GetKeyPressed(F3KEY_ATTACK)) BreatheOut();
	}ef(m_State==BREATHEOUT) {
		// 冷気放出!!
		m_ChargePower-=1.0f;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
			BringClose(m_DX,0.0f,Friction);
		}else {
			if (m_DY>=0) {
				m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			}
			m_DY += Gravity;
			if (m_DY>=0) {
				m_DY -= m_DY*JUMPFRICTIONY;
			}
		}
		if (m_ChargePower<=0.0f) {
			if (m_nPower) {
				if (m_HitBottom) Land(); else Fall();
			}else {
				Tire();
			}
		}
	}ef(m_State==TIRED) {
		// ちかれたー!
		m_PoseCounter--;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
			BringClose(m_DX,0.0f,Friction);
		}else {
			m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			if (m_HitLeft||m_HitRight) m_Direction = DIR_FRONT;
			m_DY += Gravity;
			m_DY -= m_DY*JUMPFRICTIONY;
		}
		if (m_PoseCounter==0) Land();
	}ef(m_State==FROZEN) {
		// 凍っちゃった…
		m_PoseCounter--;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION/5;
			BringClose(m_DX,0.0f,Friction/5);
		}else {
			m_DX -= (m_DX-Wind)*JUMPFRICTIONX/5;
			m_DY += Gravity*(1+ADDGRAVITY);
			m_DY -= m_DY*JUMPFRICTIONY/5;
		}
		if (m_PoseCounter==0) Land();
	}
	// 速度飽和(めり込み防止)
	Saturate(-RUNMAX,m_DX,RUNMAX);
	Saturate(-JUMPMAX,m_DY,FALLMAX);
	// 実際の移動+当たり判定
	// 1回の移動ごとに当たり判定
	// という手順ですり抜けバグは解消されるはず
	m_HitLeft = m_HitRight = m_HitTop = m_HitBottom = false;
	m_X += m_DX;
	HitCheck();
	if (!m_HitTop&&!m_HitBottom) {
		m_Y += m_DY;
		HitCheck();
	}
}