File: futaba.h

package info (click to toggle)
lcdproc 0.5.9-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 5,064 kB
  • sloc: ansic: 59,645; sh: 1,740; perl: 681; makefile: 417
file content (105 lines) | stat: -rw-r--r-- 3,018 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*- Copyright Blackeagle gm(dot)blackeagle(at)gmail(dot)com
 *-           Alex Wood <thetewood(at)gmail(dot)com 2016
 * Definitions for the Futaba TSOD-5711BB
 *
 * As found on the Black Artisan media center case.
 * This is a 7 digit VFD plus a load of symbols
 */
#ifndef FUTABA_H
#define FUTABA_H

/* INCLUDES-------------------------------------- */
#include <stdint.h>
#ifdef HAVE_LIBUSB_1_0
#include <libusb.h>
#define USB_DEVICE_HANDLE    libusb_device_handle
#define USB_RESET_DEVICE     libusb_reset_device
#define USB_CLOSE_DEVICE     libusb_close
#define USB_CONTROL_TRANSFER libusb_control_transfer
#else
#include <usb.h>
#define USB_DEVICE_HANDLE    usb_dev_handle
#define USB_RESET_DEVICE     usb_reset
#define USB_CLOSE_DEVICE     usb_close
#define USB_CONTROL_TRANSFER usb_control_msg
#endif

/* DEFINITIONS----------------------------------- */
#define FUTABA_REPORT_LENGTH 64
#define FUTABA_STR_LEN 60
#define FUTABA_SYM_LEN 30

/* OPCODES--------------------------------------- */
#define	FUTABA_OPCODE_SYMBOL 0x85
#define	FUTABA_OPCODE_STRING 0x8b

#define FUTABA_SYM_ON 0x01
#define FUTABA_SYM_OFF 0x00

/* SYMBOL DEFINITIONS---------------------------- */
#define FUTABA_VOLUME_START      0x02
#define FUTABA_VOLUME_BARS       11
#define FUTABA_ICON_ARRAY_LENGTH 40
/* REPORT STRUCTURE------------------------------ */

// The report definition for a string
typedef struct {
	uint8_t startPos;
	uint8_t len;
	char string[FUTABA_STR_LEN];
} futabaStringRep_t;

// The symbol report inner part looks like this
typedef struct {
	uint8_t symName;
	uint8_t state;
} futabaSymAttr_t;

// The complete symbol report
typedef struct {
	uint8_t count;
	futabaSymAttr_t symbol[FUTABA_SYM_LEN];
} futabaSymbolRep_t;

// Put it all together to get the overall structure of a report
typedef struct {
	uint8_t opcode;
	uint8_t param1;
	union {
		futabaStringRep_t str;
		futabaSymbolRep_t sym;
	} type;

} futabaReport_t;

// The driver object definition
typedef struct {
	USB_DEVICE_HANDLE *my_handle;
#ifdef HAVE_LIBUSB_1_0
	libusb_context *ctx;
#endif
} futabaDriver_t;

/* Function declarations------------------------- */
int futaba_send_report(USB_DEVICE_HANDLE * my_handle, futabaReport_t * report);

int futaba_set_volume(USB_DEVICE_HANDLE * my_handle, int volPercent);

int futaba_init_driver(Driver *drvthis);

int futaba_set_icon(Driver *drvthis);

void futaba_shutdown(Driver *drvthis);

MODULE_EXPORT int futaba_init(Driver *drvthis);
MODULE_EXPORT void futaba_close(Driver *drvthis);
MODULE_EXPORT int futaba_width(Driver *drvthis);
MODULE_EXPORT int futaba_height(Driver *drvthis);
MODULE_EXPORT void futaba_clear(Driver *drvthis);
MODULE_EXPORT void futaba_flush(Driver *drvthis);
MODULE_EXPORT void futaba_string(Driver *drvthis, int x, int y, const char string[]);
MODULE_EXPORT void futaba_chr(Driver *drvthis, int x, int y, char c);
MODULE_EXPORT void futaba_output(Driver *drvthis, uint64_t icon_map);
MODULE_EXPORT const char *futaba_get_info(Driver *drvthis);

#endif // #ifndef FUTABA_H