Hello. I have a sketch I'm trying to load up to my D1 mini clone, It is quite long, made up of several different bits of other codes. When I try to compile, I am getting
exit status 1
Error compiling for board LOLIN(WEMOS) D1 mini (clone).
My code is as follows:
#include <Wire.h>
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
#include <ESP8266WiFiMulti.h> // FOR WIFI SIGNAL
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <Adafruit_NeoPixel.h>
//************DEFINIR AQUI LOS SSID DE CADA DISPOSITIVO***********
#ifndef APSSID
#define APSSID "Rpwn1"
#define APPSK "batalla2"
#endif
LiquidCrystal_I2C lcd(0x27, 16, 2);
//char* GAME_TIME="Tiempo de Juego:";
//char* BOMB_TIME="Tiempo Deton.:";
//char* ARM_TIME="Tiempo de Armado:";
//char* ZERO_SECS="00 segundos";
//char* ENABLE_SOUND="Activar Sonido?";
//char* YES_OR_NOT="A: SI B: No";
//char* GAME_TIME_TOP="TIEMPO DE JUEGO";
//char* GAME_OVER = "FIN DEL JUEGO! ";
const int RSSI_MAX =-50;// define maximum strength of signal in dBm
const int RSSI_MIN =-100;// define minimum strength of signal in dBm
int pointDistance = 0;
ESP8266WiFiMulti wifiMulti;
//const uint32_t connectTimeoutMs = 10000;
/* Set these to your desired credentials. */
const char *ssid = APSSID;
const char *password = APPSK;
const byte ROWS = 1; //four rows
const byte COLS = 2; //four columns
char keys[ROWS][COLS] = {
{'c', 'd'}
};
byte rowPins[ROWS] = {15}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {13, 12}; //connect to the column pinouts of the keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
// variable for reading the pushbutton status
//TIME INTS
int GAMEHOURS = 0;
int GAMEMINUTES = 45;
int BOMBMINUTES = 4;
int ACTIVATESECONDS = 3;
boolean endGame = false;
boolean refresh = true; //1 refresh one time...
boolean sdStatus = false; //search and destroy game enable used in config
boolean saStatus = false; //same but SAbotaghe
boolean doStatus = false; //for DEmolition
boolean start = true;
boolean defusing;
boolean cancelando;
// SOUND TONES
boolean soundEnable = true;
int tonepin = 2; // Pin 2 for the sound
int alarmTone1 = 700;
int alarmTone2 = 2600;
int activeTone = 1330;
int errorTone = 100;
unsigned long iTime;
unsigned long timeCalcVar;
unsigned long redTime;
unsigned long blueTime;
unsigned long iZoneTime;//initial time for zone
byte team=0; // 0 = neutral, 1 = blue team, 2 = red team
#define PIN 14
#define NUM_LEDS 20
//LED strip
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup(){
lcd.begin();
strip.begin();
strip.show(); // Initialize all pixels to 'off'
pinMode(tonepin, OUTPUT);
Serial.begin(9600);
lcd.setCursor(1,0);
tone(tonepin,2400,300);
lcd.print("*****LOBOS******");// you can add your team name or someting cool
lcd.setCursor(2,1);
lcd.print("***DEL NORTE****");// you can add your team name or someting cool
WiFi.softAP(ssid, password);
// CONFIGURE THE BARS OF PROGRESS BAR
byte bar1[8] = {
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
B10000,
};
byte bar2[8] = {
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
B11000,
};
byte bar3[8] = {
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
B11100,
};
byte bar4[8] = {
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
B11110,
};
byte bar5[8] = {
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
B11111,
};
byte up[8] = {
B00000,
B00100,
B01110,
B11111,
B11111,
B00000,
B00000,
};
byte down[8] = {
B00000,
B00000,
B11111,
B11111,
B01110,
B00100,
B00000,
};
lcd.createChar(0,bar1);
lcd.createChar(1,bar2);
lcd.createChar(2,bar3);
lcd.createChar(3,bar4);
lcd.createChar(4,bar5);
lcd.createChar(5,up);
lcd.createChar(6,down);
}
void loop(){
domination();
}
void keypadEvent(KeypadEvent key){
switch (keypad.getState()){
case RELEASED:
switch (key){
case 'd': defusing=false;
break;
case 'c': cancelando=false;
break;
}
break;
case HOLD:
switch (key){
case 'd': defusing= true;
break;
case 'c': cancelando=true;
break;
}
break;
}
}
//##################MENUS###############################
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;
blueTime=0;
int largoTono = 50;
// 0 = neutral, 1 = blue 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)
{
if(team==1)RunningLights(0,0,0xff, 50); //CALL TO LIGHT STRIP bkue
if(team==2)RunningLights(0xff,0,0, 50); //CALL TO LIGHT STRIP red
}
if(timeCalcVar >= 50 && timeCalcVar <= 100)
{
if(team==1)RunningLights(0,0,0, 50); //turn light strip off (All black)
if(team==2)RunningLights(0,0,0, 50);
}
// 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();
}
if(showGameTime){ //THE SECOND IS /2
lcd.setCursor(0,0);
lcd.print("TIEMPO DE JUEGO");
lcd.setCursor(3,1);
printTime(minutos, aTime);
}
else if (!showGameTime){
lcd.setCursor(2,0);
if(team == 0)lcd.print("ZONA NEUTRAL");
if(team == 1)lcd.print(" ZONA AZUL");
if(team == 2)lcd.print(" ZONA ROJA");
if(team>0){
lcd.setCursor(3,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("NEUTRALIZANDO...");
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);
RunningLights(0,0,0, 50);
}
unsigned long seconds= millis() - xTime;
percent = (seconds)/(ACTIVATESECONDS*10);
drawBar(percent);
if(percent >= 100)
{
delay(1000);
if(team==1){
blueTime+=millis()-iZoneTime;
iZoneTime=0;
}
if(team==2){
redTime+=millis()-iZoneTime;
iZoneTime=0;
}
team=0;
break;
}
}
cls();
}
//Capturing red
while(defusing && team == 0 )
{
cls();
if(team==0)lcd.print("CAPTURANDO ZONA");
lcd.setCursor(0,1);
unsigned int percent=0;
unsigned long xTime=millis(); //start disabling time
while(defusing)
{
keypad.getKey();
//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;
}
timeCalcVar = (millis()- xTime)%1000;
if( timeCalcVar >= 0 && timeCalcVar <= 20)
{
RunningLights(0xff,0,0, 50);
if(soundEnable)tone(tonepin,alarmTone1,200);
}
if(timeCalcVar >= 480 && timeCalcVar <= 500)
{
if(soundEnable)tone(tonepin,alarmTone2,200);
RunningLights(0,0,0, 50);
}
unsigned long seconds= millis() - xTime;
percent = (seconds)/(ACTIVATESECONDS*10);
drawBar(percent);
if(percent >= 100)
{
RunningLights(0,0,0, 50);
team=2;
iZoneTime=millis();
delay(1000);
break;
}
}
cls();
RunningLights(0,0,0, 50);
}
//getting to blue zone
while(cancelando && team == 0 )
{
cls();
if(team==0)lcd.print("CAPTURANDO ZONA");
lcd.setCursor(0,1);
unsigned int percent=0;
unsigned long xTime=millis(); //start disabling time
while(cancelando)
{
keypad.getKey();
//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;
}
timeCalcVar = (millis()- xTime)%1000;
if( timeCalcVar >= 0 && timeCalcVar <= 20)
{
RunningLights(0,0,0xff, 50);
if(soundEnable)tone(tonepin,alarmTone1,200);
}
if(timeCalcVar >= 480 && timeCalcVar <= 500)
{
if(soundEnable)tone(tonepin,alarmTone2,200);
RunningLights(0,0,0, 50);
}
unsigned long seconds= millis() - xTime;
percent = (seconds)/(ACTIVATESECONDS*10);
drawBar(percent);
if(percent >= 100)
{
RunningLights(0,0,0, 50);
team=1;
iZoneTime=millis();
delay(1000);
break;
}
}
cls();
RunningLights(0,0,0, 50);
}
}
}
void RunningLights(byte red, byte green, byte blue, int WaveDelay) {
int Position=0;
for(int j=0; j<NUM_LEDS*2; j++)
{
Position++; // = 0; //Position + Rate;
for(int i=0; i<NUM_LEDS; i++) {
setPixel(i,((sin(i+Position) * 127 + 128)/255)*red,
((sin(i+Position) * 127 + 128)/255)*green,
((sin(i+Position) * 127 + 128)/255)*blue);
}
showStrip();
delay(70);
}
}
void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.show();
#endif
}
void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
// NeoPixel
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
// FastLED
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}
void setAll(byte red, byte green, byte blue) {
for(int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}
void gameOver(){
if(team==1)blueTime+=millis()-iZoneTime;
if(team==2)redTime+=millis()-iZoneTime;
RunningLights(0,0,0, 50);
while(!defusing){
keypad.getKey();
if(defusing){
keypad.getKey();
break;
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print("TIEMPO ACABADO!");
lcd.setCursor(1,1);
if(blueTime>redTime){
//blueteam wins
lcd.print("AZULES GANAN");
RunningLights(0,0,0xff, 50); //CALL TO LIGHT STRIP FUNCTION
}
else{
//redteam wins
lcd.print(" ROJOS GANAN");
RunningLights(0xff,0,0, 50); //CALL TO LIGHT STRIP FUNCTION
}
delay(2000);
keypad.getKey();
if(defusing){
keypad.getKey();
break;
}
cls();
lcd.print("Tiempo Rojo:");
lcd.setCursor(5,1);
printTimeDom(redTime,false);
delay(3000);
keypad.getKey();
if(defusing){
keypad.getKey();
break;
}
cls();
lcd.print("Tiempo Azul:");
lcd.setCursor(5,1);
printTimeDom(blueTime,false);
delay(2000);
keypad.getKey();
if(defusing){
keypad.getKey();
break;
}
}
}
//###########################CHECKINGS##################
void drawBar(byte porcent){
//TODO: Optimize this code
int box=(8*porcent)/10;
lcd.setCursor(0,1);
while(box>=5){
if(box>=5)
{
lcd.write(4);
box-=5;
}
}
switch(box){
case 0:
break;
case 1:
lcd.write((uint8_t)0);
break;
case 2:
lcd.write(1);
break;
case 3:
lcd.write(2);
break;
case 4:
lcd.write(3);
break;
}
}
void cls(){
lcd.clear();
lcd.setCursor(0,0);
}
void printTime(unsigned long minutos, unsigned long aTiempo){
timeCalcVar=minutos-aTiempo/60000;
//Hours
if(timeCalcVar/60==0 && refresh){
lcd.clear();
refresh=false;
//delay(100);
lcd.setCursor(3,1);
Serial.println("!!!!");
}
if(timeCalcVar/60>=1){
if(timeCalcVar/60<10)
{
lcd.setCursor(2,1);
lcd.print("0");
lcd.print(timeCalcVar/60);
}
else
{
lcd.print(timeCalcVar/60);
}
lcd.print(":");
}
//minutes
if(timeCalcVar%60<10)
{
lcd.print("0");
lcd.print(timeCalcVar%60);
}
else
{
lcd.print(timeCalcVar%60);
}
lcd.print(":");
//seconds
timeCalcVar=aTiempo/1000;
if(59-(timeCalcVar%60)<10)
{
lcd.print("0");
lcd.print(59-(timeCalcVar%60));
}
else
{
lcd.print(59-(timeCalcVar%60));
}
lcd.print(":");
lcd.print(999-(millis()%1000));
}
void printTimeDom(unsigned long aTiempo, boolean showMillis){
//minutes
if((aTiempo/60000)<10)
{
lcd.print("0");
lcd.print(aTiempo/60000);
}
else
{
lcd.print(aTiempo/60000);
}
lcd.print(":");
//seconds
if(((aTiempo/1000)%60)<10)
{
lcd.print("0");
lcd.print((aTiempo/1000)%60);
}
else
{
lcd.print((aTiempo/1000)%60);
}
if(showMillis){
lcd.print(":");
lcd.print(999-millis()%1000);
}
}
void startGameCount(){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Listo");
lcd.setCursor(0,1);
lcd.print("Presione 1 Boton");
keypad.waitForKey();//if you press a button game start
cls();
lcd.setCursor(1,0);
lcd.print("Iniciando Juego");
for(int i = 5; i > 0 ; i--){ // START COUNT GAME INIT
lcd.setCursor(5,1);
tone(tonepin,2000,100);
lcd.print(" EN ");
lcd.print(i);
delay(1000);
}
cls();
domination();
}
void checkArrows(byte i,byte maxx ){
if(i==0){
lcd.setCursor(15,1);
lcd.write(6);
}
if(i==maxx){
lcd.setCursor(15,0);
lcd.write(5);
}
if(i>0 && i<maxx){
lcd.setCursor(15,1);
lcd.write(6);
lcd.setCursor(15,0);
lcd.write(5);
}
}
int dBmtoPercentage(int dBm)
{
int quality;
if(dBm <= RSSI_MIN)
{
quality = 0;
}
else if(dBm >= RSSI_MAX)
{
quality = 100;
}
else
{
quality = 2 * (dBm + 100);
}
return quality;
}//dBmtoPercentage
Any help would be much appreciated.