Bypass pressing a BUTTON with Bluetooth

What do you want to achieve?

I have an Arduino Nano + HM10 (Bluetooth Module) and an ESP32 with ILI9488 screen attached to it. I have established the Bluetooth connection between them and I can send data from the ESP to the Arduino and vice versa. I have generated an UI in SquareLine Studio for the ESP32 with some buttons; the buttons are DISABLED and greyed out at first and will start working only after I press a “START” button on the screen, then the flags and states for the buttons will change in order to be ACTIVE and to send data to the Arduino.

I want to achieve the following: when the ESP32 is searching for the Arduino + HM10, the UI will show the buttons greyed out (DISABLED) and after the ESP32 will find the Arduino + HM10 and it will be connected to it, the buttons will be ACTIVE (I want to bypass the step with the “START” button by only using the CONNECTED state of the Bluetooth)

What have you tried so far?

I have tried to modify the following line of code (from the ui.c file) in the IF condition to be able to take the CONNECTED state of the Bluetooth and to achieve what I want:

static void ui_event_nButton(lv_event_t * e)
{
lv_event_code_t event = lv_event_get_code(e);
lv_obj_t * ta = lv_event_get_target(e);
if(event == LV_EVENT_CLICKED) {
.
.
. }

Instead of: if(event == LV_EVENT_CLICKED)
I have tried: if(connected == true)
but obviously this is not gonna work :slight_smile: because i dont have any BLE library for the ui.c file

I have tried to take this part of code form the ui.c in the main code for the ESP32 and use “if(connected == true)” and again is not working

How can I achieve the results I want?
I will be glad if anyone can help me trough this and thank you in advance!

You can change state of the button with lv_obj_clear_state(obj, LV_STATE_DISABLE) when you know that Arduino is connected to ESP32, and you can do that in function where you are comparing that. You can look at that in the docs.

Like:

void isArduinoConnected(){
  if(connected != false){
    lv_obj_clear_state(nButton, LV_STATE_DISABLE);
  }
}
3 Likes

Had the same issue, thank you @dronecz

1 Like