[Öppen källkod] Multifunktionell vägningsenhet

——Från DWIN Developer Forum

I det här numret driver vi det prisbelönta fallet med öppen källkod av DWIN Developer Forum - Multi-function Weigher. Ingenjören använder en 4-tums COF-smartskärm, och genom datainteraktionen mellan T5L OS-kärnan och HX711-modulen och 5 kg trycksensoruppsättning kan användare enkelt realisera räknevisningsfunktionerna som vikt, enhetspris, totalpris, tara, etc. ., samt funktionerna för räkning, spårning av viktförändringskurvor och korrigering av vägningsnoggrannhet, etc., så att det är enkelt att växla mellan olika applikationsscenarier för att njuta av en bekväm och effektiv vägningsupplevelse.

1. UI-utveckling

f26af533d43728cd210e0f7af5e7acc

2.C51 Design

En del av referenskoden för vägaren för att implementera prissättningsfunktionen är följande:

// Prissida====================

#define VALUATION_UNIT_PRICE_ADDR 0x1010

#define VALUATION_GRAM_ADDR 0x1000

#define VALUATION_TOTAL_PRICES_ADDR 0x1020

uint32_t valuation_decorticate = 0; // Prissättning Egenvikt

uint32_t valuation_unit_price = 0; //Enhetspris

// Enhetspris Uppdatera

void page_valuation_unit_price_refresh()

{

uint8_t test_display[10] = {0};

if(valuation_unit_price

{

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(valuation_unit_price

{

test_display[0] = valuation_unit_price / 100 000 % 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);

}

}

 

// Vikt Refresh

void page_valuation_weight_refresh()

{

uint8_t test_display[10] = {0x30};

uint32_t gram_display = 0;

if(gram_value >= valuation_decorticate)

{

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);

}

annat om(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);

}

annat om(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);

}

annat om(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);

}

}

annan

{

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

}

 

// Totalprisuppdatering

void page_valuation_price_refresh()

{

uint32_t price_value = 0;

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

if(gram_value >= valuation_decorticate)

{

price_value = (gram_value - valuation_decorticate) * valuation_unit_price * 2 / 1000;

if(pris_värde

{

test_display[0] = pris_värde / 100 % 10 + 0x30;

test_display[1] = '.';

test_display[2] = pris_värde / 10 % 10 + 0x30;

test_display[3] = pris_värde / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

annat om (pris_värde

{

test_display[0] = pris_värde / 1000 % 10 + 0x30;

test_display[1] = pris_värde / 100 % 10 + 0x30;

test_display[2] = '.';

test_display[3] = pris_värde / 10 % 10 + 0x30;

test_display[4] = pris_värde / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

annat om (pris_värde

{

test_display[0] = pris_värde / 10 000 % 10 + 0x30;

test_display[1] = pris_värde / 1000 % 10 + 0x30;

test_display[2] = pris_värde / 100 % 10 + 0x30;

test_display[3] = '.';

test_display[4] = pris_värde / 10 % 10 + 0x30;

test_display[5] = pris_värde / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

annat om (pris_värde

{

test_display[0] = pris_värde / 100 000 % 10 + 0x30;

test_display[1] = pris_värde / 10 000 % 10 + 0x30;

test_display[2] = pris_värde / 1000 % 10 + 0x30;

test_display[3] = pris_värde / 100 % 10 + 0x30;

test_display[4] = '.';

test_display[5] = pris_värde / 10 % 10 + 0x30;

test_display[6] = pris_värde / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

annan

{

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(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 1;

page_valuation_unit_price_refresh();

}

}

void page_valuation_2()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 2;

page_valuation_unit_price_refresh();

}

}

void page_valuation_3()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 3;

page_valuation_unit_price_refresh();

}

}

void page_valuation_4()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 4;

page_valuation_unit_price_refresh();

}

}

void page_valuation_5()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 5;

page_valuation_unit_price_refresh();

}

}

void page_valuation_6()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 6;

page_valuation_unit_price_refresh();

}

}

void page_valuation_7()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 7;

page_valuation_unit_price_refresh();

}

}

void page_valuation_8()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 8;

page_valuation_unit_price_refresh();

}

}

void page_valuation_9()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 9;

page_valuation_unit_price_refresh();

}

}

void page_valuation_0()

{

if(valuation_unit_price

{

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()

{

värderingsenhetspris = 0;

page_valuation_unit_price_refresh();

}


Posttid: 2024-apr-28