[Çavkaniya vekirî] Amûra giraniya pirfunctional

——Ji Foruma Pêşdebir a DWIN

Di vê hejmarê de, em doza xelat-çavkaniya vekirî ya DWIN Developer Forum - Weighter Pir-fonksiyonî derdixin pêş. Endezyar ekranek biaqil a 4-inç COF qebûl dike, û bi navgîniya danûstendina daneyê ya di navbera bingeha T5L OS û modula HX711 û seta senora zextê ya 5 kg de, bikarhêner dikarin bi hêsanî fonksiyonên dîmenderê yên wekî giranî, bihayê yekîneyê, bihayê giştî, tar, hwd. ., û her weha fonksiyonên hejmartinê, şopandina kelûpelên guheztina giraniyê, û rastkirina rastbûna giraniyê, û hwd., Ji ber vê yekê hêsan e ku meriv di navbera senaryoyên cihêreng ên serîlêdanê de biguhezîne da ku ji ezmûnek giraniya rehet û bikêrhatî sûd werbigire.

1. Pêşveçûna UI

f26af533d43728cd210e0f7af5e7acc

2.C51 Design

Beşek koda referansê ya ji bo pîvandinê ku fonksiyona bihayê bicîh tîne wiha ye:

// Rûpelê Bihayê====================

#define VALUATION_UNIT_PRICE_ADDR 0x1010

#define VALUATION_GRAM_ADDR 0x1000

#define VALUATION_TOTAL_PRICES_ADDR 0x1020

uint32_t valuation_decorticate = 0; // Bihayê Tare Weight

uint32_t valuation_unit_price = 0; //Bihayê Yekîneyê

// Nûvekirina Bihayê Yekîneyê

betal page_valuation_unit_price_refresh()

{

uint8_t test_display[10] = {0};

eger(nirx_yekîneya_biha

{

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

}

din eger (nirx_yekîneya_biha

{

test_display[0] = nirxa_yekîneya_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);

}

din eger (nirx_yekeya_biha

{

test_display[0] = nirxa_yekîneya_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);

}

din eger (nirx_yekeya_biha

{

test_display[0] = nirxa_yekîneya_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);

}

}

 

// Weight Refresh

betal page_valuation_weight_refresh()

{

uint8_t test_display[10] = {0x30};

uint32_t gram_display = 0;

eger (gram_nirx >= nirx_decorticate)

{

gram_display = gram_value - valuation_decorticate;

eger(gram_display

{

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

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

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

}

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

}

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

}

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

}

}

wekîdi

{

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

}

 

// Nûvekirina Bihayê Bi tevahî

betal page_valuation_price_refresh()

{

uint32_t price_value = 0;

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

eger (gram_nirx >= nirx_decorticate)

{

nirx_biha = (gram_nirx - valuation_decorticate) * nirxa_yekîneya_nirxê * 2 / 1000;

eger (nirx_biha

{

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

test_display[1] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

din eger (nirx_biha

{

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

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

test_display[2] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

din eger (biha_nirx

{

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

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

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

test_display[3] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

din eger (biha_nirx

{

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

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

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

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

test_display[4] = '.';

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

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

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

wekîdi

{

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

void page_valuation_decorticate()

{

valuation_decorticate = gram_value;

page_valuation_weight_refresh();

}

betal page_valuation_1()

{

heke(nirx_yekîneya_biha

{

valuation_unit_price = valuation_unit_price * 10 + 1;

page_valuation_unit_price_refresh();

}

}

betal page_valuation_2()

{

heke(nirx_yekîneya_biha

{

valuation_unit_price = valuation_unit_price * 10 + 2;

page_valuation_unit_price_refresh();

}

}

betal page_valuation_3()

{

heke(nirx_yekîneya_biha

{

valuation_unit_price = valuation_unit_price * 10 + 3;

page_valuation_unit_price_refresh();

}

}

betal page_valuation_4()

{

heke(nirx_yekîneya_biha

{

valuation_unit_price = valuation_unit_price * 10 + 4;

page_valuation_unit_price_refresh();

}

}

betal page_valuation_5()

{

heke(nirx_yekîneya_biha

{

valuation_unit_price = valuation_unit_price * 10 + 5;

page_valuation_unit_price_refresh();

}

}

betal page_valuation_6()

{

heke(nirx_yekîneya_biha

{

valuation_unit_price = valuation_unit_price * 10 + 6;

page_valuation_unit_price_refresh();

}

}

betal page_valuation_7()

{

heke(nirx_yekîneya_biha

{

valuation_unit_price = valuation_unit_price * 10 + 7;

page_valuation_unit_price_refresh();

}

}

betal page_valuation_8()

{

heke(nirx_yekîneya_biha

{

valuation_unit_price = valuation_unit_price * 10 + 8;

page_valuation_unit_price_refresh();

}

}

betal page_valuation_9()

{

heke(nirx_yekîneya_biha

{

valuation_unit_price = valuation_unit_price * 10 + 9;

page_valuation_unit_price_refresh();

}

}

betal page_valuation_0()

{

heke(nirx_yekîneya_biha

{

nirxa_yekîneya_nirx = nirxa_yekîneya_nirx * 10 + 0;

page_valuation_unit_price_refresh();

}

}

void page_valuation_back()

{

valuation_unit_price = valuation_unit_price / 10;

page_valuation_unit_price_refresh();

}

betal page_valuation_clear()

{

valuation_unit_price = 0;

page_valuation_unit_price_refresh();

}


Dema şandinê: Avrêl-28-2024