View previous topic :: View next topic |
Author |
Message |
tonkostz
Joined: 07 May 2011 Posts: 42 Location: Bulgaria
|
How to blink text without using delay_ms() function? |
Posted: Thu Jun 13, 2013 1:05 am |
|
|
I want to blink a whole text line on the lcd but without using the delay_ms() function?
I mean that this variant is not good for me:
Code: |
lcd_gotoxy(1,1);
printf(lcd_putc," Blinking ");
delay_ms(500);
lcd_gotoxy(1,1);
printf(lcd_putc," ");
delay_ms(500);
|
I want something based on a timer counter for example:
Code: |
if(blink_flag==1)
{
counter_blink++;
}
else
{
counter_blink=0;
}
if(counter_blink==50)
{
counter_blink=0;
blink=1;
}
|
The problem is that i don't know how to reset the counter after the first blink and make it blink continuously. |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Thu Jun 13, 2013 1:09 am |
|
|
Look at using the RTOS. Its easy to set up a task which repeats, and have it turn your display on and off.
Code: | #use rtos(timer=0, minor_cycle = 10ms)
#task (rate = 200ms, max = 10ms)
void display_task(void)
{
lcd_gotoxy(1,1);
blink = !blink;
if(blink)
printf(lcd_putc," Blinking ");
else
printf(lcd_putc," ");
} |
|
|
|
tonkostz
Joined: 07 May 2011 Posts: 42 Location: Bulgaria
|
|
Posted: Thu Jun 13, 2013 1:27 am |
|
|
Thank you very much! It works! |
|
|
|