0

I am being sent capacitance readings and temperature sensor readings over bluetooth using UART.

I am attempting to do this by editing a pre existing open source app called nRF-UART.

I am trying to display the temperature data on a live updating static text view, and display the capacitance data as a vertical progress bar to show the level of water being measured. In order to do that I think I need the capacitance data to be on a separate string from the temperature data.

Here is where the string is being printed out at:

   if (action.equals(UartService.ACTION_DATA_AVAILABLE)) {

                 final byte[] txValue = intent.getByteArrayExtra(UartService.EXTRA_DATA);
                 runOnUiThread(new Runnable() {
                     public void run() {
                         try {
                            String text = new String(txValue, "UTF-8");
                                listAdapter.add(text);
                                messageListView.smoothScrollToPosition(listAdapter.getCount()-1);


                         } catch (Exception e) {
                             Log.e(TAG, e.toString());
                         }
                     }
                 });
             } 

How can I split up the values and bring them outside of `listAdapter'?

The string will look like this

1,75,460,0 

Where 75 is the temperature in Fahrenheit, and 460 is the capacitance reading in mL. 1 is just a starting bit, and 0 is the ending bit.

Mark Lupas
  • 21
  • 3
  • Add an example of the string value that you receive from the UART reading. – Lucas Cabrales Apr 22 '18 at 00:02
  • I don't have a screenshot, I can get one tomorrow. But it will be like this 1, 75, 470, 0 – Mark Lupas Apr 22 '18 at 00:16
  • For splitting the string you should refer to: https://stackoverflow.com/a/3481842/7436540 – Lucas Cabrales Apr 22 '18 at 00:19
  • @LucasDeMoraisCabrales , thank you! Now can I just put the progress bar code progressBar.setProgress(progressBar.getProgress()+10); and the textview code TextView textView = findViewById(R.id.Temperature); TextView.setText(part1); in the same function? – Mark Lupas Apr 22 '18 at 23:29

0 Answers0