本期為大家推送迪文開發(fā)者論壇獲獎開源案例——多功能稱重器。工程師采用4英寸COF智能屏,通過T5L OS核與HX711模塊及5kg壓力傳感器套裝進行數據交互,用戶可輕松實現(xiàn)重量、單價、總價、去皮等計價顯示功能,以及計數、重量變化曲線跟蹤和稱重器精準度矯正等功能,輕松切換不同應用場景,享受便捷高效稱重體驗。
UI開發(fā)示例
C51工程設計 稱重器實現(xiàn)計價功能的部分參考代碼如下:
//計價頁面===================#define VALUATION_UNIT_PRICE_ADDR 0x1010#define VALUATION_GRAM_ADDR 0x1000#define VALUATION_TOTAL_PRICES_ADDR 0x1020uint32_t valuation_decorticate = 0; //計價去皮重量uint32_t valuation_unit_price = 0; //單價//單價刷新void page_valuation_unit_price_refresh(){ uint8_t test_display[10] = {0}; if(valuation_unit_price < 1000) { 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 < 10000) { 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 < 100000) { 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 < 1000000) { 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; if(gram_value >= valuation_decorticate) { gram_display = gram_value - valuation_decorticate; if(gram_display < 10) { test_display[0] = gram_display / 1 % 10 + 0x30; dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3); } else if(gram_display < 100) { 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 < 1000) { 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 < 10000) { 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 < 100000) { 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); } } else { 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}; if(gram_value >= valuation_decorticate) { price_value = (gram_value - valuation_decorticate) * valuation_unit_price * 2 / 1000; if(price_value < 1000) { 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); } else if(price_value < 10000) { 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); } else if(price_value < 100000)
{ 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);
} else if(price_value < 1000000) { 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); } } else { 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(){ if(valuation_unit_price < 100000) { valuation_unit_price = valuation_unit_price * 10 + 1; page_valuation_unit_price_refresh(); }}void page_valuation_2(){ if(valuation_unit_price < 100000) { valuation_unit_price = valuation_unit_price * 10 + 2; page_valuation_unit_price_refresh(); }}void page_valuation_3(){ if(valuation_unit_price < 100000) { valuation_unit_price = valuation_unit_price * 10 + 3; page_valuation_unit_price_refresh(); }}void page_valuation_4(){ if(valuation_unit_price < 100000) { valuation_unit_price = valuation_unit_price * 10 + 4; page_valuation_unit_price_refresh(); }}
void page_valuation_5(){ if(valuation_unit_price < 100000) { valuation_unit_price = valuation_unit_price * 10 + 5; page_valuation_unit_price_refresh(); }}void page_valuation_6(){ if(valuation_unit_price < 100000) { valuation_unit_price = valuation_unit_price * 10 + 6; page_valuation_unit_price_refresh(); }}void page_valuation_7(){ if(valuation_unit_price < 100000) { valuation_unit_price = valuation_unit_price * 10 + 7; page_valuation_unit_price_refresh(); }}void page_valuation_8(){ if(valuation_unit_price < 100000) { valuation_unit_price = valuation_unit_price * 10 + 8; page_valuation_unit_price_refresh(); }}void page_valuation_9(){ if(valuation_unit_price < 100000) { valuation_unit_price = valuation_unit_price * 10 + 9; page_valuation_unit_price_refresh(); }}void page_valuation_0(){ if(valuation_unit_price < 100000) { 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();}
-
傳感器
+關注
關注
2553文章
51448瀏覽量
756890 -
開源
+關注
關注
3文章
3412瀏覽量
42734 -
智能屏幕
+關注
關注
0文章
66瀏覽量
3417
發(fā)布評論請先 登錄
相關推薦
![](https://file1.elecfans.com/web1/M00/F5/51/wKgaoWc63BKAMTZwAAmfHSiSKYw316.png)
多功能UC1834優(yōu)化線性調節(jié)器效率
![<b class='flag-5'>多功能</b>UC1834優(yōu)化線性調節(jié)<b class='flag-5'>器</b>效率](https://file.elecfans.com/web1/M00/D9/4E/pIYBAF_1ac2Ac0EEAABDkS1IP1s689.png)
物聯(lián)網行業(yè)中的智能稱重方案介紹_稱重傳感器分析
![物聯(lián)網行業(yè)中的智能<b class='flag-5'>稱重</b>方案介紹_<b class='flag-5'>稱重傳感器</b>分析](https://file1.elecfans.com//web2/M00/08/9C/wKgaombyXFaAQI36AAwbDAKRc4g275.jpg)
【開源獲獎案例】基于T5L智能屏的汽車抬頭顯示器方案
![【<b class='flag-5'>開源</b><b class='flag-5'>獲獎</b>案例】基于T5L智能屏的汽車抬頭顯示<b class='flag-5'>器</b>方案](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
【開源獲獎案例】基于T5L智能屏的指紋識別解決方案
![【<b class='flag-5'>開源</b><b class='flag-5'>獲獎</b>案例】基于T5L智能屏的指紋識別解決方案](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
![](https://file1.elecfans.com/web2/M00/F3/0F/wKgZomZ7xaWAJxstAAJ8-pqr2jk177.png)
稱重傳感器的選型及注意事項
12芯M16插頭連接器的多功能性
![12芯M16插頭連接<b class='flag-5'>器</b>的<b class='flag-5'>多功能</b>性](https://file1.elecfans.com/web2/M00/EE/5A/wKgZomZtZfyAXjBMAADNWD6ym-8580.png)
基于T5L芯片的多功能物聯(lián)網開發(fā)套件
![基于T5L芯片的<b class='flag-5'>多功能</b>物聯(lián)網開發(fā)套件](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
使用多功能數顯表的步驟 使用多功能數顯表的注意事項
多功能數顯表的功能特點有哪些?
什么是多功能傳感器 多功能傳感器的功能介紹
![什么是<b class='flag-5'>多功能</b>傳感<b class='flag-5'>器</b> <b class='flag-5'>多功能</b>傳感<b class='flag-5'>器</b>的<b class='flag-5'>功能</b>介紹](https://file1.elecfans.com/web2/M00/C7/65/wKgaomYKO5OAYwI7AAAZg1XTW6Y798.jpg)
【開源獲獎案例】隔空手勢識別測試系統(tǒng)
![【<b class='flag-5'>開源</b><b class='flag-5'>獲獎</b>案例】隔空手勢識別測試系統(tǒng)](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
評論