Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
fix plugins, remove dupe
Browse files Browse the repository at this point in the history
  • Loading branch information
xMasterX committed Jul 25, 2023
1 parent 271b785 commit 8e800a3
Showing 1 changed file with 67 additions and 66 deletions.
133 changes: 67 additions & 66 deletions qrcode_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,81 +546,82 @@ int32_t qrcode_app(void* p) {
}

InputEvent input;
while(furi_message_queue_get(instance->input_queue, &input, FuriWaitForever) ==
FuriStatusOk) {
furi_check(furi_mutex_acquire(instance->mutex, FuriWaitForever) == FuriStatusOk);

if(input.key == InputKeyBack) {
if(instance->message) {
furi_string_free(instance->message);
instance->message = NULL;
}
if(instance->qrcode) {
qrcode_free(instance->qrcode);
instance->qrcode = NULL;
}
instance->loading = true;
instance->edit = false;
furi_mutex_release(instance->mutex);
break;
} else if(input.key == InputKeyRight) {
instance->show_stats = true;
} else if(input.key == InputKeyLeft) {
instance->show_stats = false;
} else if(instance->show_stats && !instance->loading && instance->qrcode) {
if(input.key == InputKeyUp) {
if(!instance->edit) {
instance->selected_idx = MAX(0, instance->selected_idx - 1);
} else {
if(instance->selected_idx == 0 &&
instance->set_version < MAX_QRCODE_VERSION) {
instance->set_version++;
} else if(instance->selected_idx == 1) {
uint8_t max_ecc = instance->set_version == instance->min_version ?
instance->max_ecc_at_min_version :
ECC_HIGH;
if(instance->set_ecc < max_ecc) {
instance->set_ecc++;
}
}
while(1) {
if(furi_message_queue_get(instance->input_queue, &input, 100) == FuriStatusOk) {
furi_check(furi_mutex_acquire(instance->mutex, FuriWaitForever) == FuriStatusOk);

if(input.key == InputKeyBack) {
if(instance->message) {
furi_string_free(instance->message);
instance->message = NULL;
}
} else if(input.key == InputKeyDown) {
if(!instance->edit) {
instance->selected_idx = MIN(1, instance->selected_idx + 1);
} else {
if(instance->selected_idx == 0 &&
instance->set_version > instance->min_version) {
instance->set_version--;
if(instance->set_version == instance->min_version) {
instance->set_ecc =
MAX(instance->set_ecc, instance->max_ecc_at_min_version);
if(instance->qrcode) {
qrcode_free(instance->qrcode);
instance->qrcode = NULL;
}
instance->loading = true;
instance->edit = false;
furi_mutex_release(instance->mutex);
break;
} else if(input.key == InputKeyRight) {
instance->show_stats = true;
} else if(input.key == InputKeyLeft) {
instance->show_stats = false;
} else if(instance->show_stats && !instance->loading && instance->qrcode) {
if(input.key == InputKeyUp) {
if(!instance->edit) {
instance->selected_idx = MAX(0, instance->selected_idx - 1);
} else {
if(instance->selected_idx == 0 &&
instance->set_version < MAX_QRCODE_VERSION) {
instance->set_version++;
} else if(instance->selected_idx == 1) {
uint8_t max_ecc = instance->set_version == instance->min_version ?
instance->max_ecc_at_min_version :
ECC_HIGH;
if(instance->set_ecc < max_ecc) {
instance->set_ecc++;
}
}
} else if(instance->selected_idx == 1 && instance->set_ecc > 0) {
instance->set_ecc--;
}
}
} else if(input.key == InputKeyOk) {
if(instance->edit && (instance->set_version != instance->qrcode->version ||
instance->set_ecc != instance->qrcode->ecc)) {
QRCode* qrcode = instance->qrcode;
instance->loading = true;

if(rebuild_qrcode(instance, instance->set_version, instance->set_ecc)) {
qrcode_free(qrcode);
} else if(input.key == InputKeyDown) {
if(!instance->edit) {
instance->selected_idx = MIN(1, instance->selected_idx + 1);
} else {
FURI_LOG_E(TAG, "Could not rebuild qrcode");
instance->qrcode = qrcode;
instance->set_version = qrcode->version;
instance->set_ecc = qrcode->ecc;
if(instance->selected_idx == 0 &&
instance->set_version > instance->min_version) {
instance->set_version--;
if(instance->set_version == instance->min_version) {
instance->set_ecc =
MAX(instance->set_ecc, instance->max_ecc_at_min_version);
}
} else if(instance->selected_idx == 1 && instance->set_ecc > 0) {
instance->set_ecc--;
}
}
} else if(input.key == InputKeyOk) {
if(instance->edit && (instance->set_version != instance->qrcode->version ||
instance->set_ecc != instance->qrcode->ecc)) {
QRCode* qrcode = instance->qrcode;
instance->loading = true;

if(rebuild_qrcode(instance, instance->set_version, instance->set_ecc)) {
qrcode_free(qrcode);
} else {
FURI_LOG_E(TAG, "Could not rebuild qrcode");
instance->qrcode = qrcode;
instance->set_version = qrcode->version;
instance->set_ecc = qrcode->ecc;
}

instance->loading = false;
instance->loading = false;
}
instance->edit = !instance->edit;
}
instance->edit = !instance->edit;
}
}

furi_mutex_release(instance->mutex);
furi_mutex_release(instance->mutex);
}
view_port_update(instance->view_port);
}

Expand Down

0 comments on commit 8e800a3

Please sign in to comment.