here is the module of code i am having issues with, the code as a whole works apart from trying to display the first 4 digits of redtime and greentime on the red/green 4 digit displays, all pins and settings for the displays are working, it is just getting them to display what i need
as stated earlier , i did not write the original code, but have added bits for relay operations and a few other minor changes, these do not affect anything
all required libraries are set up in another module as are some global settings
void domination(){
//SETUP INITIAL TIME
int minutos = GAMEMINUTES-1;
boolean showGameTime=true;
unsigned long a;
unsigned long iTime=millis(); // initialTime in millisec
unsigned long aTime;
team=0;
iZoneTime=0;
aTime=0;
redTime=0;
greenTime=0;
int largoTono = 50;
// 0 = neutral, 1 = green team, 2 = red team
a=millis();
//Starting Game Code
while(1) // this is the important code, is a little messy but works good.
{
if(endGame){
gameOver();
}
keypad.getKey();
aTime=millis()- iTime;
//Code for led blinking
timeCalcVar=(millis()- iTime)%1000;
if(timeCalcVar >= 0 && timeCalcVar <= 40)
{
digitalWrite(GREENRELAY, HIGH);
digitalWrite(REDRELAY, HIGH);
if(team==1)digitalWrite(GREENLED, HIGH);
if(team==1)digitalWrite(GREENRELAY, LOW);
if(team==2)digitalWrite(REDLED, HIGH);
if(team==2)digitalWrite(REDRELAY, LOW);
if(team==0)digitalWrite(BLUERELAY, LOW);
}
if(timeCalcVar >= 50 && timeCalcVar <= 100)
{
if(team==1)digitalWrite(GREENLED, LOW);
if(team==1)digitalWrite(GREENRELAY, HIGH);
if(team==2)digitalWrite(REDLED, LOW);
if(team==2)digitalWrite(REDRELAY, HIGH);
if(team==0)digitalWrite(BLUERELAY, HIGH);
}
// Sound!!! same as Destroy
if(timeCalcVar >= 0 && timeCalcVar <= 40 && soundEnable)tone(tonepin,activeTone,largoTono);
if(timeCalcVar >= 245 && timeCalcVar <= 255 && minutos-aTime/60000<2 && soundEnable)tone(tonepin,activeTone,largoTono);
if(timeCalcVar >= 495 && timeCalcVar <= 510 && minutos-aTime/60000<4 && soundEnable)tone(tonepin,activeTone,largoTono);
if(timeCalcVar >= 745 && timeCalcVar <= 760 && minutos-aTime/60000<2 && soundEnable)tone(tonepin,activeTone,largoTono);
//Help to count 3 secs
if(a+2000<millis()){
a=millis();
showGameTime=!showGameTime;
cls();
}
//THE NEXT TO METHODS SHOW "GAME TIME" AND "CONTROLED ZONE TIME" IT SHOWS 2 AND 2 SEC EACH
if(showGameTime){ //THE SECOND IS /2
lcd.setCursor(5,2);
lcd.print("GAME TIME");
lcd.setCursor(5,3);
printTime(minutos, aTime);
}
else if (!showGameTime){
lcd.setCursor(4,0);
if(team == 0)lcd.print("NEUTRAL ZONE");
if(team == 1)lcd.print(" GREEN ZONE");
if(team == 2)lcd.print(" RED ZONE");
if(team == 1)led.DigitDisplayWrite(pinClkGreen, pinDtaGreen, greenTime);
if(team == 2)led.DigitDisplayWrite(pinClkRed, pinDtaRed, redTime);
if(team>0){
lcd.setCursor(5,1);
printTimeDom(millis()-iZoneTime,true);
}
}
//###########################CHECKINGS##################
//Check If Game End
if(minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0)
{
gameOver();
}
//Check If IS neutral
while((defusing || cancelando) && team > 0)
{
cls();
if(team>0)lcd.print("NEUTRALIZING...");
lcd.setCursor(0,1);
unsigned int percent=0;
unsigned long xTime=millis(); //start disabling time
while(defusing || cancelando)
{
//check if game time runs out during the disabling
aTime= millis()- iTime;
if((minutos-aTime/60000==0 && 59-((aTime/1000)%60)==0) || minutos-aTime/60000>4000000000){
endGame = true;
}
keypad.getKey();
timeCalcVar = (millis()- xTime)%1000;
if( timeCalcVar >= 0 && timeCalcVar <= 20)
{
if(soundEnable)tone(tonepin,alarmTone1,200);
}
if(timeCalcVar >= 480 && timeCalcVar <= 500)
{
if(soundEnable)tone(tonepin,alarmTone2,200);
digitalWrite(REDLED, LOW);
}
unsigned long seconds= millis() - xTime;
percent = (seconds)/(ACTIVATESECONDS*10);
drawBar(percent);
if(percent >= 100)
{
delay(1000);
if(team==1){
greenTime+=millis()-iZoneTime;
iZoneTime=0;
}
if(team==2){
redTime+=millis()-iZoneTime;
iZoneTime=0;
}
team=0;
break;
}
}
cls();
}