mspgcc problem z napisem jako parametr funkcji

Hej! Mam problem z przekazaniem do funkcji parametru w postaci tablicy znaków. Mam to zrobione ak niżej. Chcę po prostu funkcję, która mi wyrzuci na LCD napis. To poniżej kompiluje się z Warningami odnoście typów wskaźników i niby napisy wyświetla, ale cały program jakoś głupieje :( Książki mi niewiele pomogły, więc mam nadzieję, że grupa podpowie mi jak to zrobić.

Z góry dziękuję pozdrawiam

const unsigned char LCD_M_1[] = "1. POMIAR 2. USTAW SKALE3. USTAW JEDN."; ... void WYSW_MENU(unsigned int menu,unsigned char *co,unsigned int ile, unsigned int linia); ... WYSW_MENU(menu,LCD_M_1,14,0); ... void WYSW_MENU(unsigned int menu,unsigned char *co,unsigned int ile, unsigned int linia) { SEND_CMD(0x80+linia*0x40); for(i=(menu-1)*ile;i!=menu*ile;i++) //wyswietlenie napisu { SEND_CHAR(*(co+i)); } }

Reply to
Grzegorz Latocha
Loading thread data ...

Sirtap napisał(a):

Tu chyba lepiej petla while pasuje: void LCD_Text(const unsigned char* text) { while(*text) { if (*text == '\n') { LCD_Ln(); text++; } else LCD_Send(data, *text++); } }

Pozdr AK

A odnosnie do pytania z pierwszego postu, to warningi sa, poniewaz tekst jest definiowany jak 'const' natomiast funcja wymaga parametru bez atrybutu 'const', czyli powinno byc tak:

const unsigned char LCD_M_1[] = "1. POMIAR 2. USTAW SKALE3. USTAW JEDN."; ... void WYSW_MENU(unsigned int menu, const unsigned char *co,unsigned int ile, unsigned int linia); ... WYSW_MENU(menu,LCD_M_1,14,0); ... void WYSW_MENU(unsigned int menu,const unsigned char *co,unsigned int ile, unsigned int linia) { SEND_CMD(0x80+linia*0x40); for(i=(menu-1)*ile;i!=menu*ile;i++) //wyswietlenie napisu { SEND_CHAR(*(co+i)); } }

Pozdr AK

Reply to
AK

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.