I use an Arduino Pro 328 - 5V/16MHz and tiny 4D display, until now it works fine
Good point about the serial ports.... mmmmm!! I think that we need to ask to some Serial comunication guru ;D
could be that using SoftwareSerial LIB can help us but I don't know if this increase dramatically the execution time (i guess you need to messure with an oscilloscope), other posibility can be use some compiler instructions on LIB, so when Arduino complie code it insert correctlly waht serial port is called by the PDE file. :-?
based on your observations I modify some Methods on code
//CONSTRUCTOR
uOLED::uOLED(int pin, int baud)
{
PinReset=pin;
pinMode(PinReset, OUTPUT);
BRate = baud;
}
//Make a Reset for uOLED and Clear Screen
void uOLED::StartUp()
{
//Reset display
digitalWrite(PinReset,LOW);
delay(30);
digitalWrite(PinReset,HIGH);
delay(2000);
Serial.begin(BRate);
//Send 0x55 to stablish baud rate for serial communication
Serial.write(0x55);
res=RBack();
Cls();
}
I just move Serial.Begin from class constructor to StartUp, this is important because as soon as you call Serial.begin it also takes care about TX pin line to put it into HIGH becasue HI state signal on RS232 means no data is send, when Serial.print (or any other send function) is called TX signal follows RS232 protocol (start bit, data bits, stop bit). I also verify this with oscilloscope. On your cade you manipulate manually TX pin that in my pont of view has no sense!
I put RBack as private method that modify a public attribute into the uOLED class because not always is needed to verify or debug response from 4D Display if you want to check respronse just type
char 4DDisplayResponse;
uOLED My_uOLED;
//
/*extra coding*/
//
4DDisplayResponse = My_uOLED.res;
I haven't tested neither how works Serial.write compared with Serial.print (data,BYTE) this will be a good exercise to test, waht I see that Serial.write use less space when you compile the code
if you want to add a instruction on LIB follow this steps
- On uOLED.h declare as Public method the function
unsigned int ReadPixel(chat x, char y)
- into uOLED.cpp coding the function as a member of uOLED class
unsigned int uOLED::ReadPixel(chat x, char y)
{
unsigned int data;
char temp;
Serial.write(0x52);
Serial.writeMode);
Serial.write(Value);
res=RBack(); //wait for ACK
data=int (RBack());
temp=RBack();
data=data<<8;
data=data+int(temp);
return data;
}
- on your PDE program just call method
PixelColor = my_uOLED.ReadPixel(10,10);
I hope this can help! 