——DWIN 개발자 포럼에서
이번 호에서는 수상 경력이 있는 DWIN 개발자 포럼 - 다기능 계량기의 오픈 소스 사례를 소개합니다. 엔지니어는 4인치 COF 스마트 스크린을 채택하고 T5L OS 코어와 HX711 모듈 및 5kg 압력 센서 세트 간의 데이터 상호 작용을 통해 사용자는 중량, 단가, 총 가격, 용기 등의 계산 표시 기능을 쉽게 실현할 수 있습니다. ., 계수 기능, 중량 변화 곡선 추적, 계량기 정확도 수정 등의 기능을 통해 다양한 응용 시나리오 간을 쉽게 전환하여 편리하고 효율적인 계량 경험을 누릴 수 있습니다.
1. UI 개발
![f26af533d43728cd210e0f7af5e7acc](https://ecdn6.globalso.com/upload/p/1355/source/2024-06/665f077223d2b27894.png)
2.C51 디자인
가격 책정 기능을 구현하기 위한 계량기에 대한 참조 코드의 일부는 다음과 같습니다.
// 가격 페이지===================
#define VALUATION_UNIT_PRICE_ADDR 0x1010
#define VALUATION_GRAM_ADDR 0x1000
#define VALUATION_TOTAL_PRICES_ADDR 0x1020
uint32_t valuation_decorticate = 0; // 용기 중량 가격 책정
uint32_t valuation_unit_price = 0; //단가
// 단가 새로고침
무효 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 / 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);
}
}
// 가중치 새로 고침
무효 page_valuation_weight_refresh()
{
uint8_t test_display[10] = {0x30};
uint32_t gram_display = 0;
if(gram_value >= 평가_장식)
{
gram_display = gram_value - 평가_장식;
if(그램_디스플레이
{
test_display[0] = 그램_디스플레이 / 1% 10 + 0x30;
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
그렇지 않은 경우(gram_display
{
test_display[0] = 그램_디스플레이 / 10% 10 + 0x30;
test_display[1] = 그램_디스플레이 / 1% 10 + 0x30;
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
그렇지 않은 경우(gram_display
{
test_display[0] = 그램_디스플레이 / 100 % 10 + 0x30;
test_display[1] = 그램_디스플레이 / 10 % 10 + 0x30;
test_display[2] = 그램_디스플레이 / 1% 10 + 0x30;
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
그렇지 않은 경우(gram_display
{
test_display[0] = 그램_디스플레이 / 1000 % 10 + 0x30;
test_display[1] = 그램_디스플레이 / 100 % 10 + 0x30;
test_display[2] = 그램_디스플레이 / 10 % 10 + 0x30;
test_display[3] = 그램_디스플레이 / 1% 10 + 0x30;
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
그렇지 않은 경우(gram_display
{
test_display[0] = 그램_디스플레이 / 10000 % 10 + 0x30;
test_display[1] = 그램_디스플레이 / 1000 % 10 + 0x30;
test_display[2] = 그램_디스플레이 / 100 % 10 + 0x30;
test_display[3] = 그램_디스플레이 / 10 % 10 + 0x30;
test_display[4] = 그램_디스플레이 / 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);
}
}
// 총 가격 새로고침
무효 page_valuation_price_refresh()
{
uint32_t 가격_값 = 0;
uint8_t test_display[10] = {0x30, '.', 0x30, 0x30};
if(gram_value >= 평가_장식)
{
가격_값 = (그램_값 - 평가_장식) * 평가_단가_가격 * 2 / 1000;
if(가격_값
{
test_display[0] = 가격_값 / 100 % 10 + 0x30;
test_display[1] = '.';
test_display[2] = 가격_값 / 10 % 10 + 0x30;
test_display[3] = 가격_값 / 1% 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
else if(가격_값
{
test_display[0] = 가격_값 / 1000 % 10 + 0x30;
test_display[1] = 가격_값 / 100 % 10 + 0x30;
test_display[2] = '.';
test_display[3] = 가격_값 / 10 % 10 + 0x30;
test_display[4] = 가격_값 / 1% 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
else if(가격_값
{
test_display[0] = 가격_값 / 10000 % 10 + 0x30;
test_display[1] = 가격_값 / 1000 % 10 + 0x30;
test_display[2] = 가격_값 / 100 % 10 + 0x30;
test_display[3] = '.';
test_display[4] = 가격_값 / 10 % 10 + 0x30;
test_display[5] = 가격_값 / 1% 10 + 0x30;
dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);
}
else if(가격_값
{
test_display[0] = 가격_값 / 100000 % 10 + 0x30;
test_display[1] = 가격_값 / 10000 % 10 + 0x30;
test_display[2] = 가격_값 / 1000 % 10 + 0x30;
test_display[3] = 가격_값 / 100 % 10 + 0x30;
test_display[4] = '.';
test_display[5] = 가격_값 / 10 % 10 + 0x30;
test_display[6] = 가격_값 / 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);
}
}
무효 페이지_평가_장식()
{
평가_장식 = 그램_값;
page_valuation_weight_refresh();
}
무효 page_valuation_1()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 1;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_2()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 2;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_3()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 3;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_4()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 4;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_5()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 5;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_6()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 6;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_7()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 7;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_8()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 8;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_9()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 9;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_0()
{
if(valuation_unit_price
{
valuation_unit_price = valuation_unit_price * 10 + 0;
page_valuation_unit_price_refresh();
}
}
무효 page_valuation_back()
{
valuation_unit_price = valuation_unit_price / 10;
page_valuation_unit_price_refresh();
}
무효 page_valuation_clear()
{
평가_단가_가격 = 0;
page_valuation_unit_price_refresh();
}
게시 시간: 2024년 4월 28일