简介:目前HaaS EDU K1支持通过带有OLED屏幕的JS轻量级应用程序进行开发调试,原生AliOS Things已经支持图形库,因此可以尝试通过轻量级应用程序开发方法开发GUI。

来源 | HaaS技术社区

1、前言

当前HaaS EDU K1已经支持通过JS轻应用方式进行开发调试了,这块开发板带着OLED屏,而底层的AliOS Things已经支持图形库,所以可以通过轻应用的开发方式,尝试进行GUI相应的开发。

2、下载代码及环境准备

2.1、下载代码

从以下地方下载AliOS3.3版本代码:

Gitee:
Github:
Code China:

2.2、代码配置

在solutions/amp_demo中,对AMP_ADVANCED_ADDON_UI进行配置,配置如下:

AMP_ADVANCED_ADDON_UI: 1

2.3、添加轻应用代码

在solutions/javascript_demo/board/haas-edu-k1目录里面,有轻应用的示例代码:

入口文件a

{ "version": "1.0.0", "io": { "KEY1": { "type": "GPIO", "port": 23, "dir": "irq", "pull": "pullup", "intMode":"falling" }, "KEY2": { "type": "GPIO", "port": 20, "dir": "irq", "pull": "pullup", "intMode":"falling" }, "KEY3": { "type": "GPIO", "port": 21, "dir": "irq", "pull": "pullup", "intMode":"falling" }, "KEY4": { "type": "GPIO", "port": 26, "dir": "irq", "pull": "pullup", "intMode":"falling" }, "L1":{ "type":"GPIO", "port":36, "dir":"output", "pull":"pulldown" }, "L2":{ "type":"GPIO", "port":35, "dir":"output", "pull":"pulldown" }, "L3":{ "type":"GPIO", "port":34, "dir":"output", "pull":"pulldown" }, "P04":{ "type":"GPIO", "port":4, "dir":"output", "pull":"pulldown" }, "P05":{ "type":"GPIO", "port":5, "dir":"output", "pull":"pulldown" }, "P06":{ "type":"GPIO", "port":6, "dir":"output", "pull":"pulldown" }, "P07":{ "type":"GPIO", "port":7, "dir":"output", "pull":"pulldown" }, "oled_dc": { "type": "GPIO", "port": 28, "dir": "output", "pull": "pulldown" }, "oled_res": { "type": "GPIO", "port": 30, "dir": "output", "pull": "pulldown" }, "oled_spi": { "type": "SPI", "port": 1, "mode": "mode3", "freq": 26000000 }, "SPI0":{ "type": "SPI", "port": 0, "mode": "mode1", "freq": 26000000 }, "serial": { "type": "UART", "port": 2, "dataWidth": 8, "baudRate": 115200, "stopBits": 1, "flowControl": "disable", "parity": "none" }, "sensor": { "type": "I2C", "port": 1, "addrWidth": 7, "freq": 400000, "mode": "master", "devAddr": 64 }, "ADC0":{ "type": "ADC", "port": 0, "sampling": 12000000 }, "ADC1":{ "type": "ADC", "port": 1, "sampling": 12000000 }, "ADC2":{ "type": "ADC", "port": 2, "sampling": 12000000 }, "pwm1": { "type": "PWM", "port": 1 }, "PWM2":{ "type":"PWM", "port":2 }, "PWM3":{ "type":"PWM", "port":3 }, "timer1": { "type": "TIMER", "port": 1 } }, "pages": [ "data/jsamp/uipages/page/waring" ], "debugLevel": "DEBUG", "repl":"enable" } { "version": "1.0.0", "io": { "KEY1": { "type": "GPIO", "port": 23, "dir": "irq", "pull": "pullup", "intMode":"falling" }, "KEY2": { "type": "GPIO", "port": 20, "dir": "irq", "pull": "pullup", "intMode":"falling" }, "KEY3": { "type": "GPIO", "port": 21, "dir": "irq", "pull": "pullup", "intMode":"falling" }, "KEY4": { "type": "GPIO", "port": 26, "dir": "irq", "pull": "pullup", "intMode":"falling" }, "L1":{ "type":"GPIO", "port":36, "dir":"output", "pull":"pulldown" }, "L2":{ "type":"GPIO", "port":35, "dir":"output", "pull":"pulldown" }, "L3":{ "type":"GPIO", "port":34, "dir":"output", "pull":"pulldown" }, "P04":{ "type":"GPIO", "port":4, "dir":"output", "pull":"pulldown" }, "P05":{ "type":"GPIO", "port":5, "dir":"output", "pull":"pulldown" }, "P06":{ "type":"GPIO", "port":6, "dir":"output", "pull":"pulldown" }, "P07":{ "type":"GPIO", "port":7, "dir":"output", "pull":"pulldown" }, "oled_dc": { "type": "GPIO", "port": 28, "dir": "output", "pull": "pulldown" }, "oled_res": { "type": "GPIO", "port": 30, "dir": "output", "pull": "pulldown" }, "oled_spi": { "type": "SPI", "port": 1, "mode": "mode3", "freq": 26000000 }, "SPI0":{ "type": "SPI", "port": 0, "mode": "mode1", "freq": 26000000 }, "serial": { "type": "UART", "port": 2, "dataWidth": 8, "baudRate": 115200, "stopBits": 1, "flowControl": "disable", "parity": "none" }, "sensor": { "type": "I2C", "port": 1, "addrWidth": 7, "freq": 400000, "mode": "master", "devAddr": 64 }, "ADC0":{ "type": "ADC", "port": 0, "sampling": 12000000 }, "ADC1":{ "type": "ADC", "port": 1, "sampling": 12000000 }, "ADC2":{ "type": "ADC", "port": 2, "sampling": 12000000 }, "pwm1": { "type": "PWM", "port": 1 }, "PWM2":{ "type":"PWM", "port":2 }, "PWM3":{ "type":"PWM", "port":3 }, "timer1": { "type": "TIMER", "port": 1 } }, "pages": [ "data/jsamp/uipages/page/waring" ], "debugLevel": "DEBUG", "repl":"enable" }

