GLK LCD header

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

Post Reply
lololabricole
LCD?
Posts: 3
Joined: Tue Apr 15, 2014 3:47 am

GLK LCD header

Post by lololabricole »

I've been looking for a GLK19264-7T-1U header file command definitions.

As I didn't find what I was looking for, here is mine.
Feel free to use it, and contact me if there's any mistake.

Kind rgards,

Laurent

PS : If anybody feels like writing a library / starting a open project, I'm interested :D

Code: Select all

/*****************************************************//**
    \file         glk.h
    \author       Laurent GROSBOIS <laurent.grosbois@chromlech.fr>
    \copyright      Chromlech - 2014. All right reserved.
                     This file is provided freely and can be redistributed and editted.

    \date         14 avr. 2014
    \brief        Definitions for Matrix Orbital LCD : GLK19264-7T-1U

 \par
 The author is supplying this file with the intend it can be useful to anybody
 needing a library working with matrix orbital LCD.
 If it happens you make significant file for this file, extend the library, or

 \par
 THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
 CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
               
*********************************************************/


#ifndef GLK_H_
#define GLK_H_

/********************************************************
        Includes
*********************************************************/

#include "types.h"


/********************************************************
        Definitions
*********************************************************/

/**
 * I2C Default address
 * 0x28 According to I2C Standard address
 *
 * NB : Matrix Orbital Datasheet address considers 8-bit addresses - taking I2C write/read byte into account.
 * A 0x28 7bits standard I2C address will be described as a (0x28<<1) = 0x50 Address
 */
#define GLK_I2C_ADDR            0x28

/**
 * Escape char for CMD
 */
#define    GLK_CMD_BYTE            0xFE


// ---        Communication commands        ---

#define GLK_COM_BR                            0x39        //Change Baud rate
    #define    GLK_COM_BR_9600                        207            // 9600 kbps
    #define    GLK_COM_BR_14400                    138            // 14400 kbps
    #define    GLK_COM_BR_19200                    103            // 19200 kbps
    #define    GLK_COM_BR_28800                    68            // 28800 kbps
    #define    GLK_COM_BR_38400                    51            // 38400 kbps
    #define    GLK_COM_BR_57600                    34            // 57600 kbps
    #define    GLK_COM_BR_76800                    25            // 76800 kbps
    #define    GLK_COM_BR_115200                    16            // 115200 kbps
#define GLK_COM_I2C_ADDR                    0x33        // Set I2C address
#define    GLK_COM_PROTO                        0xA0        // Transmission protocol select
    #define GLK_COM_PROTO_I2C                    0            // I2C protocol selection
    #define GLK_COM_PROTO_SERIAL                1            // RS232/RS432/USb selection
#define GLK_COM_FLOWC                        0x3F        // Flow Control mode
    #define    GLK_COM_FLOWC_NONE                    0            // No flow control
    #define    GLK_COM_FLOWC_SW                    1            // Software flow control
    #define    GLK_COM_FLOWC_HW                    2            // Hardware flow control
#define GLK_COM_FLOWC_HWTRIG                0x3E        // Hardware flow control trigger level
    #define GLK_COM_FLOWC_HWTRIG_1byte            0            // 1 byte - level 0
    #define GLK_COM_FLOWC_HWTRIG_4bytes            1            // 4 bytes - level 1
    #define GLK_COM_FLOWC_HWTRIG_8bytes            2            // 8 bytes - level 2
    #define GLK_COM_FLOWC_HWTRIG_14bytes        3            // 14 bytes - level 3
#define GLK_COM_FLOWC_SW_ON                    0x3A        // Software flow control on
#define GLK_COM_FLOWC_SW_OFF                0x3B        // Software flow control off
#define GLK_COM_FLOWC_RESP                    0x3C        // Software flow control response
#define GLK_COM_ECHO                        0xFF        // Echo
#define    GLK_COM_DELAY                        0xFB        // Delay
#define    GLK_COM_RST0                        0xFD        // RST byte 0
#define    GLK_COM_RST1                        0x4D        // RST byte 1
#define    GLK_COM_RST2                        0x4F        // RST byte 2
#define    GLK_COM_RST3                        0x75        // RST byte 3
#define    GLK_COM_RST4                        0x6E        // RST byte 4


// ---        Text commands        ---

