[Ανοικτή πηγή] Πολυλειτουργική Συσκευή Ζύγισης

——Από το Φόρουμ προγραμματιστών DWIN

Σε αυτό το τεύχος, προωθούμε τη βραβευμένη θήκη ανοιχτού κώδικα του DWIN Developer Forum - Multi-function Weigher. Ο μηχανικός υιοθετεί μια έξυπνη οθόνη COF 4 ιντσών και μέσω της αλληλεπίδρασης δεδομένων μεταξύ του πυρήνα T5L OS και της μονάδας HX711 και του σετ αισθητήρων πίεσης 5 κιλών, οι χρήστες μπορούν εύκολα να συνειδητοποιήσουν τις λειτουργίες μέτρησης της οθόνης όπως βάρος, τιμή μονάδας, συνολική τιμή, απόβαρο κ.λπ. ., καθώς και τις λειτουργίες μέτρησης, παρακολούθησης καμπυλών αλλαγής βάρους και διόρθωσης ακρίβειας ζύγισης κ.λπ., έτσι ώστε να είναι εύκολη η εναλλαγή μεταξύ διαφορετικών σεναρίων εφαρμογών για να απολαύσετε μια βολική και αποτελεσματική εμπειρία ζύγισης.

1. Ανάπτυξη διεπαφής χρήστη

f26af533d43728cd210e0f7af5e7acc

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; //Τιμή μονάδας

// Ανανέωση τιμής μονάδας

void 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);

}

}

 

// Ανανέωση βάρους

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)

{

τιμή_τιμής = (τιμή_γραμμαρίου - valuation_decorticate) * valuation_unit_price * 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);

}

}

void page_valuation_decorticate()

{

valuation_decorticate = gram_value;

page_valuation_weight_refresh();

}

void page_valuation_1()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 1;

page_valuation_unit_price_refresh();

}

}

void page_valuation_2()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 2;

page_valuation_unit_price_refresh();

}

}

void page_valuation_3()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 3;

page_valuation_unit_price_refresh();

}

}

void page_valuation_4()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 4;

page_valuation_unit_price_refresh();

}

}

void page_valuation_5()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 5;

page_valuation_unit_price_refresh();

}

}

void page_valuation_6()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 6;

page_valuation_unit_price_refresh();

}

}

void page_valuation_7()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 7;

page_valuation_unit_price_refresh();

}

}

void page_valuation_8()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 8;

page_valuation_unit_price_refresh();

}

}

void page_valuation_9()

{

if(valuation_unit_price

{

valuation_unit_price = valuation_unit_price * 10 + 9;

page_valuation_unit_price_refresh();

}

}

void page_valuation_0()

{

if(valuation_unit_price

{

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();

}


Ώρα δημοσίευσης: Απρ-28-2024