yahboom
HomeLearn
Solution
Blog
Online Store
About Us
EN/中文
K210 Module📖
0.Camera changes
  • Precautions for camera changes
1.K210-AI-Camera introduction
  • 1.K210 main chip introduction
  • 2.K210 visual recognition module introduction
  • 3.Module pin assignments
  • 4.MicroPython Introduction
  • 5. FAQ analysis
  • 6.Bracket installation
2.Development Environment Setup
  • 1.To install the serial port assistant
  • 2.Install CanMV IDE development software
  • 3.Flashcard factory firmware
  • 4.IDE import routine
  • 5.Call custom py library
  • 6.MicroPython API documentation
3.Basic experimental routines
  • 1.Lighting the RGB light experiment
  • 2.Key features of the experiment
  • 3.Timer experiment
  • 4.PWM breathing light experiment
  • 5.LCD display experiment
  • 6.The touchpad read the coordinates of the experiment
  • 7.The camera shows the experimental
  • 8.Memory card read and write files of the experiment
  • 9.External interface experimental
4.Graphical manipulation routines
  • 1.Draw graphics
  • 2.Button and the click event
  • 3.Slider
  • 4.Chart animation
  • 5.Multi-label layout
5.AI visual experiments routines
  • How to import the model file into memory cardnew
  • 1.Color recognition
  • 2.Barcode recognition
  • 3.QR code recognition
  • 4.Apriltags recognition
  • 5.Face detection
  • 6.Face feature detection
  • 7.Mask detection
  • 8.Face recognition
  • 9.Object detection
  • 10.Self-learning classification
  • 11.Handwritten digit recognition
  • 12. Multiple color recognition
  • 13. Human body detectionnew
  • 14. Yolo hand detectionnew
  • 15. License Plate Recognitionnew
  • 16. Autonomous training modelnew
6.Extended routines (sold separately)
6.1.For STM32 Car
  • 10. stm_ K210 Autonomous Learning Classification
  • 1.automatic driving
  • 2.color follow
  • 3.Handwriting digital operation
  • 4.Color reaction
  • 5.Road sign indicating the operation
  • 6.Following the apriltag
  • 7.QR code instruction
  • 8.PTZ tracking color
  • 9.PTZ tracking face
6.2.1 arduino_k210
  • 1.ard_k210-Color recognition
  • 2.ard_k210-Bar code identification
  • 3.ard_k210-QR code identification
  • 4.ard_ K210-mechanical code identification
  • 5.ard_ K210-Face Detection
  • 6. ard_ K210-facial feature detection
  • 7. ard_ K210-mask detection
  • 8. ard_ K210-facial recognition
  • 9. ard_ K210-object detection
  • 10. ard_ K210 Autonomous Learning Classification
  • 11. ard_ K210 Handwritten Digit Recognition
6.2 K210 as a coprocessor
  • ReadMe
6.2.2 stm32_k210
  • 1.stm_ K210 color recognition
  • 2. stm_ K210 barcode recognition
  • 3. stm_ K210 QR code recognition
  • 4. stm_ K210 mechanical code identification
  • 5. stm_ K210 Face Detection
  • 6.stm_ K210 facial feature detection
  • 7. stm_ K210 mask detection
  • 8. stm_ K210 facial recognition
  • 9. stm_ K210 object detection
  • 11. stm_ K210 Handwritten Digit Recognition
6.2.3 microbit_k210
  • 1.microbit_ K210 color recognition
  • 2.microbit_ K210 barcode recognition
  • 3.microbit_ K210 QR code recognition
  • 4.microbit_ K210 mechanical code identification
  • 5. microbit_ K210 Face Detection
  • 6. microbit_ K210 facial feature detection
  • 7. microbit_ K210 mask detection
  • 8. microbit_ K210 facial recognition
  • 9. microbit_ K210 object detection
  • 10. microbit_ K210 autonomous classification learning
  • 11. microbit_ K210 Handwritten Digit Recognition
