View previous topic :: View next topic |
Author |
Message |
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
where is the mistake...... |
Posted: Mon Jul 06, 2009 9:46 am |
|
|
hi, I have this code, where is the mistake:
Code: |
void ScrollMessage(unsigned char row,const char Message[])
{
char TempS[30];
unsigned int MHead=0,Done=0,count;
if(row >1) row=1;
row=row*40;
while(Done==0)
{
for(count=0;count<20;count++)
{
TempS[count]=Message[MHead+count];
if(Message[MHead+count+1]==0) Done=1;
}
MHead++;
lcd_gotoxy(1,row);
lcd_putc(TempS);
Delay_ms(200);
}
}
|
But when I want to make function active:
Code: | ScrollMessage(1,"You Wally! You are only ment to press one key at a time!!!!");
|
I get this error:
*** Error 12 "main.c" Line 25(14,15): Undefined identifier -- ScrollMessage |
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Mon Jul 06, 2009 9:56 am |
|
|
Simple, as you havn't posted a complete program I should just let you figure it out for yourself but I am in a good mood.
I assume your function
void ScrollMessage(unsigned char row,const char Message[])
Is defined somewhere after main, infact somewhere after your call to it.
You either need to rearange the code so you define the function before you call it, or you need to put a function definition header either in a header file and included at the top of the page in which you make the call or just place it at the top of your main file after the includes. |
|
![](templates/subSilver/images/spacer.gif) |
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
Posted: Mon Jul 06, 2009 10:45 am |
|
|
The function is in "flex_lcd.c"
and the flex_lcd.c is load in
main.c
Code: |
#include "main.h"
#include "flex_lcd.c"
#include "meniu.c"
#include "temperatura.c"
#include "voltmetru.c"
#include "turometru.c"
#include "DS1307.c" |
The code from main.c
Code: | #include "main.h"
#include "flex_lcd.c"
#include "meniu.c"
#include "temperatura.c"
#include "voltmetru.c"
#include "turometru.c"
#include "DS1307.c"
#define stanga input(PIN_B5)
#define asterix input(PIN_B6)
#define dreapta input(PIN_B7)
void main()
{
lcd_init();
LCD_Clrscr();
delay_ms(50);
porturi();
ds1307_init();
//setare_ceas_calendar();
while(1)
{
ScrollMessage(1,"You Wally! You are only ment to press one key at a time!!!!");
//interfata++;
//printf("timpi:%4.0i \r",interfata);
//delay_ms(80);
//lcd_send_byte(0, SHIFT_RIGHT);
//citeste_temperaturi();
//citeste_tensiuni();
//turometru();
citire_ceas();
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
bungee-
Joined: 27 Jun 2007 Posts: 206
|
|
Posted: Mon Jul 06, 2009 12:05 pm |
|
|
Your problem lies here: const char Message[]
You have to declare Message size ![Wink](images/smiles/icon_wink.gif) |
|
![](templates/subSilver/images/spacer.gif) |
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
Posted: Mon Jul 06, 2009 12:22 pm |
|
|
It's not working, how to declare the message size, where I put the message? |
|
![](templates/subSilver/images/spacer.gif) |
mkuang
Joined: 14 Dec 2007 Posts: 257
|
|
Posted: Mon Jul 06, 2009 12:32 pm |
|
|
bungee- wrote: | Your problem lies here: const char Message[]
You have to declare Message size ![Wink](images/smiles/icon_wink.gif) |
I don't think so...the const char Message is the input to a function, not a declaration. However, it is incorrectly done. Whenever you want to pass a string to a function you should declare a pointer to the string. So the function should look like:
Code: |
void ScrollMessage(unsigned char row, char *Message)
}
|
And the subsequent code needs to be modified accordingly.
That said, I have found that passing an array directly to a function as the OP did sometimes DOES compile, and sometimes it even works. But sometimes I can get some results that make me scratch my head so I stopped doing it. |
|
![](templates/subSilver/images/spacer.gif) |
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
Posted: Mon Jul 06, 2009 12:38 pm |
|
|
But the
Code: | TempS[count]=Message[MHead+count]; |
Is not counting the message length?
What modification is needed? Is there any solution to make a messange scroll? |
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
Re: where is the mistake...... |
Posted: Wed Jul 08, 2009 2:53 am |
|
|
soulraven wrote: | hi, I have this code, where is the mistake:
I get this error:
*** Error 12 "main.c" Line 25(14,15): Undefined identifier -- ScrollMessage |
So you don't get this error anymoe ? How did you fix it ?
As for your other problem,
Quote: |
for(count=0;count<20;count++)
{
TempS[count]=Message[MHead+count];
if(Message[MHead+count+1]==0) Done=1;
}
MHead++;
lcd_gotoxy(1,row);
lcd_putc(TempS);
|
What output do you actually get ? Anything ?
Did you write/modify the flex_lcd code or did someone else ?
Not sure how lcd_putc works when presented with an array of chars that is not a string, how does it know where the end of the chars is or the size of the array is ?
Are you assuming that the definition char TempS[30]; zeros out the array ? It may be possible it does, it may be that the first time the function is called that the memory used is zero. I wouldn't count on it.
Basically you may need to add
TempS[count] = '\0'; after the for loop.
That would put the null terminator at position [20] char number 21 in the array! |
|
![](templates/subSilver/images/spacer.gif) |
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Jul 08, 2009 3:32 am |
|
|
No, that is just the main.c and main.h files.
it is missing
"flex_lcd.c"
"meniu.c"
"temperatura.c"
"turometru.c"
and any .h files to go with them.
I suspect that we would only need the "flex_lcd.c" and .h file to fix the problem though. |
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Jul 08, 2009 3:37 am |
|
|
Actually I can tell you what the problem is.
I did a search on the .lst file and there is no ScrollMessage function included.
I cannot find it in the included flex_lcd.c code at all.
So you are either using the wrong version of flex_lcd or you have forgot to add it!
You seem to be changing the parameters for it each time you post as well.
Actually, if the .lst includes functions that were used then it is because your ScrollMessage call is commented out that it is not included in the file.
Last edited by Wayne_ on Wed Jul 08, 2009 3:39 am; edited 1 time in total |
|
![](templates/subSilver/images/spacer.gif) |
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Jul 08, 2009 3:45 am |
|
|
Again, your code is different to what you have been posting.
You are now calling
Scroll(1,"You Wally! You are only ment to press one key at a time!!!!");
"Scroll"
This function has not been defined anywhere in that project. |
|
![](templates/subSilver/images/spacer.gif) |
soulraven
Joined: 08 Feb 2009 Posts: 72 Location: campulung muscel
|
|
Posted: Wed Jul 08, 2009 3:48 am |
|
|
yes, i have rename the function, but no change....is i the seam error |
|
![](templates/subSilver/images/spacer.gif) |
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Wed Jul 08, 2009 3:54 am |
|
|
soulraven wrote: | yes, i have rename the function, but no change....is i the seam error |
Well, until you post the actual code (preferably a cutdown version) that contains everything needed to compile and includes the current problem you have with it then there is nothing anyone can do.
You say you have renamed it, I assume you mean you have renamed it to "Scroll" !
The only mention of "Scroll" in that project/directory is in your main.c file where you call it.
You will get the error you mentioned because you have not defined the function anywhere. If you have then please post the file that has it! |
|
![](templates/subSilver/images/spacer.gif) |
|