View previous topic :: View next topic |
Author |
Message |
MCUprogrammer
Joined: 08 Sep 2020 Posts: 221
|
320x240 graphic lcd |
Posted: Sat Jan 09, 2021 2:09 am |
|
|
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
|
|
Posted: Sat Jan 09, 2021 2:39 am |
|
|
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
|
|
Posted: Sat Jan 09, 2021 3:08 am |
|
|
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
|
|
Posted: Sat Jan 09, 2021 4:45 am |
|
|
I added the code but it only printed pixels. _________________ Best Regards...
MCUprogrammer
_______________________________
Work Hard |
|
|
MCUprogrammer
Joined: 08 Sep 2020 Posts: 221
|
|
Posted: Wed Jan 13, 2021 9:13 am |
|
|
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
|
|
Posted: Wed Jan 13, 2021 9:28 am |
|
|
Normally you would have to draw a rectangle of the 'erased' colour. |
|
|
MCUprogrammer
Joined: 08 Sep 2020 Posts: 221
|
|
Posted: Wed Jan 13, 2021 10:26 am |
|
|
I did, but it didn't work. _________________ Best Regards...
MCUprogrammer
_______________________________
Work Hard |
|
|
MCUprogrammer
Joined: 08 Sep 2020 Posts: 221
|
|
Posted: Wed Jan 13, 2021 10:38 am |
|
|
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
|
|
Posted: Wed Jan 13, 2021 11:53 am |
|
|
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
|
|
Posted: Thu Jan 14, 2021 12:19 pm |
|
|
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. |
|
|
|