[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)

[TH] Try the SoftHost USB library for ESP32.

บทความนี้เป็นตัวอย่างการนำ ESP32 Soft Host ของ nathalis มาทดลองใช้งานและทดลองแสดงผลที่จอแสดงผล OLED ที่มีความละเอียด 128×64 จุด ดังภาพที่ 1 เพื่อรับข้อมูลจากแป้นพิมพ์ หรือเมาส์ ทำให้ใช้ GPIO เพียงไม่กี่ขาแต่สามารถรับข้อมูลจากแป้นพิมพ์ที่มีจำนวนปุ่มที่เยอะได้ ซึ่งโดยปกติแล้วตัวไมโครคอนโทรลเลอร์ ESP32 ไม่รองรับการทำเชื่อมต่อกับ USB โดยตรงจึงต้องอาศัยการเขียนโปรแกรมด้วยการใช้ตัวตั้งเวลาหรือ Timer มาตรวจสอบสถานะของสายสัญญาณขา D- และ D+ เพื่อนำมาประกอบกันเป็นข้อมูลในระดับไบต์และนำมาประกอบกันเป็นแพ็คของข้อมูลเพื่อทำการตีความต่อไป

ภาพที่ 1 อุปกรณ์และบอร์ดที่เชื่อมต่อกันเพื่อเป็นตัวอย่างในบทความนี้

[EN] Python multi-threaded programming

This article discusses Python multi-threaded programming. Compiled from the website tutorialspoint.com (Make this article a memo). Running multiple threads is like running several different programs at the same time, but it’s useful:

  • Each thread can share the memory with the main thread and can communicate with each other.
  • Threads are smaller processes because they consume less memory than process calls.

[EN] PyGlet

pyglet is a Python library to create windows and cross-platform multimedia on Windows (Windows), MacOS (macOS) and Linux (Linux) for developing games or visualization applications. The library itself supports creating windows, integration with users through an event-based system, support OpenGL graphics, image/video loading support, and playing music. This article discusses installing and using pyglet on Raspberry Pi 3 B+ and Raspberry Pi 4 as a test device.

(Figure. 1 Example from 1-6)

[TH] Arduino: STM32L432 Nucleo-32’s DAC&ADC.

จากที่ได้อ่านบทความ การใช้งาน STM32 Core Support for Arduino สำหรับบอร์ด Nucleo L432KC ของอาจารย์ เรวัต ศิริโภคาภิรมย์ ทางเราเลยได้จัดหาบอร์ดมาทดลองใช้งานและเชื่อมต่อขาสำหรับส่งข้อมูลออก DAC ไปยัง ADC ตามภาพที่ 1 เพื่อทดสอบการทำงานของภาค DAC และ ADC ของบอร์ดโดยใช้โค้ดการทำงานเหมือนกับบอร์ดไมโครคอนโทรลเลอร์ ESP32, SAM-D21 และ LGT8F328P ว่าเป็นอย่างไร มาติดตามกันครับ

ภาพที่ 1 บอร์ด Neucleo L432KC เชื่อมต่อขา A3 เข้ากับ D3

[TH] Blender : Low Poly Man

บทความนี้เป็นบันทึกขั้นตอนการขึ้นรูปคนแบบโพลีกอนน้อยด้วยโปรแกรม Blender ซึ่งเป็นซอฟต์แวร์แบบแจกจ่ายฟรี และเปิดเผยโค้ด ปัจจุบันเป็นรุ่น 2.93.6 LTS โดยเริ่มต้นจากกล่องแล้วตัดฝั่งซ้ายออกไป หลังจากนั้นใช้ Modifier แบบ Mirror เพื่อให้ฝั่งซ้ายและขวาเหมือนกัน ทำให้ปรับแก้เฉกาะฝั่งขวาทำให้งฝั่งซ้ายมีผลตามไปด้วย หลังจากนั้นจัดรูปทรงให้เป็นตามภาพที่ 1

ภาพที่ 1 ขึ้นรูปจากบริเวณลำตัว

[TH] Arduino: The LGT8F328P’s ADC/DAC.

บทความนี้เป็นบทความที่ต่อเนื่องจากบทความแนะนำบอร์ด LGT8F328P และการใช้ ADC และ DAC ในก่อนหน้านี้ โดยเน้นที่การใช้งานสำหรับชิพ LGT8F328P เป็นหลัก โดยการใช้งานนั้นจะแตกต่างจาก SAM-D21 ตรงที่ ใช้ขา D4 เป็นขาที่ทำหน้าที่ DAC0 และวงจร DAC มีความละเอียดในการทำงานระดับ 8 บิต หรือส่งออกค่าได้ตั้งแต่ 0 ถึง 255 ส่วนภาค ADC นั้นใช้ขา A0, A1, … ได้ตามปกติ และมีความละเอียดในการทำงาน 12 บิต ดังนั้น ในบทความนี้จึงใช้การเชื่อมต่อขาจาก A0 เข้ากับ D4 ในการทดลองดังภาพที่ 1

ภาพที่ 1 บอร์ด LGT8F328P เชื่อมต่อขา A0 เข้ากับ D4

[EN] u8g2 Library

From the article on using the ESP8266 with an OLED graphical display written in Python, you’ll find that it’s fast and easy but when used with other microcontrollers that cannot use Micropython or CircuitPython, what must be done? One of the many options is the u8glib or u8g2 (Universal 8 bit Graphics Library) libraries, designed to work with monochromatic 8-bit graphics over either I2C or SPI communication. In this article, we are using I2C OLED as shown in Figure 1.

(Figure. 1 STM32F401CCU6 with I2C OLED)

[TH] Arduino ADC/DAC

บทความนี้แนะนำบอร์ดไมโครคอนโทรลเลอร์ ESP32 และ SAM-D21 มาใช้งานเพื่อเรียนรู้การใช้คำสั่งเกี่ยวกับ ADC (Analog to Digital Converter) และ DAC (Digital to Analog Converter) ด้วยการเชื่อมต่อขา DAC เข้ากับ ADC ดังตัวอย่างภาพที่ 1 (เชื่อม A0 เข้า A1 ของบอร์ด SAM-D21) และ 2 (เชื่อมต่อขา GPIO26 เข้ากับ GPIO36 ของ ESP32) เพื่อส่งข้อมูลที่ไป DAC และให้ ADC อ่านค่ากลับเข้ามา และส่งผลลัพธ์ออกไปที่พอร์ตอนุกรมสำหรับแสดงผลด้วย Serial Plotter ซึ่งตัวอย่างโปรแกรมสั่งส่งข้อมูล 3 แบบ คือ กราฟแบบฟันปลา กราฟแบบสามเหลี่ยม และกราฟรูปคลื่นจากฟังก์ชันไซน์

ภาพที่ 1 บอร์ด SAM-D21 เชื่อมต่อขา A0 เข้ากับ A1
ภาพที่ 2 บอร์ด ESP32 ที่เชื่อมต่อขา 26 เข้ากับ 36