File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,17 @@ public void startCollectingChannelsData(){
85
85
if (gpioController ==null || mcp3008GpioProvider ==null ){
86
86
throw new ModuleNotActiveException ("Module not active or not initialized" );
87
87
}
88
+
89
+ GpioPinAnalogInput [] gpioPinAnalogInput = new GpioPinAnalogInput [inputChannels .size ()];
90
+ /*a way of making the var of the number a final value to be used anonymously & to change it at the same time*/
91
+ final int [] position = {0 };
92
+ inputChannels .forEach (channel ->{
93
+ gpioPinAnalogInput [position [0 ]]= channel ;
94
+ position [0 ] +=1 ;
95
+ });
96
+
88
97
gpioController .addListener ((GpioPinListenerAnalog ) event -> {
98
+
89
99
double valueY =mcp3008GpioProvider .getValue (MCP3008Pin .CH0 );
90
100
double valueX =mcp3008GpioProvider .getValue (MCP3008Pin .CH1 );
91
101
@@ -110,7 +120,7 @@ public void startCollectingChannelsData(){
110
120
}
111
121
System .out .println ("Vx : " +valueX );
112
122
System .out .println ("Vy : " +valueY );
113
- }, ( GpioPinInput []) inputChannels . toArray () );
123
+ }, gpioPinAnalogInput );
114
124
115
125
gpioPinDigitalInput .addListener ((GpioPinListenerDigital ) event -> {
116
126
System .out .println ("Vz = " +event .getState ());
You can’t perform that action at this time.
0 commit comments