Rework for getAmountOfInsertedNotes due to wrong description in interface

This commit is contained in:
Siegfried Siegert 2023-12-14 15:48:37 +01:00
parent 80c7992d5b
commit 012f3430c5
Signed by: SiegfriedSiegert
GPG Key ID: 68371E015E8F0B03

View File

@ -39,13 +39,36 @@ uint32_t CashUtils::getAmountOfInsertedCoins(hwinf* hw)
uint32_t CashUtils::getAmountOfInsertedNotes(hwinf* hw)
{
uint32_t result = 0;
uint8_t numberOfInsertedNotes;
uint16_t values[MAX_NOTES];
hw->bna_getCurrentNotes(0, values);
uint16_t beforeArray = 0;
uint16_t currentNotes[4];
uint16_t afterArray = 0;
numberOfInsertedNotes = hw->bna_getCurrentNotes(0, currentNotes);
for (int i = 0; i < MAX_COINS; i++) {
result += values[i];
if ( (beforeArray != 0) || (afterArray != 0) ) {
qCritical() << "CashUtils::getAmountOfInsertedNotes() ERROR: Array";
}
if (numberOfInsertedNotes == 99) {
// Error
qCritical() << "CashUtils::getAmountOfInsertedNotes() ERROR: ";
for (int i = 0; i < 4; i++) {
qCritical() << " currentNotes[" << i << "] = " << currentNotes[i];
}
}
else {
// no error
result = currentNotes[3];
result = ( result << 16 ) | currentNotes[2];
}
// DEBUG
qCritical() << "--------------------------------------------------";
qCritical() << "CashUtils::getAmountOfInsertedNotes()";
qCritical() << " numberOfInsertedNotes = " << numberOfInsertedNotes;
qCritical() << " result = " << result;
qCritical() << "--------------------------------------------------";
return result;
}