6.2.4 pico_k210
  • 1. pico_ K210 color recognition
  • 2. Pico_ K210 barcode recognition
  • 3. Pico_ K210 QR code recognition
  • 4. pico_ K210 machine code recognition
  • 5. pico_ K210 Face Detection
  • 6. pico_ K210 facial feature detection
  • 7. pico_ K210 mask recognition
  • 8. pico_ K210 facial recognition
  • 9. pico_ K210 object detection
  • 10. pico_ K210 Autonomous Learning Classification
  • 11. pico_ K210 Handwritten Digit Recognition
6.2.5 MSPM0G3507_k210
  • 1.MSPM0_K210 color recognition
  • 2.MSPM0_K210 barcode recognition
  • 3.MSPM0_K210 QR code recognition
  • 4.MSPM0_K210 mechanical code recognition
  • 5.MSPM0_K210 face detection
  • 6.MSPM0_K210 facial feature detection
  • 7.MSPM0_K210 mask detection
  • 8.MSPM0_K210 face recognition
  • 9.MSPM0_K210 Object Detection
  • 10.MSPM0_K210 Self-study classification
  • 11.MSPM0_K210 handwritten digit recognition
6.2.6 MSPM0G3519_k210
  • 1. MSPM0_K210 Color Recognitionnew
  • 2. MSPM0_K210 Barcode Recognitionnew
  • 3. MSPM0_K210 QR Code Recognitionnew
  • 4. MSPM0_K210 Mechanical Code Recognitionnew
  • 5. MSPM0_K210 Face Detectionnew
  • 6. MSPM0_K210 Facial Feature Detectionnew
  • 7. MSPM0_K210 Mask Detectionnew
  • 8. MSPM0_K210 Face Recognitionnew
  • 9. MSPM0_K210 Object Detectionnew
  • 10. MSPM0_K210 Self-study Classificationnew
  • 11. MSPM0_K210 Handwritten Digit Recognitionnew
6.3 For 24 channel servo drive board
  • 1. 2DOF PTZ Color Tracking
  • 2. 2DOF Face Tracking
  • 3. 2DOF Fruit sorting
6.4 For autopilot map
  • 1.k210 model training
  • 2.Assembly and wiring of stm32 car
  • 3.Recognize left and right sign
  • 4.Identify and remove speed limit
  • 5.Identify parking spaces and park
  • 6.STM32 car autopilot
6.5.1 For MSPM0G3507_Wheeled Chassis Kit
  • 1.MSPM0-Automatic Driving
  • 2.MSPM0-Color follow
  • 3.MSPM0-Number recognition
  • 4.MSPM0-Color reaction
  • 5.MSPM0-Road signs
  • 6.MSPM0-Machine code following
  • 7.MSPM0-QR code recognition
6.5.2 For MSPM0G3519_Wheeled Chassis Kit
  • 1.MSPM0-Automatic Drivingnew
  • 2.MSPM0-Color follownew
  • 3.MSPM0-Number recognitionnew
  • 4.MSPM0-Color reactionnew
  • 5.MSPM0-Road signsnew
  • 6.MSPM0-Machine code followingnew
  • 7.MSPM0-QR code recognitionnew
6.5.3 For STM32_Wheeled Chassis Kit
  • 1.STM32-Automatic Driving
  • 2.STM32-Color follow
  • 3.STM32-Number recognition
  • 4.STM32-K210-Color Reaction
  • 5.STM32-Road signs
  • 6.STM32-Machine code following
  • 7.STM32-QR code recognition
Download
  • Driver development software
  • AI model
  • Source code
  • Instruction manual
  • Hardware_3DModelFile
  • K210_Chip_Data
Download ZIP

Welcome to K210 Module repository

5.Multi-label layout

5 Multi-label layout

5 Multi-label layout5.1 experimental goals5.2 experimental procedure5.3 experimental results5.4 experiment summary

5.1 experimental goals

In this lesson, you will learn how to draw a multi-label layout, which is divided into three layouts.

