GLCD Uno pin config to Mega

Hello everyone

I have a shield that I build for a GLCD for my Arduino UNO which works 100%, but now I would like to use it on my Arduino Mega as well. So the pin configuration should be the same as the UNO as I understand it. I tried to do the manual config of the library but somewhere I’m not doing something correct. When I compile this is the error list that I get:

In file included from C:\Program Files\Arduino\libraries\glcd/include/gText.h:32,
from C:\Program Files\Arduino\libraries\glcd/glcd.h:40,
from Solder_Reflow_Oven_Coding.ino:114:
C:\Program Files\Arduino\libraries\glcd/include/glcd_Device.h:59: error: ‘glcd_CHIP_COUNT’ was not declared in this scope
In file included from C:\Program Files\Arduino\libraries\glcd/glcd.h:40,
from Solder_Reflow_Oven_Coding.ino:114:
C:\Program Files\Arduino\libraries\glcd/include/gText.h:115: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:115: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:118: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:118: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:121: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:121: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:121: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:124: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:124: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:127: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:127: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:127: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:130: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:130: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:133: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:133: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:133: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:136: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:136: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:136: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:139: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:139: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:139: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/include/gText.h:139: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
In file included from Solder_Reflow_Oven_Coding.ino:114:
C:\Program Files\Arduino\libraries\glcd/glcd.h:122: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/glcd.h:123: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/glcd.h:124: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/glcd.h:125: error: ‘DISPLAY_HEIGHT’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/glcd.h:126: error: ‘DISPLAY_WIDTH’ was not declared in this scope
C:\Program Files\Arduino\libraries\glcd/glcd.h:127: error: ‘DISPLAY_HEIGHT’ was not declared in this scope

I’ve attached the config file as well as a custom configuration file that I attempted to create. Something that I’m also not certain about is that in the wiring pdf of the GLCD in arduino playground, it specifies for the UNO to wire as follows:

CS1: 14 (alog 0)
CS2: 15 (alog 1)
R/W: 16 (alog 2)
D/I: 17 (alog 3)
E: 18 (alog 4)

But what are the numbers, 14 - 18, that are referred to here. I’ve looked at the pin numbers but I don’t under stand this. I’m a bit stuck here, but thank you in advance for any assistance.

glcd_Config.h (6 KB)

ks0108_Mega_Uno_Style.h (1.56 KB)

I don't maintain or offer support for that library anymore. I can help you if you want to switch to openGLCD: https://bitbucket.org/bperrybap/openglcd/wiki/Home

Just keep in mind that openGLCD is licensed GPL v3 so it can only be used in open source projects.

--- bill

Hello Bill

Thanks for the link. Unfortunately with this library some drawing functions don't operate quite the same. My code have already been finalized so I will have to make do with the GLCDv3 library for this project. I will definitely start implementing the library you've mentioned with my next project. Thanks again.

Dirk

If you found any differences when using the GLCDv3 compatibility mode please let me know.

--- bill

Hey Bill

I didn’t include the compatibility mode:

#include <openGLCD.h>
#include <include/openGLCD_GLCDv3.h> // header to provide GLCDv3 compatibility

It’s working correctly now.

I went through the config files now and I see that your referencing different configuration files within the master config file. In the master config file, if it is setup for auto config, it uses the AutoConfig_ks0108-128x64_Panel.h config file. Then in the AutoConfig_ks0108-128x64_Panel.h config file, the AutoPinConfig_ks0108.h is listed again to get the pin configuration if I understand it correctly.

My question now is, can I change the AutoPinConfig_ks0108.h to PinConfig_ks0108-Uno.h in this configuration file so that the pin configuration is always set to the Arduino UNO pin configuration, even when using a Mega?

End goal is to get the existing shield working on the same pins as an UNO but only on a Mega. I hope I’m expressing myself clear enough. Let me know if I need to clarify on something and thank you again for the advice and assistance so far.

Hello Bill

Just tested it out and it is working like a charm. THANK YOU SO SO SO MUCH. :grin:

The Project will be open source when it is done so everything is all good, thanks for the updating me about the licensing.

Dirk

Dirka: I went through the config files now and I see that your referencing different configuration files within the master config file. In the master config file, if it is setup for auto config, it uses the AutoConfig_ks0108-128x64_Panel.h config file. Then in the AutoConfig_ks0108-128x64_Panel.h config file, the AutoPinConfig_ks0108.h is listed again to get the pin configuration if I understand it correctly.

Yes that is correct.

My question now is, can I change the AutoPinConfig_ks0108.h to PinConfig_ks0108-Uno.h in this configuration file so that the pin configuration is always set to the Arduino UNO pin configuration, even when using a Mega?

End goal is to get the existing shield working on the same pins as an UNO but only on a Mega. I hope I'm expressing myself clear enough. Let me know if I need to clarify on something and thank you again for the advice and assistance so far.

Depending on your overall needs, it might be better to use a manual config file. This is documented in the openGLCD_config.h file but maybe it wasn't clear. (I've updated the comments in the config file to make it clearer)

By using a manual config file you don't have to modify any of the auto config files, and everything (panel and pin configuration) is all in one configuration file and the pins used are the same no matter what Arduino board is used. That is the intended way to do what you are wanting to do, (Assuming you want the pins to be same for all board types not just Uno and Mega) In fact, the ManualConfig_ks0108_Panel.h header file pins already match the UNO pins so you should be able to use that manual config file "as is".

Alternatively, if you still need to keep the auto configuration capability for other boards, you could go in an modify the pins in the Mega pin configuration file.

If you want to change the pins used in the manual configuration file, I'd recommend making a copy of the ManualConfig_ks0108_Panel.h file (rename it for your use) then set the GLCDCFG_GLCDCONFIG file to point to your manual configuration file rather than editing the supplied file.


GLCDv3 Compatibility mode was intended to be used for your exact scenario where you have an existing project and would like to move to openGLCD but due to timing/resources there needs to be transition period where the older API interface can still be used.

Just keep in mind that all the documentation, and many examples are documenting and showing the openGLCD API and parameters, not the GLCDv3 API and parameters, So you will see issues if you attempt to use sample code from the examples or use the API functions as documented when enabling GLCDv3 compatibility mode. It is really just intended for the transition period and not meant to be used permanently.

--- bill

Hello Bill

I understand what your saying with the custom config file, what I've done in the AutoConfig_ks0108-128x64_Panel.h is, I changed:

#include "AutoPinConfig_ks0108.h"

to:

/*********************************************************************/
/*                                  Pin Configuration Selector                                                */
/*********************************************************************/

#include "PinConfig_ks0108-Uno.h"       //  Comment this part out if you want to use the default pin 
                                                //     configuration for the board that your using.
//#include "AutoPinConfig_ks0108.h"         //  Uncomment this part if you want to use the default pin
                                                //     configuration for the board that your using.

/**********************************************************************/

for the reason, if you want to quickly modify it to use the default pin configuration with a different board again for when compiling and using anything else. Thanks again for all the assistance. When I start with my next project, I will use the documents provided with the openGLCD library to use the correct commands to plot correctly so that I won't have to use the compatibility mode again.

That works the same as changing from the autoconfig file to the manual config file. To me it seems easier/cleaner to use the manual config file as it only requires modifying the openGLCD_Config.h file and doesn't require modifying any of the autoconfig files. When using the UNO pinout, the provided manual config file can be used so there are no other files that have to be modified.

--- bill

Hello Bill

I will change it accordingly, thank you once again for all the advise.