I create for a firma a java game using LibGDX. It will run on a Raspberry Pi 3. It is a clone of a famous arcade cabinet. The game is ready. The joystick control using a port of the evdev library works well. The application will use Pi4j library for interaction with external devices like a coin acceptor, a serial LED-chain based on a chip WS2812 and a 7-segments LED display. But the control of the serial LED-chain has troubles. The LED-chain needs to have a high frequency serial impulses. The control impulses must be between 500 and 1500 nanoseconds long to transfer the data. I have launched a simple test for pin GPIO26 to know the typical frequency of the GPIO-outputs:
long end;
long start = System.nanoTime();
for (int i =0; i++; i<10000){
ledPin.high();
ledPin.low();
}
end = System.nanoTime();
double statementChangingTime = (double)(end - start)/(10000*2);
I have got that the time between the statement changings is between 3500 - 9000 nanoseconds. It is too long.
I want to know, is it possible to increase the frequency (make the statementChangingTime smaller) using Pi4J? Maybe I need to select an another pin? Maybe I need change something in the raspi-config? Maybe I can use an another library? I don't know C/C++ and can not write myself a low-level code and a Java-wrapper for it.