Skip to content

Commit 0f8ceca

Browse files
committed
Added ConfigurationException
1 parent a795e3b commit 0f8ceca

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class ConfigurationException extends RuntimeException{
2+
private final String message;
3+
public ConfigurationException(String message){
4+
this.message=message;
5+
}
6+
7+
@Override
8+
public void printStackTrace() {
9+
System.err.println(message);
10+
}
11+
}

src/main/java/JoystickModule.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,16 @@ public void startCollectingChannelsData(){
164164
if(gpioController==null || mcp3008GpioProvider==null){
165165
throw new ModuleNotActiveException("Module not active or not initialized");
166166
}
167-
167+
if(getVxPin()==null || getVyPin()==null){
168+
throw new ConfigurationException("Please Register MCP3008 input Channels w/ the JoyStick module Vx & Vy");
169+
}
168170
GpioPinAnalogInput[] gpioPinAnalogInput= new GpioPinAnalogInput[inputChannels.size()];
169171
/*a way of making the var of the number a final value to be used anonymously & to change it at the same time*/
170172
final int[] position = {0};
171173
inputChannels.forEach(channel->{
172174
gpioPinAnalogInput[position[0]]= channel;
173175
position[0] +=1;
174176
});
175-
176177
gpioController.addListener((GpioPinListenerAnalog) event -> {
177178
double valueX=mcp3008GpioProvider.getValue(getVxPin());
178179
double valueY=mcp3008GpioProvider.getValue(getVyPin());

0 commit comments

Comments
 (0)