——Gan Fforwm Datblygwyr DWIN
Yn y rhifyn hwn, rydym yn gwthio achos ffynhonnell agored arobryn DWIN Developer Forum - Multi-function Weigher. Mae'r peiriannydd yn mabwysiadu sgrin smart COF 4-modfedd, a thrwy'r rhyngweithio data rhwng craidd T5L OS a modiwl HX711 a set synhwyrydd pwysau 5kg, gall defnyddwyr sylweddoli'n hawdd y swyddogaethau cyfrif arddangos megis pwysau, pris uned, cyfanswm pris, tare, ac ati. ., yn ogystal â swyddogaethau cyfrif, olrhain cromliniau newid pwysau, a chywiro cywirdeb pwyso, ac ati, fel ei bod hi'n hawdd newid rhwng gwahanol senarios cais i fwynhau profiad pwyso cyfleus ac effeithlon.
1. Datblygiad UI
![f26af533d43728cd210e0f7af5e7acc](https://ecdn6.globalso.com/upload/p/1355/source/2024-06/665f077223d2b27894.png)
2.C51 Dyluniad
Mae rhan o'r cod cyfeirio ar gyfer y pwyswr i weithredu'r swyddogaeth brisio fel a ganlyn:
// Tudalen Brisio=================
#define VALUATION_UNIT_PRICE_ADDR 0x1010
#define VALUATION_GRAM_ADDR 0x1000
#define VALUATION_TOTAL_PRICES_ADDR 0x1020
uint32_t prisio_decorticate = 0; // Prisio Pwysau Tare
uint32_t prisio_unit_price = 0; //Pris yr Uned
// Adnewyddu Pris Uned
tudalen gwag_valuation_unit_price_refresh()
{
uint8_t test_display[10] = {0};
if(valuation_unit_pris
{
test_display[0] = prisiad_unit_pris / 100 % 10 + 0x30;
test_display[1] = '.';
test_display[2] = prisiad_unit_pris / 10 % 10 + 0x30;
test_display[3] = prisiad_unit_pris / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);
}
arall os(valuation_unit_pris
{
test_display[0] = prisiad_unit_pris / 1000 % 10 + 0x30;
test_display[1] = prisiad_unit_pris / 100 % 10 + 0x30;
test_display[2] = '.';
test_display[3] = prisiad_unit_pris / 10 % 10 + 0x30;
test_display[4] = prisiad_unit_pris / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);
}
arall os(valuation_unit_pris
{
test_display[0] = prisiad_unit_pris / 10000 % 10 + 0x30;
test_display[1] = prisiad_unit_pris / 1000 % 10 + 0x30;
test_display[2] = prisiad_unit_pris / 100 % 10 + 0x30;
test_display[3] = '.';
test_display[4] = prisiad_unit_pris / 10 % 10 + 0x30;
test_display[5] = prisiad_unit_pris / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);
}
arall os(valuation_unit_pris
{
test_display[0] = prisiad_unit_pris / 100000 % 10 + 0x30;
test_display[1] = prisiad_unit_pris / 10000 % 10 + 0x30;
test_display[2] = prisiad_unit_pris / 1000 % 10 + 0x30;
test_display[3] = prisiad_unit_pris / 100 % 10 + 0x30;
test_display[4] = '.';
test_display[5] = prisiad_unit_pris / 10 % 10 + 0x30;
test_display[6] = prisiad_unit_pris / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);
}
}
// Adnewyddu Pwysau
tudalen wag_valuation_weight_refresh()
{
uint8_t test_display[10] = {0x30};
uint32_t gram_display = 0;
os(gram_value>= prisio_addurno)
{
gram_display = gram_value - prisio_decorticate;
os (gram_display
{
test_display[0] = gram_display / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
arall os (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);
}
arall os (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);
}
arall os (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);
}
arall os (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);
}
}
arall
{
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
}
// Cyfanswm Pris Adnewyddu
tudalen wag_valuation_pris_refresh()
{
uint32_t price_value = 0;
uint8_t test_display[10] = {0x30, '.', 0x30, 0x30};
os(gram_value>= prisio_addurno)
{
price_value = (gram_value - prisio_decorticate) * prisio_unit_price * 2 / 1000;
os(pris_gwerth
{
test_display[0] = pris_gwerth / 100 % 10 + 0x30;
test_display[1] = '.';
test_display[2] = pris_gwerth / 10 % 10 + 0x30;
test_display[3] = pris_gwerth / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
arall os(pris_gwerth
{
test_display[0] = pris_gwerth / 1000 % 10 + 0x30;
test_display[1] = pris_gwerth / 100 % 10 + 0x30;
test_display[2] = '.';
test_display[3] = pris_gwerth / 10 % 10 + 0x30;
test_display[4] = pris_gwerth / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
arall os(pris_gwerth
{
test_display[0] = pris_gwerth / 10000 % 10 + 0x30;
test_display[1] = pris_gwerth / 1000 % 10 + 0x30;
test_display[2] = pris_gwerth / 100 % 10 + 0x30;
test_display[3] = '.';
test_display[4] = pris_gwerth / 10 % 10 + 0x30;
test_display[5] = pris_gwerth / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
arall os(pris_gwerth
{
test_display[0] = pris_gwerth / 100000 % 10 + 0x30;
test_display[1] = pris_gwerth / 10000 % 10 + 0x30;
test_display[2] = pris_gwerth / 1000 % 10 + 0x30;
test_display[3] = pris_gwerth / 100 % 10 + 0x30;
test_display[4] = '.';
test_display[5] = pris_gwerth / 10 % 10 + 0x30;
test_display[6] = pris_gwerth / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
}
arall
{
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
}
tudalen wag_valuation_decorticate()
{
prisiad_decorticate = gram_value;
page_valuation_weight_refresh();
}
tudalen_valuation_1() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 1;
page_valuation_unit_price_refresh();
}
}
tudalen_valuation_2() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 2;
page_valuation_unit_price_refresh();
}
}
tudalen_valuation_3() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 3;
page_valuation_unit_price_refresh();
}
}
tudalen_valuation_4() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 4;
page_valuation_unit_price_refresh();
}
}
tudalen_valuation_5() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 5;
page_valuation_unit_price_refresh();
}
}
tudalen_valuation_6() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 6;
page_valuation_unit_price_refresh();
}
}
tudalen_valuation_7() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 7;
page_valuation_unit_price_refresh();
}
}
tudalen_valuation_8() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 8;
page_valuation_unit_price_refresh();
}
}
tudalen_valuation_9() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 9;
page_valuation_unit_price_refresh();
}
}
tudalen_valuation_0() gwag
{
if(valuation_unit_pris
{
prisio_unit_price = prisio_unit_price * 10 + 0;
page_valuation_unit_price_refresh();
}
}
tudalen wag_valuation_back()
{
prisio_unit_price = prisio_unit_price/10;
page_valuation_unit_price_refresh();
}
tudalen wag_gwerth_clir()
{
prisiad_unit_price = 0;
page_valuation_unit_price_refresh();
}
Amser postio: Ebrill-28-2024