[โอเพ่นซอร์ส] อุปกรณ์ชั่งน้ำหนักมัลติฟังก์ชั่น

——จากฟอรัมนักพัฒนา DWIN

ในฉบับนี้ เราได้ผลักดันกรณีโอเพ่นซอร์สที่ได้รับรางวัลของ DWIN Developer Forum - เครื่องชั่งน้ำหนักแบบมัลติฟังก์ชั่น วิศวกรใช้หน้าจออัจฉริยะ COF ขนาด 4 นิ้ว และผ่านการโต้ตอบข้อมูลระหว่างแกน T5L OS และโมดูล HX711 และชุดเซ็นเซอร์ความดัน 5 กก. ผู้ใช้จึงสามารถรับรู้ฟังก์ชันการแสดงผลการนับ เช่น น้ำหนัก ราคาต่อหน่วย ราคารวม น้ำหนักภาชนะ ฯลฯ ได้อย่างง่ายดาย ตลอดจนฟังก์ชันการนับ การติดตามกราฟการเปลี่ยนแปลงน้ำหนัก และการแก้ไขความแม่นยำของเครื่องชั่งน้ำหนัก ฯลฯ เพื่อให้ง่ายต่อการสลับระหว่างสถานการณ์การใช้งานต่างๆ เพื่อเพลิดเพลินกับประสบการณ์การชั่งน้ำหนักที่สะดวกและมีประสิทธิภาพ

1. การพัฒนา UI

f26af533d43728cd210e0f7af5e7acc

2.การออกแบบ C51

ส่วนหนึ่งของรหัสอ้างอิงสำหรับเครื่องชั่งน้ำหนักเพื่อใช้ฟังก์ชันการกำหนดราคามีดังนี้:

// หน้าราคา===================

#กำหนด VALUATION_UNIT_PRICE_ADDR 0x1010

#กำหนด VALUATION_GRAM_ADDR 0x1000

#กำหนด VALUATION_TOTAL_PRICES_ADDR 0x1020

uint32_t การประเมินค่า_การตกแต่ง = 0; // ราคาน้ำหนักเมื่อทดค่า

uint32_t การประเมินราคา_หน่วย_ราคา = 0; //ราคาต่อหน่วย

// รีเฟรชราคาต่อหน่วย

เป็นโมฆะ page_value_unit_price_refresh()

-

uint8_t test_display[10] = {0};

ถ้า(value_unit_price

-

test_display[0] = value_unit_price / 100 % 10 + 0x30;

test_display[1] = '.';

test_display[2] = value_unit_price / 10 % 10 + 0x30;

test_display[3] = value_unit_price / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

-

อย่างอื่นถ้า(value_unit_price

-

test_display[0] = value_unit_price / 1,000 % 10 + 0x30;

test_display[1] = value_unit_price / 100 % 10 + 0x30;

test_display[2] = '.';

test_display[3] = value_unit_price / 10 % 10 + 0x30;

test_display[4] = value_unit_price / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

-

อย่างอื่นถ้า(value_unit_price

-

test_display[0] = value_unit_price / 10,000 % 10 + 0x30;

test_display[1] = value_unit_price / 1,000 % 10 + 0x30;

test_display[2] = value_unit_price / 100 % 10 + 0x30;

test_display[3] = '.';

test_display[4] = value_unit_price / 10 % 10 + 0x30;

test_display[5] = value_unit_price / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

-

อย่างอื่นถ้า(value_unit_price

-

test_display[0] = value_unit_price / 100000 % 10 + 0x30;

test_display[1] = value_unit_price / 10,000 % 10 + 0x30;

test_display[2] = value_unit_price / 1,000 % 10 + 0x30;

test_display[3] = value_unit_price / 100 % 10 + 0x30;

test_display[4] = '.';

test_display[5] = value_unit_price / 10 % 10 + 0x30;

test_display[6] = value_unit_price / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

-

-

 

// รีเฟรชน้ำหนัก

เป็นโมฆะ page_value_weight_refresh()

-

uint8_t test_display[10] = {0x30};

uint32_t gram_display = 0;

ถ้า(gram_value >= value_decorticate)

-

gram_display = gram_value - ประเมินค่า_ตกแต่ง;

ถ้า(gram_display

-

test_display[0] = gram_display / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

-

อย่างอื่นถ้า (gram_display

-

test_display[0] = gram_display / 10 % 10 + 0x30;

test_display[1] = gram_display / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

-

อย่างอื่นถ้า (gram_display

-

test_display[0] = gram_display / 100 % 10 + 0x30;

test_display[1] = gram_display / 10 % 10 + 0x30;

test_display[2] = gram_display / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

-

อย่างอื่นถ้า (gram_display

-

test_display[0] = gram_display / 1,000 % 10 + 0x30;

test_display[1] = gram_display / 100 % 10 + 0x30;

test_display[2] = gram_display / 10 % 10 + 0x30;

test_display[3] = gram_display / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

-

อย่างอื่นถ้า (gram_display

-

test_display[0] = gram_display / 10,000 % 10 + 0x30;

test_display[1] = gram_display / 1,000 % 10 + 0x30;

test_display[2] = gram_display / 100 % 10 + 0x30;

test_display[3] = gram_display / 10 % 10 + 0x30;

test_display[4] = gram_display / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

-

-

อื่น

-

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

-

-

 

// รีเฟรชราคารวม

เป็นโมฆะ page_value_price_refresh()

-

uint32_t ราคา_ค่า = 0;

uint8_t test_display[10] = {0x30, '.', 0x30, 0x30};

ถ้า(gram_value >= value_decorticate)

-

price_value = (gram_value - value_decorticate) * value_unit_price * 2/1,000;

ถ้า(price_value

-

test_display[0] = ราคา_ค่า / 100 % 10 + 0x30;

test_display[1] = '.';

test_display[2] = price_value / 10 % 10 + 0x30;

test_display[3] = price_value / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

-

อย่างอื่นถ้า(price_value

-

test_display[0] = ราคา_ค่า / 1,000 % 10 + 0x30;

test_display[1] = price_value / 100 % 10 + 0x30;

test_display[2] = '.';

test_display[3] = price_value / 10 % 10 + 0x30;

test_display[4] = price_value / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

-

อย่างอื่นถ้า(price_value

-

test_display[0] = ราคา_ค่า / 10,000 % 10 + 0x30;

test_display[1] = ราคา_ค่า / 1,000 % 10 + 0x30;

test_display[2] = ราคา_ค่า / 100 % 10 + 0x30;

test_display[3] = '.';

test_display[4] = ราคา_ค่า / 10 % 10 + 0x30;

test_display[5] = price_value / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

-

อย่างอื่นถ้า(price_value

-

test_display[0] = ราคา_มูลค่า / 100000 % 10 + 0x30;

test_display[1] = ราคา_ค่า / 10,000 % 10 + 0x30;

test_display[2] = ราคา_ค่า / 1,000 % 10 + 0x30;

test_display[3] = ราคา_ค่า / 100 % 10 + 0x30;

test_display[4] = '.';

test_display[5] = price_value / 10 % 10 + 0x30;

test_display[6] = price_value / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

-

-

อื่น

-

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

-

-

เป็นโมฆะ page_value_decorticate()

-

value_decorticate = gram_value;

page_value_weight_refresh();

-

เป็นโมฆะ page_value_1()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 1;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_2()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 2;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_3()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 3;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_4()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 4;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_5()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 5;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_6()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 6;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_7()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 7;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_8()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 8;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_9()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 9;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_0()

-

ถ้า(value_unit_price

-

value_unit_price = value_unit_price * 10 + 0;

page_value_unit_price_refresh();

-

-

เป็นโมฆะ page_value_back()

-

value_unit_price = value_unit_price / 10;

page_value_unit_price_refresh();

-

เป็นโมฆะ page_value_clear()

-

การประเมินราคา_หน่วย_ราคา = 0;

page_value_unit_price_refresh();

-


เวลาโพสต์: 28 เมษายน-2024