在solutions/javascript_demo/board/haas-edu-k1/uipages/page目录里面,有轻应用的界面显示示例代码:

waring.css是配置文字的颜色,字号大小的样式示例

#waring { font-color: #ffffff; font-size: 16px; }

waring.js是逻辑交互的示例代码,目前暂时没有特殊逻辑实现,只是一些打印

var ui = require('ui'); if (!(ui && ui.redirectTo)) { throw new Error("ui: [failed] require(\'ui\')"); } Page({ onShow: function() { con('enter page onShow'); }, onExit: function() { con('enter page onExit'); }, onUpdate: function() { con('enter page onUpdate'); } });

waring.xml是界面开发的示例代码,目前是想要显示文本“boss coming”

<?xml version="1.0" encoding="utf-8"?> <page> <text id="waring" class="textClass" >boss coming</text> </page>

2.4、 编译下载

> 选择解决方案: “javascript_demo”

> 选择开发板: HaaS EDU K1

– 参考 HaaS100_Quick_Start 编译工程章节),点击 ✅ 即可完成编译固件。

– 参考 HaaS100_Quick_Start 烧录镜像章节),点击 "⚡️" 即可完成烧录固件。

3、结果展示

开发者支持

如需更多技术支持,可加入钉钉开发者群,或者关注微信公众号。

更多技术与解决方案介绍,请访问HaaS官方网站。

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

1.《如何用代码发短信显示文字》援引自互联网,旨在传递更多网络信息知识,仅代表作者本人观点,与本网站无关,侵删请联系页脚下方联系方式。

2.《如何用代码发短信显示文字》仅供读者参考,本网站未对该内容进行证实,对其原创性、真实性、完整性、及时性不作任何保证。

3.文章转载时请保留本站内容来源地址,https://www.lu-xu.com/keji/3212562.html