[Open source] Piranti Timbangan Multifungsi

——Saka DWIN Developer Forum

Ing masalah iki, kita nyurung kasus sumber terbuka sing menang penghargaan saka DWIN Developer Forum - Multi-function Weigher. Engineer nganggo layar cerdas COF 4-inch, lan liwat interaksi data antarane inti T5L OS lan modul HX711 lan set sensor tekanan 5kg, pangguna bisa kanthi gampang ngerteni fungsi tampilan ngitung kayata bobot, rega unit, rega total, tare, lsp. ., uga fungsi ngetang, nelusuri kurva pangowahan bobot, lan mbenerake akurasi timbangan, lan sapiturute, supaya gampang ngalih ing antarane skenario aplikasi sing beda kanggo nikmati pengalaman timbang sing trep lan efisien.

1. Pangembangan UI

f26af533d43728cd210e0f7af5e7acc

2. C51 Desain

Bagéyan saka kode referensi kanggo timbangan kanggo ngleksanakake fungsi rega kaya ing ngisor iki:

// Pricing Page ==================================

#define VALUATION_UNIT_PRICE_ADDR 0x1010

#define VALUATION_GRAM_ADDR 0x1000

#define VALUATION_TOTAL_PRICES_ADDR 0x1020

uint32_t valuation_decorticate = 0; // Rega Bobot Tare

uint32_t valuation_unit_price = 0; //Harga Satuan

// Refresh Unit Rega

void page_valuation_unit_price_refresh()

{

uint8_t test_display[10] = {0};

if(harga_unit_nilai

{

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

test_display[1] = '.';

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

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

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

else if(harga_unit_nilai

{

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

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

test_display [2] = '.';

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

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

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

else if(harga_unit_nilai

{

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

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

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

test_display[3] = '.';

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

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

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

else if(harga_unit_nilai

{

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

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

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

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

test_display [4] = '.';

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

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

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

}

 

// Bobot Refresh

void page_valuation_weight_refresh()

{

uint8_t test_display[10] = {0x30};

uint32_t gram_display = 0;

yen (nilai_gram>= valuasi_dekortikasi)

{

gram_display = gram_value - valuation_decorticate;

yen(gram_display

{

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

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

else if(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);

}

else if(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);

}

else if(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);

}

else if(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);

}

}

liyane

{

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

}

 

// Total Price Refresh

void page_valuation_price_refresh()

{

uint32_t rega_nilai = 0;

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

yen (nilai_gram>= valuasi_dekortikasi)

{

rega_rega = (nilai_gram - valuation_decorticate) * rega_unit regane * 2 / 1000;

yen (nilai_harga

{

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

test_display[1] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

else if(nilai_harga

{

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

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

test_display [2] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

else if(nilai_harga

{

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

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

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

test_display[3] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

else if(nilai_harga

{

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

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

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

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

test_display [4] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

liyane

{

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

void page_valuation_decorticate()

{

valuation_decorticate = nilai_gram;

page_valuation_weight_refresh();

}

void page_valuation_1()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 1;

page_valuation_unit_price_refresh();

}

}

void page_valuation_2()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 2;

page_valuation_unit_price_refresh();

}

}

void page_valuation_3()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 3;

page_valuation_unit_price_refresh();

}

}

void page_valuation_4()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 4;

page_valuation_unit_price_refresh();

}

}

void page_valuation_5()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 5;

page_valuation_unit_price_refresh();

}

}

void page_valuation_6()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 6;

page_valuation_unit_price_refresh();

}

}

void page_valuation_7()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 7;

page_valuation_unit_price_refresh();

}

}

void page_valuation_8()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 8;

page_valuation_unit_price_refresh();

}

}

void page_valuation_9()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 9;

page_valuation_unit_price_refresh();

}

}

void page_valuation_0()

{

yen (harga_unit_nilai

{

rega_unit regane = rega_unit regane * 10 + 0;

page_valuation_unit_price_refresh();

}

}

void page_valuation_back()

{

rega_unit_nilai = rega_unit_nilai / 10;

page_valuation_unit_price_refresh();

}

void page_valuation_clear()

{

rega_unit_nilai = 0;

page_valuation_unit_price_refresh();

}


Wektu kirim: Apr-28-2024