2019-05-27 09:55:01 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2017-03-10 17:15:17 +03:00
|
|
|
/*
|
|
|
|
* Character LCD driver for Linux
|
|
|
|
*
|
|
|
|
* Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
|
|
|
|
* Copyright (C) 2016-2017 Glider bvba
|
|
|
|
*/
|
|
|
|
|
2019-08-06 10:14:45 +03:00
|
|
|
#ifndef _CHARLCD_H
|
|
|
|
#define _CHARLCD_H
|
|
|
|
|
2020-11-03 12:58:17 +03:00
|
|
|
#define LCD_FLAG_B 0x0004 /* Blink on */
|
|
|
|
#define LCD_FLAG_C 0x0008 /* Cursor on */
|
|
|
|
#define LCD_FLAG_D 0x0010 /* Display on */
|
|
|
|
#define LCD_FLAG_F 0x0020 /* Large font mode */
|
|
|
|
#define LCD_FLAG_N 0x0040 /* 2-rows mode */
|
|
|
|
#define LCD_FLAG_L 0x0080 /* Backlight enabled */
|
|
|
|
|
2020-11-03 12:58:04 +03:00
|
|
|
enum charlcd_onoff {
|
|
|
|
CHARLCD_OFF = 0,
|
|
|
|
CHARLCD_ON,
|
|
|
|
};
|
|
|
|
|
2020-11-03 12:58:18 +03:00
|
|
|
enum charlcd_shift_dir {
|
|
|
|
CHARLCD_SHIFT_LEFT,
|
|
|
|
CHARLCD_SHIFT_RIGHT,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum charlcd_fontsize {
|
|
|
|
CHARLCD_FONTSIZE_SMALL,
|
|
|
|
CHARLCD_FONTSIZE_LARGE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum charlcd_lines {
|
|
|
|
CHARLCD_LINES_1,
|
|
|
|
CHARLCD_LINES_2,
|
|
|
|
};
|
|
|
|
|
2017-03-10 17:15:17 +03:00
|
|
|
struct charlcd {
|
|
|
|
const struct charlcd_ops *ops;
|
|
|
|
const unsigned char *char_conv; /* Optional */
|
|
|
|
|
|
|
|
int height;
|
|
|
|
int width;
|
|
|
|
|
2020-11-03 12:58:10 +03:00
|
|
|
/* Contains the LCD X and Y offset */
|
|
|
|
struct {
|
|
|
|
unsigned long x;
|
|
|
|
unsigned long y;
|
|
|
|
} addr;
|
|
|
|
|
2020-11-03 12:58:06 +03:00
|
|
|
void *drvdata;
|
2017-03-10 17:15:17 +03:00
|
|
|
};
|
|
|
|
|
2020-11-03 12:58:11 +03:00
|
|
|
/**
|
|
|
|
* struct charlcd_ops - Functions used by charlcd. Drivers have to implement
|
|
|
|
* these.
|
|
|
|
* @backlight: Turn backlight on or off. Optional.
|
|
|
|
* @print: Print one character to the display at current cursor position.
|
|
|
|
* The buffered cursor position is advanced by charlcd. The cursor should not
|
|
|
|
* wrap to the next line at the end of a line.
|
2020-11-03 12:58:12 +03:00
|
|
|
* @gotoxy: Set cursor to x, y. The x and y values to set the cursor to are
|
|
|
|
* previously set in addr.x and addr.y by charlcd.
|
2020-11-03 12:58:13 +03:00
|
|
|
* @home: Set cursor to 0, 0. The values in addr.x and addr.y are set to 0, 0 by
|
|
|
|
* charlcd prior to calling this function.
|
2020-11-03 12:58:23 +03:00
|
|
|
* @clear_display: Clear the whole display and set the cursor to 0, 0. The
|
|
|
|
* values in addr.x and addr.y are set to 0, 0 by charlcd after to calling this
|
2020-11-03 12:58:14 +03:00
|
|
|
* function.
|
2020-11-03 12:58:17 +03:00
|
|
|
* @init_display: Initialize the display.
|
2020-11-03 12:58:18 +03:00
|
|
|
* @shift_cursor: Shift cursor left or right one position.
|
|
|
|
* @shift_display: Shift whole display content left or right.
|
|
|
|
* @display: Turn display on or off.
|
|
|
|
* @cursor: Turn cursor on or off.
|
|
|
|
* @blink: Turn cursor blink on or off.
|
|
|
|
* @lines: One or two lines.
|
2020-11-03 12:58:20 +03:00
|
|
|
* @redefine_char: Redefine the actual pixel matrix of character.
|
2020-11-03 12:58:11 +03:00
|
|
|
*/
|
2017-03-10 17:15:17 +03:00
|
|
|
struct charlcd_ops {
|
2020-11-03 12:58:04 +03:00
|
|
|
void (*backlight)(struct charlcd *lcd, enum charlcd_onoff on);
|
2020-11-03 12:58:11 +03:00
|
|
|
int (*print)(struct charlcd *lcd, int c);
|
2020-11-03 12:58:25 +03:00
|
|
|
int (*gotoxy)(struct charlcd *lcd, unsigned int x, unsigned int y);
|
2020-11-03 12:58:13 +03:00
|
|
|
int (*home)(struct charlcd *lcd);
|
2020-11-03 12:58:14 +03:00
|
|
|
int (*clear_display)(struct charlcd *lcd);
|
2020-11-03 12:58:17 +03:00
|
|
|
int (*init_display)(struct charlcd *lcd);
|
2020-11-03 12:58:18 +03:00
|
|
|
int (*shift_cursor)(struct charlcd *lcd, enum charlcd_shift_dir dir);
|
|
|
|
int (*shift_display)(struct charlcd *lcd, enum charlcd_shift_dir dir);
|
|
|
|
int (*display)(struct charlcd *lcd, enum charlcd_onoff on);
|
|
|
|
int (*cursor)(struct charlcd *lcd, enum charlcd_onoff on);
|
|
|
|
int (*blink)(struct charlcd *lcd, enum charlcd_onoff on);
|
|
|
|
int (*fontsize)(struct charlcd *lcd, enum charlcd_fontsize size);
|
|
|
|
int (*lines)(struct charlcd *lcd, enum charlcd_lines lines);
|
2020-11-03 12:58:20 +03:00
|
|
|
int (*redefine_char)(struct charlcd *lcd, char *esc);
|
2017-03-10 17:15:17 +03:00
|
|
|
};
|
|
|
|
|
2020-11-03 12:58:15 +03:00
|
|
|
void charlcd_backlight(struct charlcd *lcd, enum charlcd_onoff on);
|
2020-11-03 12:58:06 +03:00
|
|
|
struct charlcd *charlcd_alloc(void);
|
2019-03-12 17:44:30 +03:00
|
|
|
void charlcd_free(struct charlcd *lcd);
|
2017-03-10 17:15:17 +03:00
|
|
|
|
|
|
|
int charlcd_register(struct charlcd *lcd);
|
|
|
|
int charlcd_unregister(struct charlcd *lcd);
|
|
|
|
|
|
|
|
void charlcd_poke(struct charlcd *lcd);
|
2019-08-06 10:14:45 +03:00
|
|
|
|
|
|
|
#endif /* CHARLCD_H */
|