[Código aberto] Dispositivo de pesaxe multifuncional

——Do DWIN Developer Forum

Neste número, impulsamos o caso de código aberto premiado de DWIN Developer Forum - Multi-function Weigher. O enxeñeiro adopta unha pantalla intelixente COF de 4 polgadas e, a través da interacción de datos entre o núcleo do sistema operativo T5L e o módulo HX711 e o conxunto de sensores de presión de 5 kg, os usuarios poden realizar facilmente as funcións de visualización de conta, como o peso, o prezo unitario, o prezo total, a tara, etc. ., así como as funcións de reconto, seguimento das curvas de cambio de peso e corrección da precisión da pesadora, etc., para que sexa fácil cambiar entre diferentes escenarios de aplicación para gozar dunha experiencia de pesaxe cómoda e eficiente.

1. Desenvolvemento da IU

f26af533d43728cd210e0f7af5e7acc

2.C51 Deseño

Parte do código de referencia para que a pesadora implemente a función de prezos é a seguinte:

// Páxina de prezos====================

#define VALUATION_UNIT_PRICE_ADDR 0x1010

#define VALUATION_GRAM_ADDR 0x1000

#define VALUATION_TOTAL_PRICES_ADDR 0x1020

uint32_t valoración_decorticate = 0; // Prezo Tare Weight

uint32_t prezo_unitario_valoración = 0; //Prezo por unidade

// Actualización do prezo unitario

void page_valuation_unit_price_refresh()

