Go Down

Topic: expected unqualified-id before numeric constant (Read 3433 times) previous topic - next topic

Hi there i'm trying to make a project using arduino, Wifly and a GPU screen by vizic technologies, but i'm getting troubles by using TimerOne library, it says i have  expected unqualified-id before numeric constant at the library TimerOne.h here's the code:
Code: [Select]
#include <Arduino.h>
#include <Streaming.h>
#include <SoftwareSerial.h>
#include "WiFlySerial.h"
#include "MemoryFree.h"
#include "Credentials.h"
#include <SMARTGPU.h>
#include <TimerOne.h>

// Pins are 3 for INCOMING TO Arduino, 5 for OUTGOING TO Wifly
// Arduino       WiFly
//  2 - receive  TX   (Send from Wifly, Receive to Arduino)
//  3 - send     RX   (Send from Arduino, Receive to WiFly)
WiFlySerial WiFly(2,3);

SMARTGPU lcd;

#define REQUEST_BUFFER_SIZE 120
#define HEADER_BUFFER_SIZE 150
#define BODY_BUFFER_SIZE 100

char bufRequest[REQUEST_BUFFER_SIZE];
char bufHeader[HEADER_BUFFER_SIZE];
char bufBody[BODY_BUFFER_SIZE];

int remPort = 3000;
boolean isConn = false;
int touch[2];
int res =0;
boolean Touch = true;
char t[5];
char none[] = {'N','O','N','E','O'};
boolean isNone = true;
int i;
 

int line = 0, offset = 10, height = 16;


//SETUP
void setup(){
////////////////////////////CONFIG WIFLY///////////////////////////////// 
 
  Timer1.detachInterrupt();
  Serial.begin(9600);
  lcd.init(); //Cnfigura el puerto serial y los pines para el SMARTGPU
  lcd.start(); //Inicializa el SMARTGPU
  printLCD( "GPU OK" );

  WiFly.begin();
 
  printLCD( "Configuring WiFly..." );
  WiFly.setAuthMode( WIFLY_AUTH_OPEN );
  WiFly.setJoinMode( WIFLY_JOIN_AUTO );
  WiFly.setDHCPMode( WIFLY_DHCP_ON );
  WiFly.setSSID( ssid );
  WiFly.SendCommand("set comm remote h",">", bufBody, BODY_BUFFER_SIZE);
  WiFly.SendCommand("set ip host 10.25.74.172",">", bufBody, BODY_BUFFER_SIZE);
  WiFly.SendCommand("set sys autoconn 2",">", bufBody, BODY_BUFFER_SIZE);
  WiFly.SendCommand("set ip flags 0x6",">", bufBody, BODY_BUFFER_SIZE);
  WiFly.setRemotePort(remPort); 
 
  // If not joined restart link
  printLCD( "Checking WiFly status..." );
  WiFly.getDeviceStatus();
  if (!WiFly.isifUp() ) {
    printLCD( "WiFly if is not up. Joining..." );
    if ( WiFly.join() ) {
      printLCD( "WiFly joined." );
      //WiFly.setNTP( ntp_server ); // use your favorite NTP server
    } else {
      printLCD( "WiFly join FAIL." );
    }
  } // if not connected
 
  printLCD( "WiFly OK" );
  printLCD( WiFly.getIP(bufRequest, REQUEST_BUFFER_SIZE));
 
  printLCD( "Opening TCP connection...");
  WiFly.SendCommand("close",">", bufBody, BODY_BUFFER_SIZE);
 
  memset (bufBody,'\0',BODY_BUFFER_SIZE);
  delay(3000);
  lcd.erase();
}

void printLCD( char* text ) {
  lcd.string( offset, nextLine(), 320-offset, 240-offset, WHITE, FONT3, TRANS, text );
}

int nextLine() {
  if( (line+1)*height > 240-offset ) {
    line = 0;
    lcd.erase();
  }
  return offset + (line++)*height;
}
/// METODOS PARA LOS DIFERENTES CASOS////
void DISPLAY(){
  lcd.erase();
  WiFly.write('L');   
}

void TOUCH(){
  Timer1.initialize(1000000);
  Timer1.attachInterrupt( ISR_PollWiFly );
  while(true) {
    while(lcd.touchScreen(touch)==0);
      for( i = 0 ; i < 5; i++) {
        WiFly.write(t[i]); //Manda las coordenadas
      }
      DISPLAY();           
  }
  Timer1.detachInterrupt();
  WiFly.write('S');   
}

void WriteGPU(){
  char g;
  g = WiFly.read();
  Serial.print(g);
}

void dibujarFondo() {

  lcd.imageSD(0,0,"TEC");
  lcd.string(30,10,310,220,CYAN,FONT3,TRANS,"Centro de Desarrollo Estudiantil");
  lcd.string(80,30,310,220,CYAN,FONT3,TRANS,"Ofertas de trabajo"); 
  lcd.drawRectangle(10,50,310,100,WHITE,FILL);
  lcd.drawRectangle(10,110,310,160,CYAN,FILL);
  lcd.drawRectangle(10,170,310,220,0xF805,FILL);
}

void ISR_PollWiFly(){
  char c;
  while(WiFly.available()) {
     c = WiFly.read();
     if(c == 's') {
       DISPLAY();       
     }
     
  }
}


//////////////////////////////////////  MAIN  //////////////////////////////////////
void loop(){
  lcd.baudChange(2000000);   
  char c;
 
  c = WiFly.read();
  switch(c){
    case 'q':
      DISPLAY();
    break;
   
    case 't':
      TOUCH();
    break;
   
    case 'g':
      WriteGPU();
    break;
   
    case 'f':
      dibujarFondo();
    break;
   
    default:
    break;
  }
}


Coding Badly


Comment-out the include...

Code: [Select]
// #include <TimerOne.h>

Does the error go away?  Move to another place?

It stands the same kind of erros:
Bolsa_T:8: error: expected unqualified-id before numeric constant
Bolsa_T:99: error: expected unqualified-id before numeric constant
Bolsa_T.cpp: In function 'void TOUCH()':
Bolsa_T:113: error: '1' cannot be used as a function
Bolsa_T.cpp: In function 'void ISR_PollWiFly()':
Bolsa_T:140: error: '1' cannot be used as a function
Bolsa_T.cpp: In function 'void loop()':
Bolsa_T:155: error: '1' cannot be used as a function

Coding Badly


Put the include back the way it was...

Code: [Select]
#include <TimerOne.h>

Verify.

Use Ctrl+A to select all the text in the status window.

Use Ctrl+C to copy all the selected text in the status window.

Click Reply.

Paste.

Click Post.











Bolsa_T:9: error: expected unqualified-id before numeric constant
Bolsa_T:100: error: expected unqualified-id before numeric constant
Bolsa_T.cpp: In function 'void TOUCH()':
Bolsa_T:113: error: '1' cannot be used as a function
Bolsa_T.cpp: In function 'void ISR_PollWiFly()':
Bolsa_T:140: error: '1' cannot be used as a function
Bolsa_T.cpp: In function 'void loop()':
Bolsa_T:155: error: '1' cannot be used as a function

Coding Badly


Generally, all uppercase letters are used to define constants.  Which means that using all uppercase letters for function names is a bad idea.  Try using something besides "DISPLAY"...

Quote
[font=Courier New]/// METODOS PARA LOS DIFERENTES CASOS////
void DISPLAY(){
  lcd.erase();
  WiFly.write('L');   
}[/font]


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy