Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
sodomon2 committed Feb 19, 2024
1 parent ad7ef1a commit 027a0ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
18 changes: 8 additions & 10 deletions example/example.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,25 @@ local items = {

local total = 0
escpos.width = 32
local line_one = string.rep("=", escpos.width)
local line_two = string.rep("-", escpos.width)

escpos:setJustification(escpos.JUSTIFY_CENTER)
escpos:feed(1)
escpos:text("TITLE")
escpos:text("NUMBER")
escpos:text("TEST")
escpos:text("POSTAL CODE")
escpos:text("================================")
escpos:text(line_one)
escpos:setJustification(escpos.JUSTIFY_LEFT)
escpos:text(escpos:two_columns("DATE: " .. date, "HOUR: " .. hour))
escpos:text(escpos:two_columns("CODE:", math.random(100000, 900000)))
escpos:text(escpos:two_columns("CLIENT:", 'John Doe'))
escpos:feed(1)
escpos:text("================================")
escpos:feed(1)
escpos:text("DIRECTION: EXAMPLE, 238")
escpos:feed(1)
escpos:setJustification(escpos.JUSTIFY_CENTER)
escpos:text("--------------------------------")
escpos:text(line_two)
escpos:text("PRODUCTS")
escpos:text("--------------------------------")
escpos:text(line_two)
escpos:feed(1)
escpos:setJustification(escpos.JUSTIFY_LEFT)
escpos:text(escpos:three_columns("ARTICLE ", "AMOUNT", " UNIT"))
Expand All @@ -45,14 +43,14 @@ for idx, value in ipairs(items) do
total = total + tonumber(value[2])
end
escpos:feed(1)
escpos:text("--------------------------------")
escpos:text(line_two)
escpos:setEmphasis(true)
escpos:text(escpos:two_columns("TOTAL UNITS: ", total))
escpos:feed(1)
escpos:setEmphasis(false)
escpos:text("--------------------------------")
escpos:text(line_two)
escpos:text("FOOTER EXAMPLE")
escpos:text("================================")
escpos:text(line_one)
escpos:feed(1)
escpos:setJustification(escpos.JUSTIFY_CENTER)
escpos:setBarcodeHeight(40)
Expand Down
8 changes: 4 additions & 4 deletions example/qr_code.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ end
-- Demo of error correction
title("Error correction")
err_co = {
["QR_ECLEVEL_L"] = escpos.QR_ERR_CO_LEVEL_L,
["QR_ECLEVEL_M"] = escpos.QR_ERR_CO_LEVEL_M,
["QR_ECLEVEL_Q"] = escpos.QR_ERR_CO_LEVEL_Q,
["QR_ECLEVEL_H"] = escpos.QR_ERR_CO_LEVEL_H
["L"] = escpos.QR_ERR_CO_LEVEL_L,
["M"] = escpos.QR_ERR_CO_LEVEL_M,
["Q"] = escpos.QR_ERR_CO_LEVEL_Q,
["H"] = escpos.QR_ERR_CO_LEVEL_H
}

for name, ec in pairs(err_co) do
Expand Down

0 comments on commit 027a0ec

Please sign in to comment.