Metadata-Version: 2.1
Name: quarky-intellio
Version: 0.1.1
Summary: Official Intellio Python SDK
Author: Intellio Team
Keywords: intellio,quarky,robotics,camera,ai
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: opencv-python
Requires-Dist: numpy
Requires-Dist: bleak

# Intellio Python Module

**Agilo Research Pvt Ltd (STEMpedia)**

**Connect Intellio hardware to Python to build robotics, sensor, computer-vision, and AI projects.**

The Intellio Python module exposes the `QuarkyIntellio` class. It connects to an Intellio board using a Bluetooth Low Energy (BLE) Wi-Fi setup flow, receives camera images over Wi-Fi, and provides Python methods for hardware controls such as LEDs, audio, motors, servos, and supported external sensors.

It can be combined with **OpenCV**, **MediaPipe**, and **NumPy** to build hand-tracking, gesture-recognition, eye-tracking, and other interactive projects on a computer.

> **Documentation scope:** This README is based on the `Intellio/camera.py`, `ble.py`, `ble_gui.py`, and `stream.py` source versions shared during development. It documents the methods **implemented in that source**, not a certification that every method has been tested on every firmware revision. In particular, Lightning RGB uses a special send-only workaround on the tested device; see [Lightning compatibility note](#lightning-compatibility-note).

## Contents

- [Features](#features)
- [Requirements](#requirements)
- [Project structure](#project-structure)
- [Set up your development environment](#set-up-your-development-environment)
  - [Windows](#windows)
  - [Linux](#linux)
  - [macOS](#macos)
  - [Conda](#conda)
  - [VS Code, PyCharm, and WSL](#vs-code-pycharm-and-wsl)
- [Install dependencies](#install-dependencies)
- [Connect to Intellio](#connect-to-intellio)
- [Camera quick start](#camera-quick-start)
- [Create a hand-tracking project](#create-a-hand-tracking-project)
- [Complete API reference](#complete-api-reference)
- [Project examples](#project-examples)
- [Lightning compatibility note](#lightning-compatibility-note)
- [Troubleshooting](#troubleshooting)
- [Development and release checklist](#development-and-release-checklist)
- [Terms of Use](#terms-of-use)

## Features

- BLE-assisted Wi-Fi configuration and automatic Intellio IP discovery.
- Live JPEG camera frames delivered to Python as OpenCV-compatible NumPy arrays.
- Hardware commands for onboard LED, motors, servos, speaker and audio, camera settings, and supported external sensors.
- Lightning extension commands for RGB strips and an 8x8 LED matrix.
- Integration with Python computer-vision libraries without running hand-tracking inference on the microcontroller.

## Requirements

**Hardware**

- Intellio board with compatible firmware.
- A Windows, Linux, or macOS computer with Bluetooth Low Energy and Wi-Fi.
- Intellio and the laptop connected to the appropriate network after BLE setup.
- Optional hardware for examples: ultrasonic/IR sensor, RGB LED matrix, OLED, supported color/motion sensors, or motors.

**Software**

- Python **3.9 or newer** for the SDK. Use **Python 3.12** for the vision examples, which depend on the legacy MediaPipe Solutions API.
- A Python virtual environment or Conda environment.
- `tkinter` and a desktop session for the BLE setup window. The camera and vision demos also open graphical windows.
- `bleak`, `opencv-python`, and `numpy` are installed with the SDK. The vision examples also require `mediapipe`.

The pip distribution is named `quarky-intellio`. Python code imports it as `Intellio`.

## Project structure

The repository contains the SDK and example projects.

```text
Intellio_pip/
|-- Intellio/
|   |-- __init__.py
|   |-- camera.py         # QuarkyIntellio public hardware API
|   |-- ble.py            # BLE scanning and GATT communication
|   |-- ble_gui.py        # Connection manager
|   `-- stream.py         # JPEG-over-UDP camera receiver
|-- Examples/
|   |-- air_harp.py
|   |-- eye_gaze_and_drowsiness_detection.py
|   |-- hand_gesture_led_matrix.py
|   |-- air_writing.py
|   |-- finger_heart_led_matrix.py
|   |-- harp_notes/
|   `-- tests/
|-- pyproject.toml
`-- README.md
```

Install the SDK into your environment before running the example scripts. Keep the capitalization in `from Intellio import QuarkyIntellio`.

## Set up your development environment

Open a terminal in the repository root, where `pyproject.toml` is located. Choose one environment below, then continue to [Install dependencies](#install-dependencies).

### Windows

Install Python 3.12 with Tcl/Tk support. In PowerShell, create and activate the environment. [Python on Windows](https://docs.python.org/3.12/using/windows.html)

```powershell
py -3.12 -m venv air-env
.\air-env\Scripts\Activate.ps1
```

In Command Prompt, activate with `air-env\Scripts\activate.bat`. In Git Bash, use `source air-env/Scripts/activate`. If PowerShell blocks script activation, use Command Prompt or run `.\air-env\Scripts\python.exe` directly in place of `python` in the install and run commands below. [Python virtual environments](https://docs.python.org/3.12/library/venv.html)

### Linux

On **Ubuntu or Debian**, install Python, Tk, and the Bluetooth and networking tools. The commands below use the distribution's default Python. Check `python3 --version`, and use the Conda setup below if you need Python 3.12 for the vision examples. [Ubuntu Python packages](https://packages.ubuntu.com/noble/python3-tk) · [Ubuntu BlueZ package](https://packages.ubuntu.com/noble/bluez)

```bash
sudo apt update
sudo apt install python3 python3-venv python3-tk bluez iproute2 libgl1
python3 -m venv air-env
source air-env/bin/activate
```

On **Fedora**, install the equivalent system packages and create the environment. [Fedora Tkinter package](https://packages.fedoraproject.org/pkgs/python3.14/python3-tkinter/)

```bash
sudo dnf install python3 python3-pip python3-tkinter bluez iproute libglvnd-glx
python3 -m venv air-env
source air-env/bin/activate
```

For BLE setup, enable Bluetooth and check that `bluetoothctl show` lists an adapter. On a systemd desktop, start the Bluetooth service with `sudo systemctl start bluetooth` if it is stopped. Bleak uses BlueZ on Linux. [Bleak Linux backend](https://bleak.readthedocs.io/en/stable/backends/linux.html)

### macOS

Install Python 3.12 from python.org, then create a virtual environment from Terminal. If macOS asks for Bluetooth access, allow it for the app running Python. If access was denied, check **System Settings > Privacy & Security > Bluetooth**. [Python on macOS](https://docs.python.org/3.12/using/mac.html) · [Bleak macOS troubleshooting](https://bleak.readthedocs.io/en/stable/troubleshooting.html)

```bash
python3.12 -m venv air-env
source air-env/bin/activate
```

### Conda

From a shell initialized for Conda, create an environment with Python 3.12, pip, and Tk. On Linux, complete the system Bluetooth setup above before using the board. [Conda environment creation](https://docs.conda.io/projects/conda/en/stable/commands/create.html)

```bash
conda create -n air-env python=3.12 pip tk
conda activate air-env
```

### VS Code, PyCharm, and WSL

- **VS Code.** Open the repository, install the Python extension, and run **Python: Select Interpreter**. Choose the environment you created, then open a new integrated terminal. [VS Code Python environments](https://code.visualstudio.com/docs/python/environments)
- **PyCharm.** Open the repository and select your existing environment in the **Python Interpreter** settings. Set the run configuration's working directory to the repository root. [PyCharm interpreter setup](https://www.jetbrains.com/help/pycharm/configuring-python-interpreter.html)
- **WSL.** Use the Linux instructions for package development. For board tests, use native Windows unless WSL has access to a Bluetooth adapter, a graphical desktop, and incoming UDP traffic from the board. [WSL USB devices](https://learn.microsoft.com/en-us/windows/wsl/connect-usb) · [WSL networking](https://learn.microsoft.com/en-us/windows/wsl/networking)

## Install dependencies

With the environment active, confirm which Python you are using. Run `python -m tkinter` to verify that a small Tk window opens, then close it.

```bash
python --version
python -c "import sys; print(sys.executable)"
python -m tkinter
```

For SDK development, install from the repository in editable mode.

```bash
python -m pip install -e .
```

To install this release from PyPI, run `python -m pip install quarky-intellio==0.1.1`. If you downloaded the wheel, run `python -m pip install quarky_intellio-0.1.1-py3-none-any.whl` from the download directory.

For the [vision examples](#project-examples), install the SDK and the example dependencies together in a fresh Python 3.12 environment. This MediaPipe release provides Python 3.12 wheels for Windows x86-64, Linux x86-64 with glibc 2.28 or newer, and macOS 11 or newer. Check the release files if your platform differs. [MediaPipe 0.10.21 release files](https://pypi.org/project/mediapipe/0.10.21/#files)

```bash
python -m pip install -e . "mediapipe==0.10.21"
python -c "import cv2, mediapipe as mp; print(cv2.__version__); print(mp.solutions.hands.Hands)"
```

Verify the SDK and its dependencies. Run the import from outside the repository if you want to confirm it resolves through your environment.

```bash
python -m pip check
python -c "from Intellio import QuarkyIntellio; print(QuarkyIntellio.__name__)"
```

## Connect to Intellio

```python
from Intellio import QuarkyIntellio

intellio = QuarkyIntellio()
intellio.connect()
print("Intellio IP:", intellio.ip)
```

1. Power on Intellio and enable Bluetooth and Wi-Fi on your laptop.
2. Run the Python program. `connect()` opens the Intellio BLE/Wi-Fi manager.
3. Scan for Intellio, select the board, and connect over Bluetooth.
4. Supply Wi-Fi credentials and choose **Station Mode** (through a router) or the compatible AP setup for your firmware.
5. Wait for the program to print a discovered Intellio IP address.
6. Close the connection-manager window to allow the script to continue. The existing implementation starts the camera-stream receiver automatically when the IP is discovered.

`connect()` **blocks while the Tkinter window is open**. You can also instantiate with a known IP, `QuarkyIntellio(ip="192.168.x.x")`, but that bypasses BLE discovery and does **not** automatically start the camera stream; call `startstream()` explicitly when using that approach.

### Communication used by the supplied implementation

| Channel | Purpose | Configuration in source |
|---|---|---|
| BLE | Device discovery and Wi-Fi provisioning | `ble.py` and `ble_gui.py` |
| UDP `5005` on PC | Incoming JPEG camera frames | `stream.py` |
| UDP `5006` on device | Outgoing PC hardware-control commands | `camera.py` |
| UDP `5007` on PC | Expected hardware-control replies | `camera.py` socket binding |

Port numbers describe the shared Python implementation. The actual board firmware and network must support the same transport for hardware commands to work.

## Camera quick start

Save as `camera_test.py` in the repository root:

```python
import time
import cv2
from Intellio import QuarkyIntellio

intellio = QuarkyIntellio()
intellio.connect()

try:
    while True:
        frame = intellio.get_frame()
        if frame is None:
            time.sleep(0.02)
            continue

        cv2.imshow("Intellio Camera", frame)
        if cv2.waitKey(1) & 0xFF == ord("q"):
            break
finally:
    intellio.stopstream()
    cv2.destroyAllWindows()
```

Run:

```bash
python camera_test.py
```

`get_frame()` returns the **most recent decoded BGR image** (a NumPy array compatible with OpenCV), or `None` until the first frame arrives. The `CameraStream` receiver runs in a separate thread and caches the latest frame.

## Create a hand-tracking project

MediaPipe analyzes each frame on the laptop. The camera comes from Intellio; OpenCV displays frames; MediaPipe returns up to 21 landmarks per hand for the `Hands` model used in these examples.

1. Activate `air-env` and install the packages shown above.
2. Create a file such as `hand_tracking.py` in the repository root.
3. Import `QuarkyIntellio`, OpenCV, and MediaPipe.
4. Connect Intellio and read frames via `get_frame()`.
5. Convert BGR to RGB for MediaPipe, then process landmarks.
6. Draw landmarks or classify gestures, and use Intellio hardware methods when the recognized gesture **changes**.

### Starter hand-tracking program

```python
import time
import cv2
import mediapipe as mp
from Intellio import QuarkyIntellio

mp_hands = mp.solutions.hands
mp_draw = mp.solutions.drawing_utils

intellio = QuarkyIntellio()
intellio.connect()

try:
    with mp_hands.Hands(
        static_image_mode=False,
        max_num_hands=2,
        model_complexity=0,
        min_detection_confidence=0.6,
        min_tracking_confidence=0.6,
    ) as hands:
        while True:
            frame = intellio.get_frame()
            if frame is None:
                time.sleep(0.02)
                continue

            frame = cv2.flip(frame, 1)  # Mirror preview
            rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
            results = hands.process(rgb)

            if results.multi_hand_landmarks:
                for hand in results.multi_hand_landmarks:
                    mp_draw.draw_landmarks(
                        frame, hand, mp_hands.HAND_CONNECTIONS
                    )
                    # Example: hand.landmark[8] is index-finger tip.
                    tip = hand.landmark[8]
                    x = int(tip.x * frame.shape[1])
                    y = int(tip.y * frame.shape[0])
                    cv2.circle(frame, (x, y), 8, (0, 255, 0), -1)

            cv2.imshow("Intellio Hand Tracking", frame)
            if cv2.waitKey(1) & 0xFF == ord("q"):
                break
finally:
    intellio.stopstream()
    cv2.destroyAllWindows()
```

Run:

```bash
python hand_tracking.py
```

**For smooth projects:** Use the latest frame, reduce inference resolution if necessary, debounce gestures (for example, hold a gesture for 0.5-0.7 seconds), and avoid sending a hardware command on every video frame. A speaker command may block until completion: send it from a **single serialized hardware-command worker** if you also need fluid video. Do not let multiple threads call the same UDP send/receive socket concurrently without synchronization.

## Complete API reference

All methods below are on an instance of `QuarkyIntellio`. Names and argument order match the shared `camera.py`; Python method names are case-sensitive. The class includes **54 public methods** in the supplied version, plus internal helpers documented at the end.

### Connection and video

| Method | Description / parameters |
|---|---|
| `QuarkyIntellio(ip=None)` | Create the client. Optional `ip` skips IP discovery but not the need for compatible Wi-Fi connectivity. |
| `connect()` | Open BLE/Wi-Fi manager; wait for window to close. IP notification also starts the stream in this source version. |
| `startstream()` | Start receiving camera frames on UDP 5005. |
| `get_frame()` | Return latest BGR OpenCV frame, or `None` while unavailable. |
| `stopstream()` | Stop the receiver and release its UDP port before returning. |

### Robot motors and servos

| Method | Description / parameters |
|---|---|
| `runrobot(direction, speed)` | Robot direction: `1` forward, `2` backward, `3` left, `4` right, `5` stop; speed `0-100` as documented in source. |
| `runbothmotors(left_speed, right_speed)` | Drive left/right motors at separate speed values. |
| `stoprobot()` | Stop robot motors. |
| `runmotor(motor, direction, speed)` | Motor `'L'` or `'R'`; direction `1` forward, `2` backward, `3` lock, `4` stop. |
| `stopmotor(motor)` | Stop one motor (`'L'` or `'R'`). |
| `setservo(pin, angle)` | Logical servo pin: `0=S1`, `1=A2`, `2=A1`; angle `0-180` degrees. |
| `servomoveintime(pin, angle, seconds)` | Move a servo to an angle over the requested duration. |

> Motor-control methods are documented from the Python implementation. Some mappings may require alignment with the specific firmware and expansion-board configuration; do not assume all have been hardware-verified.

### Built-in RGB LED

| Method | Description / parameters |
|---|---|
| `setled(r, g, b, brightness=30)` | Set Intellio's built-in RGB LED, with requested brightness. |
| `turnoffled()` | Turn off the built-in LED. |

### Lightning RGB strips and 8x8 LED matrix

| Method | Description / parameters |
|---|---|
| `initialisergb(strip, numled, pin)` | Initialize strip index (`1` is typical), number of LEDs (`64` for an 8x8 matrix), and firmware-expected pin identifier. Command `73`. |
| `setrgbpixel(strip, pixel, r, g, b)` | Set a **zero-based pixel index**; send `showrgb()` to apply it. Command `74`. |
| `showrgb(strip)` | Push pending pixel colors to the physical LEDs. Command `75`. |
| `showpattern1(pattern, strip, r, g, b, delay_ms)` | `1` Color Wipe, `2` Theater Chase. Delay in milliseconds. Command `76`. |
| `showpattern2(pattern, strip, delay_ms)` | `1` Rainbow, `2` Rainbow Cycle, `3` Theater Chase Rainbow. Delay in milliseconds. Command `77`. |
| `clearrgb(strip)` | Clear the strip/matrix. Command `78`. |

**Example (tested logical A1 setting):**

```python
# After connecting Intellio and verifying the matrix power/wiring:
intellio.initialisergb(1, 64, 2)   # strip 1, 64 LEDs, A1 argument used in test
intellio.setrgbpixel(1, 0, 10, 0, 0)
intellio.showrgb(1)
intellio.clearrgb(1)
```

The A1 `2` value is the one used in the working development test. **Do not treat `2` as a universally valid ESP32 GPIO number.** The actual output mapping depends on the board and firmware. Check matrix voltage/current requirements; many addressable 8x8 RGB matrices need a suitable **5 V supply** and a shared ground. Avoid powering 64 LEDs from an unverified 3.3 V GPIO rail.

See [Lightning compatibility note](#lightning-compatibility-note) for the **send-only** behavior used with the tested board.

### Ultrasonic and digital/analog sensors

| Method | Description / parameters |
|---|---|
| `setultrasonicpins(trig, echo)` | Assign distinct ports from `'A1'`, `'A2'`, `'S1'` to trigger and echo. Validates the names. |
| `getultrasonic()` | Read distance as a float from firmware. |
| `readdigital(pin)` | Read digital state `0` or `1`; uses GET action. |
| `prepare_ir_input(pin="A1")` | Prepare `A1`/`A2` for IR/digital input by switching PWM/analog state as required by this firmware. |
| `readanalog(pin)` | Read an analog value as float or `None`; source documents `'A1'`/`'A2'`. |
| `readpushbutton(button)` | Read left (`1`) or right (`2`) pushbutton as float or `None`. |

The ultrasonic and IR input paths were tested during development. Other sensor methods are included because they exist in `camera.py`; confirm action-code compatibility before release.

### Color and proximity sensor (APDS9960)

| Method | Description / parameters |
|---|---|
| `initcolorsensor()` | Initialize the attached color/proximity sensor; returns `True` only on exact `"Done"`. |
| `getlightlevel(channel=0)` | `0` clear, `1` red, `2` green, `3` blue channel; numeric result or `None`. |
| `iscolordetected(color)` | Check a firmware-defined color index; returns boolean. |
| `getproximity()` | Proximity value, documented `0-255`, or `None`. |
| `recordcolorprofile(slot)` | Save a color profile to slot `0-7`; returns boolean in this implementation. |
| `deleteallcolorprofiles()` | Clear recorded profiles; returns raw firmware response. |
| `iscolorprofiledetected(slot)` | Check whether a saved profile is detected; returns boolean. |
| `isgesturedetected(gesture)` | Sensor gesture indices: `0` none, `1` up, `2` down, `3` left, `4` right. Not the same as MediaPipe hand tracking. |

### Motion sensor (MPU6050)

| Method | Description / parameters |
|---|---|
| `initmotionsensor()` | Initialize supported motion sensor; returns boolean on exact `"Done"`. |
| `getacceleration(axis)` | Read acceleration, axis `0=X`, `1=Y`, `2=Z`; float or `None`. |
| `getgyroscope(axis)` | Read gyroscope value for axis `0=X`, `1=Y`, `2=Z`; float or `None`. |
| `gettiltangle(axis)` | Read tilt-angle value for axis `0=X`, `1=Y`, `2=Z`; float or `None`. |
| `gettemperature()` | Read sensor temperature in Celsius, or `None`. |

### OLED display

| Method | Description / parameters |
|---|---|
| `initoled()` | Request OLED initialization; returns boolean on exact `"Done"`. |
| `clearoled()` | Clear OLED display; returns boolean. |
| `displaytext(text)` | Display text; returns boolean. |
| `scrolltext(text)` | Scroll supplied text; returns boolean. |
| `displayemotion(emotion)` | Display a firmware-defined emotion index; returns boolean. |

**Status note:** OLED initialization was **not confirmed working** in the shared firmware. The device-side `advancesensorhandler()` section previously contained `_ensure_oled` without calling it, so a `Done` response does not prove that the display initialized. This cannot be fixed solely by documenting or calling `initoled()` from the PC. Avoid advertising OLED as tested until verified on the release firmware.

### Speaker and audio

| Method | Description / parameters |
|---|---|
| `playsound(filename, volume=80)` | Play a sound by filename available to the device/firmware. |
| `playsounduntildone(filename, volume=80)` | Play and wait for completion response; returns boolean based on `"done"`. |
| `stopsound()` | Stop currently playing device sound. |
| `setvolume(volume)` | Set speaker volume, documented `0-100` by source. |
| `playtone(frequency, duration_ms)` | Play a tone of the specified frequency (Hz) for the specified duration (milliseconds); validates positive values and waits for response. |

Example:

```python
intellio.playtone(440, 200)  # 440 Hz for 200 ms
```

`playtone()` generates a tone, **not synthesized speech**. A file passed to `playsound()` must be accessible to the Intellio firmware; an arbitrary filename on the laptop is not automatically transferred to the device.

### Camera settings

| Method | Description / parameters |
|---|---|
| `setbrightness(value)` | Set camera brightness. Firmware defines the accepted range. |
| `setcontrast(value)` | Set contrast. Firmware defines the accepted range. |
| `setsaturation(value)` | Set saturation. Firmware defines the accepted range. |
| `setquality(value)` | Set camera JPEG quality setting. Firmware defines the accepted range. |
| `setvflip(value)` | Enable/disable vertical flip (commonly `0`/`1`). |
| `sethmirror(value)` | Enable/disable horizontal mirroring (commonly `0`/`1`). |

### Internal methods (not part of the recommended public API)

| Method | Role |
|---|---|
| `_send(*args, action=2, timeout=None)` | Build a `frame/{action}/...` command, send via UDP `5006`, and await response on the client's UDP socket. |
| `_rgb_request(command, *args)` | Lightning transport helper; special handling described below. |
| `_send_sensor(*args)` | Wrap hardware command `215` for advanced sensors. |
| `_send_setting(*args)` | Send `setting/...` commands to the device. |
| `_set_ip(ip)` | Validate/set the discovered IP; starts the camera receiver on discovery. |

**Other implementation components:**

- `BLEManager` (`ble.py`): `scan()`, `connect(address)`, `disconnect()`, `send(data)`, `start_notify(callback)`, and `is_connected`. These are asynchronous BLE utilities used by the connection manager.
- `BLEApp` (`ble_gui.py`): Tkinter UI for scanning, connecting, provisioning Wi-Fi, and forwarding an IP notification to `QuarkyIntellio`.
- `CameraStream` (`stream.py`): `start()`, `stop()`, and `get_frame()`; background `_receiver()` assembles JPEG data packets into decoded OpenCV frames.

## Project examples

Run these commands from the repository root or the unpacked source distribution after installing the [vision example dependencies](#install-dependencies). Download the source archive from the [PyPI release files](https://pypi.org/project/quarky-intellio/0.1.1/#files). Script paths are case-sensitive on Linux.

| Example | Script | Run command |
|---|---|---|
| **Air Harp with Musical Samples** | [air_harp.py](Examples/air_harp.py) | `python Examples/air_harp.py` |
| **Eye Gaze and Drowsiness Detection** | [eye_gaze_and_drowsiness_detection.py](Examples/eye_gaze_and_drowsiness_detection.py) | `python Examples/eye_gaze_and_drowsiness_detection.py` |
| **Hand Gesture LED Matrix** | [hand_gesture_led_matrix.py](Examples/hand_gesture_led_matrix.py) | `python Examples/hand_gesture_led_matrix.py` |
| **Air Writing** | [air_writing.py](Examples/air_writing.py) | `python Examples/air_writing.py` |
| **Finger Heart LED Matrix** | [finger_heart_led_matrix.py](Examples/finger_heart_led_matrix.py) | `python Examples/finger_heart_led_matrix.py` |

For the Air Harp's default board playback, copy the samples from [Examples/harp_notes/](Examples/harp_notes/) to the board's audio storage and set `INTELLIO_SAMPLE_PREFIX` to match its directory. For computer playback, set `AUDIO_MODE = "computer_samples"` and install `pygame` with `python -m pip install pygame`.

The Drowsiness Detection example uses Windows speech or the `espeak` command for computer voice alerts. If those are unavailable, set `ALERT_MODE = "intellio_beep_only"` to use the board speaker.

The examples are intended for education and prototyping. Use them in accordance with the [Terms of Use](#terms-of-use).

### Gesture LED mapping example

| Recognized gesture | Action |
|---|---|
| Closed fist / 0 extended non-thumb fingers | LEDs off |
| 1 extended finger | Red |
| 2 extended fingers | Green |
| 3 extended fingers | Blue |
| 4 extended fingers | Purple |

A typical LED action fills the matrix with a single command:

```python
# Run only when the stable gesture changes.
intellio.showpattern1(1, 1, 15, 0, 0, 0)  # red Color Wipe, 0 ms delay
```

## Lightning compatibility note

**The hardware-tested development setup required a send-only Lightning request.** The earlier uploaded `camera.py` source used the regular request-response helper and raised `WinError 10054` during RGB initialization. In a later local test, replacing `_rgb_request()` with a send-only command sender allowed the LED matrix to work. Ultrasonic and IR should continue using the original `_send()` request-response path.

If your checkout still contains the acknowledgment-based `_rgb_request`, the tested workaround was to replace **only** that helper inside the `QuarkyIntellio` class:

```python
def _rgb_request(self, command, *args):
    """Send Lightning command without waiting for a UDP acknowledgment."""
    if not self.ip:
        raise RuntimeError("Intellio is not connected")

    parts = "/".join(str(x) for x in (command, *args))
    packet = ("frame/2/" + parts).encode("utf-8")

    with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as sock:
        sock.sendto(packet, (self.ip, CONTROL_PORT))

    return "SENT_UNCONFIRMED"
```

This snippet assumes `socket` and `CONTROL_PORT` are already defined at the top of `camera.py`, as in the shared implementation. **It only confirms that the PC sent the packet; it does not prove the device received or executed it.** The separate temporary socket also means firmware responses are not collected. This is a **device-/firmware-specific compatibility workaround**, not a general production guarantee. Do not modify the working `_send()` method or use this workaround indiscriminately for other sensors. A future release should ideally provide an explicit documented acknowledgment/non-acknowledgment mode and test its behavior against supported firmware.

Avoid calling long-running Rainbow patterns continuously in a live camera loop: pattern execution may block firmware control, and repeated calls can cause sluggish video or lost device commands. Prefer short Color Wipe updates triggered only by **confirmed gesture changes**.

## Troubleshooting

| Symptom | What to check |
|---|---|
| `ModuleNotFoundError: No module named 'Intellio'` | Install the SDK in the same environment that runs your script and use the exact capitalization `Intellio`. |
| `No module named 'mediapipe'`, `cv2`, or `bleak` | Activate the intended `air-env`, then install the missing package with `python -m pip`. |
| `mp.solutions` is unavailable | Verify the MediaPipe version; the example scripts use `mediapipe==0.10.21`. |
| `No module named 'tkinter'` or the Tk window cannot open | Run `python -m tkinter` and check the Tk installation and desktop session for your platform. |
| Linux cannot find a Bluetooth adapter | Check `bluetoothctl show`, the BlueZ service, and Bluetooth access in the environment running Python. |
| Connection manager opens but no IP appears | Check BLE connection, Wi-Fi credentials, compatible Station/AP mode, laptop network, and notifications. |
| `get_frame()` returns `None` | Wait for camera stream, check network and UDP `5005`, and ensure only one program owns the receiver port. |
| `[WinError 10054]` during hardware command | Check the board's UDP control service, correct device IP/port, and firmware; the camera stream can work independently of hardware commands. |
| Ultrasonic/IR works but Lightning errors | Check whether the repo uses the tested send-only `_rgb_request()`; leave general `_send()` unchanged. |
| Lightning command prints `SENT_UNCONFIRMED` but nothing lights | Confirm firmware/device receives command, strip initialization, pin mapping, LED type, power supply, data connection, and shared ground. |
| Rainbow animation appears stuck | Animation can be long or blocking; use shorter effects and avoid repeated requests. |
| OLED reports `False` | Check board firmware's OLED initialization implementation and hardware wiring; a PC-only change may not resolve it. |
| Video freezes while playing audio | Avoid blocking speaker commands on the frame-processing thread; serialize device commands in a worker. |
| `Address already in use` on UDP `5005`/`5007` | Close duplicate Python scripts or other processes holding those ports. |

### Debug from the correct environment

```bash
python -c "import sys; print(sys.executable)"
python -m pip list
python camera_test.py
```

For release issues, capture the exact method call, terminal traceback, Python and dependency versions, firmware revision, and whether camera, ultrasonic, and IR commands still work on the same session. Do not share Wi-Fi passwords, BLE secrets, or sensitive network details in public issues.

## Development and release checklist

- [ ] Verify environment activation, SDK import, and the Tk window on Windows, Linux, and macOS.
- [ ] Confirm the README's file names match the published repository contents.
- [ ] Include package metadata and dependency declarations if publishing to PyPI.
- [ ] Test BLE Station/AP setup and camera stream end to end.
- [ ] Re-test ultrasonic and IR methods after any transport change.
- [ ] Test Lightning one-pixel color, matrix clear, and simple Color Wipe with the target firmware; label send-only behavior explicitly.
- [ ] Test speaker, motor/servo, and OLED functions before claiming release support.
- [ ] Validate device power and wiring for external accessories.
- [ ] Add firmware compatibility matrix and accurate product support contacts/links when available.

## Terms of Use

These conditions apply to use of the Intellio Python SDK and its example projects.

- Use the SDK for lawful purposes. Connect only to boards and networks you own or have permission to use.
- Follow the hardware instructions and test scripts in a controlled environment before enabling motors, servos, or other attachments. Do not rely on the SDK or example projects for safety-critical decisions or emergency alerts.
- Respect the privacy of people within the camera's view. Obtain any required permissions before recording, storing, or sharing images, video, or biometric data.
- Follow any licenses supplied with the SDK, third-party libraries, and example assets.

For Agilo Research Pvt Ltd's published terms and privacy information, see the [STEMpedia Terms and Conditions](https://thestempedia.com/terms-and-conditions/) and [Privacy Policy](https://thestempedia.com/privacy-policy/).
