LCD12864_test.ino: In function 'void loop()':
LCD12864_test:24: error: no matching function for call to 'LCD12864RSPI::DisplayString(int, int, String&, int)'
C:\Users\Jim\Documents\Arduino\libraries\LCD12864RSPI/LCD12864RSPI.h:29: note: candidates are: void LCD12864RSPI::DisplayString(int, int, unsigned char*, int)
I always have trouble with char arrays-strings
Jim
can solve the problem. I never use String class so I'm not sure.
You can too remove the String class from your code and use regular C strings (using arrays of chars) that is what your compiler is trying to say to you:
I don't have your libraries, but I can see several problems:
using the String class is usually unnecessary. Better off with a char array.
You never define the LCDA object, which means you can't call the CLEAR() method. Does
LCD12864RSPI.h mean it is a Raspberry Pi library?
Why the call to delay(100)?
Since you're looking for the newline character ('\n'), use readBytesUntil() method. charsRead tells you how many
characters were sent.
void loop()
{
// String msg; Get rid of this, and use this instead...
char msg[20]; // I'm assuming the message is never more than 19 chars.
int charsRead;
LCDA.CLEAR();//???? // You have not defined a LCDA object anywhere. Does
delay(100);
if (Serial.available() > 0) {
charsRead = Serial.readBytesUntil('\n', msg, 19); // we need room for the null character for strings
msg[charsRead] = '\n';
LCDA.DisplayString(0,0,msg,16);
}
delay(500);
}
econjack:
(...)
2. You never define the LCDA object, which means you can't call the CLEAR() method. Does
LCD12864RSPI.h mean it is a Raspberry Pi library?
(...)
These are not issues. "LCD12864RSPI.h" means LCD12864R - SPI, and form the sample on this page, the definition is OK.
@luisilva: As I said, I did not have the library and had no info on it. Personally, I absolutely abhor header files that contain data definitions for class objects. I would also be surprised if the call to the LCDA.CLEAR() method worked since it is defined in the header file in lower case letters.
econjack:
I don't have your libraries, but I can see several problems:
using the String class is usually unnecessary. Better off with a char array.
You never define the LCDA object, which means you can't call the CLEAR() method. Does
LCD12864RSPI.h mean it is a Raspberry Pi library?
Why the call to delay(100)?
Since you're looking for the newline character ('\n'), use readBytesUntil() method. charsRead tells you how many
characters were sent.
1 you are probably totally right
2 yes
3 it was in the sample code. I thought it might be for a reason, so I left it in.
4 right
I will try you sample.
Jim
I been away on business, just got back, and started trying your code.
Current code
#include "LCD12864RSPI.h"
#include "DFrobot_bmp.h"
#include "DFrobot_char.h"
#define AR_SIZE( a ) sizeof( a ) / sizeof( a[0] )
unsigned char tT[]="ST7920 LCD12864 ";//
void setup()
{
LCDA.initDriverPin(2,7,10);
LCDA.Initialise(); // INIT SCREEN
delay(100);
LCDA.DrawFullScreen(logo);//LOGO
delay(5000);
Serial.begin(9600);
}
void loop()
{
char msg[20];
int charsRead;
LCDA.CLEAR();
delay(100);
if (Serial.available() > 0) {
charsRead = Serial.readBytesUntil('\n', msg, 19); // we need room for the null character for strings
msg[charsRead] = '\n';
// LCDA.DisplayString(0,0,msg,16);
LCDA.DisplayString(1,0,tT,16);
delay(500);
}
delay(5000);
}
Code as displayed does compile,and run correctly. Commented code does not compile. Error is
lcdtest.ino: In function 'void loop()':
lcdtest:28: error: invalid conversion from 'char*' to 'unsigned char*'
lcdtest:28: error: initializing argument 3 of 'void LCD12864RSPI::DisplayString(int, int, unsigned char*, int)'
I am afraid I just don't groc it when pointers are involved. I was a hardware person involved in very large power supplies(150 KV300A) before I retired.