Beispiel #1
0
void showStrtScrn(){    //Tested  
  OrbitOledClear();
  OrbitOledMoveTo(48,0);
  OrbitOledPutBmp(strtScrnW,strtScrnH,strtScrnBMP);
  // OrbitOledSetCursor(3,3);
  // OrbitOledPutString("START GAME");
  OrbitOledSetCursor(0,3);
  OrbitOledPutString(" PRESS TO START ");

  
  // for(int t=0,c='3';t<3;t++,c--){   //show timer
  //   OrbitOledSetCursor(14,3);
  //   OrbitOledPutChar(c);
  //   updateLED(4);
  //   delay(400);
  //   updateLED(0);
  //   delay(200);
  // }

  long lBtn1;
  lBtn1 = GPIOPinRead(BTN1Port, BTN1);
  while(lBtn1!=BTN1){
    updateLED(4);
    delay(100);
    updateLED(0);
    delay(100);
    lBtn1 = GPIOPinRead(BTN1Port, BTN1);
  } 
}
void Karussell::drehen() {
    NOTIFY_OPERATION(drehen, drehen(), 0, System_Karussell_drehen_SERIALIZE);
    //#[ operation drehen()
    Waage* myWaage = itsWaage[MaxStation-1]; 
    
    if( !GlaeserDrauf() ) return;
    
    for(int i=0; i < MaxStation; i++) 
    {
    	if( !itsStation[i]->isOk() ) return; 
    }
    
    for( int i = MaxStation-1; i > 0; i-- )
    {
    	itsWaage[i] = itsWaage[i-1];
    	
    }
    itsWaage[0] = myWaage;  
     
    updateLED();
     
    for(int i=0; i < MaxStation; i++) 
    {
    	itsStation[i]->GEN(evRun); 
    }
    
    jemalsgedreht = true;         
    //#]
}
Beispiel #3
0
void targetSetAllLED (uint8 msk)
{
	if (ledMsk != msk)
	{
		ledMsk = msk;
		updateLED();
	}
}
void Karussell::updateLED() {
    NOTIFY_OPERATION(updateLED, updateLED(), 0, System_Karussell_updateLED_SERIALIZE);
    //#[ operation updateLED()
    for(int i=0; i < MaxStation; i++) 
    {
    	itsLed[i]->setOn(itsWaage[i]->getBrutto() >= GlasGewicht); 
    }
    //#]
}
Beispiel #5
0
// ###### Start calculation #################################################
void FractalGeneratorView::startCalculation()
{
   if(Thread == NULL) {
      Thread = new FractalCalculationThread(this, Algorithm, ColorScheme, Buffer, Display->image(), ProgStep);
      Q_CHECK_PTR(Thread);
      Thread->start();
      updateLED(true);
   }
}
Beispiel #6
0
void displayScore () {
  char scoreStr[8];
  if(score<0)score=0; //Dont wanna mock the user with negative scores
  if (score>highScore) {
    OrbitOledClear();
    drawPusheen (); //Pusheen drawn on the right
    
  //Code for displaying high score on the left (columns 0 - 7)
      OrbitOledMoveTo(92, 0);
    OrbitOledDrawString("NEW");
    OrbitOledMoveTo(88, 8);
    OrbitOledDrawString("HIGH");
    OrbitOledMoveTo(84, 16);
    OrbitOledDrawString("SCORE");
  
    OrbitOledMoveTo(84,24);
    sprintf(scoreStr, "%05d", score);
    OrbitOledDrawString (scoreStr);
    OrbitOledUpdate();
    highScore=score;
  }
  else{
  OrbitOledClear();;
  //Display the current score
  OrbitOledSetCursor (3, 2);
  OrbitOledPutString ("SCORE:");
  OrbitOledSetCursor (10, 2);
  sprintf(scoreStr, "%05d", score);
  OrbitOledPutString (scoreStr);
  }


  long lBtn1;
  lBtn1 = GPIOPinRead(BTN1Port, BTN1);
  while(lBtn1!=BTN1){
    updateLED(4);
    delay(100);
    updateLED(0);
    delay(100);
    lBtn1 = GPIOPinRead(BTN1Port, BTN1);
  } 
}
Beispiel #7
0
void gameLoop(){
  while(lives>0){
  updateGeese();
  updateBullet();
  updateGun();
  globalHitTest();
  paintFrame();
  updateLED(lives);
  curGeeseSpeed=geeseSpeed[getPot()/2];
  }
}
Beispiel #8
0
// ###### Handle events #####################################################
bool FractalGeneratorView::eventFilter(QObject*, QEvent* event)
{
   if(Thread) {
      if(event->type() == QEvent::User) {
         Display->update();
      }
      else if(event->type() == (QEvent::Type)(QEvent::User + 1)) {
         Display->update();
         Thread->stop();
         delete Thread;
         Thread = NULL;
         updateLED(false);
      }
   }
   return(false);
}
MMSKeySymbol MMSInputLISThread::getKeyFromCode(bool pressed, unsigned char code) {
    unsigned short value;

	// try with normtab
	value = readValue(K_NORMTAB, code);
	MMSKeySymbol ks = getSymbol(code, value);

	// check special keys
    switch (ks) {
    case MMSKEY_SHIFT:
    	this->shift_pressed = pressed;
    	break;
    case MMSKEY_ALTGR:
    	this->altgr_pressed = pressed;
    	break;
    case MMSKEY_CAPS_LOCK:
    	if (!pressed) {
    		// work only with the key release event
   			this->is_caps_lock = !this->is_caps_lock;
			updateLED();
    	}
    	break;
    default:
        if ((this->shift_pressed)||(this->is_caps_lock)) {
            if (!this->altgr_pressed) {
            	// shift is pressed
            	value = readValue(K_SHIFTTAB, code);
            	ks = getSymbol(code, value);
            }
            else {
            	// shift+altgr is pressed
        		value = readValue(K_ALTSHIFTTAB, code);
        		ks = getSymbol(code, value);
            }
        }
        else
        if (this->altgr_pressed) {
        	// altgr is pressed
    		value = readValue(K_ALTTAB, code);
    		ks = getSymbol(code, value);
        }
    	break;
    }

    return ks;
}
Beispiel #10
0
void setup(){     //run once initialization code here, i.e. OledInit() will probably go here
  DeviceInit();
  score=0;
  showStrtScrn();
  calibratedAccel=getAccelY();
  switch(CheckSwitches()){
    case 0: maxBullet=5;break;
    case 1: maxBullet=4;break;
    case 2:maxBullet=3;break;
    case 3: maxBullet=2;break;
    default: maxBullet=5;
  };
  lives=4;
  updateLED(lives);
  initStuff();
  OrbitOledClear();
  OrbitOledSetFillPattern(OrbitOledGetStdPattern(1));
}
Beispiel #11
0
void updateSynthesizer()
{
	updateLED();
	updateKeyboardNotes();
	beatTicksElapsed++;
	subBeatTicksElapsed++;
	
	if(beatTicksElapsed == delayPerBeat)
	{
		beatTicksElapsed = 0;
		subBeatTicksElapsed = 0;
		updateSequencerNotes();
	}
	
	if(subBeatTicksElapsed == delayPerSubBeat)
	{
		//updateSequencerNotes();
	}
}
Beispiel #12
0
int main()
{
    Counter_1_Start();
    Counter_2_Start();
    
    QuadDec1_Start();
    QuadDec2_Start();
    QuadDec3_Start();
    
    LCD_Char1_Start();
    LCD_Char1_DisplayOn();
    LCD_Char1_Enable();
    LCD_Char1_PrintString("B.E.A.R. Con. v2.0");
    CyDelay(2000);

    PWM_Start();
    
    WaveDAC8_1_Start(); 
    WaveDAC8_2_Start();
    //double baseFreq=500;
    setFrequency0(500.0+offsetFreq); QuadDec1_SetCounter(500.0*10);
    setFrequency1(500.0+offsetFreq); QuadDec2_SetCounter(500.0*10);
    //setFrequency3(1.0);
    
    int16 quadCount1=0;
    int16 oldQCount1=0;
    int16 quadCount2=0;
    int16 oldQCount2=0;
    int16 quadCount3=0;
    int16 oldQCount3=0;

    QuadDec3_SetCounter(43);
    
    
    
    
    updateDisplay();
    
    for (;;)
    {
        quadCount1=QuadDec1_GetCounter();
        if (quadCount1!=oldQCount1)
        {
            if (CoarsePIN_Read()==0) //rapid tune pressed
            {
                int theDifference=quadCount1-oldQCount1;
                if (theDifference<0) quadCount1=quadCount1-10;
                else quadCount1=quadCount1+10;
                QuadDec1_SetCounter(quadCount1);
            }
            
            double newFreq=(((double)(quadCount1))/10);
            setFrequency0(newFreq+offsetFreq);
            oldQCount1=quadCount1;
            leftFreq=newFreq;
            updateDisplay();
            updateLED();    
        }
        quadCount2=QuadDec2_GetCounter();
        if (quadCount2!=oldQCount2)
        {
            if (CoarsePIN_Read()==0) //rapid tune pressed
            {
                int theDifference=quadCount2-oldQCount2;
                if (theDifference<0) quadCount2=quadCount2-10;
                else quadCount2=quadCount2+10;
                QuadDec2_SetCounter(quadCount2);
            }
            
            double newFreq=(((double)(quadCount2))/10);
            setFrequency1(newFreq+offsetFreq);
            oldQCount2=quadCount2;
            rightFreq=newFreq;
            updateDisplay();
            updateLED();
        }
        quadCount3=QuadDec3_GetCounter();
        if (quadCount3!=oldQCount3)
        {
            double newFreq=(((double)(quadCount3))/10);
            offsetFreq=newFreq;
            oldQCount3=quadCount3;

            newFreq= (((double)(oldQCount1))/10);
            setFrequency0(newFreq+offsetFreq);

            newFreq= (((double)(oldQCount2))/10);
            setFrequency1(newFreq+offsetFreq);
            
            updateDisplay();
            updateLED();
        
        }
    }
    
    
}
Beispiel #13
0
void showLED(){
	updateLED();
	wait(10000);
	//vTaskDelay(100);
}
Beispiel #14
0
int main(void)
{
    init_lcd();
    writecommand(0x01);
    updateScreen();

    DDRD |= (1 << PD2);//output for green LED
    DDRD |= (1 << PD3);//output for red LED

    //button pullup resistors:
    PORTB |= (1 << PB3) | (1 << PB4);

    //rotary encoder initializations:
    initialize_rotary();
    sei();

    PORTC |= (1 << PC4) | (1 << PC5);//i2c pullup resistors

    //enable line
    PORTC |= (1 << PC3);
    DDRC |= (1 << PC3); //set as output

    //DS1631
    ds1631_init();
    ds1631_conv();
    unsigned char temp[2];
    //serial communication
    init_serial();

    while (1) {
        PORTC &= ~(1 << PC3);//set enable to 0
        ds1631_temp(temp);
        int tempCelsius = temp[0];
        //convert from celsius to fahrenheit:
        if(temp[1] == 0){
            tempF = (tempCelsius*9)/5 + 32;
        }
        else{
            tempF = tempCelsius * 10 + 5;
            tempF = (tempF*9)/5 + 320;
            tempF /= 10;
        }

        if(oldTempF != tempF){//if temperature changes, update + transmit data
            //update temp
            updateTop();
            char temp[5];
            snprintf(temp, 5, "%d", tempF);
            transmitData(temp, &tempF);
        }

        oldTempF = tempF;//update old temp

        if((PINB & (1 << PB3)) == 0){//if high button is pressed
            buttonState = 1;//high
        }
        if((PINB & (1 << PB4)) == 0){//if low button is pressed
            buttonState = 0;//low
        }

        if(bufferValidFlag == 1){//valid data received
            //convert to int stored inside remoteVal
            int hundreds = (receivedDataBuffer[1]-0x30)*100;
            int tens = (receivedDataBuffer[2]-0x30)*10;
            int ones = receivedDataBuffer[3]-0x30;
            remoteVal = hundreds + tens + ones;
            if(receivedDataBuffer[0] == '-'){
                remoteVal = 0 - remoteVal;
            }
            updateTop();
            bufferValidFlag = 0;//reset
        }

        if(change == 1){
            updateScreen();
            change = 0;//reset
        }

        updateLED();
    }
    return 0;   /* never reached */
}