The reference code path for this experiment :CanMV\04-GUI\multi_layout.py

 

5.2 experimental procedure

The factory firmware of the module has been integrated with the lvgl graphical library. If you have downloaded other firmware, please burn it back to the factory firmware before experimenting.

  1. Import the relevant libraries and initialize the lvgl, register the display interface, and register the input interface.

  2. Create a new button page class, Page_Buttons, that will add buttons automatically on each click.

​x
class Page_Buttons:
    def __init__(self, app, page):
        self.app = app
        self.page = page

        # counter button
        self.counter_btn = lv.btn(page)
        self.counter_btn.set_size(100,60)
        self.counter_btn.align(page, lv.ALIGN.CENTER, 0, 0)
        self.counter_label = lv.label(self.counter_btn)
        self.counter_label.set_text('Count')
        self.counter_btn.set_event_cb(self.on_counter_btn)
        self.counter = 0

    def on_counter_btn(self, obj, event):
        if event == lv.EVENT.CLICKED:
            self.counter += 1
            self.counter_label.set_text(str(self.counter))
  1. Create a new slider page class, Page_Slider, which displays the current slider value in real time.

xxxxxxxxxx
class Page_Slider:
    def __init__(self, app, page):
        self.app = app
        self.page = page

        # slider
        self.slider = lv.slider(page)
        self.slider.align(page, lv.ALIGN.CENTER, 0, -10)
        self.slider_label = lv.label(page)
        self.slider_label.align(self.slider, lv.ALIGN.OUT_LEFT_MID, -10, 0)
        self.slider.set_event_cb(self.on_slider_changed)
        self.on_slider_changed(None)

    def on_slider_changed(self, obj=None, event=-1):
        self.slider_label.set_text(str(self.slider.get_value()))
  1. Create a new animation class, Anim.

xxxxxxxxxx
class Anim(lv.anim_t):
    def __init__(self, obj, val, size, exec_cb, path_cb, time=500, playback = False, ready_cb=None):
        super().__init__()
        lv.anim_init(self)
        lv.anim_set_time(self, time, 0)
        lv.anim_set_values(self, val, val+size)
        if callable(exec_cb):
            lv.anim_set_custom_exec_cb(self, exec_cb)
        else:
            lv.anim_set_exec_cb(self, obj, exec_cb)
        lv.anim_set_path_cb(self, path_cb )
        if playback: lv.anim_set_playback(self, 0)
        if ready_cb: lv.anim_set_ready_cb(self, ready_cb)
        lv.anim_create(self)
  1. Create a new chart animation class, AnimatedChart.

