[EN] Queue Data Structure

This article introduces the use of the list class in Micropython as a queue data structure with a limited number of members. It works according to the FIFO (First-In-First-Out) principle, which can be applied in a variety of applications, such as being used as a storage, and when the data is full but we need to insert new data, the old data must be pop out. The example in this article uses the dCore-miniML board (Figure 1) to read the temperature of the chip and store it in a Queue structure and display it in a bar graph and Micropython implemented firmware version 1.16 (2021-06-23) for the ESP Module (SPIRAM).

(Figure. 1 An example of drawing a graph with data stored in a queued data structure)
Read More

[EN] ulab v3.0

From the previous ulab article, it was found that Micropython can implement the same dataset processing instructions as used in Numpy through the previous ulab library v.0.54.0 which is the older version of ulab (currently v.3.0.1) brought up this article. This article describes how to create a Micropython that integrates the ulab library and uses it with SPIRAM versions of esp32.

(Figure. 1 Module list of ulab)

ulab3

From Figure 1, it can be seen that the structure of the ulab library has changed from the original. This causes the programming from the previous example to have to be modified. Under ulab there are libraries of numpy and scipy. The details of numpy that are supported are as follows.

Read More

[TH] How to make the stopwatch?

จากบทความสร้างนาฬิกาที่แสดงผลแบบแอนาล็อกแสดงผ่านจอแสดงผลแบบสี ครั้งนี้นำมาปรับปรุงแก้ไขเพื่อสร้างการทำงานเป็นเครื่องจับเวลาหรือนาฬิกาจับเวลา (Stopwatch) โดยใช้บอร์ด ESP32-CAM เชื่อมต่อกับจอ TFT และใช้สวิตช์จากขา GPIO0 ที่ใช้เป็นสวิตช์เลือกโหมดทำงานหรือโปรแกรมชิพเมื่อตอนบูตระบบหรือจ่ายไฟเข้าบอร์ด ESP32-CAM ดังภาพที่ 1 และการเขียนโปรแกรมยังคงใช้ภาษาไพธอนกับตัว MicroPython เช่นเคย

ภาพที่ 1 บอร์ด dCore RED บอร์ด esp32cam+REDTAB
Read More

[TH] Binary Search Tree data structure programming with Python.

ในบทความก่อนหน้านี้ได้แนะนำการเขียนโปรแกรมเพื่อใช้โครงสร้างข้อมูลแบบคิวไปแล้ว ในบทความนี้จึงแนะนำการเขียนโปรแกรมจัดการโครงสร้างข้อมูล (Data Structure) อีกประเภทหนึ่งซึ่งมีวิธีการจัดเก็บและจัดการที่แตกต่างกันไปอันมีชื่อว่าต้นไม้แบบ BST หรือ Binary Search Tree ดังในภาพที่ 1 ซึ่งเป็นโครงสร้างที่สามารถนำไปประยุกต์เกี่ยวกับการเก็บข้อมูลที่มีคุณลักษณะที่ข้อมูลทางกิ่งด้านซ้ายมีค่าที่น้อยกว่าตัวเอง และกิ่งด้านขวามีค่ามากกว่าต้นเอง หรือทำตรงกันข้ามคือกิ่งซ้ายมีค่ามากกว่า และกิ่งด้านขวามีค่าน้อยกว่า ทำให้การค้นหาข้อมูลในกรณีที่ต้นไม้มีความสมดุลย์ทั้งทางซ้ายและทางขวาบนโครงสร้าง BST ประหยัดเวลาหรือจำนวนครั้งในการค้นหาลงรอบละครึ่งหนึ่งของข้อมูลที่มี เช่น มีข้อมูล 100 ชุด ในรอบแรกถ้าตัวเองยังไม่ใช่ข้อมูลที่กำลังค้นหา จะเหลือทางเลือกให้หาจากกิ่งทางซ้ายหรือขวา ซึ่งการเลือกทำให้ข้อมูลของอีกฝั่งนั้นไม่ถูกพิจารณา หรือตัดทิ้งไปครึ่งหนึ่งโดยประมาณ แต่ถ้าเป็นกรณีที่ Binary Search Tree นั้นขาดความสมดุลย์จะส่งผลให้การค้นหามีความเร็วไม่แตกต่างกับการค้นหาแบบลำดับ (Sequential Search) เท่าใดนัก

