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

320x240 graphic lcd

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



Joined: 08 Sep 2020
Posts: 221

View user's profile Send private message

320x240 graphic lcd
PostPosted: Sat Jan 09, 2021 2:09 am     Reply with quote

Hello there
I created a driver for S1D13700. It works. I just don't want to use
glcd_text57 and sprintf. I want to add a more useful code instead.
For example as follows:
Code:

GlcdGotoTextXY (2,2);
printf (GlcdPutC, "HELLO WORD");

The codes I added:
Code:

void GlcdPutC (char c)
{
    glcd_sendByte (0x46);
    glcd_sendByte (c);
}
   
// x and y: 1 to max
void GlcdGotoTextXY (unsigned int16 x, unsigned int16 y)
{
    unsigned int16 adress = 0;
    adress = (y-1) * 40;
    adress = adress + x-1;
    setCursorAddress (adress);
}

I specify the codes I added to my driver. But it didn't work. What should I do?
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Sat Jan 09, 2021 2:39 am     Reply with quote

Problem is the LCD wants _one_ MWRITE command before the whole
sequence of text. Not one sent for every character. Also the 'send command
instruction is different from the 'send byte'. The byte needs A0 toggled,
while the command does not.
So you would need something like:
Code:

void GlcdPutc(int chr)
{
   send_byte(chr);
}

////////
   send_command(MRITE);
   printf (GlcdPutC, "HELLO WORD");

With your code having a send_byte that does the A0 toggle and a
send_command that does not.
MCUprogrammer



Joined: 08 Sep 2020
Posts: 221

View user's profile Send private message

PostPosted: Sat Jan 09, 2021 3:08 am     Reply with quote

So should I add these codes? Some of your words seem meaningless because I use the translator: D I don't understand.
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
MCUprogrammer



Joined: 08 Sep 2020
Posts: 221

View user's profile Send private message

PostPosted: Sat Jan 09, 2021 4:45 am     Reply with quote

I added the code but it only printed pixels.
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
MCUprogrammer



Joined: 08 Sep 2020
Posts: 221

View user's profile Send private message

PostPosted: Wed Jan 13, 2021 9:13 am     Reply with quote

I want to delete the articles in a certain position on this glcd screen. How can I do it ?
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Wed Jan 13, 2021 9:28 am     Reply with quote

Normally you would have to draw a rectangle of the 'erased' colour.
MCUprogrammer



Joined: 08 Sep 2020
Posts: 221

View user's profile Send private message

PostPosted: Wed Jan 13, 2021 10:26 am     Reply with quote

I did, but it didn't work.
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
MCUprogrammer



Joined: 08 Sep 2020
Posts: 221

View user's profile Send private message

PostPosted: Wed Jan 13, 2021 10:38 am     Reply with quote

So isn't that what you mean? glcd_rect (x, y, x1, y1, on, off)
_________________
Best Regards...
MCUprogrammer
_______________________________
Work Hard
Ttelmah



Joined: 11 Mar 2010
Posts: 19539

View user's profile Send private message

PostPosted: Wed Jan 13, 2021 11:53 am     Reply with quote

Yes, but we have no idea at all whether your rectangle function works,
where you are actually setting it, and it looks very strange to have,
'on, off' at the end. What are these meant to do?. Have you tested that
the function does work?.
jeremiah



Joined: 20 Jul 2010
Posts: 1354

View user's profile Send private message

PostPosted: Thu Jan 14, 2021 12:19 pm     Reply with quote

Ttelmah wrote:
Problem is the LCD wants _one_ MWRITE command before the whole
sequence of text. Not one sent for every character. Also the 'send command
instruction is different from the 'send byte'. The byte needs A0 toggled,
while the command does not.
So you would need something like:
Code:

void GlcdPutc(int chr)
{
   send_byte(chr);
}

////////
   send_command(MRITE);
   printf (GlcdPutC, "HELLO WORD");

With your code having a send_byte that does the A0 toggle and a
send_command that does not.


Side note: If you are using v5.xxx of the compiler, you can use some macro trickery and knowledge of C to make this a bit more organic looking:

Code:

#define glcd_printf(fmt,...) (send_command(MRITE),printf (GlcdPutC, fmt,__VA_ARGS__))


Then you can just call the new printf function (really macro) that you created

Code:

glcd_printf("Hello World");


This uses two special features:
1. comma separated statements - In C when you take multiple statements and separate them by a comma, it executes all the statements in order and returns the result from the last statement (if applicable)

2. Variable argument macros. This was added with v5.xxx of the compiler and allows for one to pass any number of arguments to a macro and have them forwarded to a variable argument function.
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