INF2004-Project v0.1
 
Loading...
Searching...
No Matches
barcode.h File Reference

Header file for the barcode driver. More...

#include <stdint.h>
Include dependency graph for barcode.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  barcode_line_buffer
 Struct that holds the 9 most recent barcode lines. More...
 

Macros

#define BARCODE_DEBUG_VERBOSE   0
 Verbosity level for debug print.
 
#define BARCODE_DEBUG_VERBOSE   0
 Verbosity level for debug print.
 
#define BARCODE_MAX_LINES   9
 Maximum number of barcode lines.
 
#define DEBUG_PRINT(...)   printf(__VA_ARGS__)
 Enables debug print. More...
 
#define PICO_DEBUG_MALLOC   1
 Enables malloc debugging.
 

Typedefs

typedef struct barcode_line_buffer barcode_line_buffer_t
 Struct that holds the 9 most recent barcode lines.
 

Enumerations

enum  barcode_char_t {
  BARCODE_CHAR_0 = 0b000110100 , BARCODE_CHAR_1 = 0b100100001 , BARCODE_CHAR_2 = 0b001100001 , BARCODE_CHAR_3 = 0b101100000 ,
  BARCODE_CHAR_4 = 0b000110001 , BARCODE_CHAR_5 = 0b100110000 , BARCODE_CHAR_6 = 0b001110000 , BARCODE_CHAR_7 = 0b000100101 ,
  BARCODE_CHAR_8 = 0b100100100 , BARCODE_CHAR_9 = 0b001100100 , BARCODE_CHAR_A = 0b100001001 , BARCODE_CHAR_B = 0b001001001 ,
  BARCODE_CHAR_C = 0b101001000 , BARCODE_CHAR_D = 0b000011001 , BARCODE_CHAR_E = 0b100011000 , BARCODE_CHAR_F = 0b001011000 ,
  BARCODE_CHAR_G = 0b000001101 , BARCODE_CHAR_H = 0b100001100 , BARCODE_CHAR_I = 0b001001100 , BARCODE_CHAR_J = 0b000011100 ,
  BARCODE_CHAR_K = 0b100000011 , BARCODE_CHAR_L = 0b001000011 , BARCODE_CHAR_M = 0b101000010 , BARCODE_CHAR_N = 0b000010011 ,
  BARCODE_CHAR_O = 0b100010010 , BARCODE_CHAR_P = 0b001010010 , BARCODE_CHAR_Q = 0b000000111 , BARCODE_CHAR_R = 0b100000110 ,
  BARCODE_CHAR_S = 0b001000110 , BARCODE_CHAR_T = 0b000010110 , BARCODE_CHAR_U = 0b110000001 , BARCODE_CHAR_V = 0b011000001 ,
  BARCODE_CHAR_W = 0b111000000 , BARCODE_CHAR_X = 0b010010001 , BARCODE_CHAR_Y = 0b110010000 , BARCODE_CHAR_Z = 0b011010000 ,
  BARCODE_CHAR_DASH = 0b010000101 , BARCODE_CHAR_PERIOD = 0b110000100 , BARCODE_CHAR_SPACE = 0b011000100 , BARCODE_CHAR_DOLLAR = 0b010101000 ,
  BARCODE_CHAR_SLASH = 0b010100010 , BARCODE_CHAR_PLUS = 0b010001010 , BARCODE_CHAR_PERCENT = 0b000101010 , BARCODE_CHAR_ASTERISK = 0b010010100
}
 Enum for the barcode characters. A 0 bit represents a thin line (white or black), while a 1 bit represents a thick line. More...
 
enum  barcode_line_type_t {
  BARCODE_LINE_NONE = 0 , BARCODE_LINE_BLACK_THIN = 0b0001 , BARCODE_LINE_BLACK_THICK = 0b0011 , BARCODE_LINE_WHITE_THIN = 0b0100 ,
  BARCODE_LINE_WHITE_THICK = 0b1100
}
 Enum for the barcode line types (black or white, thin or thick). None for error handling. More...
 
enum  barcode_read_response_t { BARCODE_READ_ERROR = -1 , BARCODE_READ_SUCCESS = 0 , BARCODE_READ_CONTINUE = 1 , BARCODE_READ_NO_OP = 2 }
 Enum for the barcode read response. Success or error. More...
 

Functions

char * barcode_buffer_to_binary_string (barcode_line_buffer_t *p_line_buffer)
 Returns a binary string representation of the barcode line buffer. More...
 
void barcode_clear_line_buffer (barcode_line_buffer_t *p_line_buffer)
 Initialises or clears the barcode line buffer. More...
 
barcode_char_t barcode_decode_barcode_char (barcode_line_buffer_t *p_line_buffer)
 Decodes the barcode character enum from the line buffer. More...
 
char barcode_get_char (barcode_char_t barcode_char)
 Gets the character from the barcode character enum. More...
 
char * barcode_line_to_string (barcode_line_type_t line_type)
 Helper function to get the barcode line type as a string. More...
 
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. More...
 

Detailed Description

Header file for the barcode driver.

Author
Christopher Kok (chris.nosp@m.@for.nosp@m.celig.nosp@m.htni.nosp@m.ng.xy.nosp@m.z)
Version
0.1
Date
2023-11-22

Macro Definition Documentation

◆ DEBUG_PRINT

#define DEBUG_PRINT (   ...)    printf(__VA_ARGS__)

Enables debug print.

Parameters
...Variable arguments.

Enumeration Type Documentation

◆ barcode_char_t

Enum for the barcode characters. A 0 bit represents a thin line (white or black), while a 1 bit represents a thick line.

Enumerator
BARCODE_CHAR_0 

