——De la DWIN Developer Forum
În această ediție, promovăm cazul premiat cu sursă deschisă DWIN Developer Forum - Multi-function Weigher. Inginerul adoptă un ecran inteligent COF de 4 inchi, iar prin interacțiunea datelor dintre miezul T5L OS și modulul HX711 și setul de senzori de presiune de 5 kg, utilizatorii pot realiza cu ușurință funcțiile de afișare de numărare, cum ar fi greutatea, prețul unitar, prețul total, tara etc. ., precum și funcțiile de numărare, urmărire a curbelor de modificare a greutății și corectare a preciziei cântăritorului etc., astfel încât să fie ușor să comutați între diferite scenarii de aplicație pentru a vă bucura de o experiență de cântărire convenabilă și eficientă.
1. Dezvoltarea UI
2.C51 Proiectare
O parte a codului de referință pentru cântăritor pentru a implementa funcția de stabilire a prețului este după cum urmează:
// Pagina de prețuri====================
#define VALUATION_UNIT_PRICE_ADDR 0x1010
#define VALUATION_GRAM_ADDR 0x1000
#define VALUATION_TOTAL_PRICES_ADDR 0x1020
uint32_t valuation_decorticate = 0; // Prețuri Tara
uint32_t valuation_unit_price = 0; //Preț unitar
// Reîmprospătare preț unitar
void page_valuation_unit_price_refresh()
{
uint8_t test_display[10] = {0};
if(preț_unitario_evaluare
{
test_display[0] = valuation_unit_price / 100 % 10 + 0x30;
test_display[1] = '.';
test_display[2] = valuation_unit_price / 10 % 10 + 0x30;
test_display[3] = valuation_unit_price / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);
}
else if(valuation_unit_price
{
test_display[0] = valuation_unit_price / 1000 % 10 + 0x30;
test_display[1] = valuation_unit_price / 100 % 10 + 0x30;
test_display[2] = '.';
test_display[3] = valuation_unit_price / 10 % 10 + 0x30;
test_display[4] = valuation_unit_price / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);
}
else if(valuation_unit_price
{
test_display[0] = valuation_unit_price / 10000 % 10 + 0x30;
test_display[1] = valuation_unit_price / 1000 % 10 + 0x30;
test_display[2] = valuation_unit_price / 100 % 10 + 0x30;
test_display[3] = '.';
test_display[4] = valuation_unit_price / 10 % 10 + 0x30;
test_display[5] = valuation_unit_price / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);
}
else if(preț_unitate_evaluare
{
test_display[0] = valuation_unit_price / 100000 % 10 + 0x30;
test_display[1] = valuation_unit_price / 10000 % 10 + 0x30;
test_display[2] = valuation_unit_price / 1000 % 10 + 0x30;
test_display[3] = valuation_unit_price / 100 % 10 + 0x30;
test_display[4] = '.';
test_display[5] = valuation_unit_price / 10 % 10 + 0x30;
test_display[6] = valuation_unit_price / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);
}
}
// Reîmprospătare greutate
void page_valuation_weight_refresh()
{
uint8_t test_display[10] = {0x30};
uint32_t gram_display = 0;
if(valoare_gramă >= decorticare_evaluare)
{
gram_display = gram_value - valuation_decorticate;
if(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);
}
}
altfel
{
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
}
// Reîmprospătare preț total
void page_valuation_price_refresh()
{
uint32_t valoare_preț = 0;
uint8_t test_display[10] = {0x30, '.', 0x30, 0x30};
if(valoare_gramă >= decorticare_evaluare)
{
valoare_preț = (valoare_gramă - decorticare_evaluare) * preț_unitate_evaluare * 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);
}
else if(price_value
{
test_display[0] = price_value / 1000 % 10 + 0x30;
test_display[1] = price_value / 100 % 10 + 0x30;
test_display[2] = '.';
test_display[3] = preț_valoare / 10 % 10 + 0x30;
test_display[4] = price_value / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
else if(price_value
{
test_display[0] = price_value / 10000 % 10 + 0x30;
test_display[1] = preț_valoare / 1000 % 10 + 0x30;
test_display[2] = preț_valoare / 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);
}
else if(price_value
{
test_display[0] = price_value / 100000 % 10 + 0x30;
test_display[1] = preț_valoare / 10000 % 10 + 0x30;
test_display[2] = preț_valoare / 1000 % 10 + 0x30;
test_display[3] = preț_valoare / 100 % 10 + 0x30;
test_display[4] = '.';
test_display[5] = price_value / 10 % 10 + 0x30;
test_display[6] = preț_valoare / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
}
altfel
{
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
}
void page_valuation_decorticate()
{
valuation_decorticate = gram_value;
page_valuation_weight_refresh();
}
void page_valuation_1()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 1;
page_valuation_unit_price_refresh();
}
}
void page_valuation_2()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 2;
page_valuation_unit_price_refresh();
}
}
void page_valuation_3()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 3;
page_valuation_unit_price_refresh();
}
}
void page_valuation_4()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 4;
page_valuation_unit_price_refresh();
}
}
void page_valuation_5()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 5;
page_valuation_unit_price_refresh();
}
}
void page_valuation_6()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 6;
page_valuation_unit_price_refresh();
}
}
void page_valuation_7()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 7;
page_valuation_unit_price_refresh();
}
}
void page_valuation_8()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 8;
page_valuation_unit_price_refresh();
}
}
void page_valuation_9()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 9;
page_valuation_unit_price_refresh();
}
}
void page_valuation_0()
{
if(preț_unitario_evaluare
{
valuation_unit_price = valuation_unit_price * 10 + 0;
page_valuation_unit_price_refresh();
}
}
void page_valuation_back()
{
valuation_unit_price = valuation_unit_price / 10;
page_valuation_unit_price_refresh();
}
void page_valuation_clear()
{
preţ_unitate_evaluare = 0;
page_valuation_unit_price_refresh();
}
Ora postării: 28-apr-2024