• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Vehicle control app

Hello all,
I am totally new to java and Android app development. I started playing with eclipse a week ago or so. I have basics of programming, but i always have to figure out whats going on in the code before i learn it :)
I should point that i have a lack in grafical design, drawing and java.
So, about my project:
With team we are making an electrical vehicle and at the moment we would like to make a cluster with a android tablet. We have a CANopen bus for data transfer between CPU, BMS, inverter, control units. We are using Arduino with CAN shield to get messages from CAN bus to android using bluetooth device HC-06. In this thread i would like to get as much advice and experience as i can about programming android with java.
At the moment i am using BluetoothChat example and changed it a little bit that it would show me incoming data in separate TextView fields.
I would like to draw a gauge with needle to show that digital data as an analog feedback for driver.
As i said, i will learn when i will figure out how it works. I have read few tutorials about drawing, rendering gauges but i still miss something in it, so i think the best way is to start from zero.
If anyone has questions for me i would gladly answer it.

I will poste my changes:
What i changed in main activity:
PHP:
// Show separate integers in textview fields
mGaugeSpeed = (TextView) findViewById(R.id.gaugeSpeed);
mGaugeTorque = (TextView) findViewById(R.id.gaugeTorque);

PHP:
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);
mConversationArrayAdapter.add("Rx: " + readMessage);
String[] spitStr = readMessage.split("\\|");
String numberSpeed = spitStr[0].replaceAll("\\D+","");
String numberTorque = spitStr[1].replaceAll("\\D+","");
mGaugeSpeed.setText("Speed: " + numberSpeed);
mGaugeTorque.setText("Torque: " + numberTorque);

Main layout:
PHP:
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2009 The Android Open Source Project

     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at

          http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
-->

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1">
    <ListView android:id="@+id/in"
        android:layout_width="100dp"
        android:layout_height="match_parent"
        android:stackFromBottom="true"
        android:transcriptMode="alwaysScroll"
    />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    <TextView
        android:id="@+id/gaugeSpeed"
        android:layout_width="200dp"
        android:layout_height="wrap_content"/>
    <TextView
        android:id="@+id/gaugeTorque"
        android:layout_width="200dp"
        android:layout_height="wrap_content"/>
    	</LinearLayout>
    </LinearLayout>
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        >
        <EditText android:id="@+id/edit_text_out"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_gravity="bottom"
        />
        <Button android:id="@+id/button_send"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/send"
        />
    </LinearLayout>
</LinearLayout>
The code gets from Bluetooth message like "number1|number2|number3|..." and so on and separates by "|" and adds to different TextView fields. At the moment it is done only for 2 numbers. I would like to draw 2 gauges(speedometer) and control needle with number1 and number2.

About the layout i would like to get a quick feedback, am i doing well with all that layout stuff? :)
At the moment all other code is left as it is in BluetoothChat example.
 
i am using bluetooth chat program in my project to send the command from android phone to hc06 bluetooth which is connected to arduino.bluetooth chat program is available in eclipse sample program, now i want to access this program through a single button ,can anybody help me out in this how should i do this , please tell me stepwise first we have to create which activity and then which i am very confused in this
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones