Skip to content

Bar-code type 39

The bar-code type 39 turns a text into a bar-code, including the leading and ending *.

Configure

Warning

Ensure the bar-code 39 library is included and initialised according to the configuration procedure.

As a function, the bar-code 39 element requires no configuration.

Use

1
2
3
4
5
6
bool result = codeBar39(&myScreen,
    0, dy,
    "ABC-1234",
    32,
    myColours.black, myColours.white,
    false);

The required parameters are

  • The first line sets the link to the screen;

  • The second line sets the x-y coordinates of the top-left corner of the code-bar;

  • The third line provides the text.

The optional parameters are

  • The fourth line sets the height of the bars, with 32 pixels as default;

  • The fifth line specifies the colours for the front and the background, with black on white as default;

  • The sixth line displays the text below the bar-code, with false as default.

codeBar39 returns RESULT_SUCCESS if successful, RESULT_ERROR otherwise. The most common cause of error is an overflow due to a text too long.

uint16_t dz = getCodeBar39Size("ABC-1234");

getSizeCodeBar39() returns the width of the bar-code in pixels.

Example

This is the core of the code from example Code_Bar39.ino.

void displayCodeBar39()
{
    myScreen.setOrientation(myOrientation);

    uint16_t x, y, dx, dy, dz;
    uint8_t result;

    x = myScreen.screenSizeX();
    y = myScreen.screenSizeY();
    dx = x / 5;
    dy = y / 5;

    myScreen.selectFont(fontMedium);
    myScreen.gText(0, 0, "Bar-code type 39");

    myScreen.selectFont(fontMedium);
    myScreen.gText(0, 4 * dy, "*ABC-1234*");

    dz = getSizeCodeBar39("ABC-1234");
    result = codeBar39(&myScreen, (x - dz) / 2, dy, "ABC-1234", 32, myColours.black, myColours.white, true);
    if (result == RESULT_SUCCESS)
    {
        myScreen.flushFast();
    }
}