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

Implementation of the barcode driver. More...

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
#include "irline/ir_sensor.h"
#include "irline/barcode.h"
Include dependency graph for barcode.c:

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

Implementation of 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

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.