[Mã nguồn mở] Thiết bị cân đa chức năng

--Từ Diễn đàn nhà phát triển DWIN

Trong số này, chúng tôi thúc đẩy trường hợp nguồn mở từng đoạt giải thưởng của Diễn đàn nhà phát triển DWIN - Máy cân đa chức năng. Kỹ sư sử dụng màn hình thông minh COF 4 inch và thông qua tương tác dữ liệu giữa lõi hệ điều hành T5L và mô-đun HX711 và bộ cảm biến áp suất 5kg, người dùng có thể dễ dàng nhận ra các chức năng hiển thị đếm như trọng lượng, đơn giá, tổng giá, bì, v.v. ., cũng như các chức năng đếm, theo dõi đường cong thay đổi trọng lượng và hiệu chỉnh độ chính xác của cân, v.v., để dễ dàng chuyển đổi giữa các kịch bản ứng dụng khác nhau nhằm tận hưởng trải nghiệm cân thuận tiện và hiệu quả.

1. Phát triển giao diện người dùng

f26af533d43728cd210e0f7af5e7acc

Thiết kế 2.C51

Một phần mã tham chiếu cho cân để thực hiện chức năng định giá như sau:

// Trang định giá =====================

#xác định VALUATION_UNIT_PRICE_ADDR 0x1010

#xác định VALUATION_GRAM_ADDR 0x1000

#xác định VALUATION_TOTAL_PRICES_ADDR 0x1020

uint32_t value_designate = 0; // Định giá trọng lượng bì

uint32_t value_unit_price = 0; //Đơn giá

// Làm mới đơn giá

void page_valuation_unit_price_refresh()

{

uint8_t test_display[10] = {0};

if(valuation_unit_price

{

test_display[0] = định giá_đơn vị giá / 100 % 10 + 0x30;

test_display[1] = '.';

test_display[2] = định giá_đơn vị giá / 10 % 10 + 0x30;

test_display[3] = định giá_đơn vị giá / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

khác nếu(giá trị_đơn vị_giá

{

test_display[0] = định giá_đơn vị giá / 1000 % 10 + 0x30;

test_display[1] = định giá_đơn vị giá / 100 % 10 + 0x30;

test_display[2] = '.';

test_display[3] = định giá_đơn vị giá / 10 % 10 + 0x30;

test_display[4] = định giá_đơn vị giá / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

khác nếu(giá trị_đơn vị_giá

{

test_display[0] = định giá_đơn vị giá / 10000 % 10 + 0x30;

test_display[1] = định giá_đơn vị giá / 1000 % 10 + 0x30;

test_display[2] = định giá_đơn vị giá / 100 % 10 + 0x30;

test_display[3] = '.';

test_display[4] = định giá_đơn vị giá / 10 % 10 + 0x30;

test_display[5] = định giá_đơn vị giá / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

khác nếu(giá trị_đơn vị_giá

{

test_display[0] = định giá_đơn vị giá / 100000 % 10 + 0x30;

test_display[1] = định giá_đơn vị giá / 10000 % 10 + 0x30;

test_display[2] = định giá_đơn vị giá / 1000 % 10 + 0x30;

test_display[3] = định giá_đơn vị giá / 100 % 10 + 0x30;

test_display[4] = '.';

test_display[5] = định giá_đơn vị giá / 10 % 10 + 0x30;

test_display[6] = định giá_đơn vị giá / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

}

 

// Làm mới trọng lượng

void page_valuation_weight_refresh()

{

uint8_t test_display[10] = {0x30};

uint32_t gram_display = 0;

if(gram_value >= value_designate)

{

gram_display = gram_value - value_designate;

if(gram_display

{

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

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

khác nếu(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);

}

khác nếu(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);

}

khác nếu (gram_display

{

test_display[0] = gram_display/1000 % 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);

}

khác nếu (gram_display

{

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

test_display[1] = gram_display/1000 % 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);

}

}

khác

{

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

}

 

// Làm mới tổng giá

trang trống_valuation_price_refresh()

{

uint32_t price_value = 0;

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

if(gram_value >= value_designate)

{

giá_giá_trị = (giá trị gram - giá_trị_trang trí) * giá_đơn vị_giá * 2/1000;

if(price_value

{

test_display[0] = price_value / 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);

}

khác nếu (price_value

{

test_display[0] = price_value / 1000 % 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);

}

khác nếu (price_value

{

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

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

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

test_display[3] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

khác nếu (price_value

{

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

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

test_display[2] = giá_giá trị / 1000 % 10 + 0x30;

test_display[3] = price_value / 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);

}

}

khác

{

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

khoảng trống trang_valuation_trang trí ()

{

value_decorticate = gram_value;

page_valuation_weight_refresh();

}

trang trống_valuation_1()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 1;

page_valuation_unit_price_refresh();

}

}

trang trống_valuation_2()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 2;

page_valuation_unit_price_refresh();

}

}

trang trống_valuation_3()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 3;

page_valuation_unit_price_refresh();

}

}

trang trống_valuation_4()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 4;

page_valuation_unit_price_refresh();

}

}

trang trống_valuation_5()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 5;

page_valuation_unit_price_refresh();

}

}

trang trống_valuation_6()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 6;

page_valuation_unit_price_refresh();

}

}

trang trống_valuation_7()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 7;

page_valuation_unit_price_refresh();

}

}

trang trống_valuation_8()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 8;

page_valuation_unit_price_refresh();

}

}

trang trống_valuation_9()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 9;

page_valuation_unit_price_refresh();

}

}

trang trống_valuation_0()

{

if(valuation_unit_price

{

định giá_đơn_giá = định giá_đơn_giá * 10 + 0;

page_valuation_unit_price_refresh();

}

}

void page_valuation_back()

{

định giá_đơn_giá = định giá_đơn_giá / 10;

page_valuation_unit_price_refresh();

}

trang trống_valuation_clear()

{

định giá_đơn_giá = 0;

page_valuation_unit_price_refresh();

}


Thời gian đăng: 28-04-2024