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

LCD display GLK12232-25-SM from Matrix Orbital

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



Joined: 31 Jan 2011
Posts: 1

View user's profile Send private message

LCD display GLK12232-25-SM from Matrix Orbital
PostPosted: Mon Jan 31, 2011 3:41 pm     Reply with quote

Hi!

I'm experimenting with the LCD display GLK12232-25-SM from Matrix Orbital.
The code below works, but if I put the code between the "//mogd.h" markings in a separate file (called "mogd.h") and add the line "#include "mogd.h"" at the top of the file, I get the error "Unidentified identifer -- putchar for every line containing "putchar" in mogd.h - why?



Code:
#include <16F648A.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES INTRC_IO                 //Internal RC Osc, no CLKOUT
#FUSES NOPUT                    //No Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NOBROWNOUT               //No brownout reset
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection

#use delay(clock=4000000)
#use rs232(baud=9600,parity=N,xmit=PIN_B2,rcv=PIN_B1,bits=8)

//mogd.h

void mogd_clear (void) {
   putc (0xfe);
   putc (0x58);
}

void mogd_home (void) {
   putc (0xfe);
   putc (0x48);
}

void mogd_goto (int col, int row) {
   putc (0xfe);
   putc (0x47);
   putc (col);
   putc (row);
}

void mogd_gotoxy (int col, int row) {
   putc (0xfe);
   putc (0x47);
   putc (col);
   putc (row);
}

void mogd_drawline (int x1, int x2, int y1, int y2) {
   putc (0xfe);                     // x = 0-31, y = 0-121
   putc (0x6c);
   putc (x1);
   putc (x2);
   putc (y1);
   putc (y2);
}

void mogd_contline (int x, int y) {
   putc (0xfe);
   putc (0x65);
   putc (x);
   putc (y);
}

void mogd_pixel (int x, int y) {
   putc (0xfe);
   putc (0x65);
   putc (x);
   putc (y);
}

void mogd_setcolor (int color) {    // Set drawing color
   putc (0xfe);                     // 0 = White, 255 = Black
   putc (0x63);
   putc (color);
}

void mogd_drawrect (int type, int color, int x1, int x2, int y1, int y2) {
if (type == 0) {                    // Type 0 = Outline, 1 = Solid
   putc (0xfe);                     // Color 0 = White, 255 = Black
   putc (0x72);
   putc (color);
   putc (x1);
   putc (x2);
   putc (y1);
   putc (y2);
   }
else {
   putc (0xfe);                     // GPIO = 1 or 2
   putc (0x78);
   putc (color);
   putc (x1);
   putc (x2);
   putc (y1);
   putc (y2);
   }
}

void mogd_bargraph_init (int ref, int type, int x1, int x2, int y1, int y2) {
   putc (0xfe);                     
   putc (0x67);
   putc (ref);                      // Ref = 0-15
   putc (type);                     // Type 0 = Vertical Upwards
   putc (x1);                       // Type 1 = Horizontal Rightwards
   putc (x2);                       // Type 2 = Vertical Downwards
   putc (y1);                       // Type 3 = Horizontal Leftwards
   putc (y2);                       // x/y = Placement/Size (Pixels)
}

void mogd_bargraph (int ref, int value) {
   putc (0xfe);                     // Ref = 0-15
   putc (0x67);                     // Value (Pixels, see bargraph_init)
   putc (ref);                     
   putc (value);                   
}

void mogd_backlight (int state, int minutes) {
if (state == 0) {                   // 0 = Off, 1 = On,
   putc (0xfe);                     // If minutes = 0, then continuous on
   putc (0x46);
   }
else {
   putc (0xfe);
   putc (0x42);
   putc(minutes);
   }
}


void mogd_gpio (int state, int gpio) {
if (state == 0) {                   // 0 = Off, 1 = On,
   putc (0xfe);                     // GPIO = 1 or 2
   putc (0x56);
   putc (gpio);
   }
else {
   putc (0xfe);                     
   putc (0x57);
   putc (gpio);
   }
}

void mogd_autoscroll (int state) {
if (state == 0) {                   // 0 = Off, 1 = On,
   putc (0xfe);                     // GPIO = 1 or 2
   putc (0x52);
   }
else {
   putc (0xfe);                     
   putc (0x51);
   }
}

void mogd_contrast (int value, int save) {
if (save == 0) {                    // Save 0 = No, 1 = Yes
   putc (0xfe);                     // Value =  0-255
   putc (0x50);
   putc (value);
   }
else {
   putc (0xfe);                     
   putc (0x91);
   putc (value);
   }
}


void main (void) {

   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

//mogd.h


mogd_clear ();

printf("Hello world...  ");


}

Also, writing
Code:
void mogd_clear (void) {
   putc (0xfe);
   putc (0x58);
}

works, but writing
Code:
void mogd_clear (void) {
   printf (/xFE /x58);
}

does not work (in practice, I'm not getting any errors). Why?

Also, writing printf ("Hello world..."); results in "Hello world." on the display, while writing printf ("Hello world... "); results in "Hello world..." on the display - is that an error with the display, or the code?
Ttelmah



Joined: 11 Mar 2010
Posts: 19504

View user's profile Send private message

PostPosted: Mon Jan 31, 2011 4:34 pm     Reply with quote

It needs to be included where the top //mogd.h line is, not 'at the top of the file'. Putc/getc, are not defined, till the #use rs232 line. This needs the clock statement, and these need the fuses. The order in CCS, needs basically to be:

Processor include/define
Any other #device statements (ADC=10 etc.)
Fuses
clock setup
RS232/I2C setups

Then, include other code

Then the main code.


You are using forward slash, not backslash for the printf. This will just print (hence no error), but wont give the value you want.

Best Wishes
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