error: expected primary-expression before ';' token

hi, im quite new to c++ and when i try to run my code it gives me
this error:
280:34: error: expected primary-expression before ';' token

chip = glcdDev_XYval2Chip(x, y);

^

code:

void glcd_Device::GotoXY(uint8_t x, uint8_t y)
{
uint8_t chip, cmd;

if((x == this->Coord.x) && (y == this->Coord.y))
return;

if( (x > DISPLAY_WIDTH-1) || (y > DISPLAY_HEIGHT-1) )
{
return;
}

this->Coord.x = x;
this->Coord.y = y;

chip = glcdDev_XYval2Chip(x, y); // THE ERROR LINE

#ifdef LCD_SET_XYADD
this->Coord.chip[chip].page = glcdDev_Yval2ChipPage(y);
cmd = (LCD_SET_XYADD | glcdDev_XYval2XYaddr(x,y));
this->WriteCommand(cmd, chip);
#else
if(y/8 != this->Coord.chip[chip].page)
{
this->Coord.chip[chip].page = y/8;
cmd = LCD_SET_PAGE | this->Coord.chip[chip].page;
this->WriteCommand(cmd, chip);
}

x = glcdDev_Xval2ChipCol(x);

#ifdef GLCD_XCOL_SUPPORT
if(x != this->Coord.chip[chip].col)
#endif
{

#ifdef GLCD_XCOL_SUPPORT
this->Coord.chip[chip].col = x;
#endif

#ifdef LCD_SET_ADDLO
cmd = LCD_SET_ADDLO | glcdDev_Col2addrlo(x);
this->WriteCommand(cmd, chip);

cmd = LCD_SET_ADDHI | glcdDev_Col2addrhi(x);
this->WriteCommand(cmd, chip);
#else
cmd = LCD_SET_ADD | x;
this->WriteCommand(cmd, chip);
#endif
}
#endif // LCD_SET_XYADD
}

thanks in advance.

Please post the whole code. Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

Please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Welcome to Snippets-R-Us.

Is this for someone else's library, or did you write it yourself? I tried to Google but it drew a blank.

I couldn't see anything obviously wrong, other than where and how is glcdDev_XYval2Chip defined?

Also, the button for posting code in [​code][​/code] tags looks like this </> on the menu bar.

im trying to make a new LCD chip (RA8835) for the library openGLCD,

i managd to fix that error but now it gives me the same error just for a different line

  • if you want to try this code you need to save the device in the devices inside the opensGLCD library
    as RA8835_device
    and save the configuration as ManualConfig_RA8835_panel.h*
/*
   // the RA8835 device 
  RA8835_Device.h - openGLCD library support for graphic LCDs 

 vi:ts=4

	This is a device template file that shows what needs to be
	in a device header for a glcd.

The following lcd primitives must be defined

	glcdDev_SelectChip(chip)
	glcdDev_ENstrobeHi(chip)
	glcdDev_ENstrobeLo(chip)
	glcdDev_Xval2Chip(x)
	glcdDev_Xval2ChipCol(x)

	For devices that split set column into to 2 commands of hi/lo: 

	glcdDev_Col2addrlo(x)		(x & 0xf)	// lo nibble
	glcdDev_Col2addrhi(x)		(x & 0xf0)	// hi nibble
  
*/

#ifndef GLCD_PANEL_DEVICE_H
#define GLCD_PANEL_DEVICE_H

/*
 * define name for Device
 */
#define glcdDev_DeviceName "RA8835"



/*
 * LCD commands -------------------------------------------------------------
 */

#define LCD_ON            0x59
#define LCD_OFF           0x58
#define LCD_DISP_START    0x00

#define LCD_SET_PAGE      0x44
#define LCD_SET_ADDLO     0x00
#define LCD_SET_ADDHI     0x00
/*definitions for specific LCD settings as well as the
  command codes for various function 
  RA8835, LCD drivers */
//Commands 
#define LCD_SYSTEM_SET   0x40  
#define LCD_SYS_P1       0x10 | (LCD_IV << 5) | (LCD_WS << 3) | (LCD_M2 << 2) | (LCD_M1 << 1) | LCD_M0 //SYSTEM SET Parameter P1 byte 
#define LCD_M0         0 
#define LCD_M1         0 
#define LCD_M2         0 
#define LCD_WS         0 
#define LCD_IV         1
#define LCD_SYS_P2       0x00 | (LCD_WF << 7) | LCD_FX 
#define LCD_FX         7  
#define LCD_WF         1 
#define LCD_FY         7  
#define LCD_CR         39
#define LCD_TCR        90 
#define LCD_LF         239 
#define LCD_APL        40 
#define LCD_APH        0  // P8 - AP High byte, 

#define LCD_SLEEP_IN   0x53 

#define LCD_DISP_OFF   0x58 // Display On/Off C control byte (C + P1) , display off
#define LCD_DISP_ON    0x59	// Display On/Off C control byte (C + P1) , display on 
#define	LCD_DISP_P1			// DISP P1 byte 
#define LCD_FC					
#define LCD_FP_1st				
#define LCD_FP_2cd				
#define LCD_FP_3rd			

