Skip to content

R36 Control Centre

southoz edited this page Apr 10, 2026 · 23 revisions

R36 LED & Config Service for dArkOS RE

image

Customisable Battery Warning LEDs + Full Hardware Detection for R36S / SoySauce / Clones

We are building a fully customisable LED service for the R36S device family on RK3326 DarkOS RE.
The core issue is that LED GPIOs differ across genuine R36S devices, SoySauce boards, and clones. These GPIOs also conflict with the working GPIO settings already defined in the DTB files.

Our solution ensures perfect synchronisation between the battery warning LED service (batt_led.service) and the DTB settings via:

  • Early-boot hardware detection in r36_config.sh
  • Central hardware database in /boot/dtb/r36_devices.ini (including speaker/headphone GPIOs for SoySauce)
  • Dynamic GPIO export/setup + DTB-safe LED control in userspace Python scripts

The entire service and R36 Control Centre are already installed in the latest southoz DarkOS RE image.


Table of Contents


Overview

This service solves the biggest pain point for RK3326 R36S-style handhelds on dArkOS RE:

Different mainboards use different GPIO pins for status LEDs (or PMIC control), and many DTBs define these GPIOs → causing conflicts or no LED control in userspace.

Goal: Support all R36 variants — genuine R36S (PMIC LEDs), SoySauce (Y3506), clones (G80C / G80CA / etc.) — without breaking DTB compatibility for screen / audio / other hardware.

The R36 Control Centre (R36 Control.sh) is now the single controller-friendly menu (launched from EmulationStation → OptionsR36 Control) that lets you change LED behaviour, gamma, audio, controls, video profiles, and time settings.

Screenshot: R36 Control Centre Main Menu
(Insert main menu screenshot here)


Supported Hardware Variants & GPIO/DTB Synchronization

r36_config.sh reads the exact hardware string from /proc/cpuinfo and maps it in /boot/dtb/r36_devices.ini.

Variant Devices Covered Key GPIO Settings (from r36_devices.ini) LED Script Example ALSA Path Control Scheme
r36s Genuine R36S, R36H, R36S Plus, etc. Default (DTB-managed) R36S_Green_30_Red.py SPK_HP default / no_function
soysauce Y3506 boards (V03/V04/V05) speaker_enable_gpio = 116
headphone_detect_gpio = 86
SoySauce_Blue_30_Pink_10_Red.py SPK_HP default
clone G80C, GR36, K3326 clones, etc. Default (DTB-managed) Clone_Blue_30_Purple_10_Red.py SPK_HP default
unknown Fallback None Clone_PMIC_Controlled.py SPK_HP default

SoySauce synchronisation is critical:
GPIO 116 (speaker enable) and GPIO 86 (headphone detect) are exported, given 666 permissions for the ark user, and initialised with reversed logic every boot — before batt_led.service starts. This prevents speaker mute conflicts and double-power-button issues while respecting DTB settings.


Features (v1.0)

  • Automatic hardware detection & LED script selection on first boot/hardware change
  • Safe override: LED control moved to Python scripts (no DTB GPIO conflict)
  • Gamma correction persistence (SoySauce often oversaturated, clones under-saturated)
  • ALSA Playback Path (SPK_HP vs SPK) + optional persistent boot volume
  • Control scheme selection (default vs no_function for R36H)
  • Video profile system (resolution-based tweaks from /usr/local/bin/r36_config/video/)
  • Speaker/headphone GPIO auto-setup for SoySauce
  • Controller-only R36 Control menu (joystick navigation)
  • Time Control submenu for Pokémon / RTC games (NTP toggle + calendar/timebox)
  • Logging to /boot/darkosre_device.log
  • Updated DTBs included (UHS removed from SoySauce for max compatibility)

How It Works

  1. Early boot (r36-config.servicer36_config.sh — runs before batt_led.service):
    • Reads Hardware string from /proc/cpuinfo
    • Looks up variant, gamma, ALSA path, control scheme, resolution, speaker/headphone GPIOs in r36_devices.ini
    • If no /etc/r36_config.ini or hardware changed → creates config + selects/copies matching LED script
    • Sets up SoySauce GPIOs (export, direction, permissions, initial state)
    • Applies gamma, ALSA path/volume, control scheme, video profile
  2. Battery warning (batt_led.service):
    • Runs the selected Python script (/usr/local/bin/batt_life_warning.py)
    • Monitors battery → controls LEDs via sysfs or exported GPIOs
  3. User changes via R36 Control Centre:
    • Overrides script, gamma, audio, controls, video, time
    • All persisted in /etc/r36_config.ini

Using the R36 Control Centre

Launch from EmulationStation → Options → R36 Control (or run sudo /usr/local/bin/R36 Control.sh).

Main Menu

Screenshot: Main Menu
(Insert screenshot here)

Options:

  1. Select Battery LED Warning Type
  2. Adjust Gamma Correction
  3. Audio Controls
  4. Utilities
  5. Time Control (Pokémon)
  6. Exit

1. Select Battery LED Warning Type

Scans /usr/local/bin/r36_config/batt_life_warning/ for scripts prefixed with your variant (R36S_, SoySauce_, Clone_).
Select one → service stops, new script is copied to /usr/local/bin/batt_life_warning.py, service restarts, and active_script is saved.

