Skip to content

Commit

Permalink
auto turn on 5V
Browse files Browse the repository at this point in the history
  • Loading branch information
vad7 committed Mar 11, 2023
1 parent 3ff2f5e commit 9e69335
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
Binary file added Pics/Screenshot-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Flipper Zero application for nRF24L01 external board. Sends batch commands.
<img src="https://raw.githubusercontent.com/vad7/nRF24-Batch/main/Pics/Screenshot-2.png">
<img src="https://raw.githubusercontent.com/vad7/nRF24-Batch/main/Pics/Screenshot-3.png">
<img src="https://raw.githubusercontent.com/vad7/nRF24-Batch/main/Pics/Screenshot-4.png">
<img src="https://raw.githubusercontent.com/vad7/nRF24-Batch/main/Pics/Screenshot-5.png">
<br>
<br>
Mini board for Flipper Zero to connect nRF24l01:<br><br>
Expand Down
43 changes: 24 additions & 19 deletions nrf24batch.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <u8g2.h>

#define TAG "nrf24batch"
#define VERSION "1.5"
#define VERSION "1.6"

#define SCAN_APP_PATH_FOLDER "/ext/nrf24batch"
#define LOG_FILEEXT ".txt"
Expand Down Expand Up @@ -133,7 +133,7 @@ char *ReadBatch_cmd_curr = NULL; // =0xFFFFFFFF - finish
FuriString **WriteBatch_cmd = NULL; // Names of write batch cmd
uint16_t WriteBatch_cmd_Total = 0;
uint16_t WriteBatch_cmd_curr = 0; // == _Total - finish
#define POWER_READ_PERIOD 10 // ms
#define POWER_READ_PERIOD 501 // ms
uint16_t pwr_read_timer = 0;
int Current = 0;
int CurrentStart = 0;
Expand Down Expand Up @@ -294,9 +294,10 @@ void update_power(void)

void check_en_power_5V(void)
{
if(!furi_hal_power_is_otg_enabled()) {
if(!furi_hal_power_is_otg_enabled() && !furi_hal_power_is_charging()) {
FURI_LOG_D("PWR", "NO 5V, TURN ON");
furi_delay_ms(11);
notification_message(APP->notification, &sequence_blink_yellow_100);
furi_delay_ms(10);
update_power();
CurrentStart = Current;
furi_hal_power_enable_otg();
Expand Down Expand Up @@ -1484,14 +1485,16 @@ int32_t nrf24batch_app(void* p) {
what_doing = 2;
}
} else if(rw_type == rwt_listen) {
free_Log();
prepare_nrf24();
if(!NRF_ERROR) {
nrf24_set_rx_mode(nrf24_HANDLE);
ListenNew = false;
send_status = sst_receiving; // receiving
if(listen_addr_len) {
free_Log();
prepare_nrf24();
if(!NRF_ERROR) {
nrf24_set_rx_mode(nrf24_HANDLE);
ListenNew = false;
send_status = sst_receiving; // receiving
}
what_doing = 2;
}
what_doing = 2;
}
} else if(what_doing == 2) {
if(rw_type == rwt_read_cmd) {
Expand Down Expand Up @@ -1524,14 +1527,16 @@ int32_t nrf24batch_app(void* p) {
}
} else if(what_doing == 1) {
if(rw_type == rwt_listen) {
char *ebuf = (char*)payload;
ebuf[0] = '\0';
add_to_str_hex_bytes(ebuf, listen_addr, listen_addr_len);
Edit_hex = true;
Edit_pos = ebuf + strlen(ebuf) - 1;
Edit_start = ebuf;
Edit = 1;
NRF_INITED = 0;
if(listen_addr_len) {
char *ebuf = (char*)payload;
ebuf[0] = '\0';
add_to_str_hex_bytes(ebuf, listen_addr, listen_addr_len);
Edit_hex = true;
Edit_pos = ebuf + strlen(ebuf) - 1;
Edit_start = ebuf;
Edit = 1;
NRF_INITED = 0;
}
}
} else if(what_doing == 2) {
if(rw_type == rwt_read_cmd) {
Expand Down

0 comments on commit 9e69335

Please sign in to comment.