xxxxxxxxxx
class AnimatedChart(lv.chart):
    def __init__(self, parent, val, size):
        super().__init__(parent)
        self.val = val
        self.size = size
        self.max = 2000
        self.min = 500
        self.factor = 100
        self.anim_phase1()

    def anim_phase1(self):
        Anim(
            self,
            self.val,
            self.size,
            lambda a, val: self.set_range(0, val),
            lv.anim_path_ease_in,
            ready_cb=lambda a:self.anim_phase2(),
            time=(self.max * self.factor) // 100)

    def anim_phase2(self):
        Anim(
            self,
            self.val+self.size,
            -self.size,
            lambda a, val: self.set_range(0, val),
            lv.anim_path_ease_out,
            ready_cb=lambda a:self.anim_phase1(),
            time=(self.min * self.factor) // 100)
  1. Create a new chart animation page class Page_Chart, the main function is to display chart animation effects.

xxxxxxxxxx
class Page_Chart():
    def __init__(self, app, page):
        self.app = app
        self.page = page
        self.chart = AnimatedChart(page, 100, 1000)
        self.chart.set_width(page.get_width() - 100)
        self.chart.set_height(page.get_height() - 30)
        self.chart.align(page, lv.ALIGN.CENTER, 0, 0)
        self.series1 = self.chart.add_series(lv.color_hex(0xFF0000))
        self.chart.set_type(self.chart.TYPE.POINT | self.chart.TYPE.LINE)
        self.chart.set_series_width(3)
        self.chart.set_range(0,100)
        self.chart.init_points(self.series1, 10)
        self.chart.set_points(self.series1, [10,20,30,20,10,40,50,80,95,80])
        self.chart.set_x_tick_texts('a\nb\nc\nd\ne', 2, lv.chart.AXIS.DRAW_LAST_TICK)
        self.chart.set_x_tick_length(10, 5)
        self.chart.set_y_tick_texts('1\n2\n3\n4\n5', 2, lv.chart.AXIS.DRAW_LAST_TICK)
        self.chart.set_y_tick_length(10, 5)
        self.chart.set_div_line_count(3, 3)
        self.chart.set_margin(30)

        self.slider = lv.slider(page)
        self.slider.align(self.chart, lv.ALIGN.OUT_RIGHT_TOP, 10, 0)
        self.slider.set_width(30)
        self.slider.set_height(self.chart.get_height())
        self.slider.set_range(10, 200)
        self.slider.set_value(self.chart.factor, 0)
        self.slider.set_event_cb(self.on_slider_changed)

    # Create a slider that controls the chart animation speed
    def on_slider_changed(self, obj=None, event=-1):
        self.chart.factor = self.slider.get_value()
  1. New main page class Screen_Main, the main function is to use the tabview control to manage multiple pages.

xxxxxxxxxx
class Screen_Main(lv.obj):
    def __init__(self, app, *args, **kwds):
        self.app = app
        super().__init__(*args, **kwds)

        self.tabview = lv.tabview(self)
        self.tabview.set_style(lv.tabview.STYLE.BG, lv.style_plain_color)
        self.page_buttons = Page_Buttons(self.app, self.tabview.add_tab('Button'))
        self.page_slider = Page_Slider(self.app, self.tabview.add_tab('Slider'))
        self.page_chart = Page_Chart(self.app, self.tabview.add_tab('Chart'))
  1. Initialize the main screen and load all views.

xxxxxxxxxx
screen_main = Screen_Main(lv.obj())
lv.scr_load(screen_main)
  1. Since the images of lvgl need to be updated in real time, it is necessary to refresh the tasks of lvgl every 5 ms.

xxxxxxxxxx
tim = time.ticks_ms()
while True:
    if time.ticks_ms()-tim > 5:
        tim = time.ticks_ms()
        lv.task_handler()
        lv.tick_inc(5)

 

5.3 experimental results

Connect the K210 module to the computer through the microUSB data cable, CanMV IDE click the connect button, after the connection is completed click the Run button to run the routine code. You can also download the code as main.py and run it in the K210 module.

It can be seen that three buttons are displayed on the top of the LCD display, among which the "Button" represents the switch button function page, the "Slider" button represents the switch to the slider function page, and the "Chart" button represents the switch to the dynamic chart function page. The corresponding page function can be entered by touching the corresponding button, and the function of the three pages is similar to the function of the previous routine.image-20230215152442445

image-20230215152503018

image-20230215152522385

 

5.4 experiment summary

lvgl can not only be drawn graphical buttons, sliders, etc., these may also be the layout of the collection together, divided into a plurality of interface display, such a production function that is beautiful and practical.

 

 

Chart animation
How to import the model file into memory card

COMPANY

  • About us
  • Team Style
  • Blog

LEARNING & EXPLORATION

  • Tutorials
  • Edge AI hardware
  • Educational robots
  • Embedded intelligent hardware

WHERE TO BUY

  • Yahboom Online Store
  • Amazon
  • Alibaba
  • AliExpress
  • Mercado

TECHNOLOGY SUPPORT

  • Email: support@yahboom.com

BE A DISTRIBUTOR

  • Email: sales@yahboom.com
QR Code
QR Code

Copyright © 2017-2026 Yahboom. All Rights Reserved.

EN/中文