Are there any Java examples using matrix core?

Hi

Are the any java examples using the matrix core api? I can send data to the matrix creator now but I am having issues on the basic led example because I don’t know how to use the protobuffers correctly

I get error messgaes such as

“Specific config for Everloop failed.”

My example code is below for anyone that is familiar and can see what I am doing wrong. I previously reused the LedValues but this is the state of my last try to see if clearing would improve things.

    DriverConfig.Builder driverConfig = DriverConfig.newBuilder();
    EverloopImage.Builder everloopImage = EverloopImage.newBuilder();
    ledCount = 2;
    
    while (true)
    {            
        everloopImage = everloopImage.clear();
        //For each device LED
        for (int i = 0; i < ledCount; i++)
        {
            //Set individual LED value                
            LedValue.Builder ledValue = LedValue.newBuilder();
            ledValue.setBlue((int) (Math.random() * 50));
            ledValue.setRed((int) (Math.random() * 200));
            ledValue.setGreen((int) (Math.random() * 255));
            ledValue.setWhite(0);
            everloopImage.addLed(ledValue.build());
        }

        everloopImage.build();
        driverConfig.setImage(everloopImage.build());
        
        Msg msg = new Msg(driverConfig.build().toByteArray());
        
        ZMQ.send(base, msg, 0);

        Thread.sleep(50);
    }

Through trial and error I now have it working, below is the while loop to send the commands

    while (true)
    {
        DriverConfig.Builder driverConfig = DriverConfig.newBuilder();
        EverloopImage.Builder everloopImage = EverloopImage.newBuilder();

        //For each device LED
        for (int i = 0; i < ledCount; i++)
        {
            //Set individual LED value                   
            LedValue.Builder ledValue = LedValue.newBuilder();
            ledValue.setBlue((int) (Math.random() * 50));
            ledValue.setRed((int) (Math.random() * 200));
            ledValue.setGreen((int) (Math.random() * 255));
            ledValue.setWhite(0);
            everloopImage.addLed(ledValue);
        }

        driverConfig.setImage(everloopImage);

        Msg msg = new Msg(driverConfig.build().toByteArray());

        ZMQ.send(base, msg, 0);

        Thread.sleep(50);
    }
1 Like