[Open source] Dispositivo di pesatura multifunzionale

——Dal forum degli sviluppatori DWIN

In questo numero, presentiamo il pluripremiato caso open source del DWIN Developer Forum - Multi-function Weigher. L'ingegnere adotta uno schermo intelligente COF da 4 pollici e, attraverso l'interazione dei dati tra il core del sistema operativo T5L e il modulo HX711 e il set di sensori di pressione da 5 kg, gli utenti possono facilmente realizzare le funzioni di visualizzazione del conteggio come peso, prezzo unitario, prezzo totale, tara, ecc. ., nonché le funzioni di conteggio, tracciamento delle curve di variazione del peso e correzione della precisione della pesatrice, ecc., in modo che sia facile passare da uno scenario applicativo all'altro per godere di un'esperienza di pesatura comoda ed efficiente.

1. Sviluppo dell'interfaccia utente

f26af533d43728cd210e0f7af5e7acc

2.C51 Progettazione

Parte del codice di riferimento affinché la pesatrice possa implementare la funzione di prezzatura è la seguente:

// Pagina dei prezzi===================

#define VALUATION_UNIT_PRICE_ADDR 0x1010

#define VALUATION_GRAM_ADDR 0x1000

#define VALUATION_TOTAL_PRICES_ADDR 0x1020

uint32_t valutazione_decorticata = 0; // Prezzo Tara

uint32_t prezzo_unita_valutazione = 0; //Prezzo unitario

// Aggiornamento prezzo unitario

void page_valuation_unit_price_refresh()

{

uint8_t test_display[10] = {0};

if(prezzo_unità_valutazione

{

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

test_display[1] = '.';

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

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

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

altrimenti se(valuation_unit_price

{

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

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

test_display[2] = '.';

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

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

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

altrimenti se(valuation_unit_price

{

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

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

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

test_display[3] = '.';

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

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

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

altrimenti se(valuation_unit_price

{

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

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

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

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

test_display[4] = '.';

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

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

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

}

 

// Aggiornamento peso

void page_valuation_weight_refresh()

{

uint8_t test_display[10] = {0x30};

uint32_t grammo_display = 0;

if(valore_grammo >= valutazione_decorticata)

{

display_grammo = valore_grammo - valutazione_decorticato;

if(gram_display

{

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

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

altrimenti se (gram_display

{

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

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

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

altrimenti se (gram_display

{

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

test_visualizzazione[1] = grammi_visualizzazione / 10 % 10 + 0x30;

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

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

altrimenti se (gram_display

{

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

test_visualizzazione[1] = grammi_visualizzazione / 100 % 10 + 0x30;

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

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

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

altrimenti se (gram_display

{

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

test_visualizzazione[1] = grammi_visualizzazione / 1000 % 10 + 0x30;

test_visualizzazione[2] = grammi_visualizzazione / 100 % 10 + 0x30;

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

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

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

}

altro

{

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

}

 

// Aggiornamento prezzo totale

void page_valuation_price_refresh()

{

uint32_t valore_prezzo = 0;

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

if(valore_grammo >= valutazione_decorticata)

{

valore_prezzo = (valore_grammo - valutazione_decorticato) * prezzo_unità_valutazione * 2 / 1000;

if(valore_prezzo

{

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

test_display[1] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

altrimenti se(valore_prezzo

{

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

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

test_display[2] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

altrimenti se(valore_prezzo

{

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

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

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

test_display[3] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

altrimenti se(valore_prezzo

{

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

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

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

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

test_display[4] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

altro

{

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

void page_valuation_decorticate()

{

valutazione_decorticata = valore_grammo;

page_valuation_weight_refresh();

}

pagina_valuation_1 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 1;

page_valuation_unit_price_refresh();

}

}

pagina_valuation_2 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 2;

page_valuation_unit_price_refresh();

}

}

pagina_valuation_3 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 3;

page_valuation_unit_price_refresh();

}

}

pagina_valuation_4 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 4;

page_valuation_unit_price_refresh();

}

}

pagina_valuation_5 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 5;

page_valuation_unit_price_refresh();

}

}

pagina_valuation_6 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 6;

page_valuation_unit_price_refresh();

}

}

pagina_valuation_7 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 7;

page_valuation_unit_price_refresh();

}

}

pagina_valuation_8 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 8;

page_valuation_unit_price_refresh();

}

}

pagina_valuation_9 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 9;

page_valuation_unit_price_refresh();

}

}

pagina_valuation_0 vuota()

{

if(prezzo_unità_valutazione

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione * 10 + 0;

page_valuation_unit_price_refresh();

}

}

vuoto page_valuation_back()

{

prezzo_unita_di_valutazione = prezzo_unita_di_valutazione / 10;

page_valuation_unit_price_refresh();

}

vuoto page_valuation_clear()

{

prezzo_unita_valutazione = 0;

page_valuation_unit_price_refresh();

}


Orario di pubblicazione: 28 aprile 2024