@Override
 public void onClick(View v) {
   // TODO Auto-generated method stub
   // call stop
   myService.stopProcessing();
   tempUpdService.resetRunParams();
   tempBar.setProgress(50);
   // for (int i = 0; i < 5; i++) tempValues[i] = -50.00;
   maxTempValue = 0;
   liveGraphXYSeries.clear();
 }
        @Override
        public void handleMessage(Message msg) {
          switch (msg.what) {
            case MESSAGE_STATE_CHANGE:
              Log.i(TAG, "MESSAGE_STATE_CHANGE: " + msg.arg1);
              switch (msg.arg1) {
                case BluetoothChatService.STATE_CONNECTED:
                  setStatus("Connected to " + mConnectedDeviceName);
                  mConversationArrayAdapter.clear();
                  break;
                case BluetoothChatService.STATE_CONNECTING:
                  setStatus("Connecting");
                  break;
                case BluetoothChatService.STATE_LISTEN:
                case BluetoothChatService.STATE_NONE:
                  setStatus("Not Connected");
                  break;
              }
              break;
            case MESSAGE_WRITE:
              byte[] writeBuf = (byte[]) msg.obj;
              // construct a string from the buffer
              String writeMessage = new String(writeBuf);
              mConversationArrayAdapter.add("Me:  " + writeMessage);
              break;
            case MESSAGE_READ:
              byte[] readBuf = (byte[]) msg.obj;
              // construct a string from the valid bytes in the buffer
              String readMessage = new String(readBuf, 0, msg.arg1);
              // Call our processing engine
              // TODO: only process when we have a CR.
              readMessage = leftOvers + readMessage;

              Matcher m = p.matcher(readMessage);

              if (m.find()) {

                // Try and pull out the string

                if (tempValid.isValid(m.group(1))) {
                  // Is valid double
                  processedTemp = tempValid.validate(m.group(1));
                  Log.v(TAG, "value:" + String.format("%f", processedTemp) + ":" + m.group());

                  if (acceptTempVariance > 0) {

                    currentTempVarianceAllowed = 160;
                    currentTempVarianceAllowedNeg = 160;
                    acceptTempVariance--;

                  } else {
                    currentTempVarianceAllowed = allowedTempVariance;
                    currentTempVarianceAllowedNeg = allowedTempVarianceNeg;
                  }

                  if ((tempValid.isInRange(
                          processedTemp,
                          runTemp - currentTempVarianceAllowedNeg,
                          runTemp + currentTempVarianceAllowed))
                      || runTemp < 60) {
                    tempUpdService.setCurrentTemprature(processedTemp);
                    // Clear the string(s)
                    leftOvers = "";
                    readMessage = "";
                  } else {
                    Log.v(
                        TAG,
                        "Value out of allowed range: "
                            + String.format("%f", processedTemp)
                            + " Should be +- "
                            + String.format("%f", allowedTempVariance)
                            + " of "
                            + String.format("%f", runTemp));
                  }

                } else {
                  Log.v(TAG, "Value Not Num: " + readMessage);
                }

              } else {

                failedMatches++;
                leftOvers = readMessage;
                if (failedMatches > 10) {
                  Log.v(
                      TAG,
                      "Failed 10 Matches now: "
                          + leftOvers
                          + " length "
                          + String.format("%d", leftOvers.length()));
                  failedMatches = 0;
                }
              }

              if (leftOvers.length() > stringLengthToValidate) {
                Log.v(
                    TAG,
                    "Discarding : "
                        + leftOvers
                        + " length "
                        + String.format("%d", leftOvers.length())
                        + " left behind "
                        + leftOvers.substring(leftOvers.length() - stringLengthToValidate));
                leftOvers = leftOvers.substring(leftOvers.length() - stringLengthToValidate);
              } else {
                Matcher mr = pr.matcher(leftOvers);
                if (mr.find()) { // We have a end of message event - lets
                  // prune
                  leftOvers = leftOvers.substring(mr.end());
                }
              }
              // } else {
              // //not processing no CR
              // dispMessage.setText("StrV:" + leftOvers);
              // }

              mConversationArrayAdapter.add(mConnectedDeviceName + ":  " + readMessage);
              break;
            case MESSAGE_DEVICE_NAME:
              // save the connected device's name
              mConnectedDeviceName = msg.getData().getString(DEVICE_NAME);
              Toast.makeText(
                      getApplicationContext(),
                      "Connected to " + mConnectedDeviceName,
                      Toast.LENGTH_SHORT)
                  .show();
              break;
            case MESSAGE_TOAST:
              Toast.makeText(
                      getApplicationContext(), msg.getData().getString(TOAST), Toast.LENGTH_SHORT)
                  .show();
              break;
          }
        }
 @Override
 public void onClick(View v) {
   alarmTemp--;
   tempUpdService.setMaxValue(alarmTemp, false);
   dispAlarmTemp.setText(String.format("%3d", alarmTemp));
 }