bitfield v avr-gcc

Miroslav Sinko sinkomiro@rocketmail.com
Pondělí Červen 16 23:06:09 CEST 2008


Mozno sa opat nerozumieme. Moje menu ma byt take to uzivatelske na displayi. Pole struktur je vzdy pre jedno menu, polozka menu vyzera takto:

//prototype of menuItem arrays stored in PROGMEM
typedef struct{
char *text;				//text is pointer to the string. the string may be saved in the progmem and never copied into the RAM
							//(constant string - save RAM) or in the RAM (user string, e.g. custom BaudRates) 
BYTE textLen;			//if 7th bit is NOT set, the text is PGM_P, else it is char * located in RAM.
							//it is easier for code to have a length calculated here even though it consumes 1B of RAM for each menuitem
							//and 1B of progmem too because the initialized .data on the end of progmem
DWORD	param;			//parameter passed into the menuFunc 
}S_MenuItem;


Nad tymto mam strukturu pre dane menu (kedze mam viac menu):


//prototype of menu struct stored in PROGMEM
typedef struct{
S_MenuItem *items;		//pointer to PROGMEM struct array with items 
BYTE numItems;		//number of filled items
void (*menuInitFunc)(void);//function called before the displaying the menu. useful for init user menus. can be NULL
void (*menuItemFunc)(DWORD);//function called on entered into the menuItem
S_MenuRunTimeInfo	*rtInfo;//pointer to 1 struct in RAM, where the runtime infos are stored (e.g. last position of cursor in menu)
}S_Menu;


Kod v maili vyzera ako vyzera, ale snad sa bude dat pochopit, co tym myslim a ako zhruba to funguje. 

Ak ma byt vztah menu k bitovym polozkam taky, ze cez menu si nastavujem/nulujem jednotlive bity kdesi v bitovom poli, tak u mna by to muselo ist cez funkciu menu a jednoznacny DWORD parameter urcujuci polozku. Parameter je u mna spravidla enum a vo funkcii mam switch/case. Vravel som, pohlad na efektivitu sa moze lisit. U mna prevlada snaha vyznat sa vo vlastnom kode aj po dlhsom case. No a pri user menu nie je cas vykonu kodu vobec ale vobec kriticky.

miro


--- On Mon, 6/16/08, Jan Waclawek <konfera@efton.sk> wrote:

> >????? o bitovych parametroch nic nepisem. Reagoval som
> na to, ze si chces urobit system menu. Nic o bitovych
> parametroch... Takze celou vetou: Pri tabulkou (polom
> structov) riadenom systeme menu sa da zaobist bez bitovych
> poli.
> 
> 
> Mno, pockaj, a na bity v tom menu nemyslis?
> 
> IMHO je to dost bezna polozka u jednocipoidnych veci...
> 
> wek



      



Další informace o konferenci Hw-list