bluerange-io / bluerange-mesh

BlueRange Mesh (formerly FruityMesh) - The first completely connection-based open source mesh on top of Bluetooth Low Energy (4.1/5.0 or higher)
https://bluerange.io/
Other
288 stars 109 forks source link

Added states to button handler in order to trigger events on button press and release #125

Closed NilsMinor closed 4 years ago

NilsMinor commented 4 years ago

I added an ButtonState enum to with the states INITAL, PRESSED, RELEASED. I also added a new variable 'ButtonState button1State' to . The button handler will be called on falling and rising edge and still stores the hold time in button1HoldTimeDs. Inside the overwritten Module::ButtonHandler function the user can call GS->button1State to get information about the button wass pressed or released. This commit should fix #123

mariusheil commented 4 years ago

Hi,

I think it would be better to change the signature of the ButtonHandler so that the type of button event is directly passed to that handler: void ButtonHandler(u8 buttonId, ButtonState buttonState, u32 timeDs)

Also, I think you have some code formatter that cluttered the pull request a lot. We would only be able to merge it if only the proper places in the code are changed.

Thanks :-) Marius

NilsMinor commented 4 years ago

Hi,

I thought it might be wrong to change all ButtonEvent handlers but of course I can do it this way :) I used visual code which seems to format the code different to your style. I want to change my IDE to eclipse, do you have your format style as .xml file? I have some problems figuring out why eclipse (the newest mars version) doe not find so many functions and variables. Do you provide an eclipse setup? I've seen an old project from your company with an eclipse setup (https://github.com/mwaylabs/fruitymesh-devenv) do you also provide a new repo for this? This would make the development setup much easier ^^. Thanks, Nils