Jump to content

[solved] How can I print custom characters on GLCD?


nsunier
 Share

Recommended Posts

Hi,

I'm using a KS0107/KS0108 compatible GLCD with success. I use the following functions:

  • MIOS_LCD_Clear();
  • MIOS_GLCD_GCursorSet(...,...);
  • MIOS_LCD_PrintCString("...");


    But now, I want to define new characters (with custom sizes). I've fund the following functions:

    • MIOS_GLCD_FontInit();
    • MIOS_LCD_PrintChar();


      I've copied the "
    ..\MIOS 1.9\source code\src\mios_glcd_font.xpm" into a subdirectory of my project. I haven't modified anything in this file and executed the "perl convpix.pl -c mios_glcd_font.xpm" script. Then I've modified the "mios_glcd_font.h" file in order to have the same structure as the original one:

    statis code char * charset = {...,..., ... ,...};

    In "main.c", I've included the .h file and written MIOS_GLCD_FontInit(charset);

    Then: MIOS_LCD_PrintChar(0x00); -> it prints a complete 6-pixel column with random pixels. Why?

    I haven't fund many informations, examples nor tutorials about GLCD.  :-\

    Any help is welcome.

    Thanks!

    nsunier
Link to comment
Share on other sites

Yes - since some days there are also C usage examples for GLCDs! :)

Unfortunately they are based on the new project structure, which isn't documented yet. Basically, you would use a "MIOS base" package, which includes the drivers, include files, and even some graphical fonts - and your application itself would only contain a small set of files anymore.

So, here is the C example: http://svnmios.midibox.org/trunk/apps/examples/lcd7/ks0108/c/

And here the graphic font package: http://svnmios.midibox.org/trunk/modules/glcd_font/

You won't be able to compile the code with the old approach that is currently documented on my website.

Therefore I created a temporal package for you, which should give you a good starting point (instead of the global "mios base" structure, it uses a local file structure)

-> http://www.ucapps.de/tmp/ks0108_c_example.zip

In addition, you need to install the "posix_bin" directory as described here

Best Regards, Thorsten.

Link to comment
Share on other sites

  • 2 weeks later...

I've included all subfolders of "ks0108_c_example.zip" in my project and included the "glcd_font.h" header. When I do a make, I get this error message:

error: missing definition for symbol "_GLCD_FONT_KNOB_ICONS", required by "_output\main.o"

error: missing definition for symbol "_GLCD_FONT_BIG", required by "_output\main.o"

ERROR!

Any idea?

Best regards,

nsunier

Link to comment
Share on other sites

Makefile generated.

Makefile.bat generated.

Assembling MIOS SDCC wrapper

==========================================================================

Compiling pic18f452.c

Processor: 18F452

==========================================================================

Compiling main.c

Processor: 18F452

==========================================================================

Linking project

error: missing definition for symbol "_GLCD_FONT_KNOB_ICONS", required by "_output\main.o"

error: missing definition for symbol "_GLCD_FONT_BIG", required by "_output\main.o"

ERROR!

Link to comment
Share on other sites

Ok, you tried to build the application based on the old approach, but this doesn't work anymore as stated above.

You won't be able to compile the code with the old approach that is currently documented on my website.

Therefore I created a temporal package for you, which should give you a good starting point (instead of the global "mios base" structure, it uses a local file structure)

...

In addition, you need to install the "posix_bin" directory as described here

The make.bat file, the makefile generator + all the other tools which were used in older projects are obsolete - just start with the project setup in http://www.ucapps.de/tmp/ks0108_c_example.zip

Best Regards, Thorsten.

Link to comment
Share on other sites

I've tried first to compile only "ks0108_c_example". An error message told me that "MIOS_BIN_PATH" variable was not set. So I create it in User Variables. The error message disappeared and I got this output message:

