Author Topic: Large Characters - Solved  (Read 2417 times)

TFcroft4

  • Full Member
  • ***
  • Posts: 14
    • View Profile
Large Characters - Solved
« on: May 14, 2012, 01:27:56 PM »
I am struggling to get large Characters to display.

The manual says
Command: 0x8F, “String”
Before using this command, the “Large 3x2 Number Character Set” has to be loaded with the “Load Custom Character Set“
command.
For example, to write “12:55:04” in the top 3 lines of the display, the following command can be sent to the LCD2S:
“\f1\t2:5\t5:0\t4”

This is my code snippet - the data is char from a time struture.
Code: [Select]
//

lcdPutCmd(0x8E, 3) ;// large font use space between chars

//
bigcharbuf[0] = 0x8f; // command
bigcharbuf[1] = 0x0c; // \f
                        bigcharbuf[2] = clock_time.tm_hour/10 +48;
                        bigcharbuf[3] = 0x09; // \t
bigcharbuf[4] = clock_time.tm_hour%10 +48;
bigcharbuf[5] = ':';
bigcharbuf[6] = clock_time.tm_min/10 +48;
bigcharbuf[7] = 0x09; // \t
bigcharbuf[8] = clock_time.tm_min%10 +48;
bigcharbuf[9] = ':';
bigcharbuf[10]= clock_time.tm_sec/10 +48;
bigcharbuf[11]= 0x09; // \t
bigcharbuf[12]= clock_time.tm_sec%10 +48;
bigcharbuf[13]= 0x00;
lcdPutString(bigcharbuf);

The out put is at the top of the screen in the form   1 2:3 4:5 6 in single size characters.

Does the font need to be loaded once or each time used?
Any advice or a sample would be welcomed.

TF
« Last Edit: May 16, 2012, 03:10:28 AM by TFcroft4 »

TFcroft4

  • Full Member
  • ***
  • Posts: 14
    • View Profile
Re: Large Characters
« Reply #1 on: May 16, 2012, 03:09:40 AM »
OK

Managed to solve this - I had to send a series of bytes using lcdPutArray - not a parsed string using lcdPutString.

here is a code snippet:

Code: [Select]
// code to load array with bytes
bigcharbuf[0] = 0x8f; // command
bigcharbuf[1] = 0x0c; // \f
bigcharbuf[2] = clock_time.tm_hour/10 +48;
bigcharbuf[3] = 0x09; // \t
bigcharbuf[4] = clock_time.tm_hour%10 +48;
bigcharbuf[5] = ':';
bigcharbuf[6] = clock_time.tm_min/10 +48;
bigcharbuf[7] = 0x09; // \t
bigcharbuf[8] = clock_time.tm_min%10 +48;
bigcharbuf[9] = ':';
bigcharbuf[10]= clock_time.tm_sec/10 +48;
bigcharbuf[11]= 0x09; // \t
bigcharbuf[12]= clock_time.tm_sec%10 +48;
bigcharbuf[13]= 0x00;
lcdPutArray( bigcharbuf, 13);

// function to Writes given number of characters from given buffer to the LCD Display.

char lcdPutArray( char* s, char len) {
    char i;
    char ret = 0;
    if (len == 0) return 0;   
    i2cWaitForIdle();
    i2cPutStartAndWait();       //Write I2C Start Condition, and wait for it to complete
    //Write module address
    i2cPutByteAndWait(LCD_I2C_WRITE_ADDR);
    //Only continue if slave sent ACK. If no slave present, no ACK is sent. If no slave with address sent is present, no ACK is sent.
    if(i2cWasAckReceived()) {
        //Write array
        for (i=0; i<len; i++) {
            //Write next byte to LCD display
            i2cPutByteAndWait(*s++);
            if(i2cWasAckReceived() == 0) {
                ret = 1;    //Error
                break; //Break if slave does not sent ACK
            }
        }
    }
    else {
        ret = 1;    //Error
    }
    i2cPutStopAndWait();    //Write I2C Stop condition, and wait for it to complete   
    return ret;
}