提交 af7acfa5 编写于 作者: E ethan.lcz 提交者: yilu.myl

add uilite demos for HaaS EDU K1 and M5StackCore2

Signed-off-by: Nethan.lcz <ethan.lcz@alibaba-inc.com>
上级 1b5dee13
......@@ -307,7 +307,7 @@ static int wifi_recvmsg_task()
static void wifi_connect_failed_cb(uint32_t event_id, const void *param, void *context)
{
NETMGR_WIFI_LOGE("%s:%d err=%d\n", __func__, __LINE__, event_id);
NETMGR_WIFI_LOGI("%s:%d err=%d\n", __func__, __LINE__, event_id);
if(event_id == RET_WIFI_INVALID_PASSWORD) {
g_handshake_failed_retry = NETMGR_WIFI_HANDSHAKE_FAILED_MAX_RETRY;
//netmgr_stat_chg_event(m, NOTIFY_WIFI_HANDSHAKE_FAILED, param);
......@@ -980,10 +980,10 @@ static int read_config_value(char** pos, const char* obj,int* line, netmgr_wifi_
*pos = pos_end;
NETMGR_WIFI_LOGI("%s:%d len :%d %s ", __func__, __LINE__, len, pos_start);
if(strncmp(obj,"ssid", 4) == 0) {
int contain_chinese = ssid_contain_chinese_check(config->ssid);
strncpy(config->ssid, pos_start, len);
config->ssid[len]='\0';
NETMGR_WIFI_LOGI("%s:%d ssid=%s\n", __func__, __LINE__, config->ssid);
int contain_chinese = ssid_contain_chinese_check(config->ssid);
if((1 == contain_chinese) && (0 != string_convert((uint8_t *)config->gbk_ssid, MAX_SSID_SIZE, (uint8_t *)config->ssid, strlen(config->ssid), UTF8_TO_GBK))) {
config->contain_chinese = true;
} else {
......@@ -1122,7 +1122,7 @@ static int get_wifi_config(const char *name, netmgr_wifi_ap_config_t* saved_ap_c
fd = open(name, O_RDONLY);
if(fd < 0) {
NETMGR_WIFI_LOGE("%s:%d open %s failed:%s\n", __func__, __LINE__, name, strerror(errno));
NETMGR_WIFI_LOGI("%s:%d open %s failed:%s\n", __func__, __LINE__, name, strerror(errno));
return -1;
}
......@@ -1227,9 +1227,10 @@ static void wifi_activation_report_task()
#ifdef MICROPY_PY_CHANNEL_ENABLE
static void py_app_ota_handle(void* arg)
{
printf("save wifi info to kv and start ota channel\n");
NETMGR_WIFI_LOGD("save wifi info to kv and start ota channel\n");
extern int save_ssid_and_password(char *ssid, char *passwd);
save_ssid_and_password(_amp_ssid, _amp_password);
usleep(1000 * 1000);
extern int on_get_url(char *url);
extern int check_channel_enable(void);
if(check_channel_enable() == 0)
......@@ -2202,7 +2203,7 @@ static int wifi_start_sta(netmgr_hdl_t hdl, netmgr_conn_t *conn, const char *ssi
if((conn->state == CONN_STATE_DISCONNECTED) ||
(conn->state == CONN_STATE_CONNECTING)) {
int ret = 0;
NETMGR_WIFI_LOGE("%s:%d start wifi\n", __func__, __LINE__);
NETMGR_WIFI_LOGI("%s:%d start wifi\n", __func__, __LINE__);
ret = ioctl(hdl, WIFI_DEV_CMD_CONNECT, &type);
if(ret != 0) {
NETMGR_WIFI_LOGE("%s:%d wifi connect failed=%d\n", __func__, __LINE__, ret);
......@@ -2418,9 +2419,9 @@ int netmgr_wifi_connect(netmgr_hdl_t hdl, netmgr_wifi_params_t *params)
/* get wifi config */
if(-1 == get_wifi_config(NETMGR_WIFI_TEMP_CONF, saved_ap_conf, READ_SPECIFIC_CONFIG)) {
if(-1 == get_wifi_config(NETMGR_WIFI_CONF, saved_ap_conf, READ_SPECIFIC_CONFIG)) {
NETMGR_WIFI_LOGE("%s:%d no temp config found\n", __func__, __LINE__);
NETMGR_WIFI_LOGI("%s:%d no temp config found\n", __func__, __LINE__);
} else {
NETMGR_WIFI_LOGE("%s:%d no config found\n", __func__, __LINE__);
NETMGR_WIFI_LOGI("%s:%d no config found\n", __func__, __LINE__);
}
}
}
......@@ -3040,7 +3041,7 @@ int netmgr_wifi_get_config(netmgr_hdl_t hdl, netmgr_wifi_config_t* config)
memset(config, 0, sizeof(netmgr_wifi_ap_config_t));
if(-1 == get_wifi_config(NETMGR_WIFI_TEMP_CONF, config, READ_ALL_CONFIG)) {
if(-1 == get_wifi_config(NETMGR_WIFI_CONF, config, READ_ALL_CONFIG)) {
NETMGR_WIFI_LOGE("%s:%d no config found\n", __func__, __LINE__);
NETMGR_WIFI_LOGI("%s:%d no config found\n", __func__, __LINE__);
return -1;
}
}
......@@ -3457,7 +3458,7 @@ static void handle_netmgr_wifi_help_cmd()
NETMGR_WIFI_LOGI("netmgr -t wifi -s\n");
NETMGR_WIFI_LOGI("netmgr -t wifi -p\n");
NETMGR_WIFI_LOGI("netmgr -t wifi -r\n");
NETMGR_WIFI_LOGI("netmgr -t wifi -w network={\\nssid=\"xxxxxx\"\\npassword=\"xxxxxxxx\"\\nchannel=\"1\"\\n}\\n");
NETMGR_WIFI_LOGI("netmgr -t wifi -w network={\\nssid=\"apple\"\\npassword=\"aos123456\"\\nchannel=\"1\"\\n}\\n");
NETMGR_WIFI_LOGI("netmgr -t wifi -d\n");
NETMGR_WIFI_LOGI("netmgr -t wifi -n 0\n");
NETMGR_WIFI_LOGI("netmgr -t wifi -e\n");
......
@page py_engine py_engine
[更正文档](https://gitee.com/alios-things/py_engine/edit/master/README.md) &emsp;&emsp;&emsp;&emsp; [贡献说明](https://help.aliyun.com/document_detail/302301.html)
[更正文档](https://gitee.com/alios-things/py_engine/edit/rel_3.3.0/README.md) &emsp;&emsp;&emsp;&emsp; [贡献说明](https://help.aliyun.com/document_detail/302301.html)
# 概述
py_engine (Python轻应用引擎) 以MicroPython为基础打造而成.可以快速实现IoT场景连云、控端、AI等最常见功能。快速上手文档和编程接口请参考[Python轻应用编程参考](https://g.alicdn.com/HaaSAI/PythonDoc/quickstart/index.html)
......@@ -80,7 +80,7 @@ def_config:
```yaml
depends:
- py_engine: master # helloworld_demo中引入py_engine组件
- py_engine: dev_aos # helloworld_demo中引入py_engine组件
```
## 步骤3 下载组件
......
......@@ -47,3 +47,11 @@ CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y
# 配置MBEDTLS 使用外部内存
CONFIG_MBEDTLS_EXTERNAL_MEM_ALLOC=y
# m5stackcore2 和nodemcu32s的wifi和lwip的配置保持一致,减少20KB内存
CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=4
CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=16
CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=8
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=8
CONFIG_LWIP_TCP_RECVMBOX_SIZE=8
CONFIG_LWIP_UDP_RECVMBOX_SIZE=8
......@@ -21,10 +21,9 @@ bt_disabled = kv.get('disable_bt')
if bt_disabled != "no":
uos.plussys_mm()
channel = kv.get('app_upgrade_channel')
if channel == "disable":
pass
else:
if channel == "enable":
import online_upgrade
online_upgrade.on(_on_get_url)
try:
......@@ -34,6 +33,14 @@ else:
print(e)
app_upgrade = kv.get('_amp_app_upgrade')
if app_upgrade == "enable":
print("App is being upgraded. It will take about 10 seconds.")
execfile('/lib/appUpgrade.py')
kv.remove('_amp_app_upgrade')
print("App upgrade finished.")
......
import uos as os
import uerrno as errno
import ujson as json
import uzlib
import upip_utarfile as tarfile
import gc
import time
import ussl
import usocket
import kv
import network
import time
file_buf = bytearray(128)
def install_pkg(package_url, install_path):
gzdict_sz = 16 + 15
f1 = url_open(package_url)
if(isinstance(f1, (str, bytes, bytearray)) == True):
return f1
try:
f2 = uzlib.DecompIO(f1, gzdict_sz)
f3 = tarfile.TarFile(fileobj=f2)
install_tar(f3, install_path)
except Exception as e:
print(e)
return("UNTAR_FILE_FAIL")
finally:
f1.close()
del f3
del f2
gc.collect()
return 'SUCCESS'
def download_save_file(file_url, fname):
global file_buf
f1 = url_open(file_url)
if(isinstance(f1, (str, bytes, bytearray)) == True):
return f1
_makedirs(fname)
with open(fname, "wb") as outf:
while True:
sz = f1.readinto(file_buf)
if not sz:
break
outf.write(file_buf, sz)
outf.close()
f1.close()
del f1
return 'SUCCESS'
def url_open(url):
proto, _, host, urlpath = url.split('/', 3)
try:
port = 443
if ":" in host:
host, port = host.split(":")
port = int(port)
ai = usocket.getaddrinfo(host, port, 0, usocket.SOCK_STREAM)
except OSError as e:
print("Error:", "Unable to resolve %s (no Internet?)" % host, e)
return 'HOST_RESOLVED_FAIL'
ai = ai[0]
s = usocket.socket(ai[0], ai[1], ai[2])
try:
s.connect(ai[-1])
if proto == "https:":
s = ussl.wrap_socket(s, server_hostname=host)
s.write("GET /%s HTTP/1.0\r\nHost: %s:%s\r\n\r\n" % (urlpath, host, port))
l = s.readline()
protover, status, msg = l.split(None, 2)
if status != b"200":
if status == b"404" or status == b"301":
return("Package not found")
else:
print("status is {}".format(status))
return(status)
while True:
l = s.readline()
if not l:
return("Unexpected EOF in HTTP headers")
if l == b'\r\n':
break
except Exception as e:
s.close()
print(e)
return('SOCKET_ERROR')
return s
def _makedirs(name, mode=0o777):
ret = False
s = ""
comps = name.rstrip("/").split("/")[:-1]
if comps[0] == "":
s = "/"
for c in comps:
if s and s[-1] != "/":
s += "/"
s += c
try:
os.mkdir(s)
ret = True
except OSError as e:
if e.args[0] != errno.EEXIST and e.args[0] != errno.EISDIR:
print(e)
ret = False
return ret
def install_tar(f, prefix):
for info in f:
fname = info.name
#try:
#fname = fname[fname.index("/") + 1:]
#except ValueError:
#fname = ""
outfname = prefix + fname
if info.type != tarfile.DIRTYPE:
_makedirs(outfname)
subf = f.extractfile(info)
save_file(outfname, subf)
def save_file(fname, subf):
global file_buf
with open(fname, "wb") as outf:
while True:
sz = subf.readinto(file_buf)
if not sz:
break
outf.write(file_buf, sz)
outf.close()
#download_save_file(url,"/data/pyamp/main.py")
def connect_wifi(ssid,passwd):
sta_if = network.WLAN(network.STA_IF)
sta_if.active(True)
sta_if.scan()
sta_if.connect(ssid,passwd)
time.sleep(5)
return sta_if.isconnected()
if __name__ == "__main__":
ssid = kv.get('_amp_wifi_ssid')
passwd = kv.get('_amp_wifi_passwd')
if isinstance(ssid,str) and isinstance(passwd,str):
if connect_wifi(ssid,passwd):
url = kv.get('_amp_pyapp_url')
if isinstance(url,str):
install_pkg(url,"/data/pyamp/")
kv.remove('_amp_pyapp_url')
import ubluetooth
import bluetooth
import struct
import json
import gc
import time
......@@ -7,7 +8,7 @@ from micropython import const
_wlan = network.WLAN(network.STA_IF)
_ble = ubluetooth.BLE()
_ble = bluetooth.BLE()
_bleNetConfigStatus = None
_ble_adv_name = 'esp-node'
_ble_tx = None
......@@ -26,19 +27,107 @@ NUS_UUID = 0xFFA0
RX_UUID = 0xFFA2
TX_UUID = 0xFFA3
BLE_NUS = ubluetooth.UUID(NUS_UUID)
BLE_RX = (ubluetooth.UUID(RX_UUID), ubluetooth.FLAG_WRITE)
BLE_TX = (ubluetooth.UUID(TX_UUID), ubluetooth.FLAG_NOTIFY | ubluetooth.FLAG_READ)
BLE_NUS = bluetooth.UUID(NUS_UUID)
BLE_RX = (bluetooth.UUID(RX_UUID), bluetooth.FLAG_WRITE)
BLE_TX = (bluetooth.UUID(TX_UUID),
bluetooth.FLAG_NOTIFY | bluetooth.FLAG_READ)
BLE_UART = (BLE_NUS, (BLE_TX, BLE_RX,))
SERVICES = [BLE_UART, ]
# Generate a payload to be passed to gap_advertise(adv_data=...).
# Helpers for generating BLE advertising payloads.
# Advertising payloads are repeated packets of the following form:
# 1 byte data length (N + 1)
# 1 byte type (see constants below)
# N bytes type-specific data
_ADV_TYPE_FLAGS = const(0x01)
_ADV_TYPE_NAME = const(0x09)
_ADV_TYPE_UUID16_COMPLETE = const(0x3)
_ADV_TYPE_UUID32_COMPLETE = const(0x5)
_ADV_TYPE_UUID128_COMPLETE = const(0x7)
_ADV_TYPE_UUID16_MORE = const(0x2)
_ADV_TYPE_UUID32_MORE = const(0x4)
_ADV_TYPE_UUID128_MORE = const(0x6)
_ADV_TYPE_APPEARANCE = const(0x19)
def advertising_payload(limited_disc=False, br_edr=False, name=None, services=None, appearance=0):
payload = bytearray()
def _append(adv_type, value):
nonlocal payload
payload += struct.pack("BB", len(value) + 1, adv_type) + value
_append(
_ADV_TYPE_FLAGS,
struct.pack("B", (0x01 if limited_disc else 0x02) +
(0x18 if br_edr else 0x04)),
)
if name:
_append(_ADV_TYPE_NAME, name)
if services:
for uuid in services:
b = bytes(uuid)
if len(b) == 2:
_append(_ADV_TYPE_UUID16_COMPLETE, b)
elif len(b) == 4:
_append(_ADV_TYPE_UUID32_COMPLETE, b)
elif len(b) == 16:
_append(_ADV_TYPE_UUID128_COMPLETE, b)
# See org.bluetooth.characteristic.gap.appearance.xml
if appearance:
_append(_ADV_TYPE_APPEARANCE, struct.pack("<h", appearance))
return payload
# region not used, but might be useful
def decode_field(payload, adv_type):
i = 0
result = []
while i + 1 < len(payload):
if payload[i + 1] == adv_type:
result.append(payload[i + 2: i + payload[i] + 1])
i += 1 + payload[i]
return result
def decode_name(payload):
n = decode_field(payload, _ADV_TYPE_NAME)
return str(n[0], "utf-8") if n else ""
def decode_services(payload):
services = []
for u in decode_field(payload, _ADV_TYPE_UUID16_COMPLETE):
services.append(bluetooth.UUID(struct.unpack("<h", u)[0]))
for u in decode_field(payload, _ADV_TYPE_UUID32_COMPLETE):
services.append(bluetooth.UUID(struct.unpack("<d", u)[0]))
for u in decode_field(payload, _ADV_TYPE_UUID128_COMPLETE):
services.append(bluetooth.UUID(u))
return services
# endregion
def send(data):
_ble.gatts_notify(0, _ble_tx, data + '\n')
def advertiser(name):
_name = bytes(name, 'UTF-8')
_ble.gap_advertise(100, bytearray('\x02\x01\x02') + bytearray((len(_name) + 1, 0x09)) + _name)
payload = advertising_payload(
name=name, services=[bluetooth.UUID(NUS_UUID)])
_ble.gap_advertise(interval_us=100, adv_data=payload)
def ble_irq(event, data):
global _ble_msg, _bleNetConfigStatus
......@@ -48,7 +137,7 @@ def ble_irq(event, data):
elif event == 2:
_bleNetConfigStatus = BLE_DISCONNECTED
advertiser("esp-node")
advertiser(_ble_adv_name)
elif event == 3:
buffer = _ble.gatts_read(_ble_rx)
......@@ -73,19 +162,22 @@ def ble_irq(event, data):
status = _wlan.status()
if(status == network.STAT_WRONG_PASSWORD):
_bleNetConfigStatus = BLE_COMMINICATING
ret = {'cmd':'WiFiCon', 'ret':{'state':'STAT_WRONG_PASSWORD'}}
ret = {'cmd': 'WiFiCon', 'ret': {
'state': 'STAT_WRONG_PASSWORD'}}
send(json.dumps(ret).encode('hex'))
_bleNetConfigStatus = BLE_CONNECTED
break
if(status == network.STAT_NO_AP_FOUND):
_bleNetConfigStatus = BLE_COMMINICATING
ret = {'cmd':'WiFiCon', 'ret':{'state':'STAT_NO_AP_FOUND'}}
ret = {'cmd': 'WiFiCon', 'ret': {
'state': 'STAT_NO_AP_FOUND'}}
send(json.dumps(ret).encode('hex'))
_bleNetConfigStatus = BLE_CONNECTED
break
if(status == network.STAT_GOT_IP):
_bleNetConfigStatus = BLE_COMMINICATING
ret = {'cmd':'WiFiCon', 'ret':{'state':'STAT_GOT_IP', 'ifconfig':_wlan.ifconfig()}}
ret = {'cmd': 'WiFiCon', 'ret': {
'state': 'STAT_GOT_IP', 'ifconfig': _wlan.ifconfig()}}
send(json.dumps(ret).encode('hex'))
_bleNetConfigStatus = BLE_CONNECTED
break
......@@ -93,7 +185,8 @@ def ble_irq(event, data):
pass
if(timeout < 0):
_bleNetConfigStatus = BLE_COMMINICATING
ret = {'cmd':'WiFiCon', 'ret':{'state':'STAT_CONNECT_TIMEOUT'}}
ret = {'cmd': 'WiFiCon', 'ret': {
'state': 'STAT_CONNECT_TIMEOUT'}}
send(json.dumps(ret).encode('hex'))
_bleNetConfigStatus = BLE_CONNECTED
break
......@@ -102,29 +195,37 @@ def ble_irq(event, data):
_ble_msg = ''
gc.collect()
# set name as start parm rather than another func like 'setName' to prevent user change name when ble processing
def start():
global _ble,_ble_tx, _ble_rx, _bleNetConfigStatus
def start(name):
global _ble, _ble_tx, _ble_rx, _bleNetConfigStatus, _ble_adv_name
_ble_adv_name = name
_ble.active(True)
((_ble_tx, _ble_rx,), ) = _ble.gatts_register_services(SERVICES)
_ble.irq(ble_irq)
advertiser(_ble_adv_name)
_bleNetConfigStatus = BLE_DISCONNECTED
def stop():
global _ble,_bleNetConfigStatus
global _ble, _bleNetConfigStatus
_ble.irq(None)
_ble.active(False)
_bleNetConfigStatus = BLE_DISCONNECTED
def getWLAN():
return _wlan
def getBleStatus():
return _bleNetConfigStatus
def getWiFiStatus():
return _wlan.status()
def getWiFiConfig():
return _wlan.ifconfig()
import axp192
import kv
import uos
try:
# for m5stack-core2 only
......@@ -24,11 +25,24 @@ def _connect_wifi(ssid, passwd):
sta_if.connect(ssid, passwd)
bt_disabled = kv.get('disable_bt')
if bt_disabled != "no":
uos.plussys_mm()
channel = kv.get('app_upgrade_channel')
if channel != "disable":
if channel == "enable":
ssid = kv.get('_amp_wifi_ssid')
passwd = kv.get('_amp_wifi_passwd')
if isinstance(ssid, str) and isinstance(passwd, str):
_connect_wifi(ssid, passwd)
import online_upgrade
online_upgrade.on(_on_get_url)
app_upgrade = kv.get('_amp_app_upgrade')
if app_upgrade == "enable":
print("App is being upgraded. It will take about 10 seconds.")
execfile('/lib/appUpgrade.py')
kv.remove('_amp_app_upgrade')
print("App upgrade finished.")
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/images/"
class Airpressure:
scr = None
iconImg = None
airpressureLable = None
unityLabel = None
tipLabel = None
def __init__(self, screen):
self.scr = screen
self.createAirpressureItem(self.scr, RESOURCES_ROOT + "airpressure.png", "Air pressure")
def createAirpressureItem(self, parent, iconPath, tips):
self.iconImg = lv.img(parent)
self.iconImg.set_src(iconPath)
self.iconImg.align(lv.ALIGN.TOP_LEFT, 0, 0)
self.airpressureLable = lv.label(parent)
self.airpressureLable.set_text("None")
self.airpressureLable.set_style_text_color(lv.color_white(), 0)
self.airpressureLable.set_style_text_font(lv.font_montserrat_48, 0)
self.airpressureLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel = lv.label(parent)
self.unityLabel.set_text(" HPA")
self.unityLabel.set_style_text_color(lv.color_white(), 0)
self.unityLabel.set_style_text_font(lv.font_montserrat_18, 0)
self.unityLabel.align_to(self.airpressureLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel = lv.label(parent)
self.tipLabel.set_text(tips)
self.tipLabel.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
self.tipLabel.set_style_text_font(lv.font_montserrat_14, 0)
self.tipLabel.align_to(self.airpressureLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setValue(self, humidity):
self.airpressureLable.set_text(str(int(humidity)))
def setXY(self, x, y):
self.iconImg.align(lv.ALIGN.TOP_LEFT, x, y)
self.airpressureLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel.align_to(self.airpressureLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel.align_to(self.airpressureLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setScale(self, scale):
print("To be done")
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/images/"
class Angle:
scr = None
iconImg = None
angleLable = None
unityLabel = None
tipLabel = None
def __init__(self, screen):
self.scr = screen
self.createAngleItem(self.scr, RESOURCES_ROOT + "angle.png", "Angle")
def createAngleItem(self, parent, iconPath, tips):
self.iconImg = lv.img(parent)
self.iconImg.set_src(iconPath)
self.iconImg.align(lv.ALIGN.TOP_LEFT, 0, 0)
self.angleLable = lv.label(parent)
self.angleLable.set_text("None")
self.angleLable.set_style_text_color(lv.color_white(), 0)
self.angleLable.set_style_text_font(lv.font_montserrat_48, 0)
self.angleLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel = lv.label(parent)
self.unityLabel.set_text(" o")
self.unityLabel.set_style_text_color(lv.color_white(), 0)
self.unityLabel.set_style_text_font(lv.font_montserrat_18, 0)
self.unityLabel.align_to(self.angleLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel = lv.label(parent)
self.tipLabel.set_text(tips)
self.tipLabel.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
self.tipLabel.set_style_text_font(lv.font_montserrat_14, 0)
self.tipLabel.align_to(self.angleLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setValue(self, humidity):
self.angleLable.set_text(str(int(humidity)))
def setXY(self, x, y):
self.iconImg.align(lv.ALIGN.TOP_LEFT, x, y)
self.angleLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel.align_to(self.angleLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel.align_to(self.angleLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setScale(self, scale):
print("To be done")
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/"
compass_ttf_alive = False
def compass_back_click_callback(e, win):
global compass_ttf_alive
if (compass_ttf_alive):
from smart_panel import load_smart_panel
load_smart_panel()
compass_ttf_alive = False
def compass_back_press_callback(e, image):
image.set_zoom(280)
def compass_back_release_callback(e, image):
image.set_zoom(250)
value = 0
class Compass:
def createPage(self):
global value
global compass_ttf_alive
print("Enter Compass")
# init scr
scr = lv.obj()
win = lv.obj(scr)
win.set_size(scr.get_width(), scr.get_height())
win.set_style_border_opa(0, 0)
win.set_style_radius(0, 0)
win.set_style_bg_color(lv.color_black(), 0)
win.clear_flag(lv.obj.FLAG.SCROLLABLE)
backImg=lv.img(win)
backImg.set_src(RESOURCES_ROOT + "images/back.png")
backImg.set_style_align(lv.ALIGN.LEFT_MID, 0)
backImg.add_flag(lv.obj.FLAG.CLICKABLE)
backImg.add_event_cb(lambda e: compass_back_click_callback(e, win), lv.EVENT.CLICKED, None)
backImg.add_event_cb(lambda e: compass_back_press_callback(e, backImg), lv.EVENT.PRESSED, None)
backImg.add_event_cb(lambda e: compass_back_release_callback(e, backImg), lv.EVENT.RELEASED, None)
backImg.set_ext_click_area(30)
# -------------- compass image ----------------
compass_dial = lv.img(win)
compass_dial.set_src(RESOURCES_ROOT + "images/compass_dial.png")
compass_dial.set_style_max_height(scr.get_height(), 0)
compass_dial.set_angle(value * 10)
compass_dial.center()
# -------------- indicator --------------------
compass_indicator = lv.img(win)
compass_indicator.set_src(RESOURCES_ROOT + "images/compass_indicator.png")
# compass_indicator.set_style_max_height(scr.get_height(), 0)
compass_indicator.set_angle(value * 10)
compass_indicator.center()
col_dsc = [35, 10, 25, lv.GRID_TEMPLATE.LAST]
row_dsc = [20, 35, 20, lv.GRID_TEMPLATE.LAST]
degreeArea = lv.obj(win)
degreeArea.set_size(95, 100)
degreeArea.set_style_bg_opa(0, 0)
degreeArea.set_style_border_opa(0, 0)
degreeArea.set_style_pad_all(0, 0)
degreeArea.set_layout(lv.LAYOUT_GRID.value)
degreeArea.set_grid_dsc_array(col_dsc, row_dsc)
degreeArea.center()
# degreeArea.set_style_pad_left(5, 0)
degreeArea.clear_flag(lv.obj.FLAG.SCROLLABLE)
red = lv.img(degreeArea)
red.set_src(RESOURCES_ROOT + "images/angle_red.png")
red.set_grid_cell(lv.GRID_ALIGN.CENTER, 0, 3, lv.GRID_ALIGN.CENTER, 0, 1)
degreeLable = lv.label(degreeArea)
degreeLable.set_text(str(value))
degreeLable.set_style_text_color(lv.color_white(), 0)
degreeLable.set_style_text_font(lv.font_montserrat_36, 0)
degreeLable.set_grid_cell(lv.GRID_ALIGN.CENTER, 0, 1, lv.GRID_ALIGN.CENTER, 1, 1)
degreeIcon = lv.img(degreeArea)
degreeIcon.set_src(RESOURCES_ROOT + "images/degree.png")
degreeIcon.set_style_pad_top(5, 0)
degreeIcon.set_grid_cell(lv.GRID_ALIGN.START, 1, 1, lv.GRID_ALIGN.START, 1, 1)
directionLable = lv.label(degreeArea)
directionLable.set_text("N")
directionLable.set_style_text_color(lv.color_white(), 0)
directionLable.set_style_text_font(lv.font_montserrat_36, 0)
directionLable.set_grid_cell(lv.GRID_ALIGN.START, 2, 1, lv.GRID_ALIGN.CENTER, 1, 1)
tips = lv.label(degreeArea)
tips.set_text("Compass")
tips.set_style_text_color(lv.color_white(), 0)
tips.set_style_text_font(lv.font_montserrat_12, 0)
tips.set_grid_cell(lv.GRID_ALIGN.CENTER, 0, 3, lv.GRID_ALIGN.CENTER, 2, 1)
from smart_panel import needAnimation
if (needAnimation):
lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.MOVE_LEFT, 500, 0, True)
else:
lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.NONE, 0, 0, True)
compass_ttf_alive = True
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/images/"
class Distance:
scr = None
iconImg = None
distanceLable = None
unityLabel = None
tipLabel = None
def __init__(self, screen):
self.scr = screen
self.createDistanceItem(self.scr, RESOURCES_ROOT + "distance.png", "DST")
def createDistanceItem(self, parent, iconPath, tips):
self.iconImg = lv.img(parent)
self.iconImg.set_src(iconPath)
self.iconImg.align(lv.ALIGN.TOP_LEFT, 0, 0)
self.distanceLable = lv.label(parent)
self.distanceLable.set_text("None")
self.distanceLable.set_style_text_color(lv.color_white(), 0)
self.distanceLable.set_style_text_font(lv.font_montserrat_48, 0)
self.distanceLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel = lv.label(parent)
self.unityLabel.set_text(" M")
self.unityLabel.set_style_text_color(lv.color_white(), 0)
self.unityLabel.set_style_text_font(lv.font_montserrat_18, 0)
self.unityLabel.align_to(self.distanceLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel = lv.label(parent)
self.tipLabel.set_text(tips)
self.tipLabel.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
self.tipLabel.set_style_text_font(lv.font_montserrat_14, 0)
self.tipLabel.align_to(self.distanceLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setValue(self, humidity):
self.distanceLable.set_text(str(int(humidity)))
def setXY(self, x, y):
self.iconImg.align(lv.ALIGN.TOP_LEFT, x, y)
self.distanceLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel.align_to(self.distanceLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel.align_to(self.distanceLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setScale(self, scale):
print("To be done")
import lvgl as lv
import utime
RESOURCES_ROOT = "S:/data/pyamp/"
def drawOver(e):
global g_clickTime
if (g_clickTime != 0):
currentTime = utime.ticks_ms()
print("create Environment page use: %dms" % int((currentTime - g_clickTime)))
g_clickTime = 0
environment_alive = False
def environment_back_click_callback(e, win):
global environment_alive
if (environment_alive):
from smart_panel import load_smart_panel
load_smart_panel()
environment_alive = False
def environment_back_press_callback(e, back_image):
back_image.set_zoom(280)
def environment_back_release_callback(e, back_image):
back_image.set_zoom(250)
class Environment:
def createPage(self):
global environment_alive
global g_clickTime
g_clickTime = utime.ticks_ms()
# init scr
scr = lv.obj()
win = lv.obj(scr)
win.set_size(scr.get_width(), scr.get_height())
win.set_style_border_opa(0, 0)
win.set_style_bg_color(lv.color_black(), 0)
win.set_style_radius(0, 0)
win.clear_flag(lv.obj.FLAG.SCROLLABLE)
win.add_event_cb(drawOver, lv.EVENT.DRAW_POST_END, None)
backImg=lv.img(win)
backImg.set_src(RESOURCES_ROOT + "images/back.png")
backImg.set_style_align(lv.ALIGN.LEFT_MID, 0)
backImg.add_flag(lv.obj.FLAG.CLICKABLE)
backImg.add_event_cb(lambda e: environment_back_click_callback(e, win), lv.EVENT.CLICKED, None)
backImg.add_event_cb(lambda e: environment_back_press_callback(e, backImg), lv.EVENT.PRESSED, None)
backImg.add_event_cb(lambda e: environment_back_release_callback(e, backImg), lv.EVENT.RELEASED, None)
backImg.set_ext_click_area(20)
container = lv.obj(win)
container.set_style_bg_opa(0, 0)
container.set_style_border_opa(0, 0)
container.set_size(lv.SIZE.CONTENT, lv.SIZE.CONTENT)
container.set_flex_flow(lv.FLEX_FLOW.COLUMN)
container.set_style_align(lv.ALIGN.CENTER, 0)
container.set_style_pad_left(0, 0)
self.createItem(container, RESOURCES_ROOT + "images/temperature.png", "25",
RESOURCES_ROOT + "images/centigrade_l.png", "Temperature")
self.createInterval(container, 25)
self.createItem(container, RESOURCES_ROOT + "images/humidity.png", "41 %", "", "Humidity")
from smart_panel import needAnimation
if (needAnimation):
lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.MOVE_LEFT, 500, 0, True)
else:
lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.NONE, 0, 0, True)
environment_alive = True
currentTime = utime.ticks_ms()
print("run python code use: %dms" % int((currentTime - g_clickTime)))
def createItem(self, parent, iconPath, value, unityPath, tips):
col_dsc = [lv.GRID.CONTENT, 5, lv.GRID.CONTENT, lv.GRID.CONTENT, lv.GRID_TEMPLATE.LAST]
row_dsc = [lv.GRID.CONTENT, lv.GRID.CONTENT, lv.GRID_TEMPLATE.LAST]
cont = lv.obj(parent)
cont.set_style_bg_opa(0, 0)
cont.set_style_border_opa(0, 0)
cont.set_style_pad_all(0, 0)
cont.set_size(lv.SIZE.CONTENT, lv.SIZE.CONTENT)
cont.set_style_grid_column_dsc_array(col_dsc, 0)
cont.set_style_grid_row_dsc_array(row_dsc, 0)
cont.set_layout(lv.LAYOUT_GRID.value)
img = lv.img(cont)
img.set_src(iconPath)
img.set_grid_cell(lv.GRID_ALIGN.START, 0, 1, lv.GRID_ALIGN.CENTER, 0, 2)
label = lv.label(cont)
label.set_text(value)
label.set_style_text_color(lv.color_white(), 0)
label.set_style_text_font(lv.font_montserrat_48, 0)
label.set_style_pad_all(0, 0)
label.set_grid_cell(lv.GRID_ALIGN.START, 2, 1, lv.GRID_ALIGN.CENTER, 0, 1)
if (unityPath.strip()):
iconImg = lv.img(cont)
iconImg.set_src(unityPath)
iconImg.set_zoom(205)
iconImg.set_style_pad_bottom(0, 0)
iconImg.set_grid_cell(lv.GRID_ALIGN.START, 3, 1, lv.GRID_ALIGN.CENTER, 0, 1)
tip = lv.label(cont)
tip.set_text(tips)
tip.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
tip.set_grid_cell(lv.GRID_ALIGN.START, 2, 2, lv.GRID_ALIGN.START, 1, 1)
def createInterval(self, parent, size):
interval = lv.obj(parent)
interval.set_style_bg_opa(0, 0)
interval.set_style_border_opa(0, 0)
interval.set_height(size)
interval.set_width(0)
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/images/"
class Fm:
scr = None
iconImg = None
fmLable = None
unityLabel = None
tipLabel = None
def __init__(self, screen):
self.scr = screen
self.createFmItem(self.scr, RESOURCES_ROOT + "FM.png", "FM")
def createFmItem(self, parent, iconPath, tips):
self.iconImg = lv.img(parent)
self.iconImg.set_src(iconPath)
self.iconImg.align(lv.ALIGN.TOP_LEFT, 0, 0)
self.fmLable = lv.label(parent)
self.fmLable.set_text("None")
self.fmLable.set_style_text_color(lv.color_white(), 0)
self.fmLable.set_style_text_font(lv.font_montserrat_48, 0)
self.fmLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel = lv.label(parent)
self.unityLabel.set_text(" MHz")
self.unityLabel.set_style_text_color(lv.color_white(), 0)
self.unityLabel.set_style_text_font(lv.font_montserrat_18, 0)
self.unityLabel.align_to(self.fmLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel = lv.label(parent)
self.tipLabel.set_text(tips)
self.tipLabel.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
self.tipLabel.set_style_text_font(lv.font_montserrat_14, 0)
self.tipLabel.align_to(self.fmLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setValue(self, humidity):
self.fmLable.set_text(str(int(humidity)))
def setXY(self, x, y):
self.iconImg.align(lv.ALIGN.TOP_LEFT, x, y)
self.fmLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel.align_to(self.fmLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel.align_to(self.fmLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setScale(self, scale):
print("To be done")
import lvgl as lv
font_not_load_16 = True
info_16 = None
style_16 = None
def set_text_size_16(parent):
global font_not_load_16
global info_16
global style_16
if (font_not_load_16):
info_16 = lv.ft_info_t()
info_16.name ="/data/pyamp/font/AlibabaPuHuiTiM_16.ttf"
info_16.weight = 16
info_16.style = lv.FT_FONT_STYLE.NORMAL
info_16.font_init()
style_16 = lv.style_t()
style_16.init()
style_16.set_text_font(info_16.font)
font_not_load_16 = False
parent.add_style(style_16, 0)
font_not_load_20 = True
info_20 = None
style_20 = None
def set_text_size_20(parent):
global font_not_load_20
global info_20
global style_20
if (font_not_load_20):
info_20 = lv.ft_info_t()
info_20.name ="/data/pyamp/font/AlibabaPuHuiTiM_20.ttf"
info_20.weight = 20
info_20.style = lv.FT_FONT_STYLE.NORMAL
info_20.font_init()
style_20 = lv.style_t()
style_20.init()
style_20.set_text_font(info_20.font)
font_not_load_20 = False
parent.add_style(style_20, 0)
font_not_load_22 = True
info_22 = None
style_22 = None
def set_text_size_22(parent):
global font_not_load_22
global info_22
global style_22
if (font_not_load_22):
info_22 = lv.ft_info_t()
info_22.name ="/data/pyamp/font/AlibabaPuHuiTiM_22.ttf"
info_22.weight = 22
info_22.style = lv.FT_FONT_STYLE.NORMAL
info_22.font_init()
style_22 = lv.style_t()
style_22.init()
style_22.set_text_font(info_22.font)
font_not_load_22 = False
parent.add_style(style_22, 0)
font_not_load_38 = True
info_38 = None
style_38 = None
def set_text_size_38(parent):
global font_not_load_38
global info_38
global style_38
if (font_not_load_38):
info_38 = lv.ft_info_t()
info_38.name ="/data/pyamp/font/AlibabaPuHuiTiM_38.ttf"
info_38.weight = 38
info_38.style = lv.FT_FONT_STYLE.NORMAL
info_38.font_init()
style_38 = lv.style_t()
style_38.init()
style_38.set_text_font(info_38.font)
font_not_load_38 = False
parent.add_style(style_38, 0)
def set_text_size(parent, size):
if (size == 38):
set_text_size_38(parent)
elif (size == 22):
set_text_size_22(parent)
elif (size == 20):
set_text_size_20(parent)
else:
set_text_size_16(parent)
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/images/"
class Gas:
scr = None
iconImg = None
gasLable = None
unityLabel = None
tipLabel = None
def __init__(self, screen):
self.scr = screen
self.createGasItem(self.scr, RESOURCES_ROOT + "gas.png", "Nature Gas")
def createGasItem(self, parent, iconPath, tips):
self.iconImg = lv.img(parent)
self.iconImg.set_src(iconPath)
self.iconImg.align(lv.ALIGN.TOP_LEFT, 0, 0)
self.gasLable = lv.label(parent)
self.gasLable.set_text("None")
self.gasLable.set_style_text_color(lv.color_white(), 0)
self.gasLable.set_style_text_font(lv.font_montserrat_48, 0)
self.gasLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel = lv.label(parent)
self.unityLabel.set_text(" %LEL")
self.unityLabel.set_style_text_color(lv.color_white(), 0)
self.unityLabel.set_style_text_font(lv.font_montserrat_18, 0)
self.unityLabel.align_to(self.gasLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel = lv.label(parent)
self.tipLabel.set_text(tips)
self.tipLabel.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
self.tipLabel.set_style_text_font(lv.font_montserrat_14, 0)
self.tipLabel.align_to(self.gasLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setValue(self, humidity):
self.gasLable.set_text(str(int(humidity)))
def setXY(self, x, y):
self.iconImg.align(lv.ALIGN.TOP_LEFT, x, y)
self.gasLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel.align_to(self.gasLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel.align_to(self.gasLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setScale(self, scale):
print("To be done")
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/images/"
class Hcho:
scr = None
iconImg = None
hchoLable = None
unityLabel = None
tipLabel = None
def __init__(self, screen):
self.scr = screen
self.createHchoItem(self.scr, RESOURCES_ROOT + "hcho.png", "PA")
def createHchoItem(self, parent, iconPath, tips):
self.iconImg = lv.img(parent)
self.iconImg.set_src(iconPath)
self.iconImg.align(lv.ALIGN.TOP_LEFT, 0, 0)
self.hchoLable = lv.label(parent)
self.hchoLable.set_text("None")
self.hchoLable.set_style_text_color(lv.color_white(), 0)
self.hchoLable.set_style_text_font(lv.font_montserrat_48, 0)
self.hchoLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel = lv.label(parent)
self.unityLabel.set_text(" mg/m3")
self.unityLabel.set_style_text_color(lv.color_white(), 0)
self.unityLabel.set_style_text_font(lv.font_montserrat_18, 0)
self.unityLabel.align_to(self.hchoLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel = lv.label(parent)
self.tipLabel.set_text(tips)
self.tipLabel.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
self.tipLabel.set_style_text_font(lv.font_montserrat_14, 0)
self.tipLabel.align_to(self.hchoLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setValue(self, humidity):
self.hchoLable.set_text(str(int(humidity)))
def setXY(self, x, y):
self.iconImg.align(lv.ALIGN.TOP_LEFT, x, y)
self.hchoLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel.align_to(self.hchoLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel.align_to(self.hchoLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setScale(self, scale):
print("To be done")
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/images/"
class Heartrate:
scr = None
iconImg = None
heartrateLable = None
unityLabel = None
tipLabel = None
def __init__(self, screen):
self.scr = screen
self.createHeartrateItem(self.scr, RESOURCES_ROOT + "heartrate.png", "HR")
def createHeartrateItem(self, parent, iconPath, tips):
self.iconImg = lv.img(parent)
self.iconImg.set_src(iconPath)
self.iconImg.align(lv.ALIGN.TOP_LEFT, 0, 0)
self.heartrateLable = lv.label(parent)
self.heartrateLable.set_text("None")
self.heartrateLable.set_style_text_color(lv.color_white(), 0)
self.heartrateLable.set_style_text_font(lv.font_montserrat_48, 0)
self.heartrateLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel = lv.label(parent)
self.unityLabel.set_text(" BPM")
self.unityLabel.set_style_text_color(lv.color_white(), 0)
self.unityLabel.set_style_text_font(lv.font_montserrat_18, 0)
self.unityLabel.align_to(self.heartrateLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel = lv.label(parent)
self.tipLabel.set_text(tips)
self.tipLabel.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
self.tipLabel.set_style_text_font(lv.font_montserrat_14, 0)
self.tipLabel.align_to(self.heartrateLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setValue(self, humidity):
self.heartrateLable.set_text(str(int(humidity)))
def setXY(self, x, y):
self.iconImg.align(lv.ALIGN.TOP_LEFT, x, y)
self.heartrateLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel.align_to(self.heartrateLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel.align_to(self.heartrateLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setScale(self, scale):
print("To be done")
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/images/"
class Humidity:
scr = None
iconImg = None
humidityLable = None
unityLabel = None
tipLabel = None
def __init__(self, screen):
self.scr = screen
self.createHumidityItem(self.scr, RESOURCES_ROOT + "humidity.png", "TDS")
def createHumidityItem(self, parent, iconPath, tips):
self.iconImg = lv.img(parent)
self.iconImg.set_src(iconPath)
self.iconImg.align(lv.ALIGN.TOP_LEFT, 0, 0)
self.humidityLable = lv.label(parent)
self.humidityLable.set_text("None")
self.humidityLable.set_style_text_color(lv.color_white(), 0)
self.humidityLable.set_style_text_font(lv.font_montserrat_48, 0)
self.humidityLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel = lv.label(parent)
self.unityLabel.set_text(" PPM")
self.unityLabel.set_style_text_color(lv.color_white(), 0)
self.unityLabel.set_style_text_font(lv.font_montserrat_18, 0)
self.unityLabel.align_to(self.humidityLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel = lv.label(parent)
self.tipLabel.set_text(tips)
self.tipLabel.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
self.tipLabel.set_style_text_font(lv.font_montserrat_14, 0)
self.tipLabel.align_to(self.humidityLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setValue(self, humidity):
self.humidityLable.set_text(str(int(humidity)))
def setXY(self, x, y):
self.iconImg.align(lv.ALIGN.TOP_LEFT, x, y)
self.humidityLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel.align_to(self.humidityLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel.align_to(self.humidityLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setScale(self, scale):
print("To be done")
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/"
environment_alive = False
functionImage = [
RESOURCES_ROOT + "images/refrigeration.png",
RESOURCES_ROOT + "images/heating.png",
RESOURCES_ROOT + "images/dehumidification.png",
RESOURCES_ROOT + "images/ventilation.png"]
functionImageSelected = [
RESOURCES_ROOT + "images/refrigeration_selected.png",
RESOURCES_ROOT + "images/heating_selected.png",
RESOURCES_ROOT + "images/dehumidification_selected.png",
RESOURCES_ROOT + "images/ventilation_selected.png"]
currentFunc = 0
currentSelected = None
hvac_alive = False
def hvac_back_click_callback(e, win):
global hvac_alive
if (hvac_alive):
from smart_panel import load_smart_panel
load_smart_panel()
hvac_alive = False
def hvac_back_press_callback(e, image):
image.set_zoom(280)
def hvac_back_release_callback(e, image):
image.set_zoom(250)
def sub_pressed_cb(e, self):
print("sub")
if (self.value > 16):
self.value -= 1
print("value %d" % (self.value))
self.label.set_text(str(self.value))
def add_pressed_cb(e, self):
print("add")
if (self.value < 30):
self.value += 1
print("value %d" % (self.value))
self.label.set_text(str(self.value))
def func_pressed_cb(e, index):
global currentFunc
global currentSelected
print(index)
if (index != currentFunc):
currentSelected.set_src(functionImage[currentFunc])
selectedImage = e.get_target()
currentFunc = index
selectedImage.set_src(functionImageSelected[currentFunc])
currentSelected = selectedImage
class Hvac:
value = 25
def createPage(self):
global currentFunc
global currentSelected
global hvac_alive
print("Enter Hvac")
# init scr
scr = lv.obj()
win = lv.obj(scr)
win.set_size(scr.get_width(), scr.get_height())
win.set_style_border_opa(0, 0)
win.set_style_radius(0, 0)
win.set_style_bg_color(lv.color_black(), 0)
win.clear_flag(lv.obj.FLAG.SCROLLABLE)
# --------- value container ---------
col_dsc = [60, 65, 40, 60, lv.GRID_TEMPLATE.LAST]
row_dsc = [48, lv.GRID_TEMPLATE.LAST]
valueLayout = lv.obj(win)
valueLayout.set_layout(lv.LAYOUT_GRID.value)
valueLayout.set_style_bg_opa(0, 0)
valueLayout.set_style_border_opa(0, 0)
valueLayout.set_size(lv.SIZE.CONTENT, lv.SIZE.CONTENT)
valueLayout.set_grid_align(lv.GRID_ALIGN.SPACE_BETWEEN, lv.GRID_ALIGN.SPACE_BETWEEN)
valueLayout.set_style_grid_column_dsc_array(col_dsc, 0)
valueLayout.set_style_grid_row_dsc_array(row_dsc, 0)
valueLayout.set_style_pad_top(20, 0)
valueLayout.set_style_align(lv.ALIGN.TOP_MID, 0)
# ----------- - --------------
subImage = lv.img(valueLayout)
subImage.set_src(RESOURCES_ROOT + "images/subtraction.png")
subImage.set_grid_cell(lv.GRID_ALIGN.START, 0, 1, lv.GRID_ALIGN.CENTER, 0, 1)
subImage.add_flag(lv.obj.FLAG.CLICKABLE)
subImage.add_event_cb(lambda e: sub_pressed_cb(e, self), lv.EVENT.PRESSED, None)
# subImage.add_event_cb(lambda e: hvac_back_press_callback(e, subImage), lv.EVENT.PRESSED, None)
# subImage.add_event_cb(lambda e: hvac_back_release_callback(e, subImage), lv.EVENT.RELEASED, None)
subImage.set_ext_click_area(40)
# ----------- value -----------
self.label = lv.label(valueLayout)
self.label.set_text(str(self.value))
self.label.set_style_text_color(lv.color_white(), 0)
self.label.set_style_text_font(lv.font_montserrat_48, 0)
self.label.set_grid_cell(lv.GRID_ALIGN.CENTER, 1, 1, lv.GRID_ALIGN.CENTER, 0, 1)
# ----------- ºC ------------
centigradeImage = lv.img(valueLayout)
centigradeImage.set_src(RESOURCES_ROOT + "images/centigrade_s.png")
centigradeImage.set_style_pad_bottom(8, 0)
centigradeImage.set_grid_cell(lv.GRID_ALIGN.START, 2, 1, lv.GRID_ALIGN.END, 0, 1)
# ----------- + ----------------
addImage = lv.img(valueLayout)
addImage.set_src(RESOURCES_ROOT + "images/addition.png")
addImage.set_grid_cell(lv.GRID_ALIGN.CENTER, 3, 1, lv.GRID_ALIGN.CENTER, 0, 1)
addImage.add_flag(lv.obj.FLAG.CLICKABLE)
addImage.add_event_cb(lambda e: add_pressed_cb(e, self), lv.EVENT.PRESSED, None)
# addImage.add_event_cb(lambda e: hvac_back_press_callback(e, addImage), lv.EVENT.PRESSED, None)
# addImage.add_event_cb(lambda e: hvac_back_release_callback(e, addImage), lv.EVENT.RELEASED, None)
addImage.set_ext_click_area(40)
# ----------- tips ----------
tips = lv.label(win)
tips.set_text("Temperature")
tips.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
tips.set_style_pad_bottom(20, 0)
tips.set_align(lv.ALIGN.CENTER)
# ----------- function ----------
func_col_dsc = [70, 70, 70, 70, lv.GRID_TEMPLATE.LAST]
func_row_dsc = [40, lv.GRID_TEMPLATE.LAST]
funcContainer = lv.obj(win)
funcContainer.set_style_bg_opa(0, 0)
funcContainer.set_style_border_opa(0, 0)
funcContainer.set_grid_dsc_array(func_col_dsc, func_row_dsc)
funcContainer.set_width(300)
funcContainer.set_height(90)
funcContainer.set_layout(lv.LAYOUT_GRID.value)
funcContainer.set_align(lv.ALIGN.BOTTOM_MID)
funcContainer.set_grid_align(lv.GRID_ALIGN.SPACE_BETWEEN, lv.GRID_ALIGN.SPACE_BETWEEN)
image = lv.img(funcContainer)
image.set_src(functionImage[0])
image.add_flag(lv.obj.FLAG.CLICKABLE)
image.set_ext_click_area(20)
image.add_event_cb(lambda e: func_pressed_cb(e, 0), lv.EVENT.PRESSED, None)
image.set_grid_cell(lv.GRID_ALIGN.CENTER, 0, 1, lv.GRID_ALIGN.CENTER, 0, 1)
currentSelected = image
currentSelected.set_src(functionImageSelected[0])
image1 = lv.img(funcContainer)
image1.set_src(functionImage[1])
image1.add_flag(lv.obj.FLAG.CLICKABLE)
image1.set_ext_click_area(20)
image1.add_event_cb(lambda e: func_pressed_cb(e, 1), lv.EVENT.PRESSED, None)
image1.set_grid_cell(lv.GRID_ALIGN.CENTER, 1, 1, lv.GRID_ALIGN.CENTER, 0, 1)
image2 = lv.img(funcContainer)
image2.set_src(functionImage[2])
image2.add_flag(lv.obj.FLAG.CLICKABLE)
image2.set_ext_click_area(20)
image2.add_event_cb(lambda e: func_pressed_cb(e, 2), lv.EVENT.PRESSED, None)
image2.set_grid_cell(lv.GRID_ALIGN.CENTER, 2, 1, lv.GRID_ALIGN.CENTER, 0, 1)
image3 = lv.img(funcContainer)
image3.set_src(functionImage[3])
image3.add_flag(lv.obj.FLAG.CLICKABLE)
image3.set_ext_click_area(20)
image3.add_event_cb(lambda e: func_pressed_cb(e, 3), lv.EVENT.PRESSED, None)
image3.set_grid_cell(lv.GRID_ALIGN.CENTER, 3, 1, lv.GRID_ALIGN.CENTER, 0, 1)
# for i in range(4):
# image = lv.img(funcContainer)
# image.set_src(functionImage[i])
# image.add_flag(lv.obj.FLAG.CLICKABLE)
# image.set_ext_click_area(20)
# image.add_event_cb(lambda e: func_pressed_cb(e, i), lv.EVENT.PRESSED, None)
# image.set_grid_cell(lv.GRID_ALIGN.CENTER, i, 1, lv.GRID_ALIGN.CENTER, 0, 1)
# if (currentFunc == i):
# currentSelected = image
# currentSelected.set_src(functionImageSelected[i])
backImg=lv.img(win)
backImg.set_src(RESOURCES_ROOT + "images/back.png")
backImg.set_style_align(lv.ALIGN.LEFT_MID, 0)
backImg.add_flag(lv.obj.FLAG.CLICKABLE)
backImg.add_event_cb(lambda e: hvac_back_click_callback(e, win), lv.EVENT.CLICKED, None)
backImg.add_event_cb(lambda e: hvac_back_press_callback(e, backImg), lv.EVENT.PRESSED, None)
backImg.add_event_cb(lambda e: hvac_back_release_callback(e, backImg), lv.EVENT.RELEASED, None)
backImg.set_ext_click_area(20)
from smart_panel import needAnimation
if (needAnimation):
lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.MOVE_LEFT, 500, 0, True)
else:
lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.NONE, 0, 0, True)
hvac_alive = True
import lvgl as lv
RESOURCES_ROOT = "S:/data/pyamp/images/"
class Lux:
scr = None
iconImg = None
luxLable = None
unityLabel = None
tipLabel = None
def __init__(self, screen):
self.scr = screen
self.createLuxItem(self.scr, RESOURCES_ROOT + "lux.png", "Brightness")
def createLuxItem(self, parent, iconPath, tips):
self.iconImg = lv.img(parent)
self.iconImg.set_src(iconPath)
self.iconImg.align(lv.ALIGN.TOP_LEFT, 0, 0)
self.luxLable = lv.label(parent)
self.luxLable.set_text("None")
self.luxLable.set_style_text_color(lv.color_white(), 0)
self.luxLable.set_style_text_font(lv.font_montserrat_48, 0)
self.luxLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel = lv.label(parent)
self.unityLabel.set_text(" %LEL")
self.unityLabel.set_style_text_color(lv.color_white(), 0)
self.unityLabel.set_style_text_font(lv.font_montserrat_18, 0)
self.unityLabel.align_to(self.luxLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel = lv.label(parent)
self.tipLabel.set_text(tips)
self.tipLabel.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
self.tipLabel.set_style_text_font(lv.font_montserrat_14, 0)
self.tipLabel.align_to(self.luxLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setValue(self, humidity):
self.luxLable.set_text(str(int(humidity)))
def setXY(self, x, y):
self.iconImg.align(lv.ALIGN.TOP_LEFT, x, y)
self.luxLable.align_to(self.iconImg, lv.ALIGN.OUT_RIGHT_TOP, 0, 0)
self.unityLabel.align_to(self.luxLable, lv.ALIGN.OUT_RIGHT_BOTTOM, 0, -5)
self.tipLabel.align_to(self.luxLable, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 0)
def setScale(self, scale):
print("To be done")
import display_driver
import page_welcome
page_welcome.load_page()
import lvgl as lv
from audio import Player
RESOURCES_ROOT = "S:/data/pyamp/"
functionImage = [
RESOURCES_ROOT + "images/prev.png",
RESOURCES_ROOT + "images/play.png",
RESOURCES_ROOT + "images/next.png",
RESOURCES_ROOT + "images/favorite.png"]
currentMusic = 0
musicData = [
{
"title":"Counting Stars",
"album":"OneRepublic",
"album_url": RESOURCES_ROOT + "images/album_one_republic.jpg",
"url":"file://data/pyamp/audio/test_long.mp3",
"duration":11,
"favorite": False
},
{
"title":"Aube",
"album":"Darius",
"album_url": RESOURCES_ROOT + "images/album_darius.jpg",
"url":"file://data/pyamp/audio/test_long.mp3",
"duration":155,
"favorite": False
},
]
start = False
anim = None
playedTime = None
slider = None
anim_timeline = None
player = None
durationTime = 0
currentValue = 0
image = [None, None, None, None]
albumCover = None
songTitle = None
albumTitle = None
totalTime = None
music_alive = False
def music_back_click_callback(e, win):
global anim_timeline
global start
global player
global music_alive
start = False
# stop animation
if (anim_timeline != None):
lv.anim_timeline_stop(anim_timeline)
lv.anim_timeline_del(anim_timeline)
anim_timeline = None
if (player != None):
player.pause()
player.close()
player = None
# load smart panel desktop
if (music_alive):
from smart_panel import load_smart_panel
load_smart_panel()
music_alive = False
def music_back_press_callback(e, image):
image.set_zoom(280)
def music_back_release_callback(e, image):
image.set_zoom(250)
def setLabelValue(label, value):
global slider
global anim
global start
global anim_timeline
global durationTime
minute = value / 60
second = value % 60
# if (slider.is_dragged() == True):
# print("drag: %d" % value)
# start = False
#
# lv.anim_timeline_stop(anim_timeline)
# lv.anim_timeline_del(anim_timeline)
# anim_timeline = None
#
# slider.set_value(value, lv.ANIM.ON)
# anim.set_time((durationTime - currentValue) * 1000)
# anim.set_values(currentValue, durationTime)
# anim_timeline = lv.anim_timeline_create()
# lv.anim_timeline_add(anim_timeline, 0, anim)
label.set_text('%02d:%02d'%(minute, second))
def setSpentTime(slider, value):
global playedTime
global currentValue
global durationTime
global image
global start
global anim_timeline
global player
global albumCover
global songTitle
global albumTitle
global totalTime
global currentMusic
global musicData
if (value >= durationTime):
# currentMusic += 1
# if (len(musicData) == currentMusic):
# currentMusic = 0
start = False
reset_music()
else:
currentValue = value
setLabelValue(playedTime, value)
slider.set_value(value, lv.ANIM.ON)
def cb(data):
print(data)
def reset_music():
global albumCover
global songTitle
global albumTitle
global totalTime
global musicData
global currentMusic
global durationTime
global slider
global anim
global image
global start
global currentValue
global anim_timeline
global playedTime
global player
if (anim_timeline != None):
lv.anim_timeline_stop(anim_timeline)
lv.anim_timeline_del(anim_timeline)
anim_timeline = None
albumCover.set_src(musicData[currentMusic]["album_url"])
songTitle.set_text(musicData[currentMusic]["title"])
albumTitle.set_text(musicData[currentMusic]["album"])
durationTime = musicData[currentMusic]["duration"]
currentValue = 0
slider.set_range(0, durationTime)
slider.set_value(0, lv.ANIM.ON)
anim.set_time(durationTime * 1000)
anim.set_values(0, durationTime)
anim_timeline = lv.anim_timeline_create()
lv.anim_timeline_add(anim_timeline, 0, anim)
setLabelValue(totalTime, durationTime)
setLabelValue(playedTime, 0)
if (player != None):
player.pause()
player.close()
player = None
if (start == False):
image[1].set_src(RESOURCES_ROOT + "images/play.png")
else:
image[1].set_src(RESOURCES_ROOT + "images/pause.png")
lv.anim_timeline_start(anim_timeline)
player = Player()
player.open()
# player.play(musicData[currentMusic]["url"], sync=False)
player.on(cb)
if (musicData[currentMusic]["favorite"] == False):
image[3].set_src(RESOURCES_ROOT + "images/favorite.png")
else:
image[3].set_src(RESOURCES_ROOT + "images/favorited.png")
def controller_click_cb(e, func):
global anim
global start
global anim_timeline
global durationTime
global player
global image
global currentValue
global musicData
global currentMusic
print(func, anim_timeline)
if (func == "play"):
if (start == False):
start = True
if (currentValue == durationTime):
currentValue = 0
anim.set_time((durationTime - currentValue) * 1000)
anim.set_values(currentValue, durationTime)
anim_timeline = lv.anim_timeline_create()
lv.anim_timeline_add(anim_timeline, 0, anim)
lv.anim_timeline_start(anim_timeline)
image[1].set_src(RESOURCES_ROOT + "images/pause.png")
if (player == None):
player = Player()
player.open()
# player.play(musicData[currentMusic]["url"], sync=False)
player.on(cb)
else:
player.resume()
# state = player.getState()
# print(state)
# if (state == 2):
# player.resume()
# image[1].set_src(RESOURCES_ROOT + "images/pause.png")
# else:
# player.pause()
# image[1].set_src(RESOURCES_ROOT + "images/play.png")
else:
start = False
image[1].set_src(RESOURCES_ROOT + "images/play.png")
lv.anim_timeline_stop(anim_timeline)
lv.anim_timeline_del(anim_timeline)
anim_timeline = None
anim.set_time((durationTime - currentValue) * 1000)
anim.set_values(currentValue, durationTime)
anim_timeline = lv.anim_timeline_create()
lv.anim_timeline_add(anim_timeline, 0, anim)
player.pause()
elif (func == "fav"):
if (musicData[currentMusic]["favorite"] == False):
image[3].set_src(RESOURCES_ROOT + "images/favorited.png")
musicData[currentMusic]["favorite"] = True
else:
musicData[currentMusic]["favorite"] = False
image[3].set_src(RESOURCES_ROOT + "images/favorite.png")
elif (func == "next"):
currentMusic += 1
if (len(musicData) == currentMusic):
currentMusic = 0
reset_music()
elif (func == "prev"):
currentMusic -= 1
if (currentMusic < 0):
currentMusic = len(musicData) - 1
reset_music()
class Music:
def createPage(self):
global anim
global playedTime
global durationTime
global slider
global audio_src
global player
global image
global music_alive
global currentMusic
global albumCover
global songTitle
global albumTitle
global totalTime
global anim_timeline
global scr
print("Enter Music")
# init scr
scr = lv.obj()
win = lv.obj(scr)
win.set_size(scr.get_width(), scr.get_height())
win.set_style_border_opa(0, 0)
win.set_style_radius(0, 0)
win.set_style_bg_color(lv.color_black(), 0)
win.clear_flag(lv.obj.FLAG.SCROLLABLE)
backImg=lv.img(win)
backImg.set_src(RESOURCES_ROOT + "images/back.png")
backImg.set_style_align(lv.ALIGN.LEFT_MID, 0)
backImg.add_flag(lv.obj.FLAG.CLICKABLE)
backImg.add_event_cb(lambda e: music_back_click_callback(e, win), lv.EVENT.CLICKED, None)
backImg.add_event_cb(lambda e: music_back_press_callback(e, backImg), lv.EVENT.PRESSED, None)
backImg.add_event_cb(lambda e: music_back_release_callback(e, backImg), lv.EVENT.RELEASED, None)
backImg.set_ext_click_area(30)
albumCover = lv.img(win)
albumCover.set_style_pad_left(12, 0)
albumCover.set_style_pad_top(10, 0)
songTitle = lv.label(win)
songTitle.set_style_text_font(lv.font_montserrat_20, 0)
songTitle.set_style_text_color(lv.color_white(), 0)
songTitle.align_to(albumCover, lv.ALIGN.TOP_LEFT, 130, 3)
albumTitle = lv.label(win)
albumTitle.set_style_text_font(lv.font_montserrat_16, 0)
albumTitle.set_style_text_color(lv.color_make(0xCC, 0xCC, 0xCC), 0)
albumTitle.align_to(songTitle, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 12)
props = [lv.STYLE.BG_COLOR, 0]
transition_dsc = lv.style_transition_dsc_t()
transition_dsc.init(props, lv.anim_t.path_linear, 300, 0, None)
style_main = lv.style_t()
style_indicator = lv.style_t()
style_pressed_color = lv.style_t()
style_main.init()
style_main.set_bg_opa(lv.OPA.COVER)
style_main.set_bg_color(lv.color_make(0x66, 0x66, 0x66))
style_main.set_radius(lv.RADIUS.CIRCLE)
style_main.set_line_dash_width(1)
style_indicator.init()
style_indicator.set_bg_opa(lv.OPA.COVER)
style_indicator.set_bg_color(lv.color_white())
style_indicator.set_radius(lv.RADIUS.CIRCLE)
style_indicator.set_transition(transition_dsc)
style_pressed_color.init()
style_pressed_color.set_bg_color(lv.color_white())
# Create a slider and add the style
slider = lv.slider(win)
slider.remove_style_all() # Remove the styles coming from the theme
slider.add_style(style_main, lv.PART.MAIN)
slider.add_style(style_indicator, lv.PART.INDICATOR)
slider.add_style(style_pressed_color, lv.PART.INDICATOR | lv.STATE.PRESSED)
slider.align_to(albumTitle, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 25)
slider.set_size(140, 1)
anim = lv.anim_t()
anim.init()
anim.set_var(slider)
playedTime = lv.label(win)
setLabelValue(playedTime, 0)
playedTime.set_style_text_font(lv.font_montserrat_16, 0)
playedTime.set_style_text_color(lv.color_white(), 0)
playedTime.align_to(slider, lv.ALIGN.OUT_BOTTOM_LEFT, 0, 15)
totalTime = lv.label(win)
totalTime.set_style_text_font(lv.font_montserrat_16, 0)
totalTime.set_style_text_color(lv.color_white(), 0)
totalTime.align_to(slider, lv.ALIGN.OUT_BOTTOM_RIGHT, 0, 15)
func_col_dsc = [80, 80, 80, 80, lv.GRID_TEMPLATE.LAST]
func_row_dsc = [40, lv.GRID_TEMPLATE.LAST]
funcContainer = lv.obj(win)
funcContainer.set_style_bg_opa(0x00, 0)
funcContainer.set_style_border_opa(0x00, 0)
funcContainer.set_layout(lv.LAYOUT_GRID.value)
funcContainer.set_grid_dsc_array(func_col_dsc, func_row_dsc)
funcContainer.set_grid_align(lv.GRID_ALIGN.SPACE_BETWEEN, lv.GRID_ALIGN.SPACE_BETWEEN)
funcContainer.set_align(lv.ALIGN.BOTTOM_MID)
funcContainer.set_size(320, 70)
for i in range(4):
image[i] = lv.img(funcContainer)
image[i].set_src(functionImage[i])
image[i].add_flag(lv.obj.FLAG.CLICKABLE)
image[i].set_ext_click_area(20)
image[i].set_grid_cell(lv.GRID_ALIGN.CENTER, i, 1, lv.GRID_ALIGN.CENTER, 0, 1)
if (i == 0):
image[i].add_event_cb(lambda e: controller_click_cb(e, "prev"), lv.EVENT.CLICKED, None)
elif (i == 1):
image[i].add_event_cb(lambda e: controller_click_cb(e, "play"), lv.EVENT.CLICKED, None)
elif (i == 2):
image[i].add_event_cb(lambda e: controller_click_cb(e, "next"), lv.EVENT.CLICKED, None)
elif (i == 3):
image[i].add_event_cb(lambda e: controller_click_cb(e, "fav"), lv.EVENT.CLICKED, None)
anim.set_custom_exec_cb(lambda a1, val: setSpentTime(slider, val))
reset_music()
from smart_panel import needAnimation
if (needAnimation):
lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.MOVE_LEFT, 500, 0, True)
else:
lv.scr_load_anim(scr, lv.SCR_LOAD_ANIM.NONE, 0, 0, True)
music_alive = True
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册