Jump to content

LCD 128x64 dot matrix


Dadzilla74

Recommended Posts

Hi All,

 

Has anyone set up a 128x64 LCD dot matrix before for DCS BIOS?

 

I have purchased a;

 

https://www.jaycar.com.au/arduino-compatible-128x64-dot-matrix-lcd-display-module/p/XC4617

 

with a ST7920 chip set.

 

I would like to use this for the 5 x UFC option displays in the f-18C by rotating 90 degrees and spacing out 5 lines.

 

The Arduino board I am using is a Mega Board.

 

There is very little information and the Arduino examples do not seem to suit my purpose.

 

If anyone has some experience with this, it would be greatly appreciated if you could help.


Edited by Mark McCosker
Link to comment
Share on other sites

Ok, So I have managed to get the text rotated by 90 degrees and can position 5 lines down the screen. I just need to understand what the UFC Cueing is (as I am not sure what this is for and if this is needed for the UFC option display) and a script to tell DCS bios where to place the display for the UFC Option display.

 

If anyone could help it would be greatly appreciated.


Edited by Mark McCosker
Link to comment
Share on other sites

hi all,

 

on my display board, this works good;

 

 

 

#include "U8glib.h"

 

U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17

 

void draw(void) {

// graphic commands to redraw the complete screen should be placed here

u8g.setFont(u8g_font_5x7);

//u8g.setFont(u8g_font_5x7);

u8g.drawStr( 0, 22, "TEST");

u8g.drawStr( 0, 42, "NOw WORKING");

}

 

void setup(void) {

// flip screen, if required

// u8g.setRot();

u8g.setRot270()

 

 

// set SPI backup if required

//u8g.setHardwareBackup(u8g_backup_avr_spi);

 

// assign default color value

;if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {

u8g.setColorIndex(255); // white

}

else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {

u8g.setColorIndex(3); // max intensity

}

else if ( u8g.getMode() == U8G_MODE_BW ) {

u8g.setColorIndex(1); // pixel on

}

else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {

u8g.setHiColorByRGB(255,255,255);

}

 

pinMode(8, OUTPUT);

}

 

void loop(void) {

// picture loop

u8g.firstPage();

 

do {

draw();

} while( u8g.nextPage() );

 

// rebuild the picture after some delay

//delay(50);

}

 

Moving most of this into dcs bios UFC Display looks like this;

 

/*

Tell DCS-BIOS to use a serial connection and use interrupt-driven

communication. The main program will be interrupted to prioritize

processing incoming data.

 

This should work on any Arduino that has an ATMega328 controller

(Uno, Pro Mini, many others).

*/

#define DCSBIOS_IRQ_SERIAL

 

#include "DcsBios.h"

#include "U8glib.h"

 

U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17

/* paste code snippets from the reference documentation here */

 

void onUfcOptionDisplay1Change(char* newValue) {

 

u8g.setFont(u8g_font_5x7);

//u8g.setFont(u8g_font_5x7);

u8g.drawStr( 0, 22, "TEST");

}

DcsBios::StringBuffer<4> ufcOptionDisplay1Buffer(0x542a, onUfcOptionDisplay1Change);

 

 

 

 

 

void setup() {

// u8g.setRot();

u8g.setRot270();

 

 

// set SPI backup if required

//u8g.setHardwareBackup(u8g_backup_avr_spi);

 

// assign default color value

;if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {

u8g.setColorIndex(255); // white

}

else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {

u8g.setColorIndex(3); // max intensity

}

else if ( u8g.getMode() == U8G_MODE_BW ) {

u8g.setColorIndex(1); // pixel on

}

else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {

u8g.setHiColorByRGB(255,255,255);

}

 

pinMode(8, OUTPUT);

 

 

DcsBios::setup();

 

}

void loop(void) {

// picture loop

u8g.firstPage();

 

do {

draw();

} while( u8g.nextPage() );

 

// rebuild the picture after some delay

//delay(50);

}

DcsBios::loop();

}

 

However there is an error;

'draw' was not declared in this scope.

 

Does anyone know how to fix this issue?

Link to comment
Share on other sites

However there is an error;

'draw' was not declared in this scope.

 

Does anyone know how to fix this issue?

 

I've not used any of the hardware you're using to know for sure, but just from a standard C or C++ standpoint, you have no draw() function defined in your second bit of code. Does the one from your first code work if you add it?

 

void draw(void) {

// graphic commands to redraw the complete screen should be placed here

u8g.setFont(u8g_font_5x7);

//u8g.setFont(u8g_font_5x7);

u8g.drawStr( 0, 22, "TEST");

u8g.drawStr( 0, 42, "NOw WORKING");

}

[sIGPIC][/sIGPIC]

