Skip to content

Commit 46c5f1d

Browse files
committed
fix
1 parent 0856a30 commit 46c5f1d

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

nrf24batch.c

+21-16
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,11 @@ void Edit_insert_digit(char new)
235235
furi_string_set_n(ns, fs, 0, len);
236236
furi_string_cat_printf(ns, "%c", new);
237237
furi_string_cat_str(ns, Edit_pos);
238-
furi_string_free(fs);
239238
Log[view_Batch] = ns;
240-
Edit_pos = (char*)furi_string_get_cstr(ns) + len;
239+
Edit_pos = (char*)furi_string_get_cstr(ns);
240+
Edit_start = Edit_pos + (Edit_start - (char*)furi_string_get_cstr(fs));
241+
Edit_pos += len;
242+
furi_string_free(fs);
241243
}
242244
}
243245
}
@@ -1316,16 +1318,21 @@ int32_t nrf24batch_app(void* p) {
13161318
if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
13171319
if(!ask_question) {
13181320
if(Edit) {
1319-
if(*Edit_pos != '-') {
1320-
if(*Edit_pos < '9') (*Edit_pos)++;
1321-
else if(Edit_hex) {
1322-
if(*Edit_pos == '9') *Edit_pos = 'A';
1323-
else if((*Edit_pos & ~0x20) < 'F') (*Edit_pos)++;
1324-
} else if(Edit_pos > Edit_start && *(Edit_pos - 1) < '9' && *(Edit_pos - 1) >= '0') {
1325-
*Edit_pos = '0';
1326-
(*(Edit_pos - 1))++;
1321+
char c = *Edit_pos;
1322+
if(Edit_hex) {
1323+
if(c == '9') *Edit_pos = 'A';
1324+
else if(c < 'F' || c < '9') *Edit_pos = c + 1;
1325+
} else {
1326+
if(c == '-') *Edit_pos = '0';
1327+
else if(c < '9') *Edit_pos = c + 1;
1328+
else {
1329+
c = *(Edit_pos - 1);
1330+
if(Edit_pos > Edit_start && c < '9' && c >= '0') {
1331+
*Edit_pos = '0';
1332+
(*(Edit_pos - 1)) = c + 1;
1333+
}
13271334
}
1328-
}
1335+
}
13291336
} else if(what_doing == 0) {
13301337
if(addr_len) {
13311338
if(setup_cursor > 0) setup_cursor--; else setup_cursor = 2;
@@ -1343,17 +1350,15 @@ int32_t nrf24batch_app(void* p) {
13431350
if(!ask_question) {
13441351
if(Edit) {
13451352
if(*Edit_pos != '-') {
1346-
if(Edit_hex && (*Edit_pos & ~0x20) == 'A') (*Edit_pos) = '9';
1353+
if(Edit_hex && *Edit_pos == 'A') (*Edit_pos) = '9';
13471354
else if(*Edit_pos > '0') (*Edit_pos)--;
13481355
else if(!Edit_hex) {
13491356
if(Edit_pos > Edit_start) {
1350-
if(*(Edit_pos - 1) > '0') {
1357+
if(*(Edit_pos - 1) > '0' && *(Edit_pos - 1) <= '9') {
13511358
*Edit_pos = '9';
13521359
(*(Edit_pos - 1))--;
13531360
}
1354-
} else if(strlen(Edit_start) == 1) { // negative
1355-
Edit_insert_digit('-');
1356-
}
1361+
} else Edit_insert_digit('-'); // negative
13571362
}
13581363
}
13591364
} else if(what_doing == 0) {

0 commit comments

Comments
 (0)