Subject:
|
Re: tweaking around dlcd_show( )
|
Newsgroups:
|
lugnet.robotics.rcx.legos
|
Date:
|
Mon, 3 Sep 2001 21:21:22 GMT
|
Viewed:
|
1685 times
|
| |
| |
Alexandre Bec <laleks@free.fr> writes:
> Hi all legOS users,
>
> need help about dlcd_* utilities
>
> I'd like to display on the lcd a sequence of digits:
> something like :
>
> dlcd_show (LCD_4_BOTL);
> lcd_refresh();
> msleep(250);
> lcd_clear();
> dlcd_show (LCD_4_TOPL);
> lcd_refresh();
> msleep(250);
> lcd_clear();
> dlcd_show (LCD_4_TOP);
> ...
>
> But of course this is not a good idea to hardcode a long sequence.
> So I tried to make a pattern of segments stored in an array, and access to
> the good one with an index value in a for { } loop.
>
> int progressPattern[PATTERN_ITEMS_NB]={
> {LCD_4_BOTL} ,
> {LCD_4_TOPL} ,
> {LCD_4_TOP }
> };
>
> and later
> for (...){
> ...
> lcd_clear();
> dlcd_show(progressPattern[ i ] );
> lcd_refresh();
> msleep(250);
> ...
> }
>
> and I obtain the following compilation errors concerning dlcd_show( );
>
> macro `BIT_OF' used with just one arg
> macro `BYTE_OF' used with just one arg
>
> I tried lots of braces combination , a declaration of a bidimensional array
> too, but in vain.
>
> Since I'm not an expert in C and macros, I certainly made something wrong
> when filling this array with defines, and maybe it is not the right way to
> proceed.
The macros LCD_?_* expand to two integers, separated by a comma; dlc_show()
is a macro that expects one argument but uses it as an argument to macros
expecting two arguments. I don't know exactly how this works, but it's
to do with the order of macro expansions.
A workaround may be using your own definition of dlcd_show, like this (not
fully tested, but should work :-) :
/* This one takes two arguments */
#define my_dlcd_show(a,b) bit_set((a),(b))
/* A bidimensional array */
int progressPattern[][2]={
{LCD_4_BOTL} ,
{LCD_4_TOPL} ,
{LCD_4_TOP }
};
..
/* Show i-th pattern */
my_dlcd_show( progressPattern[i][0], progressPattern[i][1] );
bye
Bernardo
e-mail: dibbe@freestation.it
|
|
Message has 1 Reply: | | Re: tweaking around dlcd_show( )
|
| Thank you Bernardo. As I explained during the discussion with Martin, I decided to use rather arrays of functions. So now I've got my own functions like void Lcd4BotL(){ dlcd_show(LCD_4_BOTL); } and the use of the array with an index is now fully (...) (23 years ago, 4-Sep-01, to lugnet.robotics.rcx.legos)
|
Message is in Reply To:
| | tweaking around dlcd_show( )
|
| Hi all legOS users, need help about dlcd_* utilities I'd like to display on the lcd a sequence of digits: something like : dlcd_show (LCD_4_BOTL); lcd_refresh(); msleep(250); lcd_clear(); dlcd_show (LCD_4_TOPL); lcd_refresh(); msleep(250); (...) (23 years ago, 25-Aug-01, to lugnet.robotics.rcx.legos)
|
10 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|