#define GLK_TXT_CLS                            0x58        // Clear screen
#define GLK_TXT_GO_HOME                        0x48        // Set cursor to top left of screen
#define GLK_TXT_CURS_POS                    0x47        // Set cursor position
#define GLK_TXT_CURS_COORD                    0x79        // Set cursor coordinates
#define GLK_TXT_WINIT                        0x2B        // Init text window
#define GLK_TXT_WSELECT                        0x2A        // Select text window
#define GLK_TXT_WCLS                        0x2C        // Clear txt window
#define GLK_TXT_LINIT                        0x2D        // Init Label
#define GLK_TXT_LUPDATE                        0x2E        // Update label with new text
#define GLK_TXT_AUTO_SCROLL_ON                0x51        // Auto scroll on
#define GLK_TXT_AUTO_SCROLL_OFF                0x52        // Auto scroll off


// ---        Drawing  commands        ---

#define GLK_DRAW_COLOR                        0x63        // Select drawing color
#define GLK_DRAW_PIX                        0x70        // Draw single pixel
#define GLK_DRAW_LINE                        0x6C        // Draw line
#define GLK_DRAW_LINE_CONT                    0x65        // Draw continue line
#define GLK_DRAW_RECT                        0x72        // Draw rectangle
#define GLK_DRAW_FRECT                        0x78        // Draw filled rectangle
#define GLK_DRAW_RRECT                        0x80        // Draw Rounded rectangle
#define GLK_DRAW_FRRECT                        0x81        // Draw filled rounded rectangle
#define GLK_DRAW_CIRCLE                        0x7B        // Draw circle
#define GLK_DRAW_FCIRCLE                    0x7C        // Draw filled circle
#define GLK_DRAW_ELLIPSE                    0x7D        // Draw Ellipse
#define GLK_DRAW_FELLIPSE                    0x7F        // Draw filled ellipse
#define GLK_DRAW_SCROLL_SCREEN                0x59        // Scroll screen
#define GLK_DRAW_BGRAPH_INIT                0x67        // Init bar graph
#define GLK_DRAW_9SLICE_BGRAPH_INIT            0x73        // Init 9-slice bar graph
#define GLK_DRAW_BGRAPH                        0x69        // Draw bar graph
#define GLK_DRAW_STRIPCHART_INIT            0x6E        // Strip Chart init
#define GLK_DRAW_STRIPCHART_UPDATE            0x6F        // Strip Chart update
#define GLK_DRAW_UPLOAD_FONT                0x24        // Upload a font file
#define GLK_DRAW_SET_FONT                    0x31        // Set current font
#define GLK_DRAW_SET_FONT_METRICS            0x32        // Set font metrics
#define GLK_DRAW_BOXSPACE                    0xAC        // Set toggle box space mode

// todo : font file struct


// ---        Bitmaps  commands        ---

#define GLK_BITMAP_UPLOAD_FILE                0x5E        // Upload bitmap file
#define GLK_BITMAP_UPLOAD_MASK0                0x5C        // Upload bitmap mask (byte 0)
#define GLK_BITMAP_UPLOAD_MASK1                0x05        // Upload bitmap mask (byte 1)
#define GLK_BITMAP_DRAW_FROM_MEM            0x62        // Draw bitmap from memory
#define GLK_BITMAP_DRAW_DIRECT                0x64        // Draw bitmap on the go

// todo : bitmap file structure


// ---        9-slice  commands        ---

#define GLK_9SLICE_UPLOAD_FILE0                0x5c        // Upload 9-slice file (byte 0)
#define GLK_9SLICE_UPLOAD_FILE1                0x03        // Upload 9-slice file (byte 1)
#define GLK_9SLICE_UPLOAD_MASK0                0x5c        // Upload 9-slice mask (byte 0)
#define GLK_9SLICE_UPLOAD_MASK1                0x06        // Upload 9-slice mask (byte 1)
#define GLK_9SLICE_DRAW                        0x5B        // Draw 9-slice


// ---        Animation  commands        ---

