——Avy amin'ny DWIN Developer Forum
Amin'ity laharana ity, dia manosika ny tranga open-source nahazo mari-pankasitrahana an'ny DWIN Developer Forum - Multi-function Weigher. Ny injeniera dia mampiasa 4-mirefy COF marani-tsaina efijery, ary amin'ny alalan'ny fifandraisana angon-drakitra eo amin'ny T5L OS fototra sy HX711 Modules sy 5kg tsindry sensor napetraka, ny mpampiasa dia afaka mora foana mahatsapa ny fanisana fampisehoana asa toy ny lanja, ny vidin'ny vondrona, ny totalin'ny vidiny, tara, sns ., ary koa ny fiasan'ny fanisana, ny fanaraha-maso ny fiovaovan'ny lanja, ary ny fanitsiana ny fahamarinan'ny mandanjalanja, sns., mba ho mora ny mifamadika eo amin'ny sehatra fampiharana samihafa mba hankafizana traikefa lanja mety sy mahomby.
1. Fampandrosoana UI
![f26af533d43728cd210e0f7af5e7acc](https://ecdn6.globalso.com/upload/p/1355/source/2024-06/665f077223d2b27894.png)
2.C51 Design
Ny ampahany amin'ny kaody reference ho an'ny weigher mba hampiharana ny vidin'ny vidiny dia toy izao manaraka izao:
// Pricing Page ====================
#farito VALUATION_UNIT_PRICE_ADDR 0x1010
#farito VALUATION_GRAM_ADDR 0x1000
#farito VALUATION_TOTAL_PRICES_ADDR 0x1020
uint32_t valuation_decorticate = 0; // Pricing Lanja tara
uint32_t valuation_unit_price = 0; //Vidin'ny singa
// Fanavaozana ny vidin'ny iray
void page_valuation_unit_price_refresh()
{
uint8_t test_display[10] = {0};
raha(vidim-bidy_fanamarinana
{
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);
}
raha tsy izany (value_unit_value
{
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);
}
raha tsy izany (value_unit_value
{
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);
}
raha tsy izany (value_unit_value
{
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);
}
}
// Weight Refresh
void page_valuation_weight_refresh()
{
uint8_t test_display[10] = {0x30};
uint32_t gram_display = 0;
raha(gram_value >= valuation_decorticate)
{
gram_display = gram_value - valuation_decorticate;
raha(gram_display
{
test_display[0] = gram_display / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
raha tsy izany (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);
}
raha tsy izany (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);
}
raha tsy izany (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);
}
raha tsy izany (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);
}
}
hafa
{
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
}
// Vidiny Total Refresh
void page_valuation_price_refresh()
{
uint32_t vidy_value = 0;
uint8_t test_display[10] = {0x30, '.', 0x30, 0x30};
raha(gram_value >= valuation_decorticate)
{
vidim-bidy = (sarobidy_grama - valuation_decorticate) * vidim-bidy_fanamarinana * 2 / 1000;
raha(prix_value
{
test_display[0] = vidy_value / 100 % 10 + 0x30;
test_display[1] = '.';
test_display[2] = vidy_value / 10 % 10 + 0x30;
test_display[3] = vidy_value / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
raha tsy izany (prix_value
{
test_display[0] = vidy_value / 1000 % 10 + 0x30;
test_display[1] = vidy_value / 100 % 10 + 0x30;
test_display[2] = '.';
test_display[3] = vidy_value / 10 % 10 + 0x30;
test_display[4] = vidy_value / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
raha tsy izany (prix_value
{
test_display[0] = vidy_value / 10000 % 10 + 0x30;
test_display[1] = vidy_value / 1000 % 10 + 0x30;
test_display[2] = vidy_value / 100 % 10 + 0x30;
test_display[3] = '.';
test_display[4] = vidy_value / 10 % 10 + 0x30;
test_display[5] = vidy_value / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
raha tsy izany (prix_value
{
test_display[0] = vidy_value / 100000 % 10 + 0x30;
test_display[1] = vidy_value / 10000 % 10 + 0x30;
test_display[2] = vidy_value / 1000 % 10 + 0x30;
test_display[3] = vidy_value / 100 % 10 + 0x30;
test_display[4] = '.';
test_display[5] = vidy_value / 10 % 10 + 0x30;
test_display[6] = vidy_value / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
}
hafa
{
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()
{
raha(vidim-bidy_fanitsiana
{
vidim-pizarana_tombana = vidim-pizarana_tombana * 10 + 1;
page_valuation_unit_price_refresh();
}
}
void page_valuation_2()
{
raha(vidim-bidy_fanitsiana
{
vidim-pizarana_tombana = vidim-pizarana_tombana * 10 + 2;
page_valuation_unit_price_refresh();
}
}
void page_valuation_3()
{
raha(vidim-bidy_fanitsiana
{
vidim-pizarana_tombanana = vidim-pizarana_tombana * 10 + 3;
page_valuation_unit_price_refresh();
}
}
void page_valuation_4()
{
raha(vidim-bidy_fanitsiana
{
vidim-pizarana_tombana = vidim-pizarana_tombana * 10 + 4;
page_valuation_unit_price_refresh();
}
}
void page_valuation_5()
{
raha(vidim-bidy_fanitsiana
{
vidim-pizarana_tombana = vidim-pizarana_tombana * 10 + 5;
page_valuation_unit_price_refresh();
}
}
void page_valuation_6()
{
raha(vidim-bidy_fanitsiana
{
vidim-pizarana_tombanana = vidim-pizarana_tombana * 10 + 6;
page_valuation_unit_price_refresh();
}
}
void page_valuation_7()
{
raha(vidim-bidy_fanitsiana
{
vidim-pizarana_tombanana = vidim-pizarana_tombana * 10 + 7;
page_valuation_unit_price_refresh();
}
}
void page_valuation_8()
{
raha(vidim-bidy_fanitsiana
{
vidim-pizarana_tombanana = vidim-pizarana_tombana * 10 + 8;
page_valuation_unit_price_refresh();
}
}
void page_valuation_9()
{
raha(vidim-bidy_fanitsiana
{
vidim-pizarana_tombanana = vidim-pizarana_tombanana * 10 + 9;
page_valuation_unit_price_refresh();
}
}
void page_valuation_0()
{
raha(vidim-bidy_fanitsiana
{
vidim-bidin'ny tombana = vidim-bidin'ny tombana * 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()
{
valuation_unit_prix = 0;
page_valuation_unit_price_refresh();
}
Fotoana fandefasana: Apr-28-2024