{

uint8_t test_display[10] = {0};

if(valor_prezo_unitario

{

test_display[0] = prezo_unitario_valoración / 100 % 10 + 0x30;

display_test[1] = '.';

display_test[2] = prezo_unitario_valoración / 10 % 10 + 0x30;

display_test[3] = prezo_unitario_valoración / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

else if(valor_prezo_unitario

{

test_display[0] = prezo_unitario_valoración / 1000 % 10 + 0x30;

display_test[1] = prezo_unitario_valoración / 100 % 10 + 0x30;

display_test[2] = '.';

display_test[3] = prezo_unitario_valoración / 10 % 10 + 0x30;

display_test[4] = prezo_unitario_valoración / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

else if(valor_prezo_unitario

{

test_display[0] = prezo_unitario_valoración / 10000 % 10 + 0x30;

display_test[1] = prezo_unitario_valoración / 1000 % 10 + 0x30;

display_test[2] = prezo_unitario_valoración / 100 % 10 + 0x30;

display_test[3] = '.';

display_test[4] = prezo_unitario_valoración / 10 % 10 + 0x30;

display_test[5] = prezo_unitario_valoración / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

else if(valor_prezo_unitario

{

test_display[0] = prezo_unitario_valoración / 100000 % 10 + 0x30;

display_test[1] = prezo_unitario_valoración / 10000 % 10 + 0x30;

display_test[2] = prezo_unitario_valoración / 1000 % 10 + 0x30;

display_test[3] = prezo_unitario_valoración / 100 % 10 + 0x30;

test_display[4] = '.';

test_display[5] = prezo_unitario_valoración / 10 % 10 + 0x30;

display_test[6] = prezo_unitario_valoración / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_UNIT_PRICE_ADDR, test_display, 4);

}

}

 

// Actualización de peso

void page_valuation_weight_refresh()

{

uint8_t test_display[10] = {0x30};

uint32_t gram_display = 0;

if(valor_gramo >= decorticar_valoración)

{

gram_display = valor_gramo - valor_decorticate;

if(mostración_grama

{

display_test[0] = visualización_gramos / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

else if(mostración_grama

{

display_test[0] = visualización_gramos / 10 % 10 + 0x30;

display_test[1] = visualización_gramos / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

else if(gram_display

{

display_test[0] = visualización_gramos / 100 % 10 + 0x30;

display_test[1] = visualización_gramos / 10 % 10 + 0x30;

display_test[2] = visualización_gramos / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

else if (mostración_grama

{

display_test[0] = visualización_gramos / 1000 % 10 + 0x30;

display_test[1] = display_gram / 100 % 10 + 0x30;

display_test[2] = visualización_gramos / 10 % 10 + 0x30;

display_test[3] = visualización_gramos / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

else if(mostración_grama

{

display_test[0] = visualización_gramos / 10000 % 10 + 0x30;

display_test[1] = visualización_gramos / 1000 % 10 + 0x30;

display_test[2] = visualización_gramos / 100 % 10 + 0x30;

display_test[3] = visualización_gramos / 10 % 10 + 0x30;

display_test[4] = display_gram / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

}

outra cousa

{

dgus_show_text_value_set(VALUATION_GRAM_ADDR, test_display, 3);

}

}

 

// Actualización do prezo total

void page_valuation_price_refresh()

{

uint32_t valor_prezo = 0;

uint8_t test_display[10] = {0x30, '.', 0x30, 0x30};

if(valor_gramo >= decorticar_valoración)

{

prezo_valor = (valor_gramo - valor_decorticado) * prezo_unitario_valoración * 2 / 1000;

if(valor_prezo

{

test_display[0] = prezo_valor / 100 % 10 + 0x30;

display_test[1] = '.';

display_test[2] = valor_prezo / 10 % 10 + 0x30;

display_test[3] = valor_prezo / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

else if (valor_prezo

{

test_display[0] = prezo_valor / 1000 % 10 + 0x30;

display_test[1] = valor_prezo / 100 % 10 + 0x30;

display_test[2] = '.';

display_test[3] = valor_prezo / 10 % 10 + 0x30;

display_test[4] = valor_prezo / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

else if (valor_prezo

{

test_display[0] = prezo_valor / 10000 % 10 + 0x30;

display_test[1] = valor_prezo / 1000 % 10 + 0x30;

display_test[2] = valor_prezo / 100 % 10 + 0x30;

display_test[3] = '.';

display_test[4] = valor_prezo / 10 % 10 + 0x30;

display_test[5] = valor_prezo / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

else if (valor_prezo

{

test_display[0] = prezo_valor / 100000 % 10 + 0x30;

display_test[1] = valor_prezo / 10000 % 10 + 0x30;

display_test[2] = valor_prezo / 1000 % 10 + 0x30;

display_test[3] = valor_prezo / 100 % 10 + 0x30;

test_display[4] = '.';

display_test[5] = valor_prezo / 10 % 10 + 0x30;

display_test[6] = valor_prezo / 1 % 10 + 0x30;

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

outra cousa

{

dgus_show_text_value_set(VALUATION_TOTAL_PRICES_ADDR, test_display, 4);

}

}

void page_valuation_decorticate()

{

valoración_decorticate = valor_gramo;

páxina_valoración_peso_refresh();

}

void page_valuation_1()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 1;

page_valuation_unit_price_refresh();

}

}

void page_valuation_2()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 2;

page_valuation_unit_price_refresh();

}

}

void page_valuation_3()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 3;

page_valuation_unit_price_refresh();

}

}

void page_valuation_4()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 4;

page_valuation_unit_price_refresh();

}

}

void page_valuation_5()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 5;

page_valuation_unit_price_refresh();

}

}

void page_valuation_6()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 6;

page_valuation_unit_price_refresh();

}

}

void page_valuation_7()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 7;

page_valuation_unit_price_refresh();

}

}

void page_valuation_8()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 8;

page_valuation_unit_price_refresh();

}

}

void page_valuation_9()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 9;

page_valuation_unit_price_refresh();

}

}

void page_valuation_0()

{

if(valor_prezo_unitario

{

prezo_unitario_valoración = prezo_unitario_valoración * 10 + 0;

page_valuation_unit_price_refresh();

}

}

void page_valuation_back()

{

prezo_unitario_valoración = prezo_unitario_valoración / 10;

páxina_valoración_prezo_unitario_refresh();

}

void page_valuation_clear()

{

prezo_unitario_valoración = 0;

page_valuation_unit_price_refresh();

}


Hora de publicación: 28-Abr-2024