User manual

Instruction set
6
-- All commands will be sent using standard file IO
-- on the USB CDC port my LCD-Term is connected to.
-- On Linux it will be either "/dev/ttyACMx" or "/dev/ttyUSBx";
-- on Windows the device is "//./COMx".
f = io.open("/dev/ttyACM0", "wb")
function wait(seconds)
local start = os.clock()
repeat until os.clock() > start + seconds
end
function clear_display(f)
f:write("\27[2J")
f:flush()
wait(0.01)
end
function clear_line(f)
f:write("\27[2K")
f:flush()
wait(0.01)
end
function gotoYX(f, y, x)
-- insert y and x at their appropriate positions
-- format: ESC[y;xH
f:write(string.format("\27[%d;%dH", y, x))
f:flush()
wait(0.01)
end
-- disable inverse mode
f:write("\27[?3l")
-- enable automatic line wrap
f:write("\27[?8h")
clear_display(f)
gotoYX(f, 4, 1)
f:write("\nSome text here...\nand here...\n\nand there.")
-- enable inverse mode
f:write("\27[?3h")
-- disable automatic line wrap
f:write("\27[?8l")
-- clear first three lines
for y = 1, 3, 1 do
gotoYX(f, y, 1)
clear_line(f)
end
date_format = "%H:%M:%S %Y/%m/%d"
while true do
-- output current time
gotoYX(f, 2, 2)
f:write(os.date(date_format))
f:flush()
end
-- never reach this because of loop for infinity
f:close()
Example3.1.example1.lua