Removed old files
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package control;
|
||||
|
||||
import com.pi4j.io.gpio.GpioFactory;
|
||||
import com.pi4j.io.gpio.GpioPinDigitalInput;
|
||||
import com.pi4j.io.gpio.Pin;
|
||||
|
||||
public class Button {
|
||||
private GpioPinDigitalInput input;
|
||||
|
||||
public Button(int buttonId, Pin pin){
|
||||
input = GpioFactory.getInstance().provisionDigitalInputPin(pin , "Button:"+buttonId);
|
||||
}
|
||||
public boolean getState(){
|
||||
return input.getState().isLow();
|
||||
}
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
package control;
|
||||
|
||||
public class ButtonEvent {
|
||||
private Button button;
|
||||
private Long now;
|
||||
|
||||
public ButtonEvent(Button button, Long now){
|
||||
this.button = button;
|
||||
this.now = now;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the button
|
||||
*/
|
||||
public Button getButton() {
|
||||
return button;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time when event was triggered
|
||||
*/
|
||||
public Long getNow() {
|
||||
return now;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package control;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.pi4j.io.gpio.GpioController;
|
||||
import com.pi4j.io.gpio.GpioFactory;
|
||||
import com.pi4j.io.gpio.GpioPinDigitalInput;
|
||||
import com.pi4j.io.gpio.RaspiPin;
|
||||
|
||||
public class Buttons {
|
||||
private ArrayList<GpioPinDigitalInput> buttons;
|
||||
private final GpioController rpi = GpioFactory.getInstance();
|
||||
/**
|
||||
Pin numbering below *not used yet, just for remembering the pin numbers*
|
||||
*/
|
||||
//arcade buttons
|
||||
private final int button1 = 29;
|
||||
private final int button2 = 28;
|
||||
private final int button3 = 27;
|
||||
private final int button4 = 25;
|
||||
private final int button5 = 24;
|
||||
private final int button6 = 23;
|
||||
//joystick
|
||||
private final int joystickleft = 26;
|
||||
private final int joystickup = 22;
|
||||
private final int joystickright = 21;
|
||||
private final int joystickdown = 11;
|
||||
//start-stop button
|
||||
private final int buttonstart = 10;
|
||||
|
||||
public Buttons(){
|
||||
buttons = new ArrayList<GpioPinDigitalInput>();
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_29 , "button1"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_28 , "button2"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_27 , "button3"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_25 , "button4"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_24 , "button5"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_23 , "button6"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_26 , "joystickleft"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_22 , "joystickup"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_21 , "joystickright"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_11 , "joystickdown"));
|
||||
buttons.add(rpi.provisionDigitalInputPin(RaspiPin.GPIO_10 , "buttonstart"));
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package control;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface ButtonsListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Invoked when a button has been pressed.
|
||||
*/
|
||||
public void buttonPressed(ButtonEvent e);
|
||||
|
||||
/**
|
||||
* Invoked when a button has been released.
|
||||
*/
|
||||
public void buttonReleased(ButtonEvent e);
|
||||
|
||||
/**
|
||||
* Invoked when a button is held down.
|
||||
*/
|
||||
public void buttonHeld(ButtonEvent e);
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package control;
|
||||
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyListener;
|
||||
|
||||
import com.pi4j.io.gpio.GpioController;
|
||||
import com.pi4j.io.gpio.GpioFactory;
|
||||
import com.pi4j.io.gpio.GpioPinDigitalInput;
|
||||
import com.pi4j.io.gpio.RaspiPin;
|
||||
import com.pi4j.io.gpio.event.GpioPinDigitalStateChangeEvent;
|
||||
import com.pi4j.io.gpio.event.GpioPinListenerDigital;
|
||||
|
||||
public class Buttontest{
|
||||
|
||||
final GpioController rpi = GpioFactory.getInstance();
|
||||
public Buttontest(){
|
||||
GpioPinDigitalInput button1 = rpi.provisionDigitalInputPin( RaspiPin.GPIO_07,
|
||||
"button1");
|
||||
button1.addListener(new GpioPinListenerDigital() {
|
||||
@Override
|
||||
public void handleGpioPinDigitalStateChangeEvent(GpioPinDigitalStateChangeEvent e){
|
||||
System.out.println(e.getPin());
|
||||
System.out.println(e.getSource());
|
||||
System.out.println(e.getState());
|
||||
}
|
||||
});
|
||||
while(true){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package control;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface JoystickListener extends EventListener {
|
||||
/**
|
||||
* Invoked when the joystick has been moved.
|
||||
*/
|
||||
public void joystickMoved(Joystickevent e);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
package control;
|
||||
|
||||
public class Joystickevent {
|
||||
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
package control;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
|
||||
public class Ledstrip {
|
||||
private BufferedReader inp;
|
||||
private BufferedWriter out;
|
||||
private Process p;
|
||||
|
||||
public Ledstrip(){
|
||||
try {
|
||||
p = Runtime.getRuntime().exec("sudo python led.py");
|
||||
inp = new BufferedReader( new InputStreamReader(p.getInputStream()) );
|
||||
out = new BufferedWriter( new OutputStreamWriter(p.getOutputStream()) );
|
||||
|
||||
setLed(15, 100, 100, 100);
|
||||
strobo();
|
||||
}
|
||||
catch (Exception err) {
|
||||
err.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void close(){
|
||||
try {
|
||||
inp.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
p.destroy();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the color of a specific led
|
||||
* @param Pixel number of the led
|
||||
* @param Red value
|
||||
* @param Green value
|
||||
* @param Blue value
|
||||
* Remember: Button leds are GRB, normal ledstrip is RGB
|
||||
*/
|
||||
public void setLed(int led, int r, int g, int b) {
|
||||
try {
|
||||
out.write( "1|" + led + "|" + r + "|" + g + "|" + b + "\n" );
|
||||
out.flush();
|
||||
}
|
||||
catch (Exception err) {
|
||||
err.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the (new) colors
|
||||
*/
|
||||
public void show(){
|
||||
try {
|
||||
out.write( "0\n" );
|
||||
out.flush();
|
||||
}
|
||||
catch (Exception err) {
|
||||
err.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void strobo(){
|
||||
boolean on = true;
|
||||
while(true){
|
||||
if(on){
|
||||
for(int i = 1; i < 66; i++){
|
||||
setLed(i, 0, 0, 0);
|
||||
}
|
||||
}else{
|
||||
for(int i = 1; i < 66; i++){
|
||||
setLed(i, 255, 255, 255);
|
||||
}
|
||||
}
|
||||
on = !on;
|
||||
show();
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
interface ButtonListener {
|
||||
public void buttonPressed();
|
||||
public void buttonReleased();
|
||||
}
|
||||
|
||||
class Button {
|
||||
List<ButtonListener> listeners = new ArrayList<ButtonListener>();
|
||||
|
||||
public void addButtonListener(ButtonListener toAdd) {
|
||||
listeners.add(toAdd);
|
||||
}
|
||||
|
||||
public void buttonPress() {
|
||||
for (ButtonListener bt : listeners)
|
||||
bt.buttonPressed();
|
||||
}
|
||||
|
||||
public void buttonRelease() {
|
||||
for (ButtonListener bt : listeners)
|
||||
bt.buttonReleased();
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
package view;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
interface JoyStickListener {
|
||||
public void onJoyStickMoved();
|
||||
}
|
||||
|
||||
class JoyStick {
|
||||
List<JoyStickListener> listeners = new ArrayList<JoyStickListener>();
|
||||
|
||||
public void addJoyStickListener(JoyStickListener toAdd) {
|
||||
listeners.add(toAdd);
|
||||
}
|
||||
|
||||
public void onJoyStickMoved() {
|
||||
for (JoyStickListener yst : listeners)
|
||||
yst.onJoyStickMoved();
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package view;
|
||||
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.Timer;
|
||||
|
||||
public class Panel extends JPanel implements ActionListener, ButtonListener, JoyStickListener{
|
||||
|
||||
Timer t;
|
||||
|
||||
public Panel()
|
||||
{
|
||||
//addButtonListener(this);
|
||||
|
||||
t = new Timer(1000/30, this);
|
||||
t.start();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent arg0) {
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g)
|
||||
{
|
||||
super.paintComponent(g);
|
||||
Graphics2D g2d = (Graphics2D) g;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buttonReleased() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoyStickMoved() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user