CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

custom character number 8 not display on lcd

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
armma



Joined: 30 Apr 2016
Posts: 7

View user's profile Send private message

custom character number 8 not display on lcd
PostPosted: Sun Sep 02, 2018 4:34 am     Reply with quote

Hi,

I'm trying to display custom characters on 2 by 16 lcd.

I wrote a code to display 8 custom characters. All characters displayed on the lcd except char #8.
Code:

#include <18f4520.h>

#device *= 16
                                                                     
#fuses NOWDT, HS, PROTECT, CPD, NOWRT, BROWNOUT, NODEBUG, NOLVP, PUT
                       
#use delay (clock = 4MHz)           

#include "lcd.c"             


#define DEGREES     0
#define THERMO1     1
#define THERMO2     2
#define BELL_ACTIVE 3
#define MENU_R      4
#define MENU_L      5
#define CANCEL      6
#define OK          7

                                                           
//!                                                                     
void lcd_load_custom_chars(void);

void main()           
{       
         lcd_init();
         DELAY_MS(500);
         lcd_load_custom_chars();
         lcd_putc('\f');lcd_putc(DEGREES);lcd_putc(THERMO1); lcd_putc(THERMO2); lcd_putc(BELL_ACTIVE);lcd_putc(CANCEL);lcd_putc(OK);LCD_GOTOXY(1,2);lcd_putc(MENU_L);LCD_GOTOXY(16,2);lcd_putc(MENU_R);             
         while(TRUE)                                 
         {                                   
                 
                 
         }                               
}



 


const int8 lcd_custom_chars[] =
{
// Char Number 1 -- Degrees
0b00001100,  // ....OO..
0b00010010,  // ...O..O.
0b00010010,  // ...O..O.
0b00001100,  // ....OO..
0b00000000,  // ........
0b00000000,  // ........
0b00000000,  // ........
0b00000000,  // ........ 

// Char Number 2 -- thermo1
   0B00100,
        0B01010,
        0B01010,
        0B01110,
        0B01110,
        0B11111,
        0B11111,
        0B01110,



// Char Number 3 -- thermo2
  0B00100,
        0B01010,
        0B01010,
        0B01010,
        0B01010,
        0B10001,
        0B10001,
        0B01110,

//bell active
4,14,14,14,31,0,4,0,
 

//menu right
   0B10000,
   0B11000,
   0B11100,
   0B11110,
   0B11100,
   0B11000,
   0B10000,
   0B00000,

//menu left
        0B00001,
        0B00011,
        0B00111,
        0B01111,
        0B00111,
        0B00011,
        0B00001,
        0B00000,

//cancel
0B00000,
        0B10001,
        0B01010,
        0B00100,
        0B01010,
        0B10001,
        0B00000,
        0B00000,

//character number 7 ... ok
 0B00000,
        0B00001,
        0B00011,
        0B10110,
        0B11100,
        0B01000,
        0B00000,
        0B00000,

};




void lcd_load_custom_chars(void)
{
int8 i;

// Set address counter pointing to CGRAM address 0.
lcd_send_byte(0, 0x40); 

// Load custom lcd character data into CGRAM.
// It can only hold a maximum of 8 custom characters.
for(i = 0; i < sizeof(lcd_custom_chars); i++)
   {
    lcd_send_byte(1, lcd_custom_chars[i]);
   }

// Set address counter pointing back to the DDRAM.
lcd_send_byte(0, 0x80);
}




 



Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Sun Sep 02, 2018 8:51 am     Reply with quote

The reason is simple. You can't send the 07 character with the standard lcd_putc. This is the ASCII '\a' character which is trapped by the driver. Add 8, and use 0xF for the character 7 (the CGRAM characters appear at 0 to 7, and then repeated at 8 to 15). Very Happy
Or use flex_lcd, which does not trap the \a character.
armma



Joined: 30 Apr 2016
Posts: 7

View user's profile Send private message

PostPosted: Tue Sep 04, 2018 4:59 pm     Reply with quote

Ttelmah wrote:
The reason is simple. You can't send the 07 character with the standard lcd_putc. This is the ASCII '\a' character which is trapped by the driver. Add 8, and use 0xF for the character 7 (the CGRAM characters appear at 0 to 7, and then repeated at 8 to 15). Very Happy
Or use flex_lcd, which does not trap the \a character.




Shocked Shocked

thank you Smile
E_Blue



Joined: 13 Apr 2011
Posts: 417

View user's profile Send private message

PostPosted: Wed Sep 05, 2018 8:26 am     Reply with quote

Ttelmah wrote:
The reason is simple. You can't send the 07 character with the standard lcd_putc. This is the ASCII '\a' character which is trapped by the driver. Add 8, and use 0xF for the character 7 (the CGRAM characters appear at 0 to 7, and then repeated at 8 to 15). Very Happy
Or use flex_lcd, which does not trap the \a character.


There's any table that shows the byte value of each of those special codes \a \f \n etc?

I know \r\n and that's all.
_________________
Electric Blue
Ttelmah



Joined: 11 Mar 2010
Posts: 19553

View user's profile Send private message

PostPosted: Wed Sep 05, 2018 9:06 am     Reply with quote

The power of Wikipedia:

<https://en.wikipedia.org/wiki/Escape_sequences_in_C>

You'll see that the /a sequence was only added in C89. Didn't exist in original K&R.

It's actually treated as a 'back to origin' code in the CCS driver. Think I prefer flex_lcd, which just ignores it...
temtronic



Joined: 01 Jul 2010
Posts: 9246
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Sep 05, 2018 10:36 am     Reply with quote

It's too bad CCS used \a for their 'home' code.
\a is supposed to be 'alert' or bell.....
sigh.
I just checked the link and \h is NOT defined so it could have been used as the 'home' code ( top left position). That would make logical sense to me....
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group