Go Down

Topic: Using U8glib to make a I2C Backpack, to reduce the pin count (Read 486 times) previous topic - next topic

zyxel13

Hello,

First of all I want to thank Oliver for his great Work!

Most LCDs that I use in my private projects are parallel driven, which wastes a lot of I/O pins, so I wanted to use the very Extensive U8glib(that supports many Controllers) as remote controllable via I2C commands, in a Master - Slave Configuration.
Master Sends the commands via I2C, Slave receives the Commands from the Master and executes the appropriate Graphic Functions Locally.

It's a Similar Functionality like the Digole GLCD Backpack that unfortunately supports only 3 Controllers.

I use 2 Nanos one as a slave (where the display is physically attached) and another as the master (main MCU that send the Commands) both are connect via I2C.

Using an LCD ST7920 based 128x64 (U8GLIB_ST7920_128X64_4X) Display in parallel mode on the Slave and having the Master sending 3 test commands in a loop to the Slave, the Slave executes these commands but on the Display the Output is shown only very briefly and not in the correct Sequence…

Tests I Made:
1) Tested the Graphic Example from Oliver on the Slave =>  all works, so the Wiring is correct
2) I tested to see if the Slave receives the correct commands from the Master => all commands are correctly received.

Here a Video showing that the Graphic Example works OK Locally on the Slave:
http://www.grsnet.net/local_slave_draw_demo.MOV

This Video show the same Demo Commands send from the Master via I2C to the Slave:
http://www.grsnet.net/remote_draw_demo.MOV

My Test Setup and the 2 Sketches(Master/Slave) are attached.

I contacted Oliver directly, but I think this perhaps could be interesting for others to, so I put my Help request here too.

Unfortunately I am Stuck,  it would be great if someone could help.

Thankyou in Advance,
Cheers,
Konstantin

david_prentice

You can drive the ST7920 by SPI or 8-bit parallel or 4-bit parallel.

Most of the time you are only writing.   Reading is unusual.

SPI uses 3 pins.   CS, MOSI, SCK.    4-bit parallel uses 6 pins.

An I2C backpack only uses 2 pins.    However,   it will be very noticeably slower when writing graphics.    

The speed does not really matter if you are using the ST7920 as a text display like a 16x4 HD44780.    The built-in Fonts look horrible.

If you have other devices on the I2C bus,  an extra I2C device costs you nothing.
If you have other devices on the SPI bus,  an extra SPI device costs you one GPIO pin for CS.

So yes,  you can use a backpack.   The advantage is debatable.

David.

zyxel13

Hi David,

Thankyou for your Answer.

But my problems is not if I shall use a Backpack or not or how to use it, I want to build a Backpack by my own (Hardware is already done) and not only for the ST7920.

I used that only for testing cause I had it handy and drive it in parallel mode.

My goal is to Design a backpack that runs the Ug8lib where any of the U8glib supported Display controllers can be attached localy.

The backpack(Slave) comunicates either via I2C or SPI or whatever with the Master that sends only commands to the Slave, so the Master will not have to sacrife a lot pins and GPU just to drive the Display.

I have attached both the Master & Slave Sketches as an Picture of my test Setup.

Cheers,
Konstantin






olikraus

Quote
I contacted Oliver directly, but I think this perhaps could be interesting for others to, so I put my Help request here too.
Did i answer? I had only limited internet access recently.

Because of the "picture-loop" it will be a little bit complicated software project. From my perspective there are only top options:
1. Picture loop on the master
This means, you do no run the picture loop an the slave side, but instead implement the first and next command as commands which are sent by the master. Other options is this:

2. You store all graphics commands in an array on the slave. Then, with another special command by the master, you execute the list of stored commands on the client. Of course the number of graphics commands is limited because of the your RAM is limited and you can store only a limited number of graphics commands.

In your approach you did not use any of the two approaches... thats why i guess your code is not working.

Oliver
 

zyxel13

Did i answer? I had only limited internet access recently.

Because of the "picture-loop" it will be a little bit complicated software project. From my perspective there are only top options:
1. Picture loop on the master
This means, you do no run the picture loop an the slave side, but instead implement the first and next command as commands which are sent by the master. Other options is this:

2. You store all graphics commands in an array on the slave. Then, with another special command by the master, you execute the list of stored commands on the client. Of course the number of graphics commands is limited because of the your RAM is limited and you can store only a limited number of graphics commands.

In your approach you did not use any of the two approaches... thats why i guess your code is not working.

Oliver
 
Good Evening Oliver,

Thanykou for your Answer,

I will try to implement the 1st Option, having the master Send the FirstPage command, send the Graphic commands and send the NextPage after all commands are completed.

Is that how you mean it ?

Master Code:
---------------------------
 Send firstPage() command via I2C to the Slave, Slave executes u8g.firstPage()
 do
   {
     Send Graphic Commands to the Slave
   }

But how to send the nextPage() to Slave, nextpage() returns a Value…, does that mean I need to have the Slave send back the Value of nextpage() to continue or exit the while loop ??

while(u8g.nextPage());

Thankyou,
Konstantin

olikraus

Quote
But how to send the nextPage() to Slave, nextpage() returns a Value…, does that mean I need to have the Slave send back the Value of nextpage() to continue or exit the while loop ??
Yes exactly, the return value of u8g.nextPage() must be sent back to the master and the master must continue the loop until this value becomes 0.

Oliver

Go Up