Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Infinite-ReConnect setting #132

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ WARNING:
* mobile device connections are extremely finnicky
* multi-connect involving mobile devices is not well tested and can easily crash

### Infinite-ReConnect

This is useful for using furble as a passive, always on GPS data source.
With this, the camera will attempt to reconnect indefinitely.
You don't need to turn on this setting if you are actively using furble.

To use:
* Enable `Settings->Infinite-ReConnect`

WARNING:
* this will not be kind to battery life
* You must Forceful power off by holding the power button

## Motivation

I found current smartphone apps for basic wireless remote shutter control to be
Expand Down
3 changes: 3 additions & 0 deletions include/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
void settings_menu_tx_power(void);
esp_power_level_t settings_load_esp_tx_power(void);

bool settings_load_reconnect(void);
void settings_save_reconnect(bool reconnect);

bool settings_load_gps(void);
void settings_menu_gps(void);

Expand Down
36 changes: 28 additions & 8 deletions src/furble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,18 @@ static uint16_t statusRefresh(void *context) {
auto camera = target->getCamera();
if (!camera->isConnected()) {
ezProgressBar progress_bar(FURBLE_STR, {"Reconnecting ..."}, {""});
if (camera->connect(settings_load_esp_tx_power(), &update_progress_bar, &progress_bar)) {
ez.screen.clear();
ez.header.show(header);
ez.buttons.show(buttons);
do {
if (camera->connect(settings_load_esp_tx_power(), &update_progress_bar, &progress_bar)) {
ez.screen.clear();
ez.header.show(header);
ez.buttons.show(buttons);

fctx->reconnected = true;
fctx->reconnected = true;

ez.redraw();
return 500;
}
ez.redraw();
return 500;
}
} while (settings_load_reconnect());
}
}

Expand Down Expand Up @@ -383,10 +385,25 @@ static bool multiconnect_toggle(ezMenu *menu, void *context) {
return true;
}

/**
* Toggle Infinite-ReConnect menu setting.
*/
static bool reconnect_toggle(ezMenu *menu, void *context) {
bool *reconnect = static_cast<bool *>(context);
*reconnect = !*reconnect;
menu->setCaption("reconnectonoff",
std::string("Infinite-ReConnect\t") + (*reconnect ? "ON" : "OFF"));

settings_save_reconnect(*reconnect);

return true;
}

static void menu_settings(void) {
ezMenu submenu(FURBLE_STR " - Settings");

bool multiconnect = settings_load_multiconnect();
bool reconnect = settings_load_reconnect();

submenu.buttons({"OK", "down"});
submenu.addItem("Backlight", "", ez.backlight.menu);
Expand All @@ -395,6 +412,9 @@ static void menu_settings(void) {
submenu.addItem("multiconnectonoff",
std::string("Multi-Connect\t") + (multiconnect ? "ON" : "OFF"), nullptr,
&multiconnect, multiconnect_toggle);
submenu.addItem("reconnectonoff",
std::string("Infinite-ReConnect\t") + (reconnect ? "ON" : "OFF"), nullptr,
&reconnect, reconnect_toggle);
submenu.addItem("Theme", "", ez.theme->menu);
submenu.addItem("Transmit Power", "", settings_menu_tx_power);
submenu.addItem("About", "", about);
Expand Down
19 changes: 19 additions & 0 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const char *PREFS_TX_POWER = "txpower";
const char *PREFS_GPS = "gps";
const char *PREFS_INTERVAL = "interval";
const char *PREFS_MULTICONNECT = "multiconnect";
const char *PREFS_RECONNECT = "reconnect";

/**
* Save BLE transmit power to preferences.
Expand Down Expand Up @@ -318,3 +319,21 @@ void settings_save_multiconnect(bool multiconnect) {
prefs.putBool(PREFS_MULTICONNECT, multiconnect);
prefs.end();
}

bool settings_load_reconnect(void) {
Preferences prefs;

prefs.begin(FURBLE_STR, true);
bool reconnect = prefs.getBool(PREFS_RECONNECT, false);
prefs.end();

return reconnect;
}

void settings_save_reconnect(bool reconnect) {
Preferences prefs;

prefs.begin(FURBLE_STR, false);
prefs.putBool(PREFS_RECONNECT, reconnect);
prefs.end();
}