i7-6700 3.4GHz - NVIDIA GTX 1060 6GB - Logitech G940 - Oculus Rift CV1

Link to comment
Share on other sites

I haven't tried this either but you may try this also;

 

/*
Tell DCS-BIOS to use a serial connection and use interrupt-driven
communication. The main program will be interrupted to prioritize
processing incoming data.

This should work on any Arduino that has an ATMega328 controller
(Uno, Pro Mini, many others).
*/
#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"
#include "U8glib.h"

U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
/* paste code snippets from the reference documentation here */

void onUfcOptionDisplay1Change(char* newValue) {

u8g.setFont(u8g_font_5x7);
//u8g.setFont(u8g_font_5x7);
u8g.drawStr( 0, 22, newValue); // added drawing the newValue instead of fixed text
}
DcsBios::StringBuffer<4> ufcOptionDisplay1Buffer(0x542a, onUfcOptionDisplay1Change);





void setup() {
// u8g.setRot();
u8g.setRot270();


// set SPI backup if required
//u8g.setHardwareBackup(u8g_backup_avr_spi);

// assign default color value
;if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255,255,255);
}

pinMode(8, OUTPUT);


DcsBios::setup();

}
void loop(void) {
DcsBios::loop(); // removed all but DCS-BIOS
}

 

It has removed the need for the draw() function and instead should refresh when getting a new value from DCS.

At least you can check if it can compile.

 

cheers

Hans

Link to comment
Share on other sites

And what happens if you follow Magnatilla's advise;

 

/*
Tell DCS-BIOS to use a serial connection and use interrupt-driven
communication. The main program will be interrupted to prioritize
processing incoming data.

This should work on any Arduino that has an ATMega328 controller
(Uno, Pro Mini, many others).
*/
#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"
#include "U8glib.h"

U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
/* paste code snippets from the reference documentation here */

void onUfcOptionDisplay1Change(char* newValue) {

u8g.setFont(u8g_font_5x7);
//u8g.setFont(u8g_font_5x7);
u8g.drawStr( 0, 22, "newValuew from DCS");
}
DcsBios::StringBuffer<4> ufcOptionDisplay1Buffer(0x542a, onUfcOptionDisplay1Change);

void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g.setFont(u8g_font_5x7);
//u8g.setFont(u8g_font_5x7);
u8g.drawStr( 0, 22, "TEST");
u8g.drawStr( 0, 42, "NOw WORKING");
}



void setup() {
// u8g.setRot();
u8g.setRot270();


// set SPI backup if required
//u8g.setHardwareBackup(u8g_backup_avr_spi);

// assign default color value
;if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255,255,255);
}

pinMode(8, OUTPUT);


DcsBios::setup();

}
void loop(void) {
// picture loop
u8g.firstPage();

do {
draw();
} while( u8g.nextPage() );

// rebuild the picture after some delay
//delay(50);
}
DcsBios::loop();
}

 

Cheers

Hans

Link to comment
Share on other sites

Looks like there's an unwanted curly close bracket before DcsBios::loop();

 

Change the last bit from

 

// rebuild the picture after some delay

//delay(50);

}

DcsBios::loop();

}

to

 

// rebuild the picture after some delay

//delay(50);

DcsBios::loop();

}

[sIGPIC][/sIGPIC]

i7-6700 3.4GHz - NVIDIA GTX 1060 6GB - Logitech G940 - Oculus Rift CV1

Link to comment
Share on other sites

more information

 

Hi All,

 

I hope someone can help me out with the loop script as I cannot get the display to show the newValue;

 

I am creating a switch box for my flight sim with several displays.

 

The hardware that I am using is the Arduino Mega and a Duinotech 128x64LCD Dot Matrix which uses the St7920 chip.

 

I also use the U8GLIB library to get the screen working, and then place this Library into the DCS File with the DCSBIOS Library.

 

Currently the pin set up is;

GND =GRD

VCC = 5V

VO = NOT CONNECTED

RS = 17

R/W= 16

E = 18

DB0 = 8

DB1 = 9

DB2 = 10

DB3 = 11

DB4 = 4

DB5 = 5

DB6 = 6

DB7 = 7

PSB = GRD

NC = NOT CONNECTED

RST = NOT CONNECTED

VOUT = NOT CONNECTED

BLA = 5V

BLK = GRD

 

The script I used to test the screen and works fine is;

 

Please remove comment from the constructor of the
 >>> connected graphics display (see below).

 Universal 8bit Graphics Library, https://github.com/olikraus/u8glib/

 Copyright (c) 2012, olikraus@gmail.com
 All rights reserved.

 Redistribution and use in source and binary forms, with or without modification,
 are permitted provided that the following conditions are met:

 * Redistributions of source code must retain the above copyright notice, this list
   of conditions and the following disclaimer.
  
 * Redistributions in binary form must reproduce the above copyright notice, this
   list of conditions and the following disclaimer in the documentation and/or other
   materials provided with the distribution.

 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 

