Newsletter
May 22, 2019 - 1:26pm, 1421 views
Hello I'm developing an application and need to shorten the boucing time, the reading on the input pin is a bit slow.
Hello,
Could you write some more about your solution, is Java API used or AT commands, how are you using GPIO, what the result is and what result woud be satisfactory?
Thanks,
Bartłomiej
Hello,
I'm using two buttons, which are being swept constantly through the thread, but I'm finding the reading a bit slow
Java API
example:
package buttons;
import java.io.IOException;
import java.util.Vector;
import com.cinterion.io.InPort;
import com.cinterion.io.InPortListener;
public class ButtonDP {
private static InPort inport;
private static InPortListener listener = null;
public synchronized static boolean getState() {
int state = 0;
try {
if (inport == null) {
Vector pins = new Vector();
pins.addElement("GPIO25");
inport = new InPort(pins);
}
state = inport.getValue();
} catch (IOException e) {
e.printStackTrace();
}
try {
if (listener == null) {
inport.release();
inport = null;
}
} catch (IOException e) {
e.printStackTrace();
}
return state == 1;
}
public static void addListener(InPortListener listener) throws IOException {
if (inport == null) {
Vector pins = new Vector();
pins.addElement("GPIO25");
inport = new InPort(pins);
}
inport.startPolling();
inport.addListener(listener);
}
}
public class ThreadButtons extends Thread {
public void run() {
inicia();
}
public void inicia() {
try {
ButtonUDP.addListener(new InPortListener() {
public void portValueChanged(int portValue) {
System.out.println("Button UDP: " + portValue);
}
});
} catch (Exception e) {
e.printStackTrace();
}
try {
ButtonCFG.addListener(new InPortListener() {
public void portValueChanged(int portValue) {
System.out.println("Button CFG: " + portValue);
}
});
} catch (Exception e) {
e.printStackTrace();
}
Hello,
Thank you for this information.
Could you please try to specify what 'a bit slow' means for you and what your expectations are?
In a meantime I paste the information regarding GPIO polling from AT commands specification:
"The pins will be polled every 6ms. In power saving mode(AT^SPOW=2), the interval of polling is reduced to 2.5s to save energy. After a state change has been detected the "^SCPOL" URC is issued if the state of the pin remains stable for 40ms. The maximum frequency of changing of the pin state that can be detected is 12Hz in non power saving mode and 0.2Hz in power saving mode."
Could you state how your test outcome is related to the above specification?
I think that Java might also introduce some delay, as it is not the first priority process for the module, depending on the system load.
Best regards,
Bartłomiej