invalid conversion from 'char*' to 'unsigned char*'

Hi !

I don’t seem to get pass these errors:

jotain.cpp: In function ‘void loop()’:
jotain:14: error: invalid conversion from ‘char*’ to 'unsigned char*'
jotain:14: error: initializing argument 3 of 'void LCD12864R::DisplayStringnew(int, int, unsigned char*)'

This is my code

#include <LCD12864R.h>

char lcdbuffer[10]; // declare buffer
int tulos = 0;

void setup() {
  LCDB.Initialise(); // INIT SCREEN
  delay(500); // Some delay
}
void loop(){

  tulos = 22; // defying a number for the integer
 
 sprintf(lcdbuffer, "RPM: %02d%", tulos); //This should do the magic?
 
 LCDB.DisplayStringnew(0,0,lcdbuffer);;//This should print RPM:22%

while(1);
}

I’m using two libraries in my project, and they are pretty similar. I was not able to copy the string function from the other library, so I changed all LCDA’s to LCDB in that library. This way I can have both libraries in same program.

This is the part from the library that the code is using:

void LCD12864R::DisplayStringnew(int X,int Y,uchar *ptr)
{
  int i;

  switch(X)
   {
     case 0:  Y|=0x80;break;

     case 1:  Y|=0x90;break;

     case 2:  Y|=0x88;break;

     case 3:  Y|=0x98;break;

     default: break;
   }
  WriteCommand(Y);

   while(*ptr)
      WriteData(ptr++);
}
 LCDB.DisplayStringnew(0,0,(uchar*)lcdbuffer);;//This should print RPM:22%

jotain.cpp: In function 'void loop()': jotain:15: error: 'uchar' was not declared in this scope jotain:15: error: expected primary-expression before ')' token

LCDB.DisplayStringnew(0,0,(uchar*)lcdbuffer);;//This should print RPM:22%

Do I need to define unchar*?

LCDB.DisplayStringnew(0,0,(unsigned char*)lcdbuffer);//This should print RPM:22%

C:\arduino-0022\libraries\LCD12864R\LCD12864R.cpp: In member function ‘void LCD12864R::DisplayStringnew(int, int, unsigned char*)’:
C:\arduino-0022\libraries\LCD12864R\LCD12864R.cpp:163: error: invalid conversion from ‘unsigned char*’ to ‘int’
C:\arduino-0022\libraries\LCD12864R\LCD12864R.cpp:163: error: initializing argument 1 of ‘void LCD12864R::WriteData(int)’

Here’s the library:

/*
LCD12864R
www.DFRobot.com
*/


#include "LCD12864R.h"
//#include "LCDSprite.h"


extern "C" 
{
#include <wiring.h> 
#include <inttypes.h>
#include <stdio.h>  //not needed yet
#include <string.h> //needed for strlen()
#include <avr/pgmspace.h>
}

LCD12864R::LCD12864R() 
{
this->DEFAULTTIME = 300; // 80 ms default time
this->delaytime = DEFAULTTIME;
} 


void LCD12864R::setPins(uint8_t tRS, uint8_t tRW, uint8_t tD7, uint8_t tD6, uint8_t tD5, uint8_t tD4, uint8_t tD3, uint8_t tD2, uint8_t tD1, uint8_t tD0) 
{
  digitalWrite(EN,1);  
  delayns();
  digitalWrite(RS, tRS);   
  digitalWrite(RW, tRW);   
  digitalWrite(D7, tD7);   
  digitalWrite(D6, tD6);   
  digitalWrite(D5, tD5);   
  digitalWrite(D4, tD4);   
  digitalWrite(D3, tD3);   
  digitalWrite(D2, tD2);   
  digitalWrite(D1, tD1);   
  digitalWrite(D0, tD0);   
  delayns();
  digitalWrite(EN, 0);   
  delayns();

}


//*********************ÑÓʱº¯Êý************************//
void LCD12864R::delayns(void)
{   
delayMicroseconds(delaytime);
 }



void LCD12864R::VectorConverter(int vector) 
{
int result = vector;
for (int i = 7; i >= 0; i--) 
{
this->temp[i] = result % 2;
result = result/2;
}

}


void LCD12864R::WriteCommand(int CMD)
{ 
   delayns();
   delayns();
   VectorConverter(CMD); // lets get the binary from the dec
   setPins(0,0,this->temp[0],this->temp[1],this->temp[2],this->temp[3],this->temp[4],this->temp[5],this->temp[6],this->temp[7]); //WriteCommand

}



