LCD 128x64 wont display due to loop instruction

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.

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;

/*

  HelloWorld.pde
  
  "Hello World!" example code.
  
  >>> Before compiling: 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 trhen 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’.

Please read the Forum Instructions.

Edit your post to put the code in a proper Code Window.

You will get a better response from Forum members.

David.

My apologies. I did not notice that you had edited your post.

It "looks" as if there should be several Code Windows with regular message text between them.
Please can you correct this.

"DcsBios.h" is not supported by the IDE Library Manager. So it is difficult to replicate your problem.

Please post links to the actual library(s) that you are using.

It is always wise to start with the library examples. Run ALL of them.

Then you can adapt / modify the most suitable example to implement your project.

The beauty of the Arduino system is that readers from every country in the world can replicate your project if you attach your sketch and quote library versions used.

David.

Hi David,

Thanks

I have amended and added some move information.

I hope someone can help soon.

Regards
Mark

"DcsBios.h" is not supported by the IDE Library Manager. So it is difficult to replicate your problem.

Please post links to the actual library(s) that you are using.

It is always wise to start with the library examples. Run ALL of them.

Then you can adapt / modify the most suitable example to implement your project.

The beauty of the Arduino system is that readers from every country in the world can replicate your project if you attach your sketch and quote library versions used.

We can attempt to draw blood from a stone. After a while, readers will lose interest.

It takes 10 minutes of your life to provide proper information. e.g. links, versions.
When you do so, readers often spend time and effort answering your question, providing a solution, ...

David.

Hi David,

You can read the Library in the script.

For the first scrip which works fine is the;

U8GLIB libary with the Hellow world example code.

For the Second code;

I use the DcsBios Libary with the IRQ Serial example
and the
8GLIB Library

I am not sure what the IDE Library is as I am not using it.

Please further explain.

The DcsBios.h library is not supported by the Library Manager.

Google finds several GitHub Forks.
How do I know which one you are using without a specific link.

Your use of C++ implies that you have some programming experience.

I am out.

David.

Hi David,

You are wrong.

I use the DCSBIOS Library and have set up multiple switches, Encoders, Potentialmeters and even a keypad which comminicates to DCSBIOS.

Regards
Mark

Hi Guys,

Worked it out myself and now is working fine.

Regards