lv_uidemo.py 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. import PikaStdLib
  2. import pika_lvgl as lv
  3. import time
  4. class MyMeter:
  5. def __init__(self,
  6. parent,
  7. label_text="label",
  8. value=0,
  9. value_set=0,
  10. unit="°C"):
  11. container = lv.obj(parent)
  12. container.set_size(200, 250)
  13. container.clear_flag(lv.obj.FLAG.SCROLLABLE)
  14. container.set_style_bg_opa(lv.OPA.TRANSP, 0)
  15. container.set_style_border_width(0, 0)
  16. meter = lv.meter(container)
  17. meter.align(lv.ALIGN.TOP_MID, 0, -20)
  18. meter.set_size(200, 200)
  19. # Add a scale first
  20. scale = meter.add_scale()
  21. meter.set_scale_ticks(
  22. scale, 51, 2, 10, lv.palette_main(lv.PALETTE.GREY))
  23. meter.set_scale_major_ticks(scale, 10, 4, 15, lv.color_black(), 10)
  24. indic = lv.meter_indicator_t()
  25. # Add a blue arc to the start
  26. indic = meter.add_arc(scale, 3, lv.palette_main(lv.PALETTE.BLUE), 0)
  27. meter.set_indicator_start_value(indic, 0)
  28. meter.set_indicator_end_value(indic, 20)
  29. # Make the tick lines blue at the start of the scale
  30. indic = meter.add_scale_lines(scale, lv.palette_main(
  31. lv.PALETTE.BLUE), lv.palette_main(lv.PALETTE.BLUE), False, 0)
  32. meter.set_indicator_start_value(indic, 0)
  33. meter.set_indicator_end_value(indic, 20)
  34. # Add a red arc to the end
  35. indic = meter.add_arc(scale, 3, lv.palette_main(lv.PALETTE.RED), 0)
  36. meter.set_indicator_start_value(indic, 80)
  37. meter.set_indicator_end_value(indic, 100)
  38. # Make the tick lines red at the end of the scale
  39. indic = meter.add_scale_lines(scale, lv.palette_main(
  40. lv.PALETTE.RED), lv.palette_main(lv.PALETTE.RED), False, 0)
  41. meter.set_indicator_start_value(indic, 80)
  42. meter.set_indicator_end_value(indic, 100)
  43. # Add a needle line indicator
  44. indic = meter.add_needle_line(
  45. scale, 4, lv.palette_main(lv.PALETTE.GREY), -10)
  46. label = lv.label(meter)
  47. label.set_text(label_text + unit)
  48. label.align(lv.ALIGN.CENTER, 0, -20)
  49. value_label = lv.label(meter)
  50. value_label.align(lv.ALIGN.CENTER, 0, 60)
  51. value_set_input = InputBox(container, label_text="given", unit=unit)
  52. value_set_input.align(lv.ALIGN.BOTTOM_MID, 0, 20)
  53. self.container = container
  54. self.lv_meter = meter
  55. self.value_label = value_label
  56. self.indic = indic
  57. self.unit = unit
  58. self.set_value(value)
  59. def align(self, align, x, y):
  60. self.container.align(align, x, y)
  61. def set_value(self, value):
  62. # str_value = "%.1f" % value
  63. str_value = str(value)
  64. self.value_label.set_text(str_value + " " + self.unit)
  65. self.lv_meter.set_indicator_end_value(self.indic, value)
  66. class InputBox:
  67. def __init__(self, parent, label_text="label", value='0.0', unit="", box_num=1, box_width=80):
  68. self.input_box_list = []
  69. container = lv.obj(parent)
  70. container.set_size(110 + box_width * box_num, 50)
  71. container.clear_flag(lv.obj.FLAG.SCROLLABLE)
  72. container.set_style_bg_opa(lv.OPA.TRANSP, 0)
  73. container.set_style_border_width(0, 0)
  74. label = lv.label(container)
  75. label.set_text(label_text)
  76. label.align(lv.ALIGN.LEFT_MID, 0, 0)
  77. for i in range(box_num):
  78. input_box = lv.textarea(container)
  79. input_box.set_size(box_width, 40)
  80. input_box.align(lv.ALIGN.LEFT_MID, 40 + box_width*i, 0)
  81. input_box.clear_flag(lv.obj.FLAG.SCROLLABLE)
  82. input_box.set_one_line(True)
  83. self.input_box_list.append(input_box)
  84. input_box.set_text(value)
  85. input_box.add_event_cb(self.event_cb, lv.EVENT.FOCUSED, None)
  86. unit_label = lv.label(container)
  87. unit_label.set_text(unit)
  88. unit_label.align(lv.ALIGN.LEFT_MID, 50 + box_width*box_num, 0)
  89. self.container = container
  90. def align(self, align, x, y):
  91. self.container.align(align, x, y)
  92. def set_size(self, width, height):
  93. self.container.set_size(width, height)
  94. def event_cb(self, e):
  95. code = e.get_code()
  96. ta = e.get_target()
  97. # kb: KeyBoard = global_dict["keyboard"]
  98. # if code == lv.EVENT.FOCUSED:
  99. # kb.set_hiden(False)
  100. # kb.set_textarea(ta)
  101. # if code == lv.EVENT.DEFOCUSED:
  102. # kb.set_textarea(None)
  103. class ProcessCount:
  104. def __init__(self, parent, label_text="label", value=0, totle=0):
  105. container = lv.obj(parent)
  106. container.set_size(150, 40)
  107. container.clear_flag(lv.obj.FLAG.SCROLLABLE)
  108. label = lv.label(container)
  109. label.set_text(label_text)
  110. label.align(lv.ALIGN.BOTTOM_MID, 0, 0)
  111. value_label = lv.label(container)
  112. value_label.align(lv.ALIGN.TOP_MID, 0, 0)
  113. self.container = container
  114. self.value_label = value_label
  115. self.set_value(value, totle)
  116. def align(self, align, x, y):
  117. self.container.align(align, x, y)
  118. def set_value(self, value, totle):
  119. self.value_label.set_text(str(value) + " / " + str(totle))
  120. class TimerView:
  121. def __init__(self,
  122. parent,
  123. label_text="label",
  124. seconds_this=0,
  125. seconds_totle=0):
  126. self.seconds_this = seconds_this
  127. self.seconds_totle = seconds_totle
  128. container = lv.obj(parent)
  129. container.set_size(200, 80)
  130. container.clear_flag(lv.obj.FLAG.SCROLLABLE)
  131. label = lv.label(container)
  132. label.set_text(label_text)
  133. label.align(lv.ALIGN.TOP_MID, 0, -10)
  134. label_this = lv.label(container)
  135. label_this.align(lv.ALIGN.TOP_MID, 0, 10)
  136. label_totle = lv.label(container)
  137. label_totle.align(lv.ALIGN.TOP_MID, 0, 30)
  138. self.container = container
  139. self.label_this = label_this
  140. self.label_totle = label_totle
  141. self.set_value(seconds_this, seconds_totle)
  142. def align(self, align, x, y):
  143. self.container.align(align, x, y)
  144. def set_value(self, seconds_this, seconds_totle):
  145. self.label_this.set_text(
  146. "time now" + str(seconds_this//60) + " min " + str(seconds_this % 60) + " s")
  147. self.label_totle.set_text(
  148. "time total " + str(seconds_totle//60) + " min " + str(seconds_totle % 60) + " s")
  149. class PIDPanel:
  150. def __init__(self, parent, label_text="label"):
  151. container = lv.obj(parent)
  152. container.set_size(300, 300)
  153. container.clear_flag(lv.obj.FLAG.SCROLLABLE)
  154. label = lv.label(container)
  155. label.set_text(label_text)
  156. label.align(lv.ALIGN.TOP_MID, 0, 0)
  157. label_partition = InputBox(container, label_text="partition")
  158. label_partition.align(lv.ALIGN.TOP_LEFT, 20, 20)
  159. label_top = lv.label(container)
  160. label_top.set_text("top partition")
  161. label_bottom = lv.label(container)
  162. label_bottom.set_text("bottom partition")
  163. label_top.align(lv.ALIGN.TOP_MID, 0, 80)
  164. label_bottom.align(lv.ALIGN.TOP_MID, 0, 160)
  165. input_box_P_top = InputBox(container, label_text="P")
  166. input_box_P_top.align(lv.ALIGN.TOP_LEFT, -20, 100)
  167. input_box_I_top = InputBox(container, label_text="I")
  168. input_box_I_top.align(lv.ALIGN.TOP_LEFT, 110, 100)
  169. input_box_P_bottom = InputBox(container, label_text="P")
  170. input_box_P_bottom.align(lv.ALIGN.TOP_LEFT, -20, 180)
  171. input_box_I_bottom = InputBox(container, label_text="I")
  172. input_box_I_bottom.align(lv.ALIGN.TOP_LEFT, 110, 180)
  173. self.container = container
  174. def align(self, align, x, y):
  175. self.container.align(align, x, y)
  176. def set_size(self, width, height):
  177. self.container.set_size(width, height)
  178. class Button:
  179. def __init__(self, parent, label_text="label"):
  180. btn = lv.btn(parent)
  181. btn.set_size(100, 50)
  182. btn.clear_flag(lv.obj.FLAG.SCROLLABLE)
  183. btn.set_style_bg_color(lv.color_white(), 0)
  184. btn.set_style_text_color(lv.color_black(), 0)
  185. btn.set_style_border_color(lv.color_black(), 0)
  186. label = lv.label(btn)
  187. label.set_text(label_text)
  188. label.align(lv.ALIGN.CENTER, 0, 0)
  189. self.is_on = False
  190. self.btn = btn
  191. self.label = label
  192. def align(self, align, x, y):
  193. self.btn.align(align, x, y)
  194. def set_text(self, text):
  195. self.label.set_text(text)
  196. def set_is_on(self, is_on):
  197. self.is_on = is_on
  198. def _event_cb_adapter(self, e):
  199. code = e.get_code()
  200. print("btn event:", self.label.get_text(), code)
  201. self.event_cb(self, e)
  202. def add_event_cb(self, event_cb, event_type, user_data=None):
  203. self.event_cb = event_cb
  204. self.btn.add_event_cb(self._event_cb_adapter, event_type, user_data)
  205. def set_size(self, width, height):
  206. self.btn.set_size(width, height)
  207. class ProcessBar:
  208. def __init__(self, parent, value=0):
  209. bar = lv.bar(parent)
  210. bar.remove_style_all() # To have a clean start
  211. bar.add_style(bar_style_bg, 0)
  212. bar.add_style(bar_style_indic, lv.PART.INDICATOR)
  213. bar.set_size(200, 40)
  214. self.bar = bar
  215. self.style_bg = bar_style_bg
  216. self.style_indic = bar_style_indic
  217. self.set_value(value)
  218. def align(self, align, x, y):
  219. self.bar.align(align, x, y)
  220. def set_value(self, value, anim=lv.ANIM.ON):
  221. self.bar.set_value(value, anim)
  222. def tab1_btnbar1_event_cb(self: "BtnProcessBar", e):
  223. if self.btn.is_on:
  224. self.btn.set_is_on(False)
  225. self.btn.set_text("start")
  226. self.bar.set_value(0)
  227. else:
  228. self.btn.set_is_on(True)
  229. self.btn.set_text("stop")
  230. self.bar.set_value(100)
  231. class BtnProcessBar:
  232. def __init__(self, parent, label_text="label", value=0):
  233. container = lv.obj(parent)
  234. container.set_size(350, 80)
  235. container.clear_flag(lv.obj.FLAG.SCROLLABLE)
  236. container.set_style_bg_opa(lv.OPA.TRANSP, 0)
  237. # 无边框
  238. container.set_style_border_width(0, 0)
  239. btn = Button(container, label_text=label_text)
  240. bar = ProcessBar(container, value=value)
  241. btn.align(lv.ALIGN.LEFT_MID, 0, 0)
  242. bar.align(lv.ALIGN.RIGHT_MID, 0, 0)
  243. self.container = container
  244. self.btn = btn
  245. self.bar = bar
  246. def align(self, align, x, y):
  247. self.container.align(align, x, y)
  248. def _event_cb_adapter(self, e):
  249. self.event_cb(self, e)
  250. def add_event_cb(self, event_cb, event_type, user_data=None):
  251. self.event_cb = event_cb
  252. self.btn.btn.add_event_cb(
  253. self._event_cb_adapter, event_type, user_data)
  254. class Chart:
  255. def __init__(self, parent, label_text="label"):
  256. container = lv.obj(parent)
  257. container.set_size(900, 450)
  258. container.clear_flag(lv.obj.FLAG.SCROLLABLE)
  259. container.set_style_bg_opa(lv.OPA.TRANSP, 0)
  260. container.set_style_border_width(0, 0)
  261. label = lv.label(container)
  262. label.set_text(label_text)
  263. label.align(lv.ALIGN.TOP_MID, 0, -20)
  264. chart = lv.chart(container)
  265. chart.set_size(800, 400)
  266. chart.align(lv.ALIGN.CENTER, 0, 0)
  267. chart.set_type(lv.chart.TYPE.LINE) # Show lines and points too
  268. # Add two data series
  269. ser1 = chart.add_series(lv.palette_main(
  270. lv.PALETTE.RED), lv.chart.AXIS.PRIMARY_Y)
  271. chart.set_axis_tick(lv.chart.AXIS.PRIMARY_Y, 10, 5, 6, 2, True, 50)
  272. chart.set_axis_tick(lv.chart.AXIS.PRIMARY_X, 10, 5, 6, 2, True, 50)
  273. # Set next points on ser1
  274. chart.set_next_value(ser1, 10)
  275. chart.set_next_value(ser1, 10)
  276. chart.set_next_value(ser1, 10)
  277. chart.set_next_value(ser1, 10)
  278. chart.set_next_value(ser1, 10)
  279. chart.set_next_value(ser1, 10)
  280. chart.set_next_value(ser1, 10)
  281. chart.set_next_value(ser1, 30)
  282. chart.set_next_value(ser1, 70)
  283. chart.set_next_value(ser1, 90)
  284. chart.refresh()
  285. self.container = container
  286. def align(self, align, x, y):
  287. self.container.align(align, x, y)
  288. class KeyBoard:
  289. def __init__(self, parent, label_text="label", is_number=True):
  290. container = lv.obj(parent)
  291. if is_number:
  292. width = 300
  293. else:
  294. width = 600
  295. container.set_size(width, 360)
  296. container.clear_flag(lv.obj.FLAG.SCROLLABLE)
  297. # container.set_style_bg_opa(lv.OPA.TRANSP, 0)
  298. # container.set_style_border_width(0, 0)
  299. label = lv.label(container)
  300. label.set_text(label_text)
  301. label.align(lv.ALIGN.TOP_MID, 0, 0)
  302. kb = lv.keyboard(container)
  303. kb.set_size(width, 300)
  304. kb.align(lv.ALIGN.BOTTOM_MID, 0, 20)
  305. # kb.add_event_cb(self.event_cb, lv.EVENT.ALL, None)
  306. if is_number:
  307. kb.set_mode(lv.keyboard.MODE.NUMBER)
  308. else:
  309. kb.set_mode(lv.keyboard.MODE.TEXT_LOWER)
  310. close_btn = Button(container, label_text="close")
  311. close_btn.set_size(40, 40)
  312. close_btn.align(lv.ALIGN.TOP_RIGHT, 0, -10)
  313. close_btn.btn.add_event_cb(
  314. self.close_btn_event_cb, lv.EVENT.CLICKED, None)
  315. container.add_event_cb(
  316. self.drag_event_cb, lv.EVENT.ALL, None)
  317. self.is_hidden = True
  318. self.container = container
  319. self.close_btn = close_btn
  320. self.kb = kb
  321. def close_btn_event_cb(self, e):
  322. self.set_hiden(True)
  323. def drag_event_cb(self, e):
  324. code = e.get_code()
  325. if code == lv.EVENT.PRESSED:
  326. indev = lv.indev_get_act()
  327. self.drag_start_point = indev.get_point()
  328. self.container_start_x = self.container.get_x()
  329. self.container_start_y = self.container.get_y()
  330. self.container.set_align(lv.ALIGN.TOP_LEFT)
  331. # print("drag start", self.drag_start_point.x, self.drag_start_point.y)
  332. if code == lv.EVENT.PRESSING:
  333. indev = lv.indev_get_act()
  334. drag_point = indev.get_point()
  335. # print("drag", drag_point.x, drag_point.y)
  336. self.container.set_pos(
  337. self.container_start_x + drag_point.x - self.drag_start_point.x, self.container_start_y + drag_point.y - self.drag_start_point.y)
  338. def event_cb(self, e):
  339. code = e.get_code()
  340. ta = e.get_target()
  341. # if code == lv.EVENT.FOCUSED:
  342. # self.kb.move_foreground()
  343. # self.kb.set_textarea(ta)
  344. # self.kb.clear_flag(lv.obj.FLAG.HIDDEN)
  345. # if code == lv.EVENT.DEFOCUSED:
  346. # self.kb.set_textarea(None)
  347. # self.kb.add_flag(lv.obj.FLAG.HIDDEN)
  348. def align(self, align, x, y):
  349. self.container.align(align, x, y)
  350. def move_foreground(self):
  351. self.container.move_foreground()
  352. def move_background(self):
  353. self.container.move_background()
  354. def set_hiden(self, is_hidden):
  355. # print("set_hiden", is_hidden)
  356. self.is_hidden = is_hidden
  357. if is_hidden:
  358. self.container.add_flag(lv.obj.FLAG.HIDDEN)
  359. else:
  360. self.container.clear_flag(lv.obj.FLAG.HIDDEN)
  361. self.move_foreground()
  362. def switch_hidden(self):
  363. self.set_hiden(not self.is_hidden)
  364. def set_textarea(self, ta):
  365. self.kb.set_textarea(ta)
  366. def kb_btn_event_cb(self, e):
  367. # print("kb_btn_event_cb")
  368. # kb: KeyBoard = global_dict["keyboard"]
  369. # kb.switch_hidden()
  370. pass
  371. def date_time_update_cb(timer):
  372. # datetime_label = global_dict["datetime_label"]
  373. asctime = time.asctime()
  374. # datetime_label.set_text(asctime)
  375. print(asctime)
  376. def main():
  377. global bar_style_bg
  378. global bar_style_indic
  379. bar_style_bg = lv.style_t()
  380. bar_style_indic = lv.style_t()
  381. bar_style_bg.init()
  382. bar_style_bg.set_border_color(lv.palette_main(lv.PALETTE.BLUE))
  383. bar_style_bg.set_border_width(2)
  384. bar_style_bg.set_pad_all(6) # To make the indicator smaller
  385. bar_style_bg.set_radius(6)
  386. bar_style_bg.set_anim_time(1000)
  387. bar_style_indic.init()
  388. bar_style_indic.set_bg_opa(lv.OPA.COVER)
  389. bar_style_indic.set_bg_color(lv.palette_main(lv.PALETTE.BLUE))
  390. bar_style_indic.set_radius(3)
  391. # print('hello pikapython!')
  392. mem = PikaStdLib.MemChecker()
  393. STATUS_BAR_HEIGHT = 40
  394. LOGO_WIDTH = 100
  395. TABVIEW_HEIGHT = 40
  396. lv.lock()
  397. status_bar = lv.obj(lv.scr_act())
  398. status_bar.set_size(lv.pct(100), STATUS_BAR_HEIGHT)
  399. status_bar.clear_flag(lv.obj.FLAG.SCROLLABLE)
  400. lv.scr_act().clear_flag(lv.obj.FLAG.SCROLLABLE)
  401. # logo label
  402. logo = lv.obj(status_bar)
  403. logo.set_size(LOGO_WIDTH, STATUS_BAR_HEIGHT)
  404. logo_label = lv.label(logo)
  405. logo_label.set_text("logo")
  406. logo_label.align(lv.ALIGN.CENTER, 0, 0)
  407. logo.align(lv.ALIGN.LEFT_MID, -20, 0)
  408. logo.clear_flag(lv.obj.FLAG.SCROLLABLE)
  409. datetime_label = lv.label(status_bar)
  410. datetime_label.set_text("2023.12.20 16:20:08")
  411. datetime_label.align(lv.ALIGN.LEFT_MID, LOGO_WIDTH, 0)
  412. timer = lv.timer_create_basic()
  413. timer.set_period(1)
  414. timer.set_cb(date_time_update_cb)
  415. # Keyboard
  416. keyboard = KeyBoard(lv.scr_act(), label_text="", is_number=False)
  417. keyboard.align(lv.ALIGN.BOTTOM_MID, 0, 0)
  418. keyboard_btn = Button(status_bar, label_text="keyboard")
  419. keyboard_btn.align(lv.ALIGN.RIGHT_MID, -20, 0)
  420. keyboard_btn.set_size(60, 30)
  421. keyboard_btn.add_event_cb(kb_btn_event_cb, lv.EVENT.ALL, None)
  422. # 创建一个tabview对象
  423. tabview = lv.tabview(lv.scr_act(), lv.DIR.TOP, TABVIEW_HEIGHT)
  424. tabview.clear_flag(lv.obj.FLAG.SCROLLABLE)
  425. tabview.align(lv.ALIGN.TOP_LEFT, 0, STATUS_BAR_HEIGHT)
  426. tabview.set_size(lv.pct(100), lv.pct(100) - 10)
  427. # 添加标签到tabview
  428. tab1 = tabview.add_tab("run")
  429. tab2 = tabview.add_tab("debug")
  430. tab3 = tabview.add_tab("log")
  431. tab4 = tabview.add_tab("alert")
  432. tab5 = tabview.add_tab("help")
  433. tab6 = tabview.add_tab("program")
  434. tab7 = tabview.add_tab("edit")
  435. # tab1
  436. meter_temp_box = MyMeter(tab1, label_text="box temp", unit="°C")
  437. meter_temp_box.align(lv.ALIGN.TOP_LEFT, 20, 0)
  438. meter_humi = MyMeter(tab1, label_text="meter humi", unit="%")
  439. meter_humi.align(lv.ALIGN.TOP_RIGHT, -20, 0)
  440. meter_temp_tube = MyMeter(tab1, label_text="tube temp", unit="°C")
  441. meter_temp_tube.align(lv.ALIGN.TOP_MID, 0, 0)
  442. meter_temp_box.set_value(20)
  443. meter_humi.set_value(50)
  444. meter_temp_tube.set_value(30)
  445. process_count_segment = ProcessCount(
  446. tab1, label_text="tim", value=0, totle=10)
  447. process_count_segment.align(lv.ALIGN.BOTTOM_LEFT, 0, -100)
  448. process_count_loop = ProcessCount(tab1, label_text="loop", value=0, totle=10)
  449. process_count_loop.align(lv.ALIGN.BOTTOM_LEFT, 160, -100)
  450. timer_segment = TimerView(tab1, label_text="segment",
  451. seconds_this=5, seconds_totle=10)
  452. timer_totle = TimerView(tab1, label_text="timer totle",
  453. seconds_this=0, seconds_totle=200)
  454. tab1_process_bar = BtnProcessBar(tab1, label_text="start")
  455. tab1_process_bar.align(lv.ALIGN.BOTTOM_LEFT, 0, 0)
  456. tab1_process_bar.add_event_cb(tab1_btnbar1_event_cb, lv.EVENT.CLICKED)
  457. # tab2
  458. timer_segment.align(lv.ALIGN.BOTTOM_RIGHT, -220, -20)
  459. timer_totle.align(lv.ALIGN.BOTTOM_RIGHT, 0, -20)
  460. pid_circle = PIDPanel(tab2, label_text="loop PID")
  461. pid_circle.align(lv.ALIGN.TOP_LEFT, 0, 0)
  462. pid_plate = PIDPanel(tab2, label_text="plate PID")
  463. pid_plate.align(lv.ALIGN.TOP_LEFT, 300, 0)
  464. pid_hit = PIDPanel(tab2, label_text="hit PID")
  465. pid_hit.align(lv.ALIGN.TOP_LEFT, 600, 0)
  466. pid_hit.set_size(350, 400)
  467. # 低气压PID
  468. label_low_pressure = lv.label(pid_hit.container)
  469. label_low_pressure.set_text("lo pressure PID")
  470. label_low_pressure.align(lv.ALIGN.BOTTOM_MID, 0, -100)
  471. input_box_in = InputBox(pid_hit.container, label_text="in", box_num=2)
  472. input_box_in.align(lv.ALIGN.BOTTOM_LEFT, 0, -50)
  473. input_box_out = InputBox(pid_hit.container, label_text="out", box_num=2)
  474. input_box_out.align(lv.ALIGN.BOTTOM_LEFT, 0, 0)
  475. tab2_btn1 = Button(tab2, label_text="btn1")
  476. tab2_btn1.align(lv.ALIGN.BOTTOM_RIGHT, -150, 0)
  477. tab2_btn2 = Button(tab2, label_text="btn2")
  478. tab2_btn2.align(lv.ALIGN.BOTTOM_RIGHT, -20, 0)
  479. # tab3
  480. chart_temp = Chart(tab3, label_text="chart temp")
  481. chart_temp.align(lv.ALIGN.CENTER, 0, 0)
  482. tabview.set_act(0, lv.ANIM.OFF)
  483. lv.unlock()
  484. mem.max()
  485. main()
  486. for i in range(1):
  487. time.sleep(0.1)
  488. lv.task_handler()
  489. lv.deinit()