void LCD12864R::WriteData(int CMD)
{  
   delayns();
   delayns();
   VectorConverter(CMD); // lets get the binary from the dec
   setPins(1,0,this->temp[0],this->temp[1],this->temp[2],this->temp[3],this->temp[4],this->temp[5],this->temp[6],this->temp[7]); //WriteData
}


void LCD12864R::Initialise(void) 
{

   pinMode(RS, OUTPUT);     
   pinMode(RW, OUTPUT);    
   pinMode(EN, OUTPUT);     
   pinMode(D0, OUTPUT);      
   pinMode(D1, OUTPUT);    
   pinMode(D2, OUTPUT);   
   pinMode(D3, OUTPUT);      
   pinMode(D4, OUTPUT);      
   pinMode(D5, OUTPUT);      
   pinMode(D6, OUTPUT);      
   pinMode(D7, OUTPUT);
   delayns();

   WriteCommand(0x30);        //¹¦ÄÜÉ趨¿ØÖÆ×Ö
   WriteCommand(0x0c);        //ÏÔʾ¿ª¹Ø¿ØÖÆ×Ö
//   WriteCommand(0x01);        //Çå³ýÆÁÄ»¿ØÖÆ×Ö
   WriteCommand(0x06);        //½øÈëÉ趨µã¿ØÖÆ×Ö
}



void LCD12864R::CLEAR(void)
{  
    WriteCommand(0x30);//
    WriteCommand(0x01);//Çå³ýÏÔʾ
}



void LCD12864R::DisplayString(int X,int Y,uchar *ptr,int dat)
{
  int i;

  switch(X)
   {
     case 0:  Y|=0x80;break;

     case 1:  Y|=0x90;break;

     case 2:  Y|=0x88;break;

     case 3:  Y|=0x98;break;

     default: break;
   }
  WriteCommand(Y); // ¶¨Î»ÏÔʾÆðʼµØÖ·

  for(i=0;i<dat;i++)
    { 
      WriteData(ptr[i]);//ÏÔʾºº×ÖʱעÒâÂëÖµ£¬Á¬ÐøÁ½¸öÂë±íʾһ¸öºº×Ö
    }
}

void LCD12864R::DisplayStringnew(int X,int Y,uchar *ptr)
{
  int i;

  switch(X)
   {
     case 0:  Y|=0x80;break;

     case 1:  Y|=0x90;break;

     case 2:  Y|=0x88;break;

     case 3:  Y|=0x98;break;

     default: break;
   }
  WriteCommand(Y);

   while(*ptr)
      WriteData(ptr++);
}


void LCD12864R::DisplaySig(int M,int N,int sig)
{
  switch(M)
   {
     case 0:  N|=0x80;break;

     case 1:  N|=0x90;break;

     case 2:  N|=0x88;break;

     case 3:  N|=0x98;break;

     default: break;
   }
  WriteCommand(N); // ¶¨Î»ÏÔʾÆðʼµØÖ·
  WriteData(sig); //Êä³öµ¥¸ö×Ö·û
 }




void LCD12864R::DrawFullScreen(uchar *p)
{
      int ygroup,x,y,i;
      int temp;
      int tmp;
             
      for(ygroup=0;ygroup<64;ygroup++)           //дÈëÒº¾§ÉÏ°ëͼÏ󲿷Ö
        {                           //дÈë×ø±ê
           if(ygroup<32)
            {
             x=0x80;
             y=ygroup+0x80;
            }
           else 
            {
              x=0x88;
              y=ygroup-32+0x80;    
            }         
           WriteCommand(0x34);        //дÈëÀ©³äÖ¸ÁîÃüÁî
           WriteCommand(y);           //дÈëyÖá×ø±ê
           WriteCommand(x);           //дÈëxÖá×ø±ê
           WriteCommand(0x30);        //дÈë»ù±¾Ö¸ÁîÃüÁî
           tmp=ygroup*16;
           for(i=0;i<16;i++)
		 {
		    temp=p[tmp++];
		    WriteData(temp);
               }
          }
        WriteCommand(0x34);        //дÈëÀ©³äÖ¸ÁîÃüÁî
        WriteCommand(0x36);        //ÏÔʾͼÏó
}


LCD12864R LCDB = LCD12864R();
WriteData(ptr++);

Right there.

Did you mean WriteData(*ptr++); ?

The compiler errors are sometimes a bit cryptic, but here, I think they're pretty spot-on.

Thank you wery much!!!

This was the last obstacle with my project (knokking wood).