rm -rf _output/*

rm -rf _output

rm -rf *.cod *.map *.lst

rm -rf *.hex

mkdir -p _output

sh ./bin/mios-sdcc -c -mpic16 -p18f452 --fommit-frame-pointer --optimize-goto --optimize-cmp --disab

le-warning 85 --obanksel=2 -pleave-reset-vector  -I./src -I ./include/c -I ./modules/glcd_font -DDEB

UG_MODE=0  modules/libdev/pic18f452.c -o _output/pic18f452.o

Processor: 18f452

./bin/mios-gpasm modifies _output/pic18f452.asm, result in _output/pic18f452__mios-gpasm-tmp.asm

sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/

glcd_font -DDEBUG_MODE=0  -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f -I ./modules/mios_wrapper module

s/mios_wrapper/mios_wrapper.asm  -o _output/mios_wrapper.o

sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/

glcd_font -DDEBUG_MODE=0  modules/app_lcd/ks0108/app_lcd.asm -o _output/app_lcd.o

sh ./bin/mios-sdcc -c -mpic16 -p18f452 --fommit-frame-pointer --optimize-goto --optimize-cmp --disab

le-warning 85 --obanksel=2 -pleave-reset-vector  -I./src -I ./include/c -I ./modules/glcd_font -DDEB

UG_MODE=0  main.c -o _output/main.o

Processor: 18f452

./bin/mios-gpasm modifies _output/main.asm, result in _output/main__mios-gpasm-tmp.asm

sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/

glcd_font -DDEBUG_MODE=0  modules/glcd_font/glcd_font_big.asm -o _output/glcd_font_big.o

sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/

glcd_font -DDEBUG_MODE=0  modules/glcd_font/glcd_font_knob_icons.asm -o _output/glcd_font_knob_icon

s.o

gplink -s ./etc/lkr/p18f452.lkr -m -o project.hex _output/pic18f452.o _output/mios_wrapper.o _output

/app_lcd.o _output/main.o _output/glcd_font_big.o _output/glcd_font_knob_icons.o

Do you think it's OK? Can I integrate my code?

Best regards,

nsunier

Link to comment
Share on other sites

An error message told me that "MIOS_BIN_PATH" variable was not set.

That's very strange... You can clearly see in makefile. where that variable is set.

MIOS_PATH = .
MIOS_BIN_PATH = ./bin
include Makefile.orig
Just to be sure I wasn't being code smart and real world dumb, I tried it... And was reminded of all the 231 errors which I didn't notice in your build - they're cosmetic (ugly but not a problem) but they should be there... I think...

C:\Temp\ks0108_c_example\ks0108_c_example>make
rm -rf _output/*
rm -rf _output
rm -rf *.cod *.map *.lst
rm -rf *.hex
mkdir -p _output
sh ./bin/mios-sdcc -c -mpic16 -p18f452 --fommit-frame-pointer --optimize-goto --optimize-cmp --disable-warning 85 --obanksel=2 -pleave-reset-vector  -I./src -I ./include/c -I ./modules/glcd_font -DDEBUG_MODE=0  modules/libdev/pic18f452.c -o
 _output/pic18f452.o
./bin/mios-gpasm modifies _output/pic18f452.asm, result in _output/pic18f452__mios-gpasm-tmp.asm
_output/pic18f452__mios-gpasm-tmp.asm:164:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:167:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:170:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:173:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:176:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:182:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:185:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:188:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:191:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:194:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:200:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:203:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:206:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:209:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:212:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:218:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:221:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:224:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:227:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:230:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:233:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:239:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:248:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:251:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:260:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:268:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:273:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:281:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:284:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:289:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:292:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:295:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:300:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:305:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:310:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:313:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:316:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:319:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:325:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:330:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:356:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:359:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:362:Warning [231] No memory has been reserved by this instruction.
_output/pic18f452__mios-gpasm-tmp.asm:374:Warning [231] No memory has been reserved by this instruction.
sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/glcd_font -DDEBUG_MODE=0  -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f -I ./modules/mios_wrapper modules/mios_wrapper/mios_wrapper.asm  -o _out
put/mios_wrapper.o
sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/glcd_font -DDEBUG_MODE=0   modules/app_lcd/ks0108/app_lcd.asm -o _output/app_lcd.o
sh ./bin/mios-sdcc -c -mpic16 -p18f452 --fommit-frame-pointer --optimize-goto --optimize-cmp --disable-warning 85 --obanksel=2 -pleave-reset-vector  -I./src -I ./include/c -I ./modules/glcd_font -DDEBUG_MODE=0  main.c -o _output/main.o
./bin/mios-gpasm modifies _output/main.asm, result in _output/main__mios-gpasm-tmp.asm
sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/glcd_font -DDEBUG_MODE=0   modules/glcd_font/glcd_font_big.asm -o _output/glcd_font_big.o
sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/glcd_font -DDEBUG_MODE=0   modules/glcd_font/glcd_font_knob_icons.asm -o _output/glcd_font_knob_icons.o
gplink -s ./etc/lkr/p18f452.lkr -m -o project.hex _output/pic18f452.o _output/mios_wrapper.o _output/app_lcd.o _output/main.o _output/glcd_font_big.o _output/glcd_font_knob_icons.o

C:\Temp\ks0108_c_example\ks0108_c_example>

Anyway you'll notice that when it works, there are no errors (OK let's ignore the 231 warnings) - So yours is good :)

Link to comment
Share on other sites

  • 3 weeks later...

I'm currently testing the GLCD functions.

It works quite well for the GLCD_FONT, GLCD_FONT_BIG, GLCD_FONT_KNOB_ICONS fonts.

But I'm not able to use the GLCD_FONT_SMALL, GLCD_FONT_METER_ICONS_H and GLCD_FONT_METER_ICONS_V ones?! I got this error message when I do a make:

rm -rf _output/*
rm -rf _output
rm -rf *.cod *.map *.lst
rm -rf *.hex
mkdir -p _output
sh ./bin/mios-sdcc -c -mpic16 -p18f452 --fommit-frame-pointer --optimize-goto --optimize-cmp --disab
le-warning 85 --obanksel=2 -pleave-reset-vector  -I./src -I ./include/c -I ./modules/glcd_font -DDEB
UG_MODE=0  modules/libdev/pic18f452.c -o _output/pic18f452.o
Processor: 18f452
./bin/mios-gpasm modifies _output/pic18f452.asm, result in _output/pic18f452__mios-gpasm-tmp.asm
sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/
glcd_font -DDEBUG_MODE=0  -DSTACK_HEAD=0x37f -DSTACK_IRQ_HEAD=0x33f -I ./modules/mios_wrapper module
s/mios_wrapper/mios_wrapper.asm  -o _output/mios_wrapper.o
sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/
glcd_font -DDEBUG_MODE=0   modules/app_lcd/ks0108/app_lcd.asm -o _output/app_lcd.o
sh ./bin/mios-sdcc -c -mpic16 -p18f452 --fommit-frame-pointer --optimize-goto --optimize-cmp --disab
le-warning 85 --obanksel=2 -pleave-reset-vector  -I./src -I ./include/c -I ./modules/glcd_font -DDEB
UG_MODE=0  main.c -o _output/main.o
Processor: 18f452
./bin/mios-gpasm modifies _output/main.asm, result in _output/main__mios-gpasm-tmp.asm
sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/
glcd_font -DDEBUG_MODE=0   modules/glcd_font/glcd_font_big.asm -o _output/glcd_font_big.o
sh ./bin/mios-gpasm -c -p p18f452 -I./src -I ./include/asm -I ./modules/app_lcd/ks0108 -I ./modules/
glcd_font -DDEBUG_MODE=0   modules/glcd_font/glcd_font_knob_icons.asm -o _output/glcd_font_knob_icon
s.o
gplink -s ./etc/lkr/p18f452.lkr -m -o project.hex _output/pic18f452.o _output/mios_wrapper.o _output
/app_lcd.o _output/main.o _output/glcd_font_big.o _output/glcd_font_knob_icons.o
error: missing definition for symbol "_GLCD_FONT_METER_ICONS_V", required by "_output/main.o"
make: *** [project.hex] Error 1
These fonts are defined in the ...\modules\glcd_font\glcd_font.h:
// $Id: glcd_font.h 69 2008-02-01 00:20:18Z tk $
/*
 * Header File for GLCD Fonts
 *
 * ==========================================================================
 */

