【Xingkong Board Python Programming Learning Main Control Board】 2. Power on and Mind+ Graphic Lighting and Music Clock Operation Evaluation
[Copy link]
This post was last edited by kit7828 on 2022-11-3 18:44
1. Power on
The board is powered on by connecting it to the computer via a Type-C cable. After powering on, you need to wait for a while and the Linux running records of the character interface will appear in sequence.
Then, stay on the initial main interface of the Xingkong board, that is, the interface waiting for the Home button
After pressing the Home button, the main menu interface appears.
At this point, you can use touch and the A and B buttons to switch menus.
Tested the screen calibration under the app
2. Mind+ starts the first graphical routine
Test and run Mind+ graphical programming, which requires hardware connection
Then, add support for the Xingkong board in the extension. You can refer to my previous review post - unboxing post https://en.eeworld.com/bbs/thread-1223052-1-1.html
In the Mind+ graphical programming interface, by dragging and dropping components, changing characters, numbers, etc., after multiple modifications, the graphic engineering for this evaluation was completed.
After connecting to the Xingkong board, just click the run button on the right to see the effect.
Specific operation effect
For those who are not familiar with Pathon code, it only takes about 1-2 hours to complete such an interface, thanks to the charm of graphical programming. (It feels like it can be freed from the limitations of specific programming languages, which is very nice)
3. Code and operation log
The background automatically generates Pathon code and log information during operation
The specific code is
# -*- coding: UTF-8 -*-
# MindPlus
# Python
from pinpong.extension.unihiker import *
from pinpong.board import Board,Pin
from unihiker import GUI
import time
# 事件回调函数
def on_buttona_click_callback():
buzzer.play(buzzer.ENTERTAINER,buzzer.Once)
p_p25_out=Pin(Pin.P25, Pin.OUT)
p_p25_out.write_digital(1)
time.sleep(1)
p_p25_out=Pin(Pin.P25, Pin.OUT)
p_p25_out.write_digital(0)
u_gui=GUI()
Board().begin()
u_gui.on_a_click(on_buttona_click_callback)
Hour = 10
Min = 0
Sec = 0
u_gui.draw_text(text="你好,行空板",x=40,y=20,font_size=20, color="#0000FF")
u_gui.draw_text(text="By Kit7828",x=110,y=52,font_size=12, color="#0000FF")
clock=u_gui.draw_clock(x=120,y=200,r=50,color="#FF0000")
while True:
clock.config(h=Hour,m=Min,s=Sec)
time.sleep(1)
Sec = (Sec + 1)
if (Sec > 59):
Sec = 0
Min = (Min + 1)
if (Min > 59):
Min = 0
Hour = (Hour + 1)
if (Hour > 23):
Hour = 0
Log information during operation
root@unihiker:~/mindplus/cache 项目1、点灯及时钟显示正在上传中,请稍后...
项目上传成功,开始运行
root@unihiker:~/mindplus/cache/1、点灯及时钟显示# access control disabled, clients can connect from any host
root@unihiker:~/mindplus/cache/1、点灯及时钟显示# cd "/root/mindplus/cache/1、点灯及时钟显示"
root@unihiker:~/mindplus/cache/1、点灯及时钟显示# python /root/mindplus/cache/1 、点灯及时钟显示/.cache-file.py
___________________________
| |
| PinPong v0.4.9 |
| Designed by DFRobot |
|___________________________|
[01] Python3.7.3 Linux-4.4.143-67-rockchip-g01bbbc5d1312-aarch64-with-debian-10.11 Board: UNIHIKER
selected -> board: UNIHIKER serial: /dev/ttyS3
[10] Opening /dev/ttyS3
[32] Firmata ID: 3.3
[22] Arduino compatible device found and connected to /dev/ttyS3
[40] Retrieving analog map...
[42] Auto-discovery complete. Found 30 Digital Pins and 30 Analog Pins
------------------------------
All right. PinPong go...
------------------------------
IV. Video
Please refer to the following video for the effects of button lighting and music playing
5. Conclusion
The charm of graphical programming is indeed very strong. You don’t need to be familiar with the style of a specific programming language, code standards, etc. You don’t need to type code, you just need to focus on the logic, and it is fast and convenient.
What needs to be complained is that runtime errors are often sent in the middle, which is mainly caused by the failure to detect the version information on the Xingkong board. The data cable was plugged and unplugged many times in the middle, and it ran normally after the version was detected.
VI. Suggestions
For clock applications, I personally think that the company should provide graphical components such as timers for precise timing. Timing through pure software should not be able to meet the precise requirements. In addition, for data communication and interaction between threads, I have not found suitable components or suitable reference posts. Perhaps the search scope is not enough.
|