You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
926 B
61 lines
926 B
10 years ago
|
//
|
||
|
// Example of basic LCD usage
|
||
|
//
|
||
|
|
||
|
#include <avr/io.h>
|
||
|
#include <avr/pgmspace.h>
|
||
|
#include <util/delay.h>
|
||
|
|
||
|
#include "lib/calc.h"
|
||
|
#include "lib/lcd.h"
|
||
|
|
||
|
// Bytes for custom glyph
|
||
|
|
||
|
// Here's a good glyph generator you can use:
|
||
|
// http://omerk.github.io/lcdchargen/
|
||
|
|
||
|
const uint8_t glyph[] PROGMEM = {
|
||
|
0b00000,
|
||
|
0b00111,
|
||
|
0b01101,
|
||
|
0b11101,
|
||
|
0b10001,
|
||
|
0b10001,
|
||
|
0b10001,
|
||
|
0b11111
|
||
|
};
|
||
|
|
||
|
|
||
|
void main()
|
||
|
{
|
||
|
lcd_init();
|
||
|
|
||
10 years ago
|
// Example of using the LCD stream
|
||
|
put_u32f(lcd, 271828, 5);
|
||
10 years ago
|
|
||
|
// Print a string
|
||
10 years ago
|
lcd_puts(" Hello\r\n");
|
||
10 years ago
|
|
||
|
// Use _pgm for strings in program memory
|
||
|
// Here we print string at position xy
|
||
10 years ago
|
lcd_puts_P(PSTR("String from PGM "));
|
||
|
|
||
|
// declare custom glyph
|
||
|
lcd_glyph_P(0, glyph);
|
||
10 years ago
|
|
||
10 years ago
|
// and show it
|
||
10 years ago
|
lcd_putc(0);
|
||
|
|
||
10 years ago
|
lcd_puts(" !");
|
||
|
|
||
10 years ago
|
// enable blink/bar cursor type
|
||
|
lcd_cursor(CURSOR_BOTH);
|
||
|
|
||
10 years ago
|
// print at given position
|
||
10 years ago
|
lcd_puts_xy(5, 2, "Third line?");
|
||
|
lcd_puts_xy(3, 3, "Fourth line!");
|
||
|
|
||
|
// end
|
||
|
while(1);
|
||
|
}
|