#ifndef _GLCD_FONT_H
#define _GLCD_FONT_H

/////////////////////////////////////////////////////////////////////////////
// Defines array pointers to all available fonts
//
// (hope that SDCC ignores predefined constants which are not
// compiled into the project)
//
// Pointers are defined as 4-byte arrays. Actually, this is only the font
// header, the bitmap data follows after the header, but is not counted
// here (not required)
/////////////////////////////////////////////////////////////////////////////

extern code char GLCD_FONT_BIG[4];
extern code char GLCD_FONT_SMALL[4];
extern code char GLCD_FONT_KNOB_ICONS[4];
extern code char GLCD_FONT_METER_ICONS_H[4];
extern code char GLCD_FONT_METER_ICONS_V[4];

#endif /* _GLCD_FONT_H */

What should I modify?

Best regards,

nsunier

Link to comment
Share on other sites

In this new structure, I can't find main.h

I was using it to define these parameters

/////////////////////////////////////////////////////////////////////////////
// Global definitions
/////////////////////////////////////////////////////////////////////////////

#define AIN_NUMBER_INPUTS     53    // number of used analog inputs (0..64)
#define AIN_MUXED_MODE         1    // set this to 1 if AIN modules are used
#define AIN_DEADBAND           7    // define deadband here (higher values reduce the effective resolution but reduce jitter)
                                    // 7 is ideal for value range 0..127 (CC events)

#define NUMBER_OF_SRIO        12    // how many shift registers chained at the DIN/DOUT port (min 1, max 16)

#define DIN_DEBOUNCE_VALUE    10    // 0..255
#define DIN_TS_SENSITIVITY     0    // optional touch sensor sensitivity: 0..255
and
/////////////////////////////////////////////////////////////////////////////
// Global Types
/////////////////////////////////////////////////////////////////////////////

// status of analog toolbox application
typedef union {
  struct {
    unsigned ALL:8;
  };
  struct {
    unsigned DISPLAY_UPDATE_REQ:1;  // requests a display update
  };
} app_flags_t;


/////////////////////////////////////////////////////////////////////////////
// Export global variables
/////////////////////////////////////////////////////////////////////////////
extern app_flags_t app_flags;

#endif /* _MAIN_H */

How can I do the same thing in the new structure?

Link to comment
Share on other sites

Oups! Sorry I read too quicky this readme file. Now it works!

But there is still a question about this readme. There is written "1) Makefile: add "glcd_font_big.o" to OBJS variable". What are .o files?

Thank you very much for your help! :)

Link to comment
Share on other sites

.o files are object files, they are the output that GPASM creates. GPLink straps them all together and makes your hex file.

With MIOS/GPUtils, we just specify the .o filename, and it will be created from the .c file by the same name.

Enjoy :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...