GithubHelp home page GithubHelp logo

chenmins / luatos Goto Github PK

View Code? Open in Web Editor NEW

This project forked from openluat/luatos

0.0 2.0 0.0 815 KB

LuatOS -- Lua base RTOS, build for many embedded systems. LuatOS是运行在嵌入式硬件的实时操作系统

Home Page: https://openluat.github.io/LuatOS/

License: MIT License

Python 0.16% C 96.11% C++ 1.18% Lua 2.55%

luatos's Introduction

LuatOS logo

license rtt-w60x ci qemu ci stm32f103re ci issue

LuatOS是运行在嵌入式硬件的实时操作系统,只需要少量内存的flash空间就能运行,用户编写lua代码就可完成各种功能

Lua base RTOS, build for many embedded systems

  1. 基于Lua 5.3.5
  2. 低内存需求, 最低32kb, 96kb flash空间
  3. 硬件抽象层兼容M3/arm/risc-v等
  4. 可测试,可模拟(qemu)
  5. 在线升级
  6. 可裁剪,可扩展

QQ群: 1061642968


总体架构

总体架构

代码示例节选

详细代码请查阅 script/app/playit/main.lua

local sys = require("sys")

sys.subscribe("WLAN_READY", function ()
    print("!!! wlan ready event !!!")
    -- 马上进行时间同步
    socket.ntpSync()
end)

disp.init("ssd1306")
display_str("Booting ...")

-- 配网回调
sys.subscribe("WLAN_PW_RE", function(ssid, password)
    if ssid then
        log.info(TAG, "airkiss GOT", ssid, password)
        local conf = {ssid=ssid,password=password}
        json.encodeFile(conf, "/wlan.json")
    else
        log.info(TAG, "airkiss fail")
    end
end)

-- 业务流程, 联网后定时发送温度数据到服务器
sys.taskInit(function()
    while 1 do
        if wlan.ready() == 1 then
            sys.wait(1000)
            local temp = (sensor.ds18b20(28) or "")
            display_str("Temp: " .. temp  .. " rssi:" .. tostring(wlan.rssi()))
            local t = {"GET /api/w60x/report/ds18b20?mac=", wlan.get_mac(), "&temp=", temp, " HTTP/1.0\r\n",
                    "Host: site0.cn\r\n",
                    "User-Agent: LuatOS/0.1.0\r\n",
                        "\r\n"}
            socket.tsend("site0.cn", 80, table.concat(t))
            log.info("network", "tsend complete, sleep 5s")
            sys.wait(5000)
        else
            log.warn("main", "wlan is not ready yet")
            sys.waitUntil("WLAN_READY", 30000)
        end
    end
end)

-- 主循环, 必须加
sys.run()

资源


配套

TODO: 构建工具链,IDE,刷机工具,等等

使用到的开源项目

授权协议

MIT License

luatos's People

Contributors

wendal avatar chenxuuu avatar snailbao avatar findlayfeng avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.