#define   LCD_SCROLL     0x44		
#define   LCD_SAD1L      0		       
#define   LCD_SAD1H      0			
#define   LCD_SL1        0xEF		
#define   LCD_SAD2L      0xB0		
#define   LCD_SAD2H      0x04		
#define   LCD_SL2        0xEF		
#define   LCD_SAD3L      0			
#define   LCD_SAD3H      0			
#define   LCD_SAD4L      0		
#define   LCD_SAD4H      0			

#define   LCD_TEXTSIZE       ((LCD_SAD2H << 8) + LCD_SAD2L)
#define   LCD_GRAPHICSTART   ((LCD_SAD2H << 8) + LCD_SAD2L) 
#define   LCD_GRAPHICSIZE    ((LCD_SL2+1) * (LCD_SCR_WIDTH+1))>>3 

#define   LCD_CSRFORM    0x5d	
#define   LCD_CRX        0x04 
#define   LCD_CSRF_P2    0x00 | (LCD_CM << 7) | LCD_CRY // CSRFORM P2
#define   LCD_CRY        0x07  
#define   LCD_CM         0		
#define   LCD_CSRDIR_U       0x4e 
#define   LCD_CSRDIR_D       0x4f 
#define   LCD_CSRDIR_L       0x4d 
#define   LCD_CSRDIR_R       0x4c 

#define   LCD_OVLAY      0x5b	
#define   LCD_OVLAY_P1   0x00 | (LCD_OV << 4) | (LCD_DM2 << 3) | (LCD_DM1 << 2) | (LCD_MX1 << 1) | LCD_MX0 // OVLAY P1 
#define   LCD_MX0        1		
#define   LCD_MX1        0	
#define   LCD_DM1        0		
#define   LCD_DM2        0		  
#define   LCD_OV         0		

#define   LCD_CGRAM_ADR    0x5c 
#define   LCD_SAGL         0	
#define   LCD_SAGH         0x70 

#define   LCD_HDOT_SCR     0x5a 
#define   LCD_D				

#define   LCD_CSRW         0x46 
#define   LCD_WADR_L			
#define   LCD_WADR_H		

#define   LCD_CSRR         0x47 
#define   LCD_RADR_L			
#define   LCD_RADR_H			

#define   LCD_MWRITE     0x42 

#define   LCD_MREAD      0x43	

#define   LCD_SCR_WIDTH  319   
#define   LCD_LINES      30  

#define   LCD_SCRD         0
#define   LCD_FLASH      0x16
#define   LCD_MEM_END      10800


/*
 * Status register bits/flags -----------------------------------------------
 */

#define LCD_BUSY_FLAG   0x80
#define LCD_BUSY_BIT    7

#define LCD_RESET_BIT		4
#define LCD_RESET_FLAG		0x10


/*
 * Define primitives used by glcd_Device.cpp --------------------------------
 */

#define glcdDev_SelectChip(chip)

/*
 * Define how to strob EN signals
 */
#define glcdDev_ENstrobeHi(chip) glcdio_WritePin(glcdPinEN, 0)
#define glcdDev_ENstrobeLo(chip) glcdio_WritePin(glcdPinEN, 1)



/*
 * Convert X & Y coordinates to chip values
 */
#if CHIP_HEIGHT < DISPLAY_HEIGHT
#define glcdDev_XYval2Chip(x, y)	(((y) < CHIP_HEIGHT) ? 0 : 1)
#else
#define glcdDev_XYval2Chip(x, y)	(((x) < CHIP_WIDTH) ? 0 : 1)
#endif
#define	glcdDev_Xval2ChipCol(x)

#define glcdDev_Col2addrlo(x)
#define glcdDev_Col2addrhi(x)

