Go Down

Topic: Problem using openGLCD with 128x64 GLCD (Read 87 times) previous topic - next topic

Mike44449

Apr 03, 2016, 09:09 pm Last Edit: Apr 03, 2016, 09:21 pm by Mike44449 Reason: Update on problem.
Hello. I have a non-touch, monochrome 128x64 GLCD, with a "backpack" on, and the pin-out is as follows, on a Mega 2560:
- SCK is on pin 40
- CS is on pin 41
- SID is on pin 42

I am using openGLCD v1.0rc2 (link: https://bitbucket.org/bperrybap/openglcd/wiki/Home.wiki#!openglcd) and the 'Hello World' example looks nice, but how do I use my GLCD with this library in a meaningful way? How do I initialize the display (the size, the pins, etc.)? I looked around the website for a while and could not find anything useful. Any help is appreciated, Thanks!

UPDATE: I tried uploading the 'print' example from the library files, I got many error messages, so I put them here.

The Code Attempted:
Code: [Select]

/*
 * print - Print class API example
 *
 * Example of using:
 * print()
 * println()
 *
 * print() is not really part of the openGLCD API.
 * It is part of the Arduino Print class.
 * Arduino doesn't have any documentation on the Print class.
 * However, refer to the Serial library for a description of the Print class
 * capabilities.
 * http://www.arduino.cc/en/Serial/Print
 *
 * The print() and println() functions can be used with the default text area or
 * with user defined text areas.
 * i.e.
 * GLCD.print(...);
 * GLCD.println(...);
 * textarea.print(...);
 * textarea.println(...);
 *
 * Examples:
 *    GLCD.print(character);     // print the character at the current cursor position
 *    GLCD.print(integer);       // print the decimal value of the integer
 *    GLCD.print(integer, DEC);  // as above
 *    GLCD.print(integer, HEX);  // print the hexadecimal value of the integer
 *    GLCD.print(integer, OCT) ; // print the octal value of the integer
 *    GLCD.print(integer, BIN) ; // print the binary value of the integer
 *    GLCD.print(float);         // print a floating point number using two decimal places
 *    GLCD.print(float, places); // print a floating point number using 'places' decimal places
 *    GLCD.print(string);        // print the string
 *    GLCD.print("string");      // print the literal string (consumes ram on AVR)
 *    GLCD.print(F("string"));   // print a string from AVR progrem space
 *    textarea.print(integer);   // print the decimal value of the integer in textarea
 *    textarea.print("string");   // print the literal string in textarea
 *
 * Note:
 *     println() works the same as print() but wraps the line after printing.
 *
 * Created by Bill Perry 2013-09-14
 * bperrybap@opensource.billsworld.billandterrie.com
 * 
 */

#include <openGLCD.h>

#define DELAY 3000 // ms delay between examples

/*
 * Create a text area for each of the 4 quadrants
 */
gText textArea[4];

void setup()
{
GLCD.Init();
GLCD.SelectFont(System5x7); // use system in "default" text area
/*
* Create the text area regions in each quadrant and assign font
*/
textArea[0].DefineArea(textAreaTOPLEFT, System5x7);
textArea[1].DefineArea(textAreaTOPRIGHT, System5x7);
textArea[2].DefineArea(textAreaBOTTOMLEFT, System5x7);
textArea[3].DefineArea(textAreaBOTTOMRIGHT, System5x7);
}

void ClearAreas()
{

/*
* Clear all the text areas
*/
for(uint8_t i = 0; i < 4; i++)
{
textArea[i].ClearArea();
}
}


void loop()
{
unsigned long val = 3735928559u; // a really big unsigned long

/*
* Put text in center of display using default text area
*/

GLCD.DrawString(F("print"), gTextfmt_center, gTextfmt_center);
delay(DELAY);
GLCD.ClearScreen();


/*
* Text on left of top line of default text area
*/
GLCD.CursorTo(0,0);
GLCD.print("hello");
delay(DELAY/2);
GLCD.CursorTo(2,1);
GLCD.print(1.25, 4); // print with 4 decimal places

delay(DELAY);

GLCD.ClearScreen();
/*
* Text on left of top line
*/
for(uint8_t i = 0; i < 4; i++)
{
textArea[i].CursorTo(0,0);
textArea[i].print(F("hello"));
delay(400);
}
delay(DELAY/2);

/*
* Text in column 2 of line 1
*/
for(uint8_t i = 0; i < 4; i++)
{
textArea[i].CursorTo(2,1);
textArea[i].print(1.25, 4); // print with 4 decimal places
delay(400);
}
/*
* Wrap text and print something in hex
*/
for(uint8_t i = 0; i < 4; i++)
{
textArea[i].println();
textArea[i].print(val, HEX);
delay(400);
}
delay(DELAY);
ClearAreas();
}


The Error Code Received:
Code: [Select]
Arduino: 1.6.4 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

print.cpp.o: In function `loop':
C:\Program Files (x86)\Arduino/print.pde:98: undefined reference to `Print::print(char const*)'
C:\Program Files (x86)\Arduino/print.pde:101: undefined reference to `Print::print(double, int)'
C:\Program Files (x86)\Arduino/print.pde:112: undefined reference to `Print::print(__FlashStringHelper const*)'
C:\Program Files (x86)\Arduino/print.pde:123: undefined reference to `Print::print(double, int)'
C:\Program Files (x86)\Arduino/print.pde:120: undefined reference to `Print::println()'
C:\Program Files (x86)\Arduino/print.pde:132: undefined reference to `Print::print(unsigned long, int)'
openGLCD\glcd.cpp.o:(.rodata._ZTV4glcd[vtable for glcd]+0x6): undefined reference to `Print::write(unsigned char const*, unsigned int)'
openGLCD\gText.cpp.o:(.rodata._ZTV5gText[vtable for gText]+0x6): undefined reference to `Print::write(unsigned char const*, unsigned int)'
collect2.exe: error: ld returned 1 exit status
Error compiling.

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.
-My name is Michael Pate, but you can call me Mike.

First rule: Thou Shalt Check Voltages!

bperrybap

Several things seem to be going on here.

Documentation:
As far as documentation goes, there is LOTs.
There are two sets of documentation.
- an overview on the repo page
- html documentation that comes with the library.

The repo page indicates this and explains where to locate the library documentation.
The html documentation included with the library has extensive documentation on which types of displays are supported, how to configure the library, how to wire up the pins, how to use fonts & bitmaps, troubleshooting, and additional resources.



Your i2c based glcd:
The library currently does not support i2c based displays.
While it supports a few other types of displays, currently, it is mainly for directly connecting ks0108 displays.


compile errors:
This one I am very interested in as I have not seen any type of issue like this.
I  reproduced it on Windows 7 and XP using IDE vesion 1.6.4
I have built that openGLCD Print class example sketch using the Arduino IDE version 1.6.4 on linux
and did not have any issues.

I do most of my testing on Linux as Windows is so hostile for s/w development.
I build and test all the sketches on linux and then go back and test a few on Windows just to make sure that things still work.
Theoretically what works on Linux should also work on Windows.
However, Windows has so many issues so this is not always the case.
This is an interesting example.

These errors on windows show up on several versions of the IDE and the errors are sometimes different.
In one case loop() and setup() were unresolved.

I spent some time to track this down.
This appears to be a issue in the IDE that only shows up on Windows.
It appears that on Windows the IDE code is getting confused over case issues and name collisions between a user sketch name and a core library file.
In this example, there is a collision between Print and print because of the IDE not properly handling case.
There is a file in in the core library with a basename of Print and this specific sketch has a basename of print.
The IDE code is somehow getting confused over this and attempting to use the print sketch object code rather than the Print core library object code.

I'm guessing this goes back to all the MASSIVE code that they threw into the IDE (rather than use make) attempting to duplicate the functionality of make. Somewhere in all that "smart" code it confuses Print.o with print.o and so it creates problems.

If you rename the directory and sketch file from "print" to something else, the problem goes away.

The more recent IDEs seem to have fixed this issue.
So I think for now, I'll just document it as a known issue.

If you update to 1.6.6 or later it appears to be fixed.

--- bill



Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy