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

Duplicated include; improved shutdown.c; store data even without switch #624

Merged
merged 1 commit into from
Aug 7, 2023

Conversation

Gabrielerusso
Copy link
Contributor

commands.c:

  • Delete duplicated include "mc_interface.h"

shutdown.c / shutdown.h / main.c:

  • Reducing possibility to write backup data frequently, now requires minimum distance to be traveled before it enables storing, common condition if push to start is enabled with a low shutdown time, say 10s, or in any other condition where user turn on/off ESC a lot of times. Saves chip life at the cost of not having updated data during very short trips.
  • Data is stored even when using "always on", basing storage condition on the inactivity time, this allower user that shutdown esc from the power source to keep data anyway or in case of a power loss.
  • Introducing possibility to store data without a power-switch by using a combination of trip distance and inactivity timer, it estimates when the scooter it's stopped for a long period after a trip, now user to save trip data just need to leave the scooter still an X amount of time to make sure all data is stored. It can be deactivated by using "always off" in app setting Shutdown Mode.

Compiled almost all version without issues, tested on my custom esc with different combinations (with power switch, without power switch) and it seems to work well.

…witch;

commands.c: delete duplicated "mc_interface.h" include
shutdown.c/shutdown.h/main.c:
- reducing possibility to write backup data frequently, now requires  minimum distance to be traveled before it enables storing, common condition if push to start is enabled with a low shutdown time, say 10s, or in any other condition where user turn on/off ESC a lot of times. Saves chip life at the cost of not having updated data during very short trips.
- Data is stored even when using "always on"
- Introducing possibility to store data without a power-switch by using a combination of trip distance and inactivity timer. It can be deactivated by using "always off" in app setting  Shutdown Mode.
@Gabrielerusso Gabrielerusso changed the title Duplicated include; improved shutdown.c; store backup without power s… Duplicated include; improved shutdown.c; store data even without switch May 3, 2023
@Gabrielerusso Gabrielerusso marked this pull request as ready for review May 15, 2023 17:24
@Gabrielerusso
Copy link
Contributor Author

Tested in those weeks with 4 escs and different configuration, 2 with power switch and 2 without, now i was able to save data, like the odometer without problems even in the version without the power switch.

@@ -67,7 +68,11 @@ void shutdown_set_sampling_disabled(bool disabled) {
}

static bool do_shutdown(void) {
conf_general_store_backup_data();
// Store data if 1000m or more have been done to possibly reduce flash
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is safe to assume that writing the backup date is fine when a shutdown is triggered. Otherwise a lot of odometer data can remain unlogged.

Copy link
Contributor Author

@Gabrielerusso Gabrielerusso Jun 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the amount of possible odometer data unlogged can be reduced by the distance, even 1m could be used even if it's pretty useless as not even car odometers have such accuracy, say one could set 10m or 100m.
Anyway it was just a suggestion as we don't use external eeprom like in automotive odometers.
STM32F405 flash endurance is >= 10k erase, those are not much compared to an eeprom with > 10^6 erase.

@1zun4
Copy link
Contributor

1zun4 commented Aug 5, 2023

Please merge this. This also solves my #638 problem, as the only reason I need it is to store odometer data without software shutdown.

@vedderb vedderb merged commit 90ea079 into vedderb:master Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants