implement LCD12864 with ST7920 for MEGA2560 for opentx

openTx has introduced a range of new features, ideas and bling. It is fast becoming the firmware of choice for many users. openTx will run on ALL current hardware platforms, including the gruvin9x and sky9x boards. Work has already started to support the new FrSky X9D radio!
Post Reply
Olli
Posts: 8
Joined: Thu Apr 09, 2015 6:34 pm
Country: -

implement LCD12864 with ST7920 for MEGA2560 for opentx

Post by Olli » Thu Apr 09, 2015 7:31 pm

Hello,

I want to build a DIY RC transmitter.
I have the joysticks, a lot of switches, pushbuttons and a 128x64 pixel LCD with a ST7920 controller inside.
At this moment I have nothing connected to the MEGA2560 except the display.
So I decided to try to change the ST7565 driver in the opentx/radio/src/targets/mega2560 folder to drive the ST7920 display.
the Init is ok and all of the data from the "displayBuf" variable gets transmitted and displayed on the LCD.
But all I can see on the dislay isn't readable.
Can anyone confirm, that my picture is okay for the opentx software?
I had never before a Transmitter with opentx, so I have no experience with that.
I wrote the Data of "displayBuf" in the first row and began with the second row with the next byte from "displayBuf"
row1 = byte0...15
row2= byte 16...31
...
If I get the driver working on my display I will share it here or in the Git Repository for everyone!

Please look over this informations and give me a little hint what is wrong here.
Thank you very much!

best regards
Attachments
LCD12864_opentx.jpg
LCD12864 with ST7920 controller on opentx
Last edited by Olli on Mon Apr 13, 2015 2:05 pm, edited 1 time in total.

User avatar
MikeB
9x Developer
Posts: 15625
Joined: Tue Dec 27, 2011 1:24 pm
Country: -
Location: Poole, Dorset, UK

Re: implement LCD12864 with ST7920 for MEGA2560 for opentx

Post by MikeB » Thu Apr 09, 2015 7:52 pm

The two chips address and display the graphic data differently. The ST7565 uses bytes vertically, while the ST7920 uses 16 bit words horizontally.

Mike.
ersky9x/er9x developer
The difficult we do immediately,
The impossible takes a little longer!

Olli
Posts: 8
Joined: Thu Apr 09, 2015 6:34 pm
Country: -

Re: implement LCD12864 with ST7920 for MEGA2560 for opentx

Post by Olli » Mon Apr 13, 2015 2:04 pm

Hello,

thank you very much MikeB for the hint!
Now I found this site:
http://edeca.net/wp/electronics/the-st7 ... ontroller/
The is a explanation of the adresses of the ST7565 Controller.
With this I was able to write a data converter from the "displayBuf" content to the ST7920 Controller of my LCD.
I wrote the driver in the "lcd_driver_ST7565R.cpp" file, so I hadn't nothing to do with the makefile.
Maybe is is possible to add this file with a correct file name to the GIT repository and make it chooseable in tme makefile.

Now I will go on to build my own RC Transmitter.
Thanks for the good software and documentation!

Best regards
Olli
Attachments
lcd_driver_ST7920.cpp
(4.74 KiB) Downloaded 323 times

vish04
Posts: 7
Joined: Fri May 01, 2015 8:52 pm
Country: -

Re: implement LCD12864 with ST7920 for MEGA2560 for opentx

Post by vish04 » Mon May 04, 2015 6:35 am

Awesome Olli!
I am stuck with 7290 based display that I purchased from Amazon without knowing what it is. Had a hard time debugging various problems, lot of soldering/desoldering and still no luck. The display would just stay blank.
Then started looking at lcd_driver and realized that the init code was doing something that didn't match with the datasheet and your code here seemed to make more sense. So, I tried it and it works!
I'd totally recommend getting this code merged and checked in with existing driver code.
Thanks!
Attachments
20150503_225720.jpg

vish04
Posts: 7
Joined: Fri May 01, 2015 8:52 pm
Country: -

Re: implement LCD12864 with ST7920 for MEGA2560 for opentx

Post by vish04 » Mon May 04, 2015 6:35 am

Awesome Olli!
I am stuck with 7290 based display that I purchased from Amazon without knowing what it is. Had a hard time debugging various problems, lot of soldering/desoldering and still no luck. The display would just stay blank.
Then started looking at lcd_driver and realized that the init code was doing something that didn't match with the datasheet and your code here seemed to make more sense. So, I tried it and it works!
I'd totally recommend getting this code merged and checked in with existing driver code.
Thanks!
Attachments
20150503_225720.jpg


Olli
Posts: 8
Joined: Thu Apr 09, 2015 6:34 pm
Country: -

Re: implement LCD12864 with ST7920 for MEGA2560 for opentx

Post by Olli » Fri May 15, 2015 7:12 pm

Hello,

I forgot to post the necessary changes in "board_mega2560.h"
In the section "LCD driver" the following pins have to be declared:

Code: Select all

// LCD driver
#define PORTA_LCD_DAT         PORTA
#define PORTC_LCD_CTRL        PORTC
#define OUT_C_LCD_E           7
#define OUT_C_LCD_RnW         6
#define OUT_C_LCD_RS          5
#define OUT_C_LCD_RES         4
#define OUT_C_LIGHT           2  
This pins are ususal IO pins without any special function. So they can be changed.
The names are the same on the pcb of the ST7920 LCD.

Best regards
Olli

Post Reply

Return to “openTx”