——ຈາກ DWIN Developer Forum
ໃນບັນຫານີ້, ພວກເຮົາຊຸກຍູ້ກໍລະນີເປີດແຫຼ່ງທີ່ໄດ້ຮັບຮາງວັນຂອງ DWIN Developer Forum - Multi-function Weigher. ວິສະວະກອນຮັບຮອງເອົາຫນ້າຈໍອັດສະລິຍະ COF 4 ນິ້ວ, ແລະໂດຍຜ່ານການໂຕ້ຕອບຂໍ້ມູນລະຫວ່າງ T5L OS core ແລະ HX711 ໂມດູນແລະຊຸດເຊັນເຊີຄວາມກົດດັນ 5kg, ຜູ້ໃຊ້ສາມາດຮັບຮູ້ຫນ້າທີ່ສະແດງຜົນການນັບໄດ້ຢ່າງງ່າຍດາຍເຊັ່ນ: ນ້ໍາຫນັກ, ລາຄາຫນ່ວຍ, ລາຄາລວມ, tare, ແລະອື່ນໆ. ., ເຊັ່ນດຽວກັນກັບຫນ້າທີ່ຂອງການນັບ, ການຕິດຕາມເສັ້ນໂຄ້ງການປ່ຽນແປງນ້ໍາຫນັກ, ແລະການແກ້ໄຂຄວາມຖືກຕ້ອງຂອງເຄື່ອງຊັ່ງນໍ້າຫນັກ, ແລະອື່ນໆ, ດັ່ງນັ້ນມັນງ່າຍທີ່ຈະປ່ຽນລະຫວ່າງສະຖານະການຄໍາຮ້ອງສະຫມັກທີ່ແຕກຕ່າງກັນເພື່ອເພີດເພີນກັບປະສົບການການຊັ່ງນໍ້າຫນັກທີ່ສະດວກແລະມີປະສິດທິພາບ.
1. ການພັດທະນາ UI
2.C51 ການອອກແບບ
ສ່ວນຫນຶ່ງຂອງລະຫັດອ້າງອີງສໍາລັບເຄື່ອງຊັ່ງນໍ້າຫນັກເພື່ອປະຕິບັດຫນ້າທີ່ການກໍານົດລາຄາແມ່ນດັ່ງຕໍ່ໄປນີ້:
// ໜ້າລາຄາ ====
#ກຳນົດ VALUATION_UNIT_PRICE_ADDR 0x1010
#ກຳນົດ VALUATION_GRAM_ADDR 0x1000
#ກຳນົດ VALUATION_TOTAL_PRICES_ADDR 0x1020
uint32_t valuation_decorticate = 0; // ລາຄາ Tare ນ້ໍາຫນັກ
uint32_t valuation_unit_price = 0; //ລາຄາຕໍ່ຫນ່ວຍ
// ປັບປຸງລາຄາຫົວໜ່ວຍ
void page_valuation_unit_price_refresh()
{
uint8_t test_display[10] = {0};
ຖ້າ(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);
}
ອື່ນຖ້າ(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);
}
ອື່ນຖ້າ (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);
}
ອື່ນຖ້າ (valuation_unit_price
{
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);
}
}
// ນໍ້າໜັກສົດຊື່ນ
void page_valuation_weight_refresh()
{
uint8_t test_display[10] = {0x30};
uint32_t gram_display = 0;
ຖ້າ(gram_value >= valuation_decorticate)
{
gram_display = gram_value - valuation_decorticate ;
ຖ້າ(gram_display
{
test_display[0] = gram_display / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
ອື່ນຖ້າ(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);
}
ອື່ນຖ້າ(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);
}
ອື່ນຖ້າ(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);
}
ອື່ນຖ້າ(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);
}
}
ອື່ນ
{
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
}
// ລາຄາລວມຄືນໃຫມ່
void page_valuation_price_refresh()
{
uint32_t price_value = 0;
uint8_t test_display[10] = {0x30, '.', 0x30, 0x30};
ຖ້າ(gram_value >= valuation_decorticate)
{
price_value = (gram_value - valuation_decorticate) * valuation_unit_price * 2/1000;
ຖ້າ(price_value
{
test_display[0] = price_value / 100 % 10 + 0x30;
test_display[1] = '.';
test_display[2] = price_value / 10 % 10 + 0x30;
test_display[3] = price_value / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
ອື່ນຖ້າ (price_value
{
test_display[0] = price_value / 1000 % 10 + 0x30;
test_display[1] = price_value / 100 % 10 + 0x30;
test_display[2] = '.';
test_display[3] = price_value / 10 % 10 + 0x30;
test_display[4] = price_value / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
ອື່ນຖ້າ (price_value
{
test_display[0] = price_value / 10000 % 10 + 0x30;
test_display[1] = price_value / 1000 % 10 + 0x30;
test_display[2] = price_value / 100 % 10 + 0x30;
test_display[3] = '.';
test_display[4] = price_value / 10 % 10 + 0x30;
test_display[5] = price_value / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
ອື່ນຖ້າ (price_value
{
test_display[0] = price_value / 100000 % 10 + 0x30;
test_display[1] = price_value / 10000 % 10 + 0x30;
test_display[2] = price_value / 1000 % 10 + 0x30;
test_display[3] = price_value / 100 % 10 + 0x30;
test_display[4] = '.';
test_display[5] = price_value / 10 % 10 + 0x30;
test_display[6] = price_value / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
}
ອື່ນ
{
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()
{
ຖ້າ(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 1 ;
page_valuation_unit_price_refresh();
}
}
void page_valuation_2()
{
ຖ້າ(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 2 ;
page_valuation_unit_price_refresh();
}
}
void page_valuation_3()
{
ຖ້າ(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 3 ;
page_valuation_unit_price_refresh();
}
}
void page_valuation_4()
{
ຖ້າ(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 4 ;
page_valuation_unit_price_refresh();
}
}
void page_valuation_5()
{
ຖ້າ(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 5 ;
page_valuation_unit_price_refresh();
}
}
void page_valuation_6()
{
ຖ້າ(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 6 ;
page_valuation_unit_price_refresh();
}
}
void page_valuation_7()
{
ຖ້າ(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 7 ;
page_valuation_unit_price_refresh();
}
}
void page_valuation_8()
{
ຖ້າ(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 8 ;
page_valuation_unit_price_refresh();
}
}
void page_valuation_9()
{
ຖ້າ(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 9 ;
page_valuation_unit_price_refresh();
}
}
void page_valuation_0()
{
ຖ້າ(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()
{
valuation_unit_price = 0;
page_valuation_unit_price_refresh();
}
ເວລາປະກາດ: 28-4-2024