Skip to content

Commit

Permalink
new configuration version and some bugs solved
Browse files Browse the repository at this point in the history
  • Loading branch information
pat1 committed Feb 25, 2022
1 parent a715b2f commit 2a12a11
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion platformio/stima_v3/i2c-rain/src/i2c-rain-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
\def MODULE_CONFIGURATION_VERSION
\brief Module version of compatibile configuration. If you change it, you have to reconfigure.
*/
#define MODULE_CONFIGURATION_VERSION (1)
#define MODULE_CONFIGURATION_VERSION (2)

/*!
\def MODULE_TYPE
Expand Down
12 changes: 12 additions & 0 deletions platformio/stima_v3/i2c-rain/src/i2c-rain.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,18 @@ bool is_start;
*/
bool is_stop;

/*!
\var is_test
\brief Execute stop command in test mode.
*/
bool is_test;

/*!
\var is_started
\brief Start command is active and measure is active.
*/
bool is_started;

/*!
\var rain_tips_event_occurred_time_ms
\brief System time (in millisecond) when rain tips occured.
Expand Down
15 changes: 9 additions & 6 deletions platformio/stima_v3/i2c-rain/src/i2c-rain.ino
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void tipping_bucket_task () {

case TIPPING_BUCKET_READ:
// increment rain tips if oneshot mode is on and oneshot start command It has been received
if (configuration.is_oneshot && is_start) {
if (configuration.is_oneshot && is_started) {
// re-read pin status to filter spikes
if (digitalRead(TIPPING_BUCKET_PIN) == LOW) {
rain.tips_count++;
Expand Down Expand Up @@ -584,20 +584,17 @@ void command_task() {
LOGN(F("Execute [ %s ]"), "TEST READ");
is_start = false;
is_stop = true;
is_test = true;
break;

case I2C_RAIN_COMMAND_SAVE:
LOGN(F("Execute [ %s ]"), "SAVE");
save_configuration(CONFIGURATION_CURRENT);
init_wire();
is_start = false;
is_stop = false;
break;

default:
LOGE(F("Command UNKNOWN"));
is_start = false;
is_stop = false;
}

commands();
Expand All @@ -619,19 +616,25 @@ void commands() {
readable_data_write_ptr->rain.tips_count = rain.tips_count;
readable_data_write_ptr->rain.rain = rain.rain;
exchange_buffers();
if (! is_test) is_started=false;
}

if (is_start) {
reset_buffers();
is_started=true;
}

} else {

LOGE(F("Continous mode not supported!"));

}

interrupts();
is_start = false;
is_stop = false;
is_test = false;

LOGN(F("Total tips : %d"), readable_data_read_ptr->rain.tips_count);
LOGN(F("Total rain : %d"), readable_data_read_ptr->rain.rain);
}

0 comments on commit 2a12a11

Please sign in to comment.