/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */ /* * Copyright (c) 2005 Henk Vergonet <[email protected]> */ #ifndef MAP_TO_7SEGMENT_H #define MAP_TO_7SEGMENT_H /* This file provides translation primitives and tables for the conversion * of (ASCII) characters to a 7-segments notation. * * The 7 segment's wikipedia notation below is used as standard. * See: https://en.wikipedia.org/wiki/Seven_segment_display * * Notation: +-a-+ * f b * +-g-+ * e c * +-d-+ * * Usage: * * Register a map variable, and fill it with a character set: * static SEG7_DEFAULT_MAP(map_seg7); * * * Then use for conversion: * seg7 = map_to_seg7(&map_seg7, some_char); * ... * * In device drivers it is recommended, if required, to make the char map * accessible via the sysfs interface using the following scheme: * * static ssize_t map_seg7_show(struct device *dev, * struct device_attribute *attr, char *buf) * { * memcpy(buf, &map_seg7, sizeof(map_seg7)); * return sizeof(map_seg7); * } * static ssize_t map_seg7_store(struct device *dev, * struct device_attribute *attr, const char *buf, * size_t cnt) * { * if(cnt != sizeof(map_seg7)) * return -EINVAL; * memcpy(&map_seg7, buf, cnt); * return cnt; * } * static DEVICE_ATTR_RW(map_seg7); * * History: * 2005-05-31 RFC [email protected] */ #include <linux/errno.h> #define BIT_SEG7_A … #define BIT_SEG7_B … #define BIT_SEG7_C … #define BIT_SEG7_D … #define BIT_SEG7_E … #define BIT_SEG7_F … #define BIT_SEG7_G … #define BIT_SEG7_RESERVED … struct seg7_conversion_map { … }; static __inline__ int map_to_seg7(struct seg7_conversion_map *map, int c) { … } #define SEG7_CONVERSION_MAP(_name, _map) … /* * It is recommended to use a facility that allows user space to redefine * custom character sets for LCD devices. Please use a sysfs interface * as described above. */ #define MAP_TO_SEG7_SYSFS_FILE … /******************************************************************************* * ASCII conversion table ******************************************************************************/ #define _SEG7(l,a,b,c,d,e,f,g) … #define _MAP_0_32_ASCII_SEG7_NON_PRINTABLE … #define _MAP_33_47_ASCII_SEG7_SYMBOL … #define _MAP_48_57_ASCII_SEG7_NUMERIC … #define _MAP_58_64_ASCII_SEG7_SYMBOL … #define _MAP_65_90_ASCII_SEG7_ALPHA_UPPR … #define _MAP_91_96_ASCII_SEG7_SYMBOL … #define _MAP_97_122_ASCII_SEG7_ALPHA_LOWER … #define _MAP_123_126_ASCII_SEG7_SYMBOL … /* Maps */ /* This set tries to map as close as possible to the visible characteristics * of the ASCII symbol, lowercase and uppercase letters may differ in * presentation on the display. */ #define MAP_ASCII7SEG_ALPHANUM … /* This set tries to map as close as possible to the symbolic characteristics * of the ASCII character for maximum discrimination. * For now this means all alpha chars are in lower case representations. * (This for example facilitates the use of hex numbers with uppercase input.) */ #define MAP_ASCII7SEG_ALPHANUM_LC … #define SEG7_DEFAULT_MAP(_name) … #endif /* MAP_TO_7SEGMENT_H */