mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-21 19:29:18 +00:00
Button: Add doPressButton() and doReleaseButton() to Button class
As every Button has a node-specific implementation part, this should be the minimal interface to the backend node emulator for pressing and releasing a button.
This commit is contained in:
parent
378ca2629d
commit
be88a4fc52
@ -55,17 +55,27 @@ public class ESBButton extends Button {
|
||||
}
|
||||
|
||||
public void releaseButton() {
|
||||
mote.esbNode.setButton(false);
|
||||
doReleaseButton();
|
||||
setChanged();
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doReleaseButton() {
|
||||
mote.esbNode.setButton(false);
|
||||
}
|
||||
|
||||
public void pressButton() {
|
||||
mote.esbNode.setButton(true);
|
||||
doPressButton();
|
||||
setChanged();
|
||||
notifyObservers();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPressButton() {
|
||||
mote.esbNode.setButton(true);
|
||||
}
|
||||
|
||||
public boolean isPressed() {
|
||||
return false;
|
||||
}
|
||||
|
@ -62,20 +62,30 @@ public class MspButton extends Button {
|
||||
public void pressButton() {
|
||||
sim.invokeSimulationThread(new Runnable() {
|
||||
public void run() {
|
||||
button.setPressed(true);
|
||||
doPressButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPressButton() {
|
||||
button.setPressed(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseButton() {
|
||||
sim.invokeSimulationThread(new Runnable() {
|
||||
public void run() {
|
||||
button.setPressed(false);
|
||||
doReleaseButton();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doReleaseButton() {
|
||||
button.setPressed(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPressed() {
|
||||
return button.isPressed();
|
||||
|
@ -81,7 +81,8 @@ public class SkyButton extends Button {
|
||||
});
|
||||
}
|
||||
|
||||
public void doPressButton() {
|
||||
@Override
|
||||
protected void doPressButton() {
|
||||
skyMote.skyNode.setButton(true);
|
||||
}
|
||||
|
||||
@ -93,7 +94,8 @@ public class SkyButton extends Button {
|
||||
});
|
||||
}
|
||||
|
||||
public void doReleaseButton() {
|
||||
@Override
|
||||
protected void doReleaseButton() {
|
||||
skyMote.skyNode.setButton(false);
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,8 @@ public class ContikiButton extends Button implements ContikiMoteInterface {
|
||||
});
|
||||
}
|
||||
|
||||
private void doReleaseButton() {
|
||||
@Override
|
||||
protected void doReleaseButton() {
|
||||
moteMem.setByteValueOf("simButtonIsDown", (byte) 0);
|
||||
|
||||
if (moteMem.getByteValueOf("simButtonIsActive") == 1) {
|
||||
@ -142,7 +143,8 @@ public class ContikiButton extends Button implements ContikiMoteInterface {
|
||||
}
|
||||
}
|
||||
|
||||
private void doPressButton() {
|
||||
@Override
|
||||
protected void doPressButton() {
|
||||
moteMem.setByteValueOf("simButtonIsDown", (byte) 1);
|
||||
|
||||
if (moteMem.getByteValueOf("simButtonIsActive") == 1) {
|
||||
|
@ -59,11 +59,21 @@ public abstract class Button extends MoteInterface {
|
||||
*/
|
||||
public abstract void releaseButton();
|
||||
|
||||
/**
|
||||
* Node-type dependent implementation of pressing a button.
|
||||
*/
|
||||
protected abstract void doPressButton();
|
||||
|
||||
/**
|
||||
* Presses button (if not already pressed).
|
||||
*/
|
||||
public abstract void pressButton();
|
||||
|
||||
/**
|
||||
* Node-type dependent implementation of releasing a button.
|
||||
*/
|
||||
protected abstract void doReleaseButton();
|
||||
|
||||
/**
|
||||
* @return True if button is pressed
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user