always consuming button events

(bug fix: mote falls asleep during fast button clicks)
This commit is contained in:
fros4943 2007-04-02 14:14:26 +00:00
parent 5a96a9cdb7
commit 3d5298ab69
3 changed files with 15 additions and 8 deletions

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: button-sensor.c,v 1.3 2007/03/22 20:37:34 fros4943 Exp $
* $Id: button-sensor.c,v 1.4 2007/04/02 14:14:28 fros4943 Exp $
*/
#include "lib/sensors.h"
@ -100,9 +100,9 @@ doInterfaceActionsBeforeTick(void)
if(timer_expired(&debouncetimer)) {
timer_set(&debouncetimer, CLOCK_SECOND / 10);
sensors_changed(&button_sensor);
}
}
simButtonChanged = 0;
}
}
}
/*---------------------------------------------------------------------------*/
static void

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: ContikiButton.java,v 1.5 2007/01/09 10:05:19 fros4943 Exp $
* $Id: ContikiButton.java,v 1.6 2007/04/02 14:14:28 fros4943 Exp $
*/
package se.sics.cooja.contikimote.interfaces;
@ -102,11 +102,11 @@ public class ContikiButton extends Button implements ContikiMoteInterface {
moteMem.setByteValueOf("simButtonIsDown", (byte) 0);
if (moteMem.getByteValueOf("simButtonIsActive") == 1) {
// moteMem.setByteValueOf("simButtonChanged", (byte) 1);
moteMem.setByteValueOf("simButtonChanged", (byte) 1);
// If mote is inactive, wake it up
// if (RAISES_EXTERNAL_INTERRUPT)
// mote.setState(Mote.State.ACTIVE);
if (RAISES_EXTERNAL_INTERRUPT)
mote.setState(Mote.State.ACTIVE);
setChanged();
notifyObservers();
@ -137,6 +137,12 @@ public class ContikiButton extends Button implements ContikiMoteInterface {
}
public void doActionsAfterTick() {
// Make sure a mote never falls asleep with unhandled button events
if (moteMem.getByteValueOf("simButtonChanged") == 1
&& RAISES_EXTERNAL_INTERRUPT) {
mote.setState(Mote.State.ACTIVE);
}
// If a button is pressed and should be clicked, release it now
if (shouldBeReleased) {
// Make sure that the earlier press event has been handled by core

View File

@ -26,7 +26,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: Visualizer2D.java,v 1.8 2007/03/23 20:48:29 fros4943 Exp $
* $Id: Visualizer2D.java,v 1.9 2007/04/02 14:14:26 fros4943 Exp $
*/
package se.sics.cooja.plugins;
@ -103,7 +103,8 @@ public abstract class Visualizer2D extends VisPlugin {
private class ButtonClickMoteMenuAction implements MoteMenuAction {
public boolean isEnabled(Mote mote) {
return mote.getInterfaces().getButton() != null;
return mote.getInterfaces().getButton() != null
&& !mote.getInterfaces().getButton().isPressed();
}
public String getDescription(Mote mote) {
return "Click button on " + mote;