-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* door switch controller added
- Loading branch information
Markus Martini
committed
Jan 13, 2017
1 parent
c0da6b2
commit f311ec6
Showing
5 changed files
with
75 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
jar/src/main/java/de/ck35/raspberry/happy/chameleon/rest/DoorSwitchController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package de.ck35.raspberry.happy.chameleon.rest; | ||
|
||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import com.pi4j.io.gpio.GpioPinDigitalInput; | ||
import com.pi4j.io.gpio.PinState; | ||
|
||
@RestController | ||
@RequestMapping("/door") | ||
public class DoorSwitchController { | ||
|
||
private final GpioPinDigitalInput myDoorSwitch; | ||
|
||
public DoorSwitchController(GpioPinDigitalInput myDoorSwitch) { | ||
this.myDoorSwitch = myDoorSwitch; | ||
} | ||
|
||
@RequestMapping("/status") | ||
public String status() { | ||
PinState ps = myDoorSwitch.getState(); | ||
|
||
if (myDoorSwitch.isHigh()) { | ||
// Door is open | ||
} | ||
|
||
return "Door status is: " + ps.getName(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters