——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 評価単位価格 = 0; //単価
// 単価の更新
void page_valuation_unit_price_refresh()
{
uint8_t test_display[10] = {0};
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_UNIT_PRICE_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_UNIT_PRICE_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_UNIT_PRICE_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_UNIT_PRICE_ADDR, test_display, 4);
}
}
// ウェイトの更新
void page_valuation_weight_refresh()
{
uint8_t test_display[10] = {0x30};
uint32_t gram_display = 0;
if(gram_value >= valuation_decorticate)
{
gram_display = gram_value - valuation_decorticate;
if(gram_display
{
test_display[0] = gram_display / 1 % 10 + 0x30;
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
else 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);
}
else 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);
}
else 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);
}
else 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);
}
}
それ以外
{
dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);
}
}
// 合計価格の更新
void page_valuation_price_refresh()
{
uint32_t 価格_値 = 0;
uint8_t test_display[10] = {0x30, '.', 0x30, 0x30};
if(gram_value >= valuation_decorticate)
{
価格値 = (グラム値 - 評価額) * 評価単位価格 * 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(price_value
{
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(price_value
{
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(price_value
{
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);
}
}
void page_valuation_decorticate()
{
評価_装飾 = グラム値;
page_valuation_weight_refresh();
}
void page_valuation_1()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 1;
page_valuation_unit_price_refresh();
}
}
void page_valuation_2()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 2;
page_valuation_unit_price_refresh();
}
}
void page_valuation_3()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 3;
page_valuation_unit_price_refresh();
}
}
void page_valuation_4()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 4;
page_valuation_unit_price_refresh();
}
}
void page_valuation_5()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 5;
page_valuation_unit_price_refresh();
}
}
void page_valuation_6()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 6;
page_valuation_unit_price_refresh();
}
}
void page_valuation_7()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 7;
page_valuation_unit_price_refresh();
}
}
void page_valuation_8()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 8;
page_valuation_unit_price_refresh();
}
}
void page_valuation_9()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 9;
page_valuation_unit_price_refresh();
}
}
void page_valuation_0()
{
if(評価単価
{
評価単価 = 評価単価 * 10 + 0;
page_valuation_unit_price_refresh();
}
}
void page_valuation_back()
{
評価単価 = 評価単価 / 10;
page_valuation_unit_price_refresh();
}
void page_valuation_clear()
{
評価単価 = 0;
page_valuation_unit_price_refresh();
}
投稿日時: 2024 年 4 月 28 日