How to change a 0.22 lib --> 1.0

Hi all,

Today I migrated to 1.0 but there are some issues I cannot solve. For my project I use SerialGLCD, but that needs some changing due to the other approach with using Wire and Serial.

During compilation I get errors like:
E:\Arduino\arduino-1.0-windows\arduino-1.0\libraries\serialGLCD\serialGLCD.cpp: In member function ‘void serialGLCD::togglePixel(int, int, int)’:
E:\Arduino\arduino-1.0-windows\arduino-1.0\libraries\serialGLCD\serialGLCD.cpp:193: error: call of overloaded ‘write(int)’ is ambiguous
E:\Arduino\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/HardwareSerial.h:58: note: candidates are: virtual size_t HardwareSerial::write(uint8_t)
E:\Arduino\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
E:\Arduino\arduino-1.0-windows\arduino-1.0\libraries\serialGLCD\serialGLCD.cpp:202: error: call of overloaded ‘write(int)’ is ambiguous
E:\Arduino\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/HardwareSerial.h:58: note: candidates are: virtual size_t HardwareSerial::write(uint8_t)
E:\Arduino\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)

This is a piece code that belongs to that:

void serialGLCD::togglePixel(int x, int y, int z)
{ /* Toggles a pixel. x and y for coord, z=1 sets, z=0 erases.
Example: lcd.togglePixel(30,30,1);
*/
Serial.write(0x7C);
Serial.write(0x10);
if(x > 128) {
Serial.write(128);
}
else if(x < 0) {
Serial.write(0);
}
else {
Serial.write((byte)x);
}
if(y > 64) {
Serial.write(64);
}
else if(y < 0) {
Serial.write(0);
}
else {
Serial.write((byte)y);
}
if(z != 1 && z != 0) {
Serial.write(1);
}
else {
Serial.write((byte)z);
}
}

I added the (byte) directive, which seem to help in some other parts, but not here.

I really could use some help.

Thanjks,
Bert

In cases where the variable is already defined, it isn’t necessary to cast.

This won’t compile:

 Serial.write(0);

However, these will:

Serial.write((uint8_t)0);
Serial.write(0,1);

The 2nd example, the “1” argument specifies the length of characters.

Thanks for the help, it worked. But it is a little funny, because in the example in the reference it is used in the way I used it:

regards, Bert

void setup(){ Serial.begin(9600); }

void loop(){ Serial.write(45); // send a byte with the value 45

int bytesSent = Serial.write(“hello”); //send the string “hello” and return the length of the string.