Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
Hi all,
having declared an lcd, if you add the two methods below. then, instead of
lcd.printf("some text"),simply
teletype("This is nice",0)and you have a little teletyper !
(I realise that some of you may have no idea what I am talking about)
char* left(string Source,int NewLen) { char* result; char* temp; if (NewLen <=0) NewLen =1; /* Minimum length */ result = (char*)malloc(NewLen + 1); /* +1 = DFTTZ! */ *result=' '; /* default for unassigned strings */ temp=result; if (Source && *Source) /* don't copy an empty string */ { while (NewLen-- >0) *temp++=*Source++; } else temp++; *temp='\0'; return result; } void teletype(char* text, int row) { lcd.locate(0,row); lcd.printf(" "); int whole=strlen(text); for (int i=1;i<=whole;i++) { lcd.locate(0,row); char* a = left(text,i); lcd.printf(a); free(a); wait(0.15); } }