#define glcdDev_Init(chip) (\
{\
  uint8_t status;\
  do {\
    digitalWrite(glcdPinCSEL1, 1);\
    digitalWrite(glcdPinRW, 1);\
    digitalWrite(glcdPinEN, 1);\
    digitalWrite(glcdPinDI, 1);\
    digitalWrite(glcdPinRST, 1);\
    pinMode(glcdPinCSEL1, OUTPUT);\
    pinMode(glcdPinRST, OUTPUT);\
    pinMode(glcdPinDI, OUTPUT);\
    pinMode(glcdPinRW, OUTPUT);\
    pinMode(glcdPinEN, OUTPUT);\
    digitalWrite(glcdPinRST, 0);\
    delay(50);\
    digitalWrite(glcdPinRST, 1);\
    delay(50);\
    WriteCommand(LCD_SYSTEM_SET, chip);\
    delayMicroseconds(1000);\
    WriteData(LCD_SYS_P1);\
    delayMicroseconds(1);\
    WriteData(LCD_SYS_P2);\
    delayMicroseconds(1);\
    WriteData(LCD_FY);\
    delayMicroseconds(1);\
    WriteData(LCD_CR);\
    delayMicroseconds(1);\
    WriteData(LCD_TCR);\
    delayMicroseconds(1);\
    WriteData(LCD_LF);\
    delayMicroseconds(1);\
    WriteData(LCD_APL);\
    delayMicroseconds(1);\
    WriteData(LCD_APH);\
    WriteCommand(LCD_SCROLL, chip);\
    WriteData(LCD_SAD1L);\
    WriteData(LCD_SAD1H);\
    WriteData(LCD_SL1);\
    WriteData(LCD_SAD2L);\
    WriteData(LCD_SAD2H);\
    WriteData(LCD_SL2);\
    WriteData(LCD_SAD3L);\
    WriteData(LCD_SAD3H);\
    WriteData(LCD_SAD4L);\
    WriteData(LCD_SAD4H);\
    WriteCommand(LCD_CSRFORM, chip);\
    WriteData(LCD_CRX);\
    WriteData(LCD_CSRF_P2);\
    WriteCommand(LCD_CGRAM_ADR, chip);\
    WriteData(LCD_SAGL);\
    WriteData(LCD_SAGH);\
    WriteCommand(LCD_CSRDIR_R, chip);\
    WriteCommand(LCD_HDOT_SCR, chip);\
    WriteData(LCD_SCRD);\
    WriteCommand(LCD_OVLAY, chip);\
    WriteData(LCD_OVLAY_P1);\
    WriteCommand(LCD_DISP_ON, chip);\
    WriteData(LCD_FLASH);\
  }\
  while (0);\
  status = GLCD_ENOERR;\
  status;   /* return value of macro */\
})

#endif //GLCD_PANEL_DEVICE_H












// the RA8835 manual config

#ifndef GLCD_PANEL_CONFIG_H
#define GLCD_PANEL_CONFIG_H

/*
 * define name for panel configuration
 */
#define glcd_ConfigName "RA8835-Manual" 


#define DISPLAY_WIDTH 240
#define DISPLAY_HEIGHT 160

// panel controller chips
#define CHIP_WIDTH     240 // pixels per chip 
#define CHIP_HEIGHT    160 // pixels per chip 

// calculate number of chips & round up if width is not evenly divisable
#define glcd_CHIP_COUNT (1)


#define glcdPinData0    37
#define glcdPinData1    36
#define glcdPinData2    35
#define glcdPinData3    34
#define glcdPinData4    33
#define glcdPinData5    32
#define glcdPinData6    31
#define glcdPinData7    30

#define glcdPinRW      9	// this is the WR pin of the panel
#define glcdPinDI      10   // this is the A0 pin of the panel
#define glcdPinRST      12   // this is the reset pin of the panel

#define glcdPinCSEL1   11	// this is the CS pin of the panel 
#define glcdPinEN      8	// this is the RD pin of the panel

#define glcd_BLactlevel HIGH


#define GLCD_tDDR    85    /* tACC6: Data Delay time (E high to valid read data)             */
#define GLCD_tAS      0    /* tAW6:  Address setup time (ctrl line changes to E high)        */
#define GLCD_tDSW    100    /* tDS6:  Data setup time (Write data lines setup to dropping E)  */
#define GLCD_tWH     120    /* tEW:   E hi level width (minimum E hi pulse width)             */ 
#define GLCD_tWL     250    /* E lo level width (minimum E lo pulse width)                    */


#include "device/RA8835_Device.h"
#endif //GLCD_PANEL_CONFIG_H

Please post the entire text of the error message. It is easy to do. There is a "copy error message" button. Copy the error message and paste to a new post.

I've seen that error when there is a misplace or mismatched curly-bracket.

The complier doesn't really know what the error is or exactly where the error is, it just knows that what you've written doesn't make sense to the compiler.

Sometimes you can zero-in on the problem by commenting-out sections of code. But of course, you have to do that in a way that makes sense too. For example you can comment-out almost everything in a function and perhaps make it return a dummy value. Then bring-back a few lines of code at a time until you find the code that's causing the error.

...And it helps if you develop your code a little at a time, testing as you go so you always know where to look for the error.

the entire error messge:

D:\Arduino\libraries\openGLCD\glcd_Device.cpp: In member function 'void glcd_Device::GotoXY(uint8_t, uint8_t)':

D:\Arduino\libraries\openGLCD\glcd_Device.cpp:303:29: error: expected primary-expression before ';' token

  x = glcdDev_Xval2ChipCol(x);

                             ^

D:\Arduino\libraries\openGLCD\glcd_Device.cpp:315:46: error: expected primary-expression before ';' token

   cmd = LCD_SET_ADDLO | glcdDev_Col2addrlo(x);

                                              ^

D:\Arduino\libraries\openGLCD\glcd_Device.cpp:318:46: error: expected primary-expression before ';' token

   cmd = LCD_SET_ADDHI | glcdDev_Col2addrhi(x);

                                              ^

exit status 1
Error compiling for board Arduino Mega or Mega 2560.