Android Question Making a 4-key control panel using the panel in B4A

Hi everyone, please help me. I want to build a wi-fi remote control car for my little sister but I want to built it control panel in an application on her android phone, but I don't know how can I built this app. please hint me and here is my source code for this app. (to see its source code click on My app source code or click on attached file)
The problem is when I touch the panel I want to show its toast massage until I release it, but it don't work as I want.
My app source code
 

Attachments

  • panel.rar
    489.7 KB · Views: 97
Last edited:

walt61

Active Member
Licensed User
Longtime User
Please use File/Export As Zip to create a zip file with your project, it will omit most of the Objects folder and the AutoBackups folder.

You can't 'keep' a toast message, it does what it does. I would suggest you add a label to the layout and put the desired text in that label (and clear it when the touch is released). Detect the down/up touch actions as @Erel explained in this post: https://www.b4x.com/android/forum/threads/panel-touch-action.12255/#post-68839

Hope this helps!
 
Upvote 1
Thanks a lot walt61
but now I have a new problem I want to detect which panels will be touch at a same time and then decide what to do
I write a function for this but seem it doesn't work currently so I need your help once more again.
here is my code
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
Before you go any further you need to understand how this forum works. This is outlined in this post at the top of this forum page. In particular always start a new question in a new thread, and use the code tags (</> in the menu above) to post your code example.
 
Upvote 0

walt61

Active Member
Licensed User
Longtime User
Please use File/Export As Zip to create a zip file with your project, it will omit most of the Objects folder and the AutoBackups folder. It will also result in a zip file <512Kb and you'll be able to attach it straight to the post.

Your 'detect' code is wrong:
- 'a And d' performs a logical 'And' on these values and results in a Boolean (True or False), and you want to detect the condition 'both values are 1'
- your first test was 'If a = 1'; if that condition was satisfied, you'd never reach e.g. the 'And d = 1' bit

It should be:
B4X:
Sub detect

    If a = 1 Then
        If c = 1 Then
            Log("Go front left")
        Else If d = 1 Then
            Log("Go front-right")
        Else
            Log("Go front")
        End If
    Else If b = 1 Then
        If d = 1 Then
            Log("Go reverse-right")
        Else If c = 1 Then
            Log("Go reverse-left")
        Else
            Log("Go reverse")
        End If
    Else If c = 1 Then
        Log("Go left")
    Else If d = 1 Then
        Log("Go right")
    Else
        Log("STOP")
    End If
            
End Sub
 
Upvote 0

walt61

Active Member
Licensed User
Longtime User
The attached version makes your code more compact (and elegant ;)) and was exported as zip (making the zip only 10Kb).

In Designer, these changes were made too:
- set the 'Tag' property for the 4 panels to 'Left', 'Right', 'Front', 'Reverse'
- changed the 'Event Name' property for the 4 panels to 'k' so that they share the same event
 

Attachments

  • panel.zip
    9.8 KB · Views: 103
Upvote 0
The attached version makes your code more compact (and elegant ;)) and was exported as zip (making the zip only 10Kb).

In Designer, these changes were made too:
- set the 'Tag' property for the 4 panels to 'Left', 'Right', 'Front', 'Reverse'
- changed the 'Event Name' property for the 4 panels to 'k' so that they share the same event

Thanks again Walt61
Please explain more about this
 
Upvote 0
Hi, walt61.
Thanks a lot for your answers and support.
I finally made my own control app for my wifi remote car and here is the most stable version of my app.
I send it for you to thank you and see my app. I create two link of this file in my google drive because it's uploaded twice in a same time and I couldn't understand which one is the real file.
first link
second link
And the library I used to create some of the control's mode.
 

Attachments

  • JoystickViewLibFiles.zip
    8.5 KB · Views: 108
Upvote 0
Top