ในบทความนี้ใช้ภาษาไพธอนที่ทำงานได้ทั้งบนตัวแปลภาษา Python 3 หรือ MicroPython เพื่อจัดเก็บข้อมูล การเพิ่มข้อมูล การค้นหาข้อมูล เพื่อเป็นตัวอย่างของการนำไปพัฒนาต่อไป

BST : Binary Search Tree
ภาพที่ 1 ตัวอย่าง BST
Read More

[TH] Calculate Regression with MicroPython on esp32-C3.

บทความนี้กล่าวถึงการคำนวณค่าถดถอย (Regression) ด้วยภาษาไพธอนของ MicroPython โดยใช้บอร์ดไมโครคอนโทรลเลอร์ ESP32-C3 พร้อมทั้งแสดงผลด้วยจอแสดงผลกราฟิกแบบ 2 สี (แสดงกับไม่แสดงเม็ดสี) แบบ OLED ดังภาพที่ 1 ซึ่งค่าที่นำมาใช้เป็นตัวอย่างในการใช้งานเป็นค่าที่ได้จากการอ่านอุณหภูมิ

ภาพที่ 1 บอร์ด ESP32-C3 ที่ต่อเติมโมดูล OLED และขาสำหรับเชื่อมต่อภายนอก
Read More

[TH] The MaixPy’s image class Part 1. draw and find something.

บทความนี้กล่าวถึงการใช้คลาส image กับโมดูลแสดงผล TFT-LCD ของบอร์ด Sipeed M1W dock suit ผ่านทางคลาส lcd (MaixPy’s lcd class) ดังภาพที่ 1 ที่มีมากับ MaixPy เพื่อศึกษารายการคำสั่งที่คลาส image เตรียมไว้ให้ และตัวอย่างโปรแกรมการใช้งานคำสั่งเกี่ยวกับการสร้างวัตถุบัฟเฟอร์ การล้างค่าในบัฟเฟอร์ การลบบัฟเฟอร์ การวาดเส้นตรง วงกลม สี่เเหลี่ยม แสดงตัวอักษร การบันทึกข้อมูลจากบัฟเฟอร์ลงการ์ดหน่วยความจำ (microSD Card) การค้นหาเส้นตรงในบัฟเฟอร์ (find_lines) การค้นหาวงกลมในบัฟเฟอร์ (find_circles) และการค้นหาสี่เหลี่ยม (find_rects) ในบัฟเฟอร์ด้วยฟังก์ชันทำงานที่มีมาให้ ซึ่งใช้หลักการของ Hough Transform เพื่อหาตำแหน่งและพารามิเตอร์ของวัตถุที่ค้นหา

ภาพที่ 1 บอร์ด Sipeed M1W dock suit
ภาพที่ 1 บอร์ด Sipeed M1W dock suit
Read More

[TH] The MaixPy’s lcd class.

บทความนี้กล่าวถึงการใช้โมดูล TFT-LCD ของบอร์ด Sipeed M1W dock suit ผ่านทางคลาส lcd (MaixPy’s lcd class) ที่มีมากับ MaixPy ซึ่งเป็นโมดูลที่ทำให้ผู้เขียนโปรแกรมสามารถใช้งานโดยประสิทธิภาพของการทำงานของคลาสนั้นมีความเร็วสูง

ภาพที่ 1 จอแสดงผลของ Sipeed M1W dock Suit
Read More

[TH] Maix Class

บทความนี้รวบรวมรายการชุดคำสั่งของคลาสต่าง ๆ ที่อยู่ภายใต้คลาส Maix ของ MaixPy ซึ่งเป็น MicroPython ของบอร์ด Sipeed M1W dock suit (ภาพที่ 1) ที่เคยได้กล่าวถึงไปแล้ว

ภาพที่ 1 บอร์ด Sipeed M1W doc suit
Read More

[EN] QRCode Detected!

This article describes how to use OpenCV to find QRCode from an image from a Web Camera connected to the Raspberry Pi via a USB port. The example contains an example of reading the results from a web camera. And exit the program by pressing the ESC key, the QRCode search example and decoding the text within the image and storing the result in the image file.

(Figure. 1)
Read More