本期为大家推送迪文开发者论坛获奖开源案例——多功能称重器。工程师采用4英寸COF智能屏,通过T5L OS核与HX711模块及5kg压力传感器套装进行数据交互,用户可轻松实现重量、单价、总价、去皮等计价显示功能,以及计数、重量变化曲线跟踪和称重器精准度矫正等功能,轻松切换不同应用场景,享受便捷高效称重体验。
UI开发示例
C51工程设计 称重器实现计价功能的部分参考代码如下:
//计价页面===================#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();}
-
传感器
+关注
关注
2536文章
48863浏览量
743559 -
开源
+关注
关注
3文章
3040浏览量
41829 -
智能屏幕
+关注
关注
0文章
55浏览量
3146
发布评论请先 登录
相关推荐
基于T5L芯片的多功能物联网开发套件
![基于T5L芯片的<b class='flag-5'>多功能</b>物联网开发套件](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
![](https://file1.elecfans.com/web2/M00/C0/5C/wKgaomW8lKqAHKOOAALCMIvdF4c117.png)
【开源获奖案例】智能培养室
![【<b class='flag-5'>开源</b><b class='flag-5'>获奖</b>案例】智能培养室](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
【开源获奖案例】四轴机械臂控制系统
![【<b class='flag-5'>开源</b><b class='flag-5'>获奖</b>案例】四轴机械臂控制系统](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
小而美!【aDataFlow】多功能串口工具
![小而美!【aDataFlow】<b class='flag-5'>多功能</b>串口工具](https://file.elecfans.com/web2/M00/43/7B/pYYBAGJ-B6aAHuNPAAAf8J1Ebk4778.jpg)
开源 | 小而美!【aDataFlow】多功能串口工具,数据监听+USB转串口+ESP32烧录器…
![<b class='flag-5'>开源</b> | 小而美!【aDataFlow】<b class='flag-5'>多功能</b>串口工具,数据监听+USB转串口+ESP32烧录器…](https://file1.elecfans.com//web2/M00/B5/A6/wKgaomV8EO2AHy25AA-fIkw_8Sg972.gif)
【开源获奖案例】水泥多量测定仪
![【<b class='flag-5'>开源</b><b class='flag-5'>获奖</b>案例】水泥多量测定仪](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
内嵌图形化编程环境,LiClock多功能墨水屏
![内嵌图形化编程环境,LiClock<b class='flag-5'>多功能</b>墨水屏](https://file.elecfans.com/web2/M00/43/7B/pYYBAGJ-B6aAHuNPAAAf8J1Ebk4778.jpg)
开源 | 内嵌图形化编程环境,LiClock多功能墨水屏【天气+时钟+电子书…】
![<b class='flag-5'>开源</b> | 内嵌图形化编程环境,LiClock<b class='flag-5'>多功能</b>墨水屏【天气+时钟+电子书…】](https://file1.elecfans.com//web2/M00/B0/98/wKgZomVW6fKAeFf_AAOMzy4Js8s846.png)
【开源获奖案例】基于T5L的smtp邮件发送器
![【<b class='flag-5'>开源</b><b class='flag-5'>获奖</b>案例】基于T5L的smtp邮件发送器](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
![](https://file1.elecfans.com/web2/M00/AB/49/wKgaomU_QJeAM08TAALAaQ7k1O4172.png)
【开源获奖案例】智能猫粮控制系统
![【<b class='flag-5'>开源</b><b class='flag-5'>获奖</b>案例】智能猫粮控制系统](https://file.elecfans.com/web2/M00/2A/81/poYBAGHKtJGANsQ1AAT-FWnPlz8451.jpg)
开源鸿蒙智慧多功能杆化身“机器人”,看得见、能感知、会说话!
![<b class='flag-5'>开源</b>鸿蒙智慧<b class='flag-5'>多功能</b>杆化身“机器人”,看得见、能感知、会说话!](https://file1.elecfans.com/web2/M00/8E/59/wKgaomTEiamAeJfRAAAkSOFOsSU299.png)
![](https://file.elecfans.com/web2/M00/B1/A1/pYYBAGS3fJWAB0B4AANLc__nKqw771.png)
评论