INF2004-Project v0.1
 
Loading...
Searching...
No Matches
barcode.h
Go to the documentation of this file.
1
11#include <stdint.h>
12
13#ifndef BARCODE_H // Include guard.
14#define BARCODE_H
15
16// Definitions.
17// ----------------------------------------------------------------------------
18//
19
27#define BARCODE_MAX_LINES 9 // End of barcode_definitions group.
30
31#ifndef BARCODE_DEBUG_VERBOSE // Verbosity level for debug print.
36#define BARCODE_DEBUG_VERBOSE 0
37#endif
38
39#ifndef NDEBUG
44#define PICO_DEBUG_MALLOC 1
45
50#define BARCODE_DEBUG_VERBOSE 0
51#ifndef DEBUG_PRINT
57#define DEBUG_PRINT(...) printf(__VA_ARGS__) // Enable debug print.
58#endif
59#else
60#define DEBUG_PRINT(...) // Disable debug print.
61#endif
62
63// Type definitions.
64// ----------------------------------------------------------------------------
65//
66
71typedef enum
72{
73 BARCODE_CHAR_0 = 0b000110100,
74 BARCODE_CHAR_1 = 0b100100001,
75 BARCODE_CHAR_2 = 0b001100001,
76 BARCODE_CHAR_3 = 0b101100000,
77 BARCODE_CHAR_4 = 0b000110001,
78 BARCODE_CHAR_5 = 0b100110000,
79 BARCODE_CHAR_6 = 0b001110000,
80 BARCODE_CHAR_7 = 0b000100101,
81 BARCODE_CHAR_8 = 0b100100100,
82 BARCODE_CHAR_9 = 0b001100100,
83 BARCODE_CHAR_A = 0b100001001,
84 BARCODE_CHAR_B = 0b001001001,
85 BARCODE_CHAR_C = 0b101001000,
86 BARCODE_CHAR_D = 0b000011001,
87 BARCODE_CHAR_E = 0b100011000,
88 BARCODE_CHAR_F = 0b001011000,
89 BARCODE_CHAR_G = 0b000001101,
90 BARCODE_CHAR_H = 0b100001100,
91 BARCODE_CHAR_I = 0b001001100,
92 BARCODE_CHAR_J = 0b000011100,
93 BARCODE_CHAR_K = 0b100000011,
94 BARCODE_CHAR_L = 0b001000011,
95 BARCODE_CHAR_M = 0b101000010,
96 BARCODE_CHAR_N = 0b000010011,
97 BARCODE_CHAR_O = 0b100010010,
98 BARCODE_CHAR_P = 0b001010010,
99 BARCODE_CHAR_Q = 0b000000111,
100 BARCODE_CHAR_R = 0b100000110,
101 BARCODE_CHAR_S = 0b001000110,
102 BARCODE_CHAR_T = 0b000010110,
103 BARCODE_CHAR_U = 0b110000001,
104 BARCODE_CHAR_V = 0b011000001,
105 BARCODE_CHAR_W = 0b111000000,
106 BARCODE_CHAR_X = 0b010010001,
107 BARCODE_CHAR_Y = 0b110010000,
108 BARCODE_CHAR_Z = 0b011010000,
109 BARCODE_CHAR_DASH = 0b010000101,
110 BARCODE_CHAR_PERIOD = 0b110000100,
111 BARCODE_CHAR_SPACE = 0b011000100,
112 BARCODE_CHAR_DOLLAR = 0b010101000,
113 BARCODE_CHAR_SLASH = 0b010100010,
114 BARCODE_CHAR_PLUS = 0b010001010,
115 BARCODE_CHAR_PERCENT = 0b000101010,
117 = 0b010010100
119
124typedef enum
125{
132
137{
141
143
147typedef enum
148{
155
156// Public function prototypes.
157// ----------------------------------------------------------------------------
158//
159
160char barcode_get_char(barcode_char_t barcode_char);
163 barcode_line_type_t line_type);
166 barcode_line_buffer_t *p_line_buffer);
168
169#endif // BARCODE_H
170
171// End of file driver/irline/barcode.h.
barcode_char_t barcode_decode_barcode_char(barcode_line_buffer_t *p_line_buffer)
Decodes the barcode character enum from the line buffer.
Definition: barcode.c:256
char * barcode_buffer_to_binary_string(barcode_line_buffer_t *p_line_buffer)
Returns a binary string representation of the barcode line buffer.
Definition: barcode.c:287
void barcode_clear_line_buffer(barcode_line_buffer_t *p_line_buffer)
Initialises or clears the barcode line buffer.
Definition: barcode.c:238
char barcode_get_char(barcode_char_t barcode_char)
Gets the character from the barcode character enum.
Definition: barcode.c:31
barcode_read_response_t
Enum for the barcode read response. Success or error.
Definition: barcode.h:148
@ BARCODE_READ_SUCCESS
Successfully read barcode.
Definition: barcode.h:150
@ BARCODE_READ_ERROR
Error reading barcode.
Definition: barcode.h:149
@ BARCODE_READ_CONTINUE
Definition: barcode.h:151
@ BARCODE_READ_NO_OP
No operation performed.
Definition: barcode.h:153
struct barcode_line_buffer barcode_line_buffer_t
Struct that holds the 9 most recent barcode lines.
int8_t barcode_update_line_buffer(barcode_line_buffer_t *p_line_buffer, barcode_line_type_t line_type)
Updates the line buffer with the line type detected.
Definition: barcode.c:161
barcode_line_type_t
Enum for the barcode line types (black or white, thin or thick). None for error handling.
Definition: barcode.h:125
@ BARCODE_LINE_BLACK_THIN
Black thin barcode line.
Definition: barcode.h:127
@ BARCODE_LINE_BLACK_THICK
Black thick barcode line.
Definition: barcode.h:128
@ BARCODE_LINE_WHITE_THIN
White thin barcode line.
Definition: barcode.h:129
@ BARCODE_LINE_WHITE_THICK
White thick barcode line.
Definition: barcode.h:130
@ BARCODE_LINE_NONE
No barcode line detected.
Definition: barcode.h:126
barcode_char_t
Enum for the barcode characters. A 0 bit represents a thin line (white or black), while a 1 bit repre...
Definition: barcode.h:72
@ BARCODE_CHAR_V
'V' character.
Definition: barcode.h:104
@ BARCODE_CHAR_K
'K' character.
Definition: barcode.h:93
@ BARCODE_CHAR_M
'M' character.
Definition: barcode.h:95
@ BARCODE_CHAR_7
'7' character.
Definition: barcode.h:80
@ BARCODE_CHAR_W
'W' character.
Definition: barcode.h:105
@ BARCODE_CHAR_U
'U' character.
Definition: barcode.h:103
@ BARCODE_CHAR_9
'9' character.
Definition: barcode.h:82
@ BARCODE_CHAR_DOLLAR
'$' character.
Definition: barcode.h:112
@ BARCODE_CHAR_N
'N' character.
Definition: barcode.h:96
@ BARCODE_CHAR_SLASH
'/' character.
Definition: barcode.h:113
@ BARCODE_CHAR_P
'P' character.
Definition: barcode.h:98
@ BARCODE_CHAR_DASH
'-' character.
Definition: barcode.h:109
@ BARCODE_CHAR_D
'D' character.
Definition: barcode.h:86
@ BARCODE_CHAR_ASTERISK
'*' character (used as a delimiter).
Definition: barcode.h:116
@ BARCODE_CHAR_6
'6' character.
Definition: barcode.h:79
@ BARCODE_CHAR_S
'S' character.
Definition: barcode.h:101
@ BARCODE_CHAR_I
'I' character.
Definition: barcode.h:91
@ BARCODE_CHAR_2
'2' character.
Definition: barcode.h:75
@ BARCODE_CHAR_G
'G' character.
Definition: barcode.h:89
@ BARCODE_CHAR_SPACE
' ' (space) character.
Definition: barcode.h:111
@ BARCODE_CHAR_Q
'Q' character.
Definition: barcode.h:99
@ BARCODE_CHAR_T
'T' character.
Definition: barcode.h:102
@ BARCODE_CHAR_H
'H' character.
Definition: barcode.h:90
@ BARCODE_CHAR_PLUS
'+' character.
Definition: barcode.h:114
@ BARCODE_CHAR_E
'E' character.
Definition: barcode.h:87
@ BARCODE_CHAR_Y
'Y' character.
Definition: barcode.h:107
@ BARCODE_CHAR_PERCENT
'' character.
Definition: barcode.h:115
@ BARCODE_CHAR_3
'3' character.
Definition: barcode.h:76
@ BARCODE_CHAR_C
'C' character.
Definition: barcode.h:85
@ BARCODE_CHAR_4
'4' character.
Definition: barcode.h:77
@ BARCODE_CHAR_F
'F' character.
Definition: barcode.h:88
@ BARCODE_CHAR_1
'1' character.
Definition: barcode.h:74
@ BARCODE_CHAR_0
'0' character.
Definition: barcode.h:73
@ BARCODE_CHAR_O
'O' character.
Definition: barcode.h:97
@ BARCODE_CHAR_PERIOD
'.' character.
Definition: barcode.h:110
@ BARCODE_CHAR_J
'J' character.
Definition: barcode.h:92
@ BARCODE_CHAR_A
'A' character.
Definition: barcode.h:83
@ BARCODE_CHAR_L
'L' character.
Definition: barcode.h:94
@ BARCODE_CHAR_Z
'Z' character.
Definition: barcode.h:108
@ BARCODE_CHAR_R
'R' character.
Definition: barcode.h:100
@ BARCODE_CHAR_X
'X' character.
Definition: barcode.h:106
@ BARCODE_CHAR_5
'5' character.
Definition: barcode.h:78
@ BARCODE_CHAR_B
'B' character.
Definition: barcode.h:84
@ BARCODE_CHAR_8
'8' character.
Definition: barcode.h:81
char * barcode_line_to_string(barcode_line_type_t line_type)
Helper function to get the barcode line type as a string.
Definition: barcode.c:135
Struct that holds the 9 most recent barcode lines.
Definition: barcode.h:137
uint16_t line_buffer_index
Index of the line buffer.
Definition: barcode.h:140
barcode_line_type_t line_buffer[9]
Definition: barcode.h:138