#define GLK_ANIM_UPLOAD0                    0x5C        // Upload animation file (byte 0)
#define GLK_ANIM_UPLOAD1                    0x5C        // Upload animation file (byte 0)
#define GLK_ANIM_DISPLAY                    0xC1        // Display animation
#define GLK_ANIM_DELETE                        0xC7        // Delete animation
#define GLK_ANIM_START_STOP                    0xC2        // Start/Stop animation
#define GLK_ANIM_SET                        0xC5        // Set animation frame
#define GLK_ANIM_GET                        0xC4        // Get animation frame


// ---        General Purpose output  commands        ---

#define GLK_GPO_ON                            0x56        // General Purpose Output On
#define GLK_GPO_OFF                            0x57        // General Purpose Output Off
#define GLK_GPO_SET_STARTUP                    0xC3        // Set Start Up GPO State
#define GLK_GPO_SET_LED                        0x5A        // Set LED Indicators


// ---        One wire commands  commands        ---

#define GLK_1WIRE                            0xC8        // 1 wire command byte
#define GLK_1WIRE_SEARCH                    0x02        // Search for a One-Wire Device
#define GLK_1WIRE_TRANSACT                    0x01        // Dallas One-Wire Transaction


// ---        Piezo buzzer  commands        ---

#define GLK_BUZZ_ON                            0xBB        // Activate Piezo Buzzer
#define GLK_BUZZ_BEEP                        0xBC        // Set Default Buzzer Beep
#define GLK_BUZZ_KEY                        0xB6        // Set Keypad Buzzer Beep


// ---        Key  commands        ---

#define GLK_KEY_AUTOTX_ON                    0x41        // Auto Transmit Key Presses On
#define GLK_KEY_AUTOTX_OFF                    0x47        // Auto Transmit Key Presses Off
#define GLK_KEY_POLL                        0x26        // Poll Key Press
#define GLK_KEY_CLEARBUF                    0x45        // Clear Key Buffer
#define GLK_KEY_DEBOUNCE_TIME                0x55        // Set Debounce Time
#define GLK_KEY_REPEAT_OFF                    0x60        // Auto Repeat Mode Off
#define GLK_KEY_ASSIGN_CODES                0xD5        // Assign Keypad Codes
#define GLK_KEY_BACKLIGHT_OFF                0x98        // Keypad Backlight Off
#define GLK_KEY_BRIGHTNESS                    0x9C        // Set Keypad Brightness
#define GLK_KEY_AUTO_BACKLIGHT                0x9D        // Set Auto Backlight
#define GLK_KEY_TYPEMATIC_DELAY                0x9F        // Set Typematic Delay
#define GLK_KEY_TYPEMATIC_INTERVAL            0x9E        // Set Typematic Interval


// ---        Display  commands        ---

#define GLK_DISP_BACKLIGHT_ON                0x42        // Backlight On
#define GLK_DISP_BACKLIGHT_OFF                0x46        // Backlight Off
#define GLK_DISP_SET_BRIGHTNESS                0x99        // Set Brightness
#define GLK_DISP_SETSAVE_BRIGHTNESS            0x98        // Set and Save Brightness
#define GLK_DISP_SET_CONTRAST                0x50        // Set Contrast
#define GLK_DISP_SETSAVE_CONTRAST            0x91        // Set and Save Contrast


// ---        Script  commands        ---

#define GLK_SCRIPT_UPLOAD0                    0x5C        // Upload a Script File (byte 0)
#define GLK_SCRIPT_UPLOAD1                    0x02        // Upload a Script File (byte 1)
#define GLK_SCRIPT_SET                        0x8D        // Set Scripted Key
#define GLK_SCRIPT_RUN                        0x5D        // Run Script File


// ---        Filesystem  commands        ---

#define GLK_FSYS_ERASE_ALL0                    0x21        // Delete Filesystem (byte 0)
#define GLK_FSYS_ERASE_ALL1                    0x59        // Delete Filesystem (byte 1)
#define GLK_FSYS_ERASE_ALL2                    0x21        // Delete Filesystem (byte 2)
#define GLK_FSYS_DEL                        0xAD        // Delete a File
#define GLK_FSYS_SPACE                        0xAF        // Get Filesystem Space
#define GLK_FSYS_DIR                        0xB3        // Get Filesystem Directory
#define GLK_FSYS_UPLOAD                        0xB0        // Filesystem Upload
#define GLK_FSYS_DWL_ALL                    0x30        // Filesystem Download
#define GLK_FSYS_DWL                        0xB2        // File Download
#define GLK_FSYS_MOVE                        0xB4        // File Move
#define GLK_FSYS_XMODEM_UPLOAD_ALL            0xDB        // XModem Filesystem Upload
#define GLK_FSYS_XMODEM_DWL_ALL                0xDE        // XModem Filesystem Download
#define GLK_FSYS_XMODEM_UPLOAD                0xDC        // XModem File Upload
#define GLK_FSYS_XMODEM_DWL                    0xDD        // XModem File Download
#define GLK_FSYS_XMODEM1                    0x85        // XModem cmd (byte 1) (byte 0 is xmodem command)
#define GLK_FSYS_XMODEM2                    0x06        // XModem cmd (byte 2)
#define GLK_FSYS_XMODEM3                    0x30        // XModem cmd (byte 3)