'0' character.

BARCODE_CHAR_1 

'1' character.

BARCODE_CHAR_2 

'2' character.

BARCODE_CHAR_3 

'3' character.

BARCODE_CHAR_4 

'4' character.

BARCODE_CHAR_5 

'5' character.

BARCODE_CHAR_6 

'6' character.

BARCODE_CHAR_7 

'7' character.

BARCODE_CHAR_8 

'8' character.

BARCODE_CHAR_9 

'9' character.

BARCODE_CHAR_A 

'A' character.

BARCODE_CHAR_B 

'B' character.

BARCODE_CHAR_C 

'C' character.

BARCODE_CHAR_D 

'D' character.

BARCODE_CHAR_E 

'E' character.

BARCODE_CHAR_F 

'F' character.

BARCODE_CHAR_G 

'G' character.

BARCODE_CHAR_H 

'H' character.

BARCODE_CHAR_I 

'I' character.

BARCODE_CHAR_J 

'J' character.

BARCODE_CHAR_K 

'K' character.

BARCODE_CHAR_L 

'L' character.

BARCODE_CHAR_M 

'M' character.

BARCODE_CHAR_N 

'N' character.

BARCODE_CHAR_O 

'O' character.

BARCODE_CHAR_P 

'P' character.

BARCODE_CHAR_Q 

'Q' character.

BARCODE_CHAR_R 

'R' character.

BARCODE_CHAR_S 

'S' character.

BARCODE_CHAR_T 

'T' character.

BARCODE_CHAR_U 

'U' character.

BARCODE_CHAR_V 

'V' character.

BARCODE_CHAR_W 

'W' character.

BARCODE_CHAR_X 

'X' character.

BARCODE_CHAR_Y 

'Y' character.

BARCODE_CHAR_Z 

'Z' character.

BARCODE_CHAR_DASH 

'-' character.

BARCODE_CHAR_PERIOD 

'.' character.

BARCODE_CHAR_SPACE 

' ' (space) character.

BARCODE_CHAR_DOLLAR 

'$' character.

BARCODE_CHAR_SLASH 

'/' character.

BARCODE_CHAR_PLUS 

'+' character.

BARCODE_CHAR_PERCENT 

'' character.

BARCODE_CHAR_ASTERISK 

'*' character (used as a delimiter).

◆ barcode_line_type_t

Enum for the barcode line types (black or white, thin or thick). None for error handling.

Enumerator
BARCODE_LINE_NONE 

No barcode line detected.

BARCODE_LINE_BLACK_THIN 

Black thin barcode line.

BARCODE_LINE_BLACK_THICK 

Black thick barcode line.

BARCODE_LINE_WHITE_THIN 

White thin barcode line.

BARCODE_LINE_WHITE_THICK 

White thick barcode line.

◆ barcode_read_response_t

Enum for the barcode read response. Success or error.

Enumerator
BARCODE_READ_ERROR 

Error reading barcode.

BARCODE_READ_SUCCESS 

Successfully read barcode.

BARCODE_READ_CONTINUE 

Successfully read barcode, but buffer is still not full.

BARCODE_READ_NO_OP 

No operation performed.

Function Documentation

◆ barcode_buffer_to_binary_string()

char * barcode_buffer_to_binary_string ( barcode_line_buffer_t p_line_buffer)

Returns a binary string representation of the barcode line buffer.

Parameters
p_line_bufferPointer to the barcode line buffer.
Returns
char* Pointer to the binary string.
Warning
The returned string needs to be freed.

References BARCODE_LINE_BLACK_THICK, BARCODE_LINE_BLACK_THIN, BARCODE_LINE_WHITE_THICK, BARCODE_LINE_WHITE_THIN, DEBUG_PRINT, barcode_line_buffer::line_buffer, and barcode_line_buffer::line_buffer_index.

◆ barcode_clear_line_buffer()

void barcode_clear_line_buffer ( barcode_line_buffer_t p_line_buffer)

Initialises or clears the barcode line buffer.

Parameters
p_line_bufferPointer to the barcode line buffer.

References barcode_line_buffer::line_buffer_index.

◆ barcode_decode_barcode_char()

barcode_char_t barcode_decode_barcode_char ( barcode_line_buffer_t p_line_buffer)

Decodes the barcode character enum from the line buffer.

Parameters
p_line_bufferPointer to the barcode line buffer.
Returns
barcode_char_t Enum representing the decoded character.

References BARCODE_LINE_BLACK_THICK, BARCODE_LINE_WHITE_THICK, barcode_line_buffer::line_buffer, and barcode_line_buffer::line_buffer_index.

◆ barcode_get_char()

◆ barcode_line_to_string()

char * barcode_line_to_string ( barcode_line_type_t  line_type)

Helper function to get the barcode line type as a string.

Parameters
line_typeBarcode line type.
Returns
char* Pointer to the barcode line type string.

References BARCODE_LINE_BLACK_THICK, BARCODE_LINE_BLACK_THIN, BARCODE_LINE_WHITE_THICK, and BARCODE_LINE_WHITE_THIN.

◆ barcode_update_line_buffer()

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.

Parameters
p_line_bufferPointer to the line type buffer.
line_typeThe line type detected.
Returns
-1 on error, 0 on success, 1 if the line type has not changed.

References BARCODE_LINE_NONE, BARCODE_LINE_WHITE_THICK, BARCODE_LINE_WHITE_THIN, BARCODE_MAX_LINES, BARCODE_READ_CONTINUE, BARCODE_READ_ERROR, BARCODE_READ_NO_OP, BARCODE_READ_SUCCESS, barcode_line_buffer::line_buffer, and barcode_line_buffer::line_buffer_index.