# include/lc7981.c File Reference

`#include "lc7981.h"`

## 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)
| Outputs text in at the current cursor position.
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, PGM_P bitmap, uint8_t w, uint8_t h)
| This function will plot a bitmap with the upper left corner to the given coordinates.
void | lcd_plot_char (uint8_t x_off, uint8_t y_off, uint8_t c, uint8_t fw, uint8_t fh, PGM_P font)
| Plots a single character in graphicmode.
void | lcd_plot_text (uint8_t x_off, uint8_t y_off, const char *text, uint8_t fw, uint8_t fh, PGM_P font)
| Plots a text using lcd_plot_char.
void | lcd_plot_pgmtext (uint8_t x_off, uint8_t y_off, PGM_P text, uint8_t fw, uint8_t fh, PGM_P font)
| Plots a text using lcd_plot_char.

## Variables

uint8_t | lcd_mode
| Currently used mode, can be text or graphic.
uint8_t | lcd_curline
| Current line. Used for scrolling in text mode.

## Function Documentation

void lcd_clear | ( | void |  | ) |

Clears the display by setting the whole memory to 0.

void lcd_gotoxy | ( | uint8_t | x,
|  | uint8_t | y |
| ) |  |  |

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.

Parameters:

  | 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.

Parameters:

  | mode | LCD_TEXT for text mode and LCD_GRAPHIC for graphic mode

void lcd_plot_bitmap | ( | uint8_t | x,
|  | uint8_t | y,
|  | PGM_P | 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.
Actually it just loops bitwise through the bitmap and uses some
nice bit shifting magic to get it anywhere you want.

Parameters:

  | 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

This function is dedicated to Greta, one of the most important persons in my life so far.

void lcd_plot_char | ( | uint8_t | x_off,
|  | uint8_t | y_off,
|  | uint8_t | c,
|  | uint8_t | fw,
|  | uint8_t | fh,
|  | PGM_P | font |
| ) |  |  |

Plots a single character in graphicmode.

Each character of the font is stored linewise.
This means for a 8x8 Pixel font the 8 bytes are needed.
The first byte is the first line and the last byte is the last line.
The next 8byte are the next character.
If the position is too close to the display edge so it can't be displayed completely,
It won't be displayed at all.

Parameters:

  | x_off | horizontal position of the character
  | y_off | vertical position of the character
  | c | the character or it's ascii code
  | fw | width of the font (we start counting from 0, so a 10px width font will have fw = 9)
  | fh | height of the font (we start counting from 0, so a 10px height font will have fh = 9)
  | font | pointer to the flash area where the font is stored

void lcd_plot_pgmtext | ( | uint8_t | x_off,
|  | uint8_t | y_off,
|  | PGM_P | text,
|  | uint8_t | fw,
|  | uint8_t | fh,
|  | PGM_P | font |
| ) |  |  |

Plots a text using lcd_plot_char.

Parameters:

  | x_off | horizontal position of the character
  | y_off | vertical position of the character
  | text | flash area where the text is stored
  | fw | width of the font (we start counting from 0, so a 10px width font will have fw = 9)
  | fh | height of the font (we start counting from 0, so a 10px height font will have fh = 9)
  | font | pointer to the flash area where the font is stored

See also:
  lcd_plot_char
  lcd_plot_text

void lcd_plot_pixel | ( | uint8_t | x,
|  | uint8_t | y,
|  | uint8_t | set |
| ) |  |  |

set or unset a pixel at the specified location

Parameters:

  | 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

void lcd_plot_text | ( | uint8_t | x_off,
|  | uint8_t | y_off,
|  | const char * | text,
|  | uint8_t | fw,
|  | uint8_t | fh,
|  | PGM_P | font |
| ) |  |  |

Plots a text using lcd_plot_char.

Parameters:

  | x_off | horizontal position of the character
  | y_off | vertical position of the character
  | text | the text that is plotted
  | fw | width of the font (we start counting from 0, so a 10px width font will have fw = 9)
  | fh | height of the font (we start counting from 0, so a 10px height font will have fh = 9)
  | font | pointer to the flash area where the font is stored

See also:
  lcd_plot_char

void lcd_write_text | ( | char * | txt | ) |

Outputs text in at the current cursor position.

If a \n occurs in the last line of the display, all the other line will be 'scrolled' up. This function is textmode only. The the second line becomes the first, the third the second and so on ...

Parameters:

  | txt | the text

## Variable Documentation

uint8_t lcd_curline

Current line. Used for scrolling in text mode.

uint8_t lcd_mode

Currently used mode, can be text or graphic.