// ---        Data security  commands        ---

#define GLK_SET_REMEMBER                    0x147        // Set Remember
#define GLK_SET_DATALOCK                    0x202        // Set Data Lock
#define GLK_SETSAVEDATALOCK                    0x203        // Set and Save Data Lock
#define GLK_SET_DATALOCK1                    0x245        // Data lock byte 1 (byte 0 is set or set&save)
#define GLK_SET_DATALOCK2                    0x160        // Data lock byte 2


// ---        Misc  commands        ---

#define GLK_MISC_WDATA                        0x34        // Write Customer Data
#define GLK_MISC_RDATA                        0x35        // Read Customer Data
#define GLK_MISC_WSCRPAD                    0xCC        // Write to Scratchpad
#define GLK_MISC_RSCRPAD                    0xCD        // Read from Scratchpad
#define GLK_MISC_VERSION                    0x36        // Read Version Number
#define GLK_MISC_MODULETYPE                    0x37        // Read Module Type
#define GLK_MISC_SCREEN                        0xB8        // Read Screen




/********************************************************
        Fonctions
*********************************************************/

void glk_init( void );
int  glk_open( void );
int  glk_close( void );

#endif /* GLK_H_ */


 
Laurent GROSBOIS
CHROMLECH - Development Engineer

Tino
Matrix Orbital
Matrix Orbital
Posts: 158
Joined: Wed May 22, 2013 9:04 am
Location: Matrix Orbital

Re: GLK LCD header

Post by Tino »

Hi Laurent,

Thank you for posting on our Forums.

The Header File looks good!

Thanks again
Martino
Martino DeLeon
Matrix Orbital
Technical Support Representative

lololabricole
LCD?
Posts: 3
Joined: Tue Apr 15, 2014 3:47 am

Re: GLK LCD header

Post by lololabricole »

You're welcome.

There are some mistakes in this file, I will post my whole library as soon as I've tested it extensively.
Maybe Matrix orbital could consider opening a ghithub open project to allow a community to grow around your products and provide free and open sources libraries.

In the meantime, I'd like to pin out that the GLK19264-7T-1U does not work properly in I2C with 10K pullup resistors.
I'm now using 2K resistors and it seems to be allright.

Another question : the following page indicates that fonts and bitmap might not work through I2C.
Has anyone tested it - is it working fine ?
The document concerned the PCB revision 1.0. Is it OK on revision 2.0 ?
Q: Can I upload fonts or bitmaps over I2C?
A: Theoretically, fonts and bitmaps can be uploaded over I2C but this is something that is not tested. The easiest way to perform font or bitmap upload is via the software mogd# (in RS32 mode).

source : http://www.matrixorbital.ca/appnotes/i2c/i2c_general
By the way, I don't find acceptable to sell a product and openly say that the fonctionality has not been tested, but this is only my opinion...
I need my board to upload the fonts and bitmaps by itself at the first startup, requiring an operator to configure the LCD using mogd# is not an acceptable industrial solution and my design has no more uart available.


Thank you in advance for your answer.
Laurent GROSBOIS
CHROMLECH - Development Engineer

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: GLK LCD header

Post by Clark »

Hello Laurent,

I think I've found a suitable home for that file within our existing Matrix Orbital GitHub profile here: https://github.com/MatrixOrbital/MatrixOrbitalCProject/blob/master/Libraries/glk.h.

I've actually had some code up at GitHub for a couple years now, but have had little feedback. We're always open to finding new ways of interfacing with our customers and the display community in general so if there is anything we can do to make your life as a developer easier, please don't hesitate to ask.

