|
@@ -173,7 +173,7 @@ static bool is_digit(char *ptr, bool hex)
|
|
|
if(hex) {
|
|
if(hex) {
|
|
|
c &= ~0x20;
|
|
c &= ~0x20;
|
|
|
if(c >= 'A' && c <= 'F') return true;
|
|
if(c >= 'A' && c <= 'F') return true;
|
|
|
- }
|
|
|
|
|
|
|
+ } else if(c == '-') return true;
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -218,6 +218,29 @@ static void add_to_str_hex_bytes(char *out, uint8_t *arr, int bytes)
|
|
|
} while(--bytes);
|
|
} while(--bytes);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void Edit_insert_digit(char new)
|
|
|
|
|
+{
|
|
|
|
|
+ if(*Edit_pos == '-') return;
|
|
|
|
|
+ if(what_doing <= 1) {
|
|
|
|
|
+ if(strlen(Edit_start) < (what_doing == 0 && setup_cursor == 2 ? 3 : 5 * 2)) {
|
|
|
|
|
+ memmove(Edit_pos + 1, Edit_pos, strlen(Edit_pos) + 1);
|
|
|
|
|
+ *Edit_pos = new;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ FuriString *fs = Log[view_Batch];
|
|
|
|
|
+ FuriString *ns = furi_string_alloc();
|
|
|
|
|
+ if(ns) {
|
|
|
|
|
+ uint16_t len = Edit_pos - (char*)furi_string_get_cstr(fs);
|
|
|
|
|
+ furi_string_set_n(ns, fs, 0, len);
|
|
|
|
|
+ furi_string_cat_printf(ns, "%c", new);
|
|
|
|
|
+ furi_string_cat_str(ns, Edit_pos);
|
|
|
|
|
+ furi_string_free(fs);
|
|
|
|
|
+ Log[view_Batch] = ns;
|
|
|
|
|
+ Edit_pos = (char*)furi_string_get_cstr(ns) + len;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
int32_t get_payload_receive_field(uint8_t *var, uint8_t size)
|
|
int32_t get_payload_receive_field(uint8_t *var, uint8_t size)
|
|
|
{
|
|
{
|
|
|
if(size <= 1) return *var;
|
|
if(size <= 1) return *var;
|
|
@@ -361,7 +384,7 @@ static void prepare_nrf24(void)
|
|
|
NRF_INITED = 0;
|
|
NRF_INITED = 0;
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- // EN_DYN_ACK(0x01) option for W_TX_PAYLOAD_NOACK cmd broke AA on some fake nRF24l01+ modules
|
|
|
|
|
|
|
+ // EN_DYN_ACK(0x01) option for W_TX_PAYLOAD_NOACK cmd broke AA on some fake nRF24l01+, i.e. set it to 0
|
|
|
nrf24_write_reg(nrf24_HANDLE, REG_FEATURE, (NRF_DPL ? 4 : 0)); // Dynamic Payload, Payload with ACK, W_TX_PAYLOAD_NOACK command
|
|
nrf24_write_reg(nrf24_HANDLE, REG_FEATURE, (NRF_DPL ? 4 : 0)); // Dynamic Payload, Payload with ACK, W_TX_PAYLOAD_NOACK command
|
|
|
nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, NRF_channel);
|
|
nrf24_write_reg(nrf24_HANDLE, REG_RF_CH, NRF_channel);
|
|
|
nrf24_write_reg(nrf24_HANDLE, REG_RF_SETUP, (NRF_rate == 0 ? 0b00100000 : NRF_rate == 1 ? 0 : 0b00001000) | 0b111); // +TX high power
|
|
nrf24_write_reg(nrf24_HANDLE, REG_RF_SETUP, (NRF_rate == 0 ? 0b00100000 : NRF_rate == 1 ? 0 : 0b00001000) | 0b111); // +TX high power
|
|
@@ -1292,13 +1315,15 @@ int32_t nrf24batch_app(void* p) {
|
|
|
if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
|
|
if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
|
|
|
if(!ask_question) {
|
|
if(!ask_question) {
|
|
|
if(Edit) {
|
|
if(Edit) {
|
|
|
- if(*Edit_pos < '9') (*Edit_pos)++;
|
|
|
|
|
- else if(Edit_hex) {
|
|
|
|
|
- if(*Edit_pos == '9') *Edit_pos = 'A';
|
|
|
|
|
- else if((*Edit_pos & ~0x20) < 'F') (*Edit_pos)++;
|
|
|
|
|
- } else if(Edit_pos > Edit_start && *(Edit_pos - 1) < '9') {
|
|
|
|
|
- *Edit_pos = '0';
|
|
|
|
|
- (*(Edit_pos - 1))++;
|
|
|
|
|
|
|
+ if(*Edit_pos != '-') {
|
|
|
|
|
+ if(*Edit_pos < '9') (*Edit_pos)++;
|
|
|
|
|
+ else if(Edit_hex) {
|
|
|
|
|
+ if(*Edit_pos == '9') *Edit_pos = 'A';
|
|
|
|
|
+ else if((*Edit_pos & ~0x20) < 'F') (*Edit_pos)++;
|
|
|
|
|
+ } else if(Edit_pos > Edit_start && *(Edit_pos - 1) < '9' && *(Edit_pos - 1) >= '0') {
|
|
|
|
|
+ *Edit_pos = '0';
|
|
|
|
|
+ (*(Edit_pos - 1))++;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} else if(what_doing == 0) {
|
|
} else if(what_doing == 0) {
|
|
|
if(addr_len) {
|
|
if(addr_len) {
|
|
@@ -1316,11 +1341,19 @@ int32_t nrf24batch_app(void* p) {
|
|
|
if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
|
|
if(event.input.type == InputTypeShort || event.input.type == InputTypeRepeat) {
|
|
|
if(!ask_question) {
|
|
if(!ask_question) {
|
|
|
if(Edit) {
|
|
if(Edit) {
|
|
|
- if(Edit_hex && (*Edit_pos & ~0x20) == 'A') (*Edit_pos) = '9';
|
|
|
|
|
- else if(*Edit_pos > '0') (*Edit_pos)--;
|
|
|
|
|
- else if(!Edit_hex && Edit_pos > Edit_start && *(Edit_pos - 1) > '0') {
|
|
|
|
|
- *Edit_pos = '9';
|
|
|
|
|
- (*(Edit_pos - 1))--;
|
|
|
|
|
|
|
+ if(*Edit_pos != '-') {
|
|
|
|
|
+ if(Edit_hex && (*Edit_pos & ~0x20) == 'A') (*Edit_pos) = '9';
|
|
|
|
|
+ else if(*Edit_pos > '0') (*Edit_pos)--;
|
|
|
|
|
+ else if(!Edit_hex) {
|
|
|
|
|
+ if(Edit_pos > Edit_start) {
|
|
|
|
|
+ if(*(Edit_pos - 1) > '0') {
|
|
|
|
|
+ *Edit_pos = '9';
|
|
|
|
|
+ (*(Edit_pos - 1))--;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else if(strlen(Edit_start) == 1) { // negative
|
|
|
|
|
+ Edit_insert_digit('-');
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
} else if(what_doing == 0) {
|
|
} else if(what_doing == 0) {
|
|
|
if(addr_len) {
|
|
if(addr_len) {
|
|
@@ -1415,24 +1448,7 @@ int32_t nrf24batch_app(void* p) {
|
|
|
}
|
|
}
|
|
|
ask_question = 0;
|
|
ask_question = 0;
|
|
|
} else if(Edit) { // insert digit
|
|
} else if(Edit) { // insert digit
|
|
|
- if(what_doing <= 1) {
|
|
|
|
|
- if(strlen(Edit_start) < (what_doing == 0 && setup_cursor == 2 ? 3 : 5 * 2)) {
|
|
|
|
|
- memmove(Edit_pos + 1, Edit_pos, strlen(Edit_pos) + 1);
|
|
|
|
|
- *Edit_pos = '0';
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- FuriString *fs = Log[view_Batch];
|
|
|
|
|
- FuriString *ns = furi_string_alloc();
|
|
|
|
|
- if(ns) {
|
|
|
|
|
- uint16_t len = Edit_pos - (char*)furi_string_get_cstr(fs);
|
|
|
|
|
- furi_string_set_n(ns, fs, 0, len);
|
|
|
|
|
- furi_string_cat_str(ns, "0");
|
|
|
|
|
- furi_string_cat_str(ns, Edit_pos);
|
|
|
|
|
- furi_string_free(fs);
|
|
|
|
|
- Log[view_Batch] = ns;
|
|
|
|
|
- Edit_pos = (char*)furi_string_get_cstr(ns) + len;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Edit_insert_digit('0');
|
|
|
} else if(what_doing == 0) {
|
|
} else if(what_doing == 0) {
|
|
|
if(setup_cursor == 0) { // open file
|
|
if(setup_cursor == 0) { // open file
|
|
|
file_stream_close(file_stream);
|
|
file_stream_close(file_stream);
|
|
@@ -1515,13 +1531,14 @@ int32_t nrf24batch_app(void* p) {
|
|
|
if(Edit) { // delete
|
|
if(Edit) { // delete
|
|
|
if(what_doing <= 1) {
|
|
if(what_doing <= 1) {
|
|
|
if(strlen(Edit_start) > 1) {
|
|
if(strlen(Edit_start) > 1) {
|
|
|
- memmove(Edit_pos, Edit_pos + 1, strlen(Edit_pos) + 1);
|
|
|
|
|
|
|
+ memmove(Edit_pos, Edit_pos + 1, strlen(Edit_pos));
|
|
|
if(*Edit_pos == '\0') Edit_pos--;
|
|
if(*Edit_pos == '\0') Edit_pos--;
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
FuriString *fs = Log[view_Batch];
|
|
FuriString *fs = Log[view_Batch];
|
|
|
if(is_digit(Edit_pos + 1, Edit_hex) || (Edit_pos > Edit_start && is_digit(Edit_pos - 1, Edit_hex))) {
|
|
if(is_digit(Edit_pos + 1, Edit_hex) || (Edit_pos > Edit_start && is_digit(Edit_pos - 1, Edit_hex))) {
|
|
|
memmove(Edit_pos, Edit_pos + 1, strlen(Edit_pos));
|
|
memmove(Edit_pos, Edit_pos + 1, strlen(Edit_pos));
|
|
|
|
|
+ if(*Edit_pos == '\0') Edit_pos--;
|
|
|
furi_string_left(fs, furi_string_size(fs) - 1);
|
|
furi_string_left(fs, furi_string_size(fs) - 1);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|