Hi.
I hope someone can help me, and thanks in advance for anything with this.
I've just started using a ST7565 RGB LCD 128x64.
I've not really delved in to ports etc, its always something I was going to leave until I had everything else working first, and then strip the code back.
Now I'm faced with an ultra low refresh rate, which wont bode well in my design..
I'm currently working with this lib:
This is the code I've identified to adjust in THIS FILE:
inline void ST7565::spiwrite(uint8_t c) {
shiftOut(sid, sclk, MSBFIRST, c);
}
}
void ST7565::st7565_command(uint8_t c) {
digitalWrite(a0, LOW);
spiwrite(c);
}
void ST7565::st7565_data(uint8_t c) {
digitalWrite(a0, HIGH);
To (something like) this:
inline void ST7565::spiwrite(uint8_t c) {
#if 0
shiftOut(sid, sclk, MSBFIRST, c);
#else
for (byte mask = 0x80; mask != 0; mask >>= 1){
bitWrite(PORTC, 0, c & mask);
bitSet(PORTD, 4);
bitClear(PORTD, 4);
}
#endif
}
void ST7565::st7565_command(uint8_t c) {
#if 0
digitalWrite(a0, LOW);
#else
bitClear(PORTC, 3);
#endif
spiwrite(c);
}
void ST7565::st7565_data(uint8_t c) {
#if 0
digitalWrite(a0, HIGH);
#else
bitSet(PORTC, 3);
#endif
spiwrite(c);
}
I tried following this tutorial:
http://jeelabs.org/2010/11/19/speedier-graphics/#comments
I uploaded as is, and get a blank display, so thought this was more than likely to do with the port assignment.
(From THIS IMAGE).
For example:
bitSet(PORTD, 4);
I'm reading as digitalPin 4. (Is this correct?!)
So, I take that I need to change these assignments to the correct ones?
I haven't got any reference to what is contained in the link attached in the page, so working in the dark as to whether I'm on the right track or not.
As far as I can see, there are only 3 ports to change, which I believe to be:
PORTC, 0
PORTD, 4
PORTC, 3
From the ref HERE would be:
digitalPin 23
digitalPin 4
digitalPin 26
I have no idea what pins were used when they wrote the example. So can not be sure I'm even talking to the right ports etc.
With my set up, I'm using the following:
CS digitalPin 5
RST digitalPin 6
A0 digitalPin 7
SID digitalPin 9
SCLK digitalPin 11
Also getting confused as to what pins the functions are referring to (CS / A0 / SI).
eg.
void ST7565::st7565_data(uint8_t c) {
#if 0
digitalWrite(a0, HIGH);
#else
bitSet(PORTC, 3);
#endif
spiwrite(c);
}
I can see that they are using A0 after '#if', but unsure which 'PORTC, 3' is pointing at.
I could be well off generally anyway, as it seems everyone else uses bitWrite etc in bin.
Generally confused and unsure what to do, with the added fear that I'll short, brick or otherwise damage my Arduino.
Again, thanks in advance!