*/


#include "U8glib.h"

U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);  // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17

// setup u8g object, please remove comment from one of the following constructor calls
// IMPORTANT NOTE: The following list is incomplete. The complete list of supported
// devices with all constructor calls is here: https://github.com/olikraus/u8glib/wiki/device

//U8GLIB_ST7920_128X64_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_128X64_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_128X64_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_128X64_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_192X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_192X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_192X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_192X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_192X32_1X u8g(13, 11, 10);	// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10
//U8GLIB_ST7920_192X32_4X u8g(10);		// SPI Com: SCK = en = 13, MOSI = rw = 11, CS = di = 10, HW SPI
//U8GLIB_ST7920_202X32_1X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_202X32_4X u8g(8, 9, 10, 11, 4, 5, 6, 7, 18, 17, 16);   // 8Bit Com: D0..D7: 8,9,10,11,4,5,6,7 en=18, di=17,rw=16
//U8GLIB_ST7920_202X32_1X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
//U8GLIB_ST7920_202X32_4X u8g(18, 16, 17);	// SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17



void draw(void) {
 // graphic commands to redraw the complete screen should be placed here


 u8g.setFont(u8g_font_5x7);
 //u8g.setFont(u8g_font_5x7);
 u8g.drawStr( 0, 22, "TEST");
 u8g.drawStr( 0, 42, "NOW WORKING");


}

void setup(void) {
 // flip screen, if required
  // u8g.setRot();
  u8g.setRot270()


 // set SPI backup if required
 //u8g.setHardwareBackup(u8g_backup_avr_spi);

 // assign default color value
 ;if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
   u8g.setColorIndex(255);     // white
 }
 else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
   u8g.setColorIndex(3);         // max intensity
 }
 else if ( u8g.getMode() == U8G_MODE_BW ) {
   u8g.setColorIndex(1);         // pixel on
 }
 else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
   u8g.setHiColorByRGB(255,255,255);
 }

 pinMode(8, OUTPUT);
}

void loop(void) {
 // picture loop
 u8g.firstPage(); 
 do {
   draw();
 } while( u8g.nextPage() );

 // rebuild the picture after some delay
 //delay(50);
}

 

I have then taken the information from the above code and placed it in my DCS Bios script like;

 


Tell DCS-BIOS to use a serial connection and use interrupt-driven
communication. The main program will be interrupted to prioritize
processing incoming data.

This should work on any Arduino that has an ATMega328 controller
(Uno, Pro Mini, many others).
*/
#define DCSBIOS_IRQ_SERIAL

#include "DcsBios.h"
#include "U8glib.h"

U8GLIB_ST7920_128X64_1X u8g(18, 16, 17); // SPI Com: SCK = en = 18, MOSI = rw = 16, CS = di = 17
/* paste code snippets from the reference documentation here */

void onUfcOptionDisplay1Change(char* newValue) {

u8g.setFont(u8g_font_5x7);
//u8g.setFont(u8g_font_5x7);
u8g.drawStr( 0, 22, "newValue from DCS");
}
DcsBios::StringBuffer<4> ufcOptionDisplay1Buffer(0x542a, onUfcOptionDisplay1Change);



void setup() {
// u8g.setRot();
u8g.setRot270();


// set SPI backup if required
//u8g.setHardwareBackup(u8g_backup_avr_spi);

// assign default color value
;if ( u8g.getMode() == U8G_MODE_R3G3B2 ) {
u8g.setColorIndex(255); // white
}
else if ( u8g.getMode() == U8G_MODE_GRAY2BIT ) {
u8g.setColorIndex(3); // max intensity
}
else if ( u8g.getMode() == U8G_MODE_BW ) {
u8g.setColorIndex(1); // pixel on
}
else if ( u8g.getMode() == U8G_MODE_HICOLOR ) {
u8g.setHiColorByRGB(255,255,255);
}

pinMode(8, OUTPUT);


DcsBios::setup();

}
void loop (void){
// picture loop
u8g.firstPage();

do {
draw();
} while( u8g.nextPage() );

// rebuild the picture after some delay
//delay(50);

DcsBios:: loop();
}



 

Unfortunately There is an issue with the 'draw' line under 'do'.

 

I have tried to modify to the script but cannot seem to get anything working.

 

I have also tried taking the loop out of the first script yet the screen goes blank.

 

Hopefully someone might be able to help with the loop section to get the script working and displaying the 'newValue'.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...