View on GitHub

microbit-2of5-font

2of5 number screen in makecode microbit

microbit-2of5-font

README | TH-README

ส่วนขยาย MakeCode สำหรับ micro:bit ที่แสดงตัวเลขบนหน้าจอ LED 5×5 ในรูปแบบ 2 of 5
ได้รับแรงบันดาลใจจากตระกูลบาร์โค้ด 2 of 5 โดยเฉพาะ Interleaved 2 of 5 (ITF)

เดโม:

หน้าโปรเจกต์: https://quarequin.github.io/microbit-2of5-font/


คุณสมบัติ


การติดตั้งเป็น Extension

  1. เปิด https://makecode.microbit.org/
  2. สร้าง New Project
  3. คลิกไอคอนเฟือง → Extensions
  4. วางลิงก์นี้แล้วกด Import:
https://github.com/Quarequin/microbit-2of5-font

(ลิงก์เดิม https://github.com/phatisena/microbit-2of5-font ยังใช้งานได้)


บล็อก / ฟังก์ชันหลัก

ฟังก์ชัน คำอธิบาย
write2of5(a, b) แปลงตำแหน่งบิต 2 ตำแหน่ง (0–4) เป็นตัวเลข 2of5 (คืนค่า -1 ถ้าไม่ถูกต้อง)
show2of5Number(n, guard, transpose?, brightness?) แสดงตัวเลขเต็ม (สูงสุด 5 หรือ 6 หลัก)
show2of5SingleNumber(n, col, inv, transpose?, brightness?) แสดงตัวเลข 1 หลักที่ตำแหน่งคอลัมน์ที่กำหนด
show2of5DualNumber(a, b, align, transpose?, brightness?) แสดงตัวเลข 2 ค่าพร้อมกัน (ซ้าย / กลาง / ขวา)

พารามิเตอร์สำคัญ


รูปแบบการเข้ารหัส 2 of 5

แต่ละหลักถูกเข้ารหัสด้วย 5 บิต (มีบิตที่เป็น 1 อยู่พอดี 2 บิต):

0 → 11000
1 → 10100
2 → 10010
3 → 10001
4 → 01100
5 → 01010
6 → 01001
7 → 00110
8 → 00101
9 → 00011

เก็บใน Buffer แบบเรียงจากมากไปน้อย (เรียกกันเล่น ๆ ว่า 2of5 magic buffer):

const pin2of5: Buffer = hex`181412110C0A09060503`

ฟังก์ชัน write2of5 ใช้ binary search บน Buffer นี้เพื่อแปลงตำแหน่งบิต 2 จุดกลับเป็นตัวเลข


แก้ไขโปรเจกต์นี้

  1. เปิด https://makecode.microbit.org/
  2. คลิก ImportImport URL
  3. วางลิงก์:
https://github.com/Quarequin/microbit-2of5-font

ข้อมูลทางเทคนิค


Metadata (used for search, rendering)

microbit-2of5-font

README | TH-README

ส่วนขยาย MakeCode สำหรับ micro:bit ที่แสดงตัวเลขบนหน้าจอ LED 5×5 ในรูปแบบ 2 of 5
ได้รับแรงบันดาลใจจากตระกูลบาร์โค้ด 2 of 5 โดยเฉพาะ Interleaved 2 of 5 (ITF)

เดโม:

หน้าโปรเจกต์: https://quarequin.github.io/microbit-2of5-font/


คุณสมบัติ


การติดตั้งเป็น Extension

  1. เปิด https://makecode.microbit.org/
  2. สร้าง New Project
  3. คลิกไอคอนเฟือง → Extensions
  4. วางลิงก์นี้แล้วกด Import:
https://github.com/Quarequin/microbit-2of5-font

(ลิงก์เดิม https://github.com/phatisena/microbit-2of5-font ยังใช้งานได้)


บล็อก / ฟังก์ชันหลัก

ฟังก์ชัน คำอธิบาย
write2of5(a, b) แปลงตำแหน่งบิต 2 ตำแหน่ง (0–4) เป็นตัวเลข 2of5 (คืนค่า -1 ถ้าไม่ถูกต้อง)
show2of5Number(n, guard, transpose?) แสดงตัวเลขเต็ม (สูงสุด 5 หรือ 6 หลัก)
show2of5SingleNumber(n, inv, col, transpose?) แสดงตัวเลข 1 หลักที่ตำแหน่งคอลัมน์ที่กำหนด
show2of5DualNumber(a, b, align, transpose?) แสดงตัวเลข 2 ค่าพร้อมกัน (ซ้าย / กลาง / ขวา)

พารามิเตอร์สำคัญ


รูปแบบการเข้ารหัส 2 of 5

แต่ละหลักถูกเข้ารหัสด้วย 5 บิต (มีบิตที่เป็น 1 อยู่พอดี 2 บิต):

0 → 11000
1 → 10100
2 → 10010
3 → 10001
4 → 01100
5 → 01010
6 → 01001
7 → 00110
8 → 00101
9 → 00011

เก็บใน Buffer แบบกระชับ:

const pin2of5: Buffer = hex`181412110C0A09060503`

แก้ไขโปรเจกต์นี้

  1. เปิด https://makecode.microbit.org/
  2. คลิก ImportImport URL
  3. วางลิงก์:
https://github.com/Quarequin/microbit-2of5-font

ข้อมูลทางเทคนิค


Metadata (used for search, rendering)