Screenshot: LED Selection
(Insert screenshot here)

2. Adjust Gamma Correction

Choose from 0.4–1.8 (0.1 steps).
Value is saved to config and written to /dev/shm/CURRENT_GAMMA.
Changes apply on next reboot.
Live preview tip: Hold R3 + D-Pad Left/Right (if your gamma tool supports runtime adjustment).

Screenshot: Gamma Menu
(Insert screenshot here)

3. Audio Controls

Submenu:

  • Select ALSA Playback Path
    • SPK_HP = Speaker + Headphone jack detection
    • SPK = Speaker only
      Automatically updates /usr/local/bin/ogage and restarts ogage.service.
  • Manage Boot Volume
    • Set fixed % (10–100 in 5% steps) → saved as alsa_volume and applied every boot
    • Clear → removes persistent volume (use normal volume controls)

Screenshot: Audio Submenu
(Insert screenshot here)

4. Utilities

  • View Current Config → shows full /etc/r36_config.ini
  • Delete Current Config → removes file (defaults restored on reboot)
  • Select Control Scheme
    • default = R36S style (Function button → menu)
    • no_function = R36H style (no Function button)
      Applies via r36_controls.sh + matching .ini files.
  • Select Video Profile
    Scans /usr/local/bin/r36_config/video/*.ini and applies resolution-specific tweaks.

Screenshot: Utilities Submenu
(Insert screenshot here)

5. Time Control (Pokémon / RTC Games)

Controller-only (joystick navigation):

  • Enable NTP
  • Disable NTP (stops + disables systemd-timesyncd)
  • Set system clock & date
    • Calendar dialog (date)
    • Timebox dialog (HH:MM:SS) — Left/Right moves fields, Up/Down changes digits
      Uses sudo date + hwclock -w

Screenshot: Time Control Menu
(Insert screenshot here)


Available LED Scripts

File Fully Charged 🔌 🔋 >30% 🔋 >10% <=10%
Clone_Blue_30_Purple_10_Red.py TBA 🔴 >30% 🔵 >10% Purple <=10% 🔴
Clone_Off_30_Purple_10_Red.py TBA 🔴 >30% Off >10% Purple <=10% 🔴
Clone_Off_10_Red.py TBA 🔴 Off Off <=10% 🔴
Clone_PMIC_Controlled.py TBA 🔴 PMIC PMIC PMIC
SoySauce_Blue_30_Pink_10_Red.py TBA 🔴 >30% 🔵 >10% Pink <=10% 🔴
SoySauce_Off_30_Pink_10_Red.py TBA 🔴 >30% Off >10% Pink <=10% 🔴
SoySauce_Off_10_Red.py TBA 🔴 Off Off <=10% 🔴
SoySauce_PMIC_Controlled.py TBA 🔴 PMIC PMIC PMIC
R36S_Green_30_Red.py TBA Orange >30% 🟢 >30% 🟢 <=30% 🔴
R36S_Green_20_Red.py TBA Orange >20% 🟢 >20% 🟢 <=20% 🔴
R36S_Green_10_Red.py TBA Orange >10% 🟢 >10% 🟢 <=10% 🔴
R36S_PMIC_Controlled.py TBA 🔴 PMIC Green/Blue PMIC PMIC

Important Notes & Warnings

  • Genuine R36S often use PMIC-controlled LEDs (Green/Blue) → limited userspace control. Scripts focus on Red warning.
  • SoySauce DTBs have UHS removed from SD card → better compatibility (no speed loss).
  • Audio init issues on some V12 clones → may need sleep/wake cycle (handled in ogage).
  • If LEDs don’t work → check DTB has no conflicting GPIO definitions for LED/charger/battery.
  • Unknown hardware → defaults to clone-like behaviour + full script list.
  • Logs: cat /boot/darkosre_device.log

DTB Status Table

DTB File Status
G80CA-MB V1.2-20250422 Panel 8 Completed, GPIO Pin 0 Blue, GPIO Pin 17 Red
R36S-V12 2023-08-18 Variant 3 Panel A Completed, GPIO Pin 0 Blue, GPIO Pin 17 Red
Y3506_V05_20251215 2601 Completed, GPIO Pin 0 Blue, GPIO Pin 1 Red
R36S-V21 2024-12-18 Completed, GPIO Pin 77 Red, PMIC Controlled Green

Troubleshooting

Issue Likely Cause Fix
LED wrong colour / not working Wrong script selected R36 Control → 1. Select Battery LED Warning Type
Speaker always muted SoySauce GPIO not synced Check log for GPIO 116/86 setup
Audio path conflicts ALSA vs DTB mismatch Audio Controls submenu
Controls broken on R36H Default scheme used Utilities → Select Control Scheme → no_function
Time drifts (Pokémon) NTP active Time Control → Disable NTP
Gamma not applied Needs reboot Reboot after change

Home

Guides

Help

Arcade Systems

Console Systems

Handheld Systems

Ports and Recompilations

Advanced

In development

The guides below are for ArkOS-G80CA; once they are above this marker, they are relevant.

Clone this wiki locally