Skip to content

Commit

Permalink
Remove name attribute from state
Browse files Browse the repository at this point in the history
  • Loading branch information
jonblack committed Sep 3, 2015
1 parent 9c0811e commit 0887ff7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
5 changes: 2 additions & 3 deletions Fsm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
#include "Fsm.h"


State::State(String name, void (*on_enter)(), void (*on_exit)())
: name(name),
on_enter(on_enter),
State::State(void (*on_enter)(), void (*on_exit)())
: on_enter(on_enter),
on_exit(on_exit)
{
}
Expand Down
3 changes: 1 addition & 2 deletions Fsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@

struct State
{
State(String name, void (*on_enter)(), void (*on_exit)());
State(void (*on_enter)(), void (*on_exit)());

String name;
void (*on_enter)();
void (*on_exit)();
};
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ feature branch.
* Remove AUTHORS files: too much hassle to maintain
* Add library.properties
* Add keywords.txt
* Remove name attribute from state

**1.0.0 - 24/12/2013**

Expand Down
4 changes: 2 additions & 2 deletions examples/light_switch/light_switch.ino
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ void on_trans_light_off_light_on()
Serial.println("Transitioning from LIGHT_OFF to LIGHT_ON");
}

State state_light_on("LIGHT_ON", on_light_on_enter, &on_light_on_exit);
State state_light_off("LIGHT_OFF", on_light_off_enter, &on_light_off_exit);
State state_light_on(on_light_on_enter, &on_light_on_exit);
State state_light_off(on_light_off_enter, &on_light_off_exit);
Fsm fsm(&state_light_off);

void setup()
Expand Down

2 comments on commit 0887ff7

@redge76
Copy link

Choose a reason for hiding this comment

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

Why remove the name ? It's quite convenient when debugging.

@jonblack
Copy link
Owner Author

Choose a reason for hiding this comment

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

It wasn't really serving any purpose. The variable name contains the same information, and nothing is ever done with the name. Of course, I didn't consider debugging. That said, you can always use the callbacks to aid debugging.

Please sign in to comment.