How to change images graphically when receiving data?

Good afternoon, I am using a terminal to send data via com-port. I work under the protocol.

In the project, the Displaydata tab contains the string “case 35” - the # symbol.

What to write between case 35: and break; To achieve this?

The OOP JAVA code is used.

The command can be sent through the terminal using a virtual com port.

Command: #, 10 ,! picture 1.

For example: the number 10 could represent the minutes of the picture button.

Hello,

This was a quick exploration with your code and managed to get it to update the button when it received serial data as per your protocol.

The Arduino monitor was used to send data.

I added a method to your imageButton class:

void serButton (String num) {
  min = int(num);
  stateIndex = min/10;
  }

Added:

if (testRead != null)
    {
      println(incomingData);
      x = (int) testRead[0].charAt(0);
      num = testRead[1];  //global String num;
      //button.serButton(num);
     
      println(x, num, button.min);
      Displaydata();
    }

Added:

  case 35:
    // What to write?
    //label(num +" Мин."); // ImageButton #,10,!
    println("Case 35");
    button.serButton(num);
    //println(button.min);
    break;

Changed this to easily receive the serial data from Arduino monitor for testing:

    //incomingData = serialPort.readStringUntil(RC);
    incomingData = serialPort.readStringUntil('\n');

:)

1 Like

Thank you very much, happy new year to you.

1 Like