#include <avr/io.h>
#include <util/delay.h>
#include <avr/pgmspace.h>
Go to the source code of this file.
Defines | |
#define | LC7981_H_ LC7981_H_ |
protects this file from beeing double included | |
#define | LCD_CTRL PORTC |
Port used for control signals. | |
#define | LCD_CRTL_DDR DDRC |
Data-Direction-Register for the control signals. | |
#define | LCD_RS PC4 |
Register-Select Pin of the Display. | |
#define | LCD_RW PC2 |
Read-Write-select Pin. | |
#define | LCD_EN PC0 |
Strobe Pin. | |
#define | LCD_DATA PORTD |
Port used for data. | |
#define | LCD_DATA_DDR DDRD |
Data-Direction-Register for Data. | |
#define | lcd_rs_high() (LCD_CTRL |= (1 << LCD_RS)) |
Set the Register-Select pin high. | |
#define | lcd_rs_low() (LCD_CTRL &= ~(1 << LCD_RS)) |
Set the Register-Select pin low. | |
#define | lcd_rw_high() (LCD_CTRL |= (1 << LCD_RW)) |
Set the Read-Write-Select pin high. | |
#define | lcd_rw_low() (LCD_CTRL &= ~(1 << LCD_RW)) |
Set the Register-Select pin low. | |
#define | lcd_en_high() (LCD_CTRL |= (1 << LCD_EN)) |
Set the strobe pin high. | |
#define | lcd_en_low() (LCD_CTRL &= ~(1 << LCD_EN)) |
Set the strobe pin low. | |
#define | LCD_TEXT 0 |
Constant for text mode. | |
#define | LCD_TEXT_LINES 10 |
Number of lines in text mode. | |
#define | LCD_TEXT_COLUMNS 26 |
Number of columns in text mode. | |
#define | LCD_GRAPHIC 1 |
Constant for graphic mode. | |
#define | LCD_GRAPHIC_WIDTH 160 |
Horizontal display size in pixels. | |
#define | LCD_GRAPHIC_HEIGHT 80 |
Vertical display size in pixels. | |
#define | PIXEL_ON 1 |
see lcd_plot_pixel | |
#define | PIXEL_OFF 0 |
see lcd_plot_pixel | |
Functions | |
void | lcd_init (uint8_t mode) |
lcd_init set the to default values. | |
void | lcd_clear () |
Clears the display by setting the whole memory to 0. | |
void | lcd_write_text (char *txt) |
void | lcd_gotoxy (uint8_t x, uint8_t y) |
Set the display cursor to a specific location. | |
void | lcd_plot_pixel (uint8_t x, uint8_t y, uint8_t set) |
set or unset a pixel at the specified location | |
void | lcd_plot_bitmap (uint8_t x, uint8_t y, const uint8_t *bitmap, uint8_t w, uint8_t h) |
This function will plot a bitmap with the upper left corner to the given coordinates. | |
void | lcd_strobe () |
Generates the strobe signal for writing data. | |
void | lcd_write_command (uint8_t cmd, uint8_t data) |
Writes a command and a data byte to the lcd. | |
uint8_t | lcd_read_byte () |
Reads a byte from the display memory. |
#define LC7981_H_ LC7981_H_ |
protects this file from beeing double included
#define LCD_CRTL_DDR DDRC |
Data-Direction-Register for the control signals.
#define LCD_CTRL PORTC |
Port used for control signals.
#define LCD_DATA PORTD |
Port used for data.
#define LCD_DATA_DDR DDRD |
Data-Direction-Register for Data.
#define LCD_EN PC0 |
Strobe Pin.
#define lcd_en_high | ( | ) | (LCD_CTRL |= (1 << LCD_EN)) |
Set the strobe pin high.
#define lcd_en_low | ( | ) | (LCD_CTRL &= ~(1 << LCD_EN)) |
Set the strobe pin low.
#define LCD_GRAPHIC 1 |
Constant for graphic mode.
#define LCD_GRAPHIC_HEIGHT 80 |
Vertical display size in pixels.
#define LCD_GRAPHIC_WIDTH 160 |
Horizontal display size in pixels.
#define LCD_RS PC4 |
Register-Select Pin of the Display.
#define lcd_rs_high | ( | ) | (LCD_CTRL |= (1 << LCD_RS)) |
Set the Register-Select pin high.
#define lcd_rs_low | ( | ) | (LCD_CTRL &= ~(1 << LCD_RS)) |
Set the Register-Select pin low.
#define LCD_RW PC2 |
Read-Write-select Pin.
#define lcd_rw_high | ( | ) | (LCD_CTRL |= (1 << LCD_RW)) |
Set the Read-Write-Select pin high.
#define lcd_rw_low | ( | ) | (LCD_CTRL &= ~(1 << LCD_RW)) |
Set the Register-Select pin low.
#define LCD_TEXT 0 |
Constant for text mode.
#define LCD_TEXT_COLUMNS 26 |
Number of columns in text mode.
#define LCD_TEXT_LINES 10 |
Number of lines in text mode.
#define PIXEL_OFF 0 |
see lcd_plot_pixel
#define PIXEL_ON 1 |
see lcd_plot_pixel
void lcd_clear | ( | ) | [inline] |
Clears the display by setting the whole memory to 0.
void lcd_gotoxy | ( | uint8_t | x, | |
uint8_t | y | |||
) | [inline] |
Set the display cursor to a specific location.
Right now this does only work in text mode, since there's no need for it now in graphics mode.
If the x and y values are to big, the function does nothing.
x | the horizontal cursorposition (starts at 0) | |
y | the vertical cursorposition (starts at 0) |
void lcd_init | ( | uint8_t | mode | ) |
lcd_init set the to default values.
mode | LCD_TEXT for text mode and LCD_GRAPHIC for graphic mode |
void lcd_plot_bitmap | ( | uint8_t | x_off, | |
uint8_t | y_off, | |||
const uint8_t * | bitmap, | |||
uint8_t | w, | |||
uint8_t | h | |||
) |
This function will plot a bitmap with the upper left corner to the given coordinates.
If the bitmap doesn't fit on the display at this location, nothing is drawn at all.
Unset pixels are treated as transparent
This function is by far the most tricky piece of code in this project,
don't worry if you don't understand it at first sight.
And if you know a better way to do this, tell me.
x | horizontal position of the bitmap | |
y | vertical position of the bitmap | |
bitmap | pointer to the bitmap in pgmspace | |
w | width of the bitmap | |
h | height of the bitmap |
void lcd_plot_pixel | ( | uint8_t | x, | |
uint8_t | y, | |||
uint8_t | set | |||
) |
set or unset a pixel at the specified location
x | horizontal position of the pixel (starts at 0) | |
y | horizontal position of the pixel (starts at 0) | |
set | can be PIXEL_ON or PIXEL_OFF |
uint8_t lcd_read_byte | ( | ) | [inline] |
Reads a byte from the display memory.
lcd_gotoxy can be used to set the location. Important : lcd_gotoxy doesn't work in graphics mode yet.
void lcd_strobe | ( | ) | [inline] |
Generates the strobe signal for writing data.
This function is meant for internal usage only.
void lcd_write_command | ( | uint8_t | cmd, | |
uint8_t | data | |||
) | [inline] |
Writes a command and a data byte to the lcd.
cmd | the command byte | |
data | the data that is going to be written after the command |
void lcd_write_text | ( | char * | txt | ) |