With regard to I2C, I have a little more info for you:
  • Pullups: The I2C standard is between 1K and 10K ohms, I agree that a value around 2K works best for me as well.
  • Uploads: Are difficult in I2C, but I have confirmed this afternoon that they are definitely possible with PCB Rev2.0, following the Filesystem AppNote .
  • Testing: Uploads are the same in I2C as they are in RS232, so they should absolutely work. The reason the work theoretical was used is that the upload handshaking is very taxing on the I2C protocol, so implementation is not easy.
I'll upload my code once I have tested further, if you have any questions before then, please feel free to post.

Cheers,
Troy
Troy Clark
Design & Development
Matrix Orbital

lololabricole
LCD?
Posts: 3
Joined: Tue Apr 15, 2014 3:47 am

Re: GLK LCD header

Post by lololabricole »

Thank you for your answer. I'll post the corrected .h and my whole library as soon as I'm sure the functionalities I need are ok.

As you suggested, I'm trying to upload the smiley example from the datasheed instead of my whole bitmap.

I'm first reading the module type, which is properly returned :
me : 0xFE, 0x37
glk : 0x2A

I'm then initiating a bitmap file transfer, ad id = 1 and file size of 5 bytes :
me : 0xFE, 0x5E, 0x01, 0x00, 0x05, 0x00, 0x00, 0x00
glk : 0x00 - which is neither an ACK (0x01) or a nack (0x08) but looks like a no key event answer (0x00) ??

Am I doing something wrong ? Yet the bytes seem to be properly be in little endian...

Here is the I2C transaction sniff from my logic analyzer :

Code: Select all

Time [s],Packet ID,Address,Data,Read/Write,ACK/NAK
1.403109000000000,0,0x50,0xFE,Write,ACK
1.403201000000000,0,0x50,0x37,Write,ACK
1.403867000000000,1,0x51,0x2A,Read,NAK
1.405632000000000,2,0x50,0xFE,Write,ACK
1.405724500000000,2,0x50,0x5E,Write,ACK
1.405816500000000,2,0x50,0x01,Write,ACK
1.405909000000000,2,0x50,0x00,Write,ACK
1.406001500000000,2,0x50,0x05,Write,ACK
1.406093500000000,2,0x50,0x00,Write,ACK
1.406186000000000,2,0x50,0x00,Write,ACK
1.406278500000000,2,0x50,0x00,Write,ACK
1.406944500000000,,0x51,0x00,Read,NAK
If you want to have a look at my timings, I've attacced three screen captures :
- the whole transaction
- the module read
- the bitmap file transfer init

Please note I've already set the protocol answer to I2C mode as I'm properly reading the module type.

I've a delay of around 1.5ms between the two transactions and 476µs between the last read ACK and the beginning of the read start condition associated to the command.

Thank you for your answer and the time you're spending on my issue.
Attachments
Bitmap upload init sequence
Bitmap upload init sequence
glk_init_bmp.png (146.65 KiB) Viewed 4864 times
Module read command
Module read command
glk_init_module_read.png (140.52 KiB) Viewed 4864 times
Whole transaction sequence
Whole transaction sequence
glk_init_whole.png (177.9 KiB) Viewed 4864 times
Laurent GROSBOIS
CHROMLECH - Development Engineer

Clark
Matrix Orbital
Matrix Orbital
Posts: 881
Joined: Fri Aug 17, 2007 10:58 am
Location: Matrix Orbital
Contact:

Re: GLK LCD header

Post by Clark »

Hello Laurent,

I've finished tweaking what simple code I have and uploaded to both our .ca support site and GitHub C project page. I've included your library which came in handy, thanks again.
The biggest issues I had were in timing, which is why you'll see rather large delays of 10ms between each individual byte write and 50ms after each write transaction. I found without these delays I was either reading when there was no data available (0x00), or reading what I had just written (0xFE, 0x05, 0x01, etc). These delays will be different for every controller, typically you'll start with large values and reduce them to the point where communication is just on the comfortable side.

Your implementation appears correct; bytes are transmitted little endian style and the logic analyzer output looks good. Please try delays using the Arduino code as a reference and let me know if you have any further trouble.

Cheers,
Troy
Troy Clark
Design & Development
Matrix Orbital

Post Reply