HelloWorld.sel

#!./Selene
-- The unavoidable "Hello world"

-- Helper
if not table.pack then
    function table.pack (...)
        return {n=select('#',...); ...}
    end
end

Selene.UseOLED()

if not arg or #arg ~=2 then
	print "Missing expected arguments :"
	print "- Screen identifier"
	print "- I2c bus to use"
	print ""
	print("Example : ", SELENE_SCRIPT_NAME .." 2 /dev/i2c-2")
	print ""

	print "Known screens :"
	print("ident","name")
	local l = table.pack( SelOLED.oled_type() )
	for _,x in ipairs(l)
	do
		print(_, x)
	end
else
	if SelOLED.Init(arg[1], arg[2]) == false then
		error("Can't open I2C Device\n")
	end

	SelOLED.Clear()
	SelOLED.SetTextSize(2)
	SelOLED.SetTextColor(1)
	SelOLED.SetCursor(10,0)
	SelOLED.Print("Hello,\n  world !")
	SelOLED.Display()

	local f,i = true, 0
	while true do
		Selene.Sleep(1)
		SelOLED.Invert(f)
		f = not f

		i = i+1
		if i%3 == 0 then
			SelOLED.Flip(f)
		end
	end
	Selene.Sleep(1)

	SelOLED.OnOff(false) -- Save display life
	SelOLED.Close()
end
generated by LDoc 1.4.6 Last updated 2022-09-05 22:24:51