Global Moderators

Forum wide moderators

Private

Posts

  • RE: Looking for BLE example for UNO R4 WFi

    @al1fch Hi,

    try the code below (install the latest ArduinoBLE library through Library Manager).

    /*
     * GUI-O Basic BLE example for Arduino UNO R4 WiFi
     *
     * Uses the ArduinoBLE library and Nordic UART Service (NUS) UUIDs.
     *
     * Connect an LED (with a suitable series resistor) to PWM pin D9.
     * The onboard LED is not used because brightness control requires PWM.
     *
     * SPDX-License-Identifier: BSD-3-Clause
     */
    
    #include <ArduinoBLE.h>
    
    namespace led {
      constexpr uint8_t PIN = 9;  // UNO R4 WiFi PWM-capable pin
    }
    
    namespace uuid {
      constexpr char SERVICE[] = "6E400001-B5A3-F393-E0A9-E50E24DCCA9E";
      constexpr char RX[]      = "6E400002-B5A3-F393-E0A9-E50E24DCCA9E";
      constexpr char TX[]      = "6E400003-B5A3-F393-E0A9-E50E24DCCA9E";
    }
    
    namespace ble {
      // A 20-byte payload works without depending on a larger negotiated MTU.
      constexpr size_t NOTIFY_CHUNK_SIZE = 20;
      constexpr int RX_BUFFER_SIZE = 512;
    }
    
    void parseGuioMsg(const String &msg);
    void sendMsg(const String &msg);
    
    BLEService nusService(uuid::SERVICE);
    
    // GUI-O writes commands to RX.
    BLECharacteristic rxCharacteristic(
      uuid::RX,
      BLEWrite | BLEWriteWithoutResponse,
      ble::RX_BUFFER_SIZE
    );
    
    // UNO R4 sends GUI commands through TX notifications.
    BLECharacteristic txCharacteristic(
      uuid::TX,
      BLENotify,
      ble::NOTIFY_CHUNK_SIZE
    );
    
    bool wasConnected = false;
    
    void setup() {
      Serial.begin(115200);
    
      pinMode(led::PIN, OUTPUT);
      analogWrite(led::PIN, 0);
    
      if (!BLE.begin()) {
        Serial.println("Failed to initialize BLE!");
        while (true) {
          delay(1000);
        }
      }
    
      BLE.setLocalName("BasicBLE_NUS");
      BLE.setDeviceName("BasicBLE_NUS");
      BLE.setAdvertisedService(nusService);
    
      nusService.addCharacteristic(rxCharacteristic);
      nusService.addCharacteristic(txCharacteristic);
      BLE.addService(nusService);
    
      BLE.advertise();
      Serial.println("BLE advertising started.");
    }
    
    void loop() {
      BLE.poll();
    
      BLEDevice central = BLE.central();
      const bool connected = central && central.connected();
    
      if (connected && !wasConnected) {
        Serial.print("Connected to: ");
        Serial.println(central.address());
        wasConnected = true;
      }
    
      if (!connected && wasConnected) {
        Serial.println("Disconnected!");
        wasConnected = false;
    
        // Explicitly resume advertising for reliable reconnection.
        BLE.advertise();
      }
    
      if (connected && rxCharacteristic.written()) {
        const int length = rxCharacteristic.valueLength();
    
        if (length > 0) {
          String msg;
          msg.reserve(length);
    
          const uint8_t *value = rxCharacteristic.value();
          for (int i = 0; i < length; ++i) {
            msg += static_cast<char>(value[i]);
          }
    
          parseGuioMsg(msg);
        }
      }
    }
    
    /***************************/
    /* IMPLEMENT YOUR GUI HERE */
    /***************************/
    void sendMsg(const String &msg) {
      if (!wasConnected) {
        return;
      }
    
      const uint8_t *data = reinterpret_cast<const uint8_t *>(msg.c_str());
      size_t remaining = msg.length();
    
      while (remaining > 0) {
        const size_t chunkLength =
          remaining > ble::NOTIFY_CHUNK_SIZE
            ? ble::NOTIFY_CHUNK_SIZE
            : remaining;
    
        if (!txCharacteristic.writeValue(data, chunkLength)) {
          Serial.println("Failed to send BLE notification.");
          return;
        }
    
        data += chunkLength;
        remaining -= chunkLength;
    
        BLE.poll();
        delay(10);
      }
    }
    
    void parseGuioMsg(const String &msg) {
      if (msg.startsWith("@init")) {
        Serial.println("GUI-O app is requesting INITIALIZATION!");
    
        // Clear screen and set background.
        sendMsg("@cls\r\n");
        sendMsg("@guis BGC:#FFFFFF\r\n");
        delay(100);
    
        // Initialize simple example GUI.
        sendMsg("|LB UID:title X:50 Y:15 TXT:\"Simple light switch\" FFA:\"font8\" FSZ:3.5\r\n");
        sendMsg("|LB UID:tap_me X:50 Y:70 TXT:\"TAP ME!\" FFA:\"font8\" FSZ:3 FFA:\"font5\"\r\n");
        sendMsg("|CB UID:brightness X:50 Y:50 W:90 BTH:5 HAH:8 HAW:8 VIS:0 STA:135 ENA:45 FGC:#000000 SFGC:#FFFF00 BGC:#CBCBCB\r\n");
        sendMsg("|IM UID:light_off X:50 Y:50 IP:\"https://i.imgur.com/3VbsS0Z.png\" VIS:1\r\n");
        sendMsg("|IM UID:light_on X:50 Y:50 IP:\"https://i.imgur.com/gNdck9A.png\" VIS:0\r\n");
      }
      else if (msg.startsWith("@light_off")) {
        Serial.println("GUI-O app is requesting LIGHT ON!");
    
        sendMsg("@light_off VIS:0\r\n");
        sendMsg("@light_on VIS:1\r\n");
        sendMsg("@brightness VIS:1 VAL:100\r\n");
    
        analogWrite(led::PIN, 255);
      }
      else if (msg.startsWith("@light_on")) {
        Serial.println("GUI-O app is requesting LIGHT OFF!");
    
        sendMsg("@light_off VIS:1\r\n");
        sendMsg("@light_on VIS:0\r\n");
        sendMsg("@brightness VIS:0 VAL:0\r\n");
    
        analogWrite(led::PIN, 0);
      }
      else if (msg.startsWith("@brightness")) {
        const int idx = msg.indexOf(' ');
    
        if (idx > 0) {
          const int val = msg.substring(idx + 1).toInt();
    
          if (val >= 0 && val <= 100) {
            Serial.print("GUI-O app is requesting LIGHT BRIGHTNESS: ");
            Serial.println(val);
    
            const int pwmValue = map(val, 0, 100, 0, 255);
            analogWrite(led::PIN, pwmValue);
          }
        }
      }
    }
    

    I just used Chat to port the code from ESP32 on the GUI-O website. Should work...

    Best regards,
    Kl3m3n

    posted in Wishlist
  • RE: Graphique commands

    @Bernard If the assistant did not solve your issue, I can check your code. 😁

    posted in General Discussion
  • RE: Graphique commands

    @Bernard said in Graphique commands:

    Hello,
    I have a problem. I define a Time graph like this:
    sendMqtt("|CH UID:ch_N X:43 Y:50 W:190 H:33 CHT:0 FSZ:0.5 ROT:90 BGC:#000000 FSZ:1.5 CHN:"Event Log" YTC:9 XMA:9 YMA:6 SCI:2");
    I write to the graph like this;
    sendMqtt("@ch_N PLI:"pl0,pl1,pl2,pl3,pl4" PLC:"#FF0000,#00FF00,#0000FF,#FF77FF,#FFFF00" YP:"" + String(tempExt, 1) + " ; " + String(tempBal, 1) + " ; " + String(tempMoule, 1) + " ; " + String(poidsActuel, 1) + " ; " + String(epaisseurNeige, 1) + """);
    and I get the message: Number of parameters mismatch error (ch_N). Can you help me?

    Have you tried using GUI-O assistant? Just copy and paste your entire question:
    https://assistant.gui-o.com/

    Best regards,
    Kl3m3n

    posted in General Discussion
  • RE: Landscape/portrait

    @Bernard Hi!

    Use global portrait orientation - this is default, so no changes needed there.

    This way page 1 and page 2 work out-of-the box.
    For page 3, rotate the chart by 90° (or -90°, depending on your preference).

    But, you will have to wait for the next release to support this as app has widget size limits... So, currently, if you rotate the chart, you will only achieve 100% width size - you will not be able to fill the entire landscape.

    The fix will be available tomorrow - I planed a new release to fix some issues and I will also include this.

    Best regards,
    Kl3m3n

    posted in General Discussion
  • AI-powered GUI-O assistant

    Try the AI-powered GUI-O assistant:

    https://assistant.gui-o.com/

    Any feedback is appreciated.

    Best regards,
    Kl3m3n

    posted in Announcements
  • RE: Intro - Please read carefully

    @gammda

    The issue is .au.
    Try just bobstantonx@gmail.com

    Regards.

    posted in GUI-O Drag-and-Drop Designer (Early Development) - Feedback Wanted
  • RE: Intro - Please read carefully

    @heromed

    Bob, would you like to add something?

    For example - where can the potential testers get the preview of the designer?
    Additional info on how to set it up, what environment to use etc...?

    posted in GUI-O Drag-and-Drop Designer (Early Development) - Feedback Wanted
  • Intro - Please read carefully

    A GUI-O user has started developing a new visual designer for GUI-O that will support drag-and-drop widget creation, while still remaining fully compatible with the existing GUI-O app and command protocol.

    The goal is to make GUI creation easier by allowing users to visually place widgets, configure their properties, and generate the corresponding GUI-O ASCII commands automatically.

    The project is still in early development, and the developer would like to collect feedback from the community while designing the tool.

    This is a good opportunity to help shape the direction of the designer.

    Feedback that would be useful at this stage includes:

    • features a visual GUI-O designer should support
    • workflow ideas (layout editing, widget configuration, etc.)
    • suggestions for simplifying GUI-O interface creation
    • etc.

    If you are interested in contributing ideas or participating in future testing, feel free to share your thoughts in this thread.

    You can also contact the developer directly:

    Email: bobstantonx@gmail.com
    Forum handle: @heromed

    Community feedback at this stage will help ensure the designer evolves into something that is truly useful for GUI-O users.

    posted in GUI-O Drag-and-Drop Designer (Early Development) - Feedback Wanted
  • RE: an experiment with AI

    @Bernard That is great! 🙂

    I also use AI for various tasks. It is incredibly useful, but in my opinion it is only a tool and should be treated as such.

    Kl3m3n

    posted in Share Your Projects
  • RE: User password

    @Bernard Hi!

    Currently, no, it is not possible.
    I will see if i can make a "toggle visibility" option for the next release.

    Kl3m3n

    posted in General Discussion

Member List