Skip to content

Commit

Permalink
Merge branch 'master' of https://gitee.com/openLuat/LuatOS
Browse files Browse the repository at this point in the history
  • Loading branch information
allewalker committed Apr 19, 2023
2 parents b1153f6 + 048075b commit 9cc4beb
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 31 deletions.
2 changes: 1 addition & 1 deletion demo/eink/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function eink_pin()
elseif rtos_bsp == "ESP32S3" then
return 2,16,15,14,13
elseif rtos_bsp == "EC618" then
return 0,1,10,8,18
return 0,1,10,8,22
else
log.info("main", "bsp not support")
return
Expand Down
2 changes: 1 addition & 1 deletion demo/sht20/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ sys.taskInit(function()
-- 按实际修改哦
local id = 0

log.info("i2c", "initial",i2c.setup(0))
log.info("i2c", "initial",i2c.setup(id))

while true do
--第一种方式
Expand Down
2 changes: 1 addition & 1 deletion demo/sht30/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ sys.taskInit(function()
-- 按实际修改哦
local id = 0

log.info("i2c", "initial",i2c.setup(0))
log.info("i2c", "initial",i2c.setup(id))

while true do
--第一种方式
Expand Down
47 changes: 19 additions & 28 deletions script/libs/netLed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ local netLed = require ("netLed")
local LEDA = gpio.setup(27,1,gpio.PULLUP) --LED引脚判断赋值结束
sys.taskInit(function()
--呼吸灯
sys.wait(5080) --延时5秒等待网络注册
log.info("mobile.status()", mobile.status())
sys.wait(5080)--延时5秒等待网络注册
log.info("mobile.status()", mobile.status())
while true do
if mobile.status() == 1 --已注册
thensys.wait(688)
netLed.setupBreateLed(LEDA)
end
end
if mobile.status() == 1--已注册
thensys.wait(688)
netLed.setupBreateLed(LEDA)
end
end
end)
]]

Expand All @@ -28,7 +28,6 @@ netLed = {}

local simError --SIM卡状态:true为异常,false或者nil为正常
local flyMode --是否处于飞行模式:true为是,false或者nil为否
local gsmRegistered --是否注册上GSM网络,true为是,false或者nil为否
local gprsAttached --是否附着上GPRS网络,true为是,false或者nil为否
local socketConnected --是否有socket连接上后台,true为是,false或者nil为否

Expand All @@ -37,8 +36,7 @@ local socketConnected --是否有socket连接上后台,true为是,false或者nil
NULL:功能关闭状态
FLYMODE:飞行模式
SIMERR:未检测到SIM卡或者SIM卡锁pin码等SIM卡异常
IDLE:未注册GSM网络
GSM:已注册GSM网络
IDLE:未注册GPRS网络
GPRS:已附着GPRS数据网络
SCK:socket已连接上后台
]]
Expand All @@ -51,7 +49,6 @@ local ledBlinkTime =
FLYMODE = {0,0xFFFF}, --常灭
SIMERR = {300,5700}, --亮300毫秒,灭5700毫秒
IDLE = {300,3700}, --亮300毫秒,灭3700毫秒
GSM = {300,1700}, --亮300毫秒,灭1700毫秒
GPRS = {300,700}, --亮300毫秒,灭700毫秒
SCK = {100,100}, --亮100毫秒,灭100毫秒
}
Expand All @@ -71,7 +68,7 @@ local LTEPIN = 26 --LTE指示灯默认PIN脚(GPIO26)
netLed.setState()
]]
function netLed.setState()
log.info("netLed.setState",ledSwitch,ledState,flyMode,simError,gsmRegistered,gprsAttached,socketConnected)
log.info("netLed.setState",ledSwitch,ledState,flyMode,simError,gprsAttached,socketConnected)
if ledSwitch then
local newState = "IDLE"
if flyMode then
Expand All @@ -82,8 +79,6 @@ netLed.setState()
newState = "SCK"
elseif gprsAttached then
newState = "GPRS"
elseif gsmRegistered then
newState = "GSM"
end
--指示灯状态发生变化
if newState~=ledState then
Expand All @@ -99,7 +94,7 @@ end
@return nil 无返回值
@usage
local LEDA = gpio.setup(27,1,gpio.PULLUP) --LED引脚判断赋值结束
netled.taskLed(LEDA)
netLed.taskLed(LEDA)
]]
function netLed.taskLed(ledPinSetFunc)
while true do
Expand Down Expand Up @@ -206,14 +201,14 @@ local netLed = require ("netLed")
local LEDA = gpio.setup(27,1,gpio.PULLUP) --LED引脚判断赋值结束
sys.taskInit(function()
--呼吸灯
sys.wait(5080) --延时5秒等待网络注册
log.info("mobile.status()", mobile.status())
sys.wait(5080)--延时5秒等待网络注册
log.info("mobile.status()", mobile.status())
while true do
if mobile.status() == 1 --已注册
thensys.wait(688)
netLed.setupBreateLed(LEDA)
end
end
if mobile.status() == 1--已注册
thensys.wait(688)
netLed.setupBreateLed(LEDA)
end
end
end)
]]
function netLed.setupBreateLed(ledPin)
Expand Down Expand Up @@ -246,13 +241,9 @@ function netLed.setupBreateLed(ledPin)
end

sys.subscribe("FLYMODE", function(mode) if flyMode~=mode then flyMode=mode netLed.setState() end end)
-- sys.subscribe("SIM_IND", function(para) if simError~=(para~="RDY") then simError=(para~="RDY") netLed.setState() end end)
sys.subscribe("SIM_IND", function(para) if simError~=(para~="RDY") and simError~=(para~="GET_NUMBER") then simError=(para~="RDY") netLed.setState() end log.info("sim status", para) end)
sys.subscribe("IP_LOSE", function() if gsmRegistered then gsmRegistered=false netLed.setState() end end)
sys.subscribe("IP_READY", function() if not gsmRegistered then gsmRegistered=true netLed.setState() end end)
sys.subscribe("IP_READY", function(ip, attach) if gprsAttached~=attach then gprsAttached=attach netLed.setState() end log.info("mobile", "IP_READY", ip, (attach or -1) == socket.LWIP_GP) end)
sys.subscribe("IP_LOSE", function() if gprsAttached then gprsAttached=false netLed.setState() end log.info("mobile", "IP_LOSE", (adapter or -1) == socket.LWIP_GP) end)
sys.subscribe("IP_READY", function(ip, adapter) if gprsAttached~=adapter then gprsAttached=adapter netLed.setState() end log.info("mobile", "IP_READY", ip, (adapter or -1) == socket.LWIP_GP) end)
sys.subscribe("SOCKET_ACTIVE", function(active) if socketConnected~=active then socketConnected=active netLed.setState() end end)
--sys.subscribe("NET_UPD_NET_MODE", function() if lteSwitch then sys.publish("LTE_LED_UPDATE",net.getNetMode()==net.NetMode_LTE) end end)


return netLed

0 comments on commit 9cc4beb

Please sign in to comment.