HIDLCD
This driver library allows the host to communicate with HID-compliant Auxiliary Display for PC based on Arduino.
hidlcd.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 abratchik
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19  * File: hidlcd.h
20  * Author: abratchik
21  *
22  * Created on November 12, 2021, 5:48 PM
23  */
24 
34 #ifndef HIDLCD_H
35 #define HIDLCD_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include <stdlib.h>
42 #include <string.h>
43 #include <hidapi/hidapi.h>
44 
45 // Display params flags
46 #define HID_AUXD_ASCII_CHARSET 0x80
47 #define HID_AUXD_DATAREAD_BACK 0x40
48 #define HID_AUXD_FONTREAD_BACK 0x20
49 
50 // Display control flags
51 #define HID_AUXD_CLEAR 0x80
52 #define HID_AUXD_ENABLE 0x40
53 #define HID_AUXD_SSENABLE 0x20
54 #define HID_AUXD_VSCROLL 0x10
55 #define HID_AUXD_HSCROLL 0x08
56 #define HID_AUXD_DISABLE 0x0
57 
58 // Cursor control flags
59 #define HID_ADCC_PIXELPOS 0x80
60 #define HID_ADCC_INCREMENT 0x40
61 #define HID_ADCC_ENABLE 0x20
62 #define HID_ADCC_BLINK 0x10
63 
64 
67 typedef enum {
75 
80 typedef enum {
85 
91 typedef struct
92 {
93  u_int8_t rows;
94  u_int8_t cols;
95  u_int8_t chrw;
96  u_int8_t chrh;
97  u_int8_t flags;
99 
107 HIDDisplayParams* HID_API_EXPORT HID_API_CALL hidlcd_get_display_params(hid_device *dev);
108 
118 HID_API_EXPORT hid_device * HID_API_CALL hidlcd_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number);
119 
126 void HID_API_EXPORT HID_API_CALL hidlcd_close(hid_device *dev);
127 
134 int HID_API_EXPORT HID_API_CALL hidlcd_exit(void);
135 
142 int HID_API_EXPORT HID_API_CALL hidlcd_init(void);
143 
153 int HID_API_EXPORT HID_API_CALL hidlcd_set_cursor(hid_device *dev, u_int8_t row, u_int8_t col);
154 
164 int HID_API_EXPORT HID_API_CALL hidlcd_set_cursor_flags_ext(hid_device *dev, u_int8_t flags, HID_ADCMD_MODE mode);
165 
175 int HID_API_EXPORT HID_API_CALL hidlcd_print(hid_device *dev,
176  HIDDisplayParams *display_params,
177  const char *string);
178 
188 int HID_API_EXPORT HID_API_CALL hidlcd_send_command_ext(hid_device *dev, u_int8_t command, HID_ADCMD_MODE mode);
189 
198 int HID_API_EXPORT HID_API_CALL hidlcd_send_command(hid_device *dev, u_int8_t command);
199 
200 
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif /* HIDLCD_H */
207 
Cursor position report.
Definition: hidlcd.h:69
Control report.
Definition: hidlcd.h:72
u_int8_t chrw
character width (HID usage 0x3d)
Definition: hidlcd.h:95
Cursor flags.
Definition: hidlcd.h:73
int HID_API_EXPORT HID_API_CALL hidlcd_init(void)
Initialize the HIDLCD library.
HIDDisplayParams *HID_API_EXPORT HID_API_CALL hidlcd_get_display_params(hid_device *dev)
Returns the physical parameters of the connected auxiliary LCD display.
HID_AUXD_REPORT
Supported HID reports for HID LCD Display.
Definition: hidlcd.h:67
int HID_API_EXPORT HID_API_CALL hidlcd_exit(void)
Closes the HIDLCD library and releases associated resources.
Clear the command/state.
Definition: hidlcd.h:82
HID_API_EXPORT hid_device *HID_API_CALL hidlcd_open(unsigned short vendor_id, unsigned short product_id, const wchar_t *serial_number)
Returns the device handle.
int HID_API_EXPORT HID_API_CALL hidlcd_set_cursor(hid_device *dev, u_int8_t row, u_int8_t col)
This function sets the cursor of the LCD display in the specified position.
int HID_API_EXPORT HID_API_CALL hidlcd_set_cursor_flags_ext(hid_device *dev, u_int8_t flags, HID_ADCMD_MODE mode)
This function sets the cursor extended parameters and display mode.
u_int8_t cols
nuber of columns (HID usage 0x36)
Definition: hidlcd.h:94
int HID_API_EXPORT HID_API_CALL hidlcd_print(hid_device *dev, HIDDisplayParams *display_params, const char *string)
Prints the text on the LCD screen.
u_int8_t flags
display capabilities bitmap. 0x21|0x22|0x29|5 unused
Definition: hidlcd.h:97
u_int8_t rows
number of rows (HID usage 0x35)
Definition: hidlcd.h:93
int HID_API_EXPORT HID_API_CALL hidlcd_send_command_ext(hid_device *dev, u_int8_t command, HID_ADCMD_MODE mode)
Sends the command to the LCD display with mode.
HID_ADCMD_MODE
Modes of setting the command flags to the LCD display.
Definition: hidlcd.h:80
Character report.
Definition: hidlcd.h:70
u_int8_t chrh
character height (HID usage 0x3e)
Definition: hidlcd.h:96
void HID_API_EXPORT HID_API_CALL hidlcd_close(hid_device *dev)
Closes the device handle and releases associated resources.
Display parameters report.
Definition: hidlcd.h:68
Command flags are added to the existing state of screen.
Definition: hidlcd.h:81
int HID_API_EXPORT HID_API_CALL hidlcd_send_command(hid_device *dev, u_int8_t command)
Sends the command to the LCD display.
The structure holding the physical parameters and other capabilities of the LCD display.
Definition: hidlcd.h:91
Font report.
Definition: hidlcd.h:71
Ovewrite the state of the screen.
Definition: hidlcd.h:83