Example #1
0
void startOver(){
  blinkLights(pinRed, pinGreen, pinBlue, pinWhite);
  int i = 0;
  for(i; i<counter; i++){
    newGame[i] = 0;
  }
  counter = 0;
}
Example #2
0
int main(int argc, char **argv) {

  signal(SIGALRM, handle);
  declareTermiosCrap();
  wiringPiSetup();
  setPins(pinRed, pinGreen, pinBlue, pinWhite);
  setSwitches();
  blinkLights(pinRed, pinGreen, pinBlue, pinWhite);
  repeatColors();
  verify();
  

	tcsetattr(0, TCSANOW, &initial_settings);
	return 0;
}
int *getCommand(void){
    int commandTemp[9];
    static int commandFinal[9];
    long j = 0;
    int i = 0;
    int k = 0;
    long timeOut = 50000;
    int error = 0;

    j = 0; //clear the counter
    for(i = 0; i < 9; i++ ){  //all 8 bits of data and the closing bracket. 9 total
        while((!(PORTB & pulsePin))  ){ //  && (j < timeOut)){ // wait till pulse starts
                j++;
        }
        delay_ms(1); //tiny delay to ensure we have good data before writing it

        if( i < 8)
                commandTemp[i] = (PORTB & dataPin); // WRITE DATA
        else if(i == 8)
                commandTemp[i] = (PORTB & (dataPin + parityPin));  // closing bracket

        while((PORTB & pulsePin)  ){   //&& (j < timeOut)){ // wait till pulse is over
                j++;
        }
        delay_ms(1); //tiny delay to ensure pulse is really over before starting again

        /* if(j >= timeOut)
                break; // leaves the FOR loop because we timed out */
    }

    if((commandTemp[8] == (dataPin + parityPin))   ){  // && (j < timeOut)){  //all went well
		for(i = 0; i < 8; i++) {                           //put temp into final array
			commandFinal[i] = commandTemp[i];
		}

		return commandFinal;
    }
    else{
		blinkLights();
		while(PORTB & 0b01110000);  // wait until port B is clean before continuing
        return 0;  //something is wrong
    }
}