/Control.java Secret
Created
April 23, 2015 00:50
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
package bastide.pi.bbq; | |
import java.io.IOException; | |
import javax.servlet.ServletException; | |
import javax.servlet.annotation.WebServlet; | |
import javax.servlet.http.HttpServlet; | |
import javax.servlet.http.HttpServletRequest; | |
import javax.servlet.http.HttpServletResponse; | |
import com.pi4j.io.gpio.GpioController; | |
import com.pi4j.io.gpio.GpioFactory; | |
import com.pi4j.io.gpio.GpioPinDigitalOutput; | |
import com.pi4j.io.gpio.PinMode; | |
import com.pi4j.io.gpio.PinState; | |
import com.pi4j.io.gpio.RaspiPin; | |
/** | |
* Servlet implementation class Control | |
*/ | |
@WebServlet("/Control") | |
public class Control extends HttpServlet { | |
private static final long serialVersionUID = 1L; | |
/** | |
* @see HttpServlet#HttpServlet() | |
*/ | |
public Control() { | |
super(); | |
// TODO Auto-generated constructor stub | |
} | |
/** | |
* simple processing of the status flag for the servlet | |
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) | |
*/ | |
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { | |
String param = request.getParameter("status"); | |
if(param!=null && !param.isEmpty()){ | |
boolean status = Boolean.parseBoolean(param); | |
final GpioController gpio = GpioFactory.getInstance(); | |
// RaspiPin.GPIO_23); | |
final GpioPinDigitalOutput pin = gpio.provisionDigitalOutputPin(RaspiPin.GPIO_23, "MyLED", PinState.HIGH); | |
gpio.setMode(PinMode.DIGITAL_OUTPUT, pin); | |
System.out.println("--> GPIO state should be: " + status); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment