title |
categories |
date |
draft |
featured_image |
Бегущая строка |
|
2016-02-19T00:00:00+03:00 |
false |
miniature.jpg |
#include <avr/io.h>
#include <string.h>
#include <util/delay.h>
#include "lcd_lib.h"
#define LINE 16
char *str = "Postapokaliptichesky1232323123";
char *pstr;
char buf[LINE + 1];
void lcd_clear() {
LCDsendCommand(0x01);
}
void lcd_zero_coord() {
char y = 0;
char x = 0;
LCDsendCommand(0x80 | ((0x40 * y) + x));
}
void lcd_data(char byte) {
LCDsendChar(byte);
}
void lcd_str(char *s) {
while (*s != '\0') lcd_data(*(s++));
}
int main(void) {
LCDinit();
lcd_clear();
while (1) {
int len = strlen(str) + LINE;
for (int i = 0; i < len; ++i) {
lcd_clear();
lcd_zero_coord();
strcpy(buf, str);
int spaces = LINE - i;
buf[i] = '\0';
pstr = buf;
if (spaces > 0) for (int s = 0; s < spaces; ++s) lcd_data(' ');
else pstr += i - LINE;
lcd_str(pstr);
_delay_ms(100);
}
}
}