1 year ago

#73615

test-img

northcitizen

SerialInputOutputManager, average received values

I use library for usb i/o and cant't understand how to average incoming data and show it in 500ms.. I'm trying to edit example from the library and there is method

@Override
    public void onNewData(byte[] data) {
        mainLooper.post(() -> {
            receive(data);
        });
    }

private void receive(byte[] data) {
        SpannableStringBuilder spn = new SpannableStringBuilder();
        receiveView.setText(" ");
        if(data.length > 0)
            spn.append(HexDump.fromByteArrayToString(data)).append("\n");
        receiveView.append(spn);
    }

onNewData is called when new incoming data is available, but it's too fast for me. How can I edit the example to get average value and show it on TextView?

java

android

stm32

usbserial

0 Answers

Your Answer

Accepted video resources