RemoteWebViewClient icon indicating copy to clipboard operation
RemoteWebViewClient copied to clipboard

Remoteview doesnt respect display rotation

Open Samurai1201 opened this issue 1 year ago • 20 comments

Even when settings my display config to with rotation: 180, the webview always remains in the same rotation.

Samurai1201 avatar Oct 18 '25 07:10 Samurai1201

This is interesting. I'd need to understand who should do the rotation (I thought the driver should do it).

strange-v avatar Oct 18 '25 08:10 strange-v

For context, could you share which device you’re using?

strange-v avatar Oct 18 '25 08:10 strange-v

Even when settings my display config to with rotation: 180, the webview always remains in the same rotation.

Did you try it with

transform:
      mirror_x: true

Rotation may not work anymore...

steigerbalett avatar Oct 18 '25 10:10 steigerbalett

Im using a guition jc8012p4a1 board. Its a somewhat weird configuration with an external component for the display driver. But lvgl respects the display orientation, thats why I thought it could be a problem on the remoteview side

Samurai1201 avatar Oct 18 '25 14:10 Samurai1201

I've just tested with Gution ESP32-4848s040 (st7701s display driver), it works fine.

Image

I might consider software rotation, but it definitely won’t be added anytime soon.

strange-v avatar Oct 18 '25 19:10 strange-v

Same problem with ESP32-8048S043.

I can't rotate the screen with rotation in esphome.

Transform is not compatible with rpi_dpi_rgb.

henriquevianasilva avatar Oct 29 '25 22:10 henriquevianasilva

rpi_dpi_rgb is now redundant and replaced by mipi_rgb.

At the same time, I do not have much experience with mipi_rgb. For example, if I try using it with GUITION-4848S040, the screen is 180° rotated, and to make it correct, I'd need to set

transform:
  mirror_x: true
  mirror_y: true

But it reports that mirror_y is not supported by the hardware, which is strange, as st7701s supports both.

The second issue is that the image is in some way not clear/pixelized at the edges...

strange-v avatar Nov 01 '25 08:11 strange-v

@strange-v no rotation with mini_rbg and transform.

esphome:
  name: esp32-display43
  friendly_name: esp32 display43
  platformio_options:
    build_flags: "-DBOARD_HAS_PSRAM"
    board_build.esp-idf.memory_type: qio_opi
    board_build.flash_mode: dio
    board_upload.maximum_ram_size: 524288
  on_boot:
    priority: -100
    then:
      - script.execute: backlight_timer


esp32:
  board: esp32-s3-devkitc-1
  variant: esp32s3
  flash_size: 16MB
  framework:
    type: esp-idf
    # Required to achieve sufficient PSRAM bandwidth
    sdkconfig_options:
      COMPILER_OPTIMIZATION_SIZE: y
      CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240: y
      CONFIG_ESP32S3_DATA_CACHE_64KB: y
      CONFIG_ESP32S3_DATA_CACHE_LINE_64B: y
      CONFIG_SPIRAM_FETCH_INSTRUCTIONS: y
      CONFIG_SPIRAM_RODATA: y
      CONFIG_ESPTOOLPY_FLASHSIZE_16MB: y # fix warning about 2mb found
    components:
      - name: "espressif/esp_websocket_client"
        ref: 1.5.0
      - name: "espressif/esp-dsp"
        ref: 1.7.0
      - name: "bitbank2/jpegdec"
        source: https://github.com/strange-v/jpegdec-esphome



external_components:
  - source: github://strange-v/RemoteWebViewClient@main
    refresh: 0s
    components: [ remote_webview ]

logger:
  hardware_uart: UART0

# Enable Home Assistant API
api:
  encryption:
    key: "XXXXXXXXX"

ota:
  - platform: esphome
    password: "XXXXXXXXX"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32-Display43 Fallback Hotspot"
    password: "XXXXXXXXX"

captive_portal:

psram:
  mode: octal
  speed: 80MHz

i2c:
  - sda: 19
    scl: 20
    scan: true

output:
  - id: gpio_backlight_pwm
    platform: ledc
    pin: 2
    frequency: 1220

light:
  - id: backlight
    name: Backlight
    platform: monochromatic
    output: gpio_backlight_pwm
    restore_mode: ALWAYS_ON


display:

  - platform: mipi_rgb
    model: RPI
    id: main_display
    update_interval: never
    auto_clear_enabled: false
    color_order: RGB
    dimensions:
      width: 800
      height: 480
    de_pin: 40
    hsync_pin: 39
    vsync_pin: 41
    pclk_pin: 42
    pclk_inverted: True
    pclk_frequency: 14MHz # unsure about this
    hsync_front_porch: 8
    hsync_pulse_width: 4
    hsync_back_porch: 8
    vsync_front_porch: 8
    vsync_pulse_width: 4
    vsync_back_porch: 8
    data_pins:
      red: [45, 48, 47, 21, 14]
      green: [5, 6, 7, 15, 16, 4]
      blue: [8, 3, 46, 9, 1]
    transform:
      mirror_x: true
      mirror_y: true

touchscreen:
  - id: main_touchscreen
    platform: gt911
    address: 0x5D
    update_interval: 16ms
    transform:
      swap_xy: False
      mirror_y: False
    # reset_pin: 38
    # on_touch:
    #   - lambda: |-
    #         ESP_LOGI("cal", "x=%d, y=%d, x_raw=%d, y_raw=%0d",
    #           touch.x,
    #           touch.y,
    #           touch.x_raw,
    #           touch.y_raw
    #         );
    on_touch:
      - script.stop: backlight_timer
      - script.execute: backlight_timer
binary_sensor:
  - platform: status
    name: Status

sensor:
  - id: wifi_signal_db
    name: WiFi Signal
    platform: wifi_signal
    update_interval: 60s
    entity_category: diagnostic

  - id: wifi_signal_strength
    name: WiFi Strength
    platform: copy
    source_id: wifi_signal_db
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "%"
    entity_category: diagnostic

text_sensor:
  - platform: wifi_info
    ip_address:
      name: IP Address
      entity_category: diagnostic
    ssid:
      name: Connected SSID
      entity_category: diagnostic
    mac_address:
      name: Mac Address
      entity_category: diagnostic

remote_webview:
  id: rwv
  display_id: main_display
  touchscreen_id: main_touchscreen
  device_id: esp32-display43
  server: 192.168.1.5:8081
  url: http://192.168.1.5:8123/dashboard-screen32/0  # set url: "self-test" to initiate the self-test
  full_frame_tile_count: 1
  max_bytes_per_msg: 61440
  jpeg_quality: 85

text:
  - platform: template
    id: rwv_url
    name: "http://192.168.1.5:8123/dashboard-screen32/0"
    optimistic: true
    restore_value: false
    mode: TEXT
    min_length: 1
    set_action:
      - lambda: |-
          if (!id(rwv).open_url(std::string(x.c_str()))) {
            id(rwv).set_url(std::string(x.c_str()));
            ESP_LOGI("remote_webview", "URL queued (not connected): %s", x.c_str());
          }
script:
  id: backlight_timer
  then:
  - light.turn_on:
      id: backlight
      brightness: 100%
  - delay: 30s
  - light.turn_on:
      id: backlight
      brightness: 50%
  - delay: 10s
  - light.turn_off: backlight

switch:
  - platform: restart
    name: "ESP32-2432S028 Display Restart"

henriquevianasilva avatar Nov 01 '25 15:11 henriquevianasilva

With rotation 90 stay like this.

Image

henriquevianasilva avatar Nov 01 '25 15:11 henriquevianasilva

@henriquevianasilva, I have only one mipi_rgb display: the Guition JC8048W550. I can confirm that it ignores the transform section entirely. Neither the test card nor RWV (obviously) is shown rotated.

According to the docs, transform is a hardware method and should work with RWV. By contrast, rotation is a software method and won’t work with RWV, since we operate on buffers rendered directly to the display.

Software rotation could be implemented in the RWV client or, preferably, in the server to minimize performance degradation, but it would be a completely new feature. If someone is brave enough to implement it and open a PR, I’ll be happy to review and merge. Otherwise, I may implement it myself at some point, but I’m currently focused on other projects.

strange-v avatar Nov 01 '25 16:11 strange-v

I just ran into the same issue when deciding to switch all my ESP32-8048S043 and ESP32-8048S050 to use remotewebview. mipi_rgb doesn't support transform: swap_xy with model: RPI it seems, and the mirror settings have no effect . :'(

Not sure if we can try model: CUSTOM as I don't know the init_sequence

RyanEwen avatar Nov 01 '25 17:11 RyanEwen

Curiously the picture doesn't look stretched when removing all the rotation and transform options. Server is set to 800 tall by 480 wide, while the display is showing 480 tall by 800 wide. Does the server adapt to the display resolution despite the settings on it?

RyanEwen avatar Nov 01 '25 18:11 RyanEwen

@RyanEwen, server config values are defaults; each device communicates its own width and height to the server when it connects.

strange-v avatar Nov 01 '25 18:11 strange-v

@RyanEwen, server config values are defaults; each device communicates its own width and height to the server when it connects.

Thanks for clarifying - this is actually wonderful as I had setup multiple instances of the server thinking I needed one for each resolution. Now I can remove the extras

RyanEwen avatar Nov 01 '25 18:11 RyanEwen

Yeah, at this stage, I should probably just remove them. Those defaults made sense for standalone clients, which might not send the required data, but now that only the ESPHome component is used, they just confuse people.

strange-v avatar Nov 01 '25 18:11 strange-v

@henriquevianasilva just curious if you are seeing an issue with this device where certain images, when displayed on it, cause the entire display to go solid red? I have tried both display drivers but both do it. When I try to find other settings (eg, by asking AI), it shows me the same settings we're using (it seems to get them mostly from my own esphome-lvgl repo and my posts on the Home Assistant Community funny enough). Hoping to find some better settings that fix it.

RyanEwen avatar Nov 01 '25 18:11 RyanEwen

@RyanEwen, check the last item in recommendations

strange-v avatar Nov 01 '25 18:11 strange-v

@RyanEwen, check the last item in recommendations

Perfect, thank you! I didn't have luck increasing max_bytes_per_msg but for some reason I had full_frame_tile_count: 1, and that must be too much at 800x480, so I unset it and now all is well.

RyanEwen avatar Nov 01 '25 19:11 RyanEwen

Okay, it wasn’t so hard. Software rotation has been added to the latest server and client releases (v1.1.0). Please check it and let me know if it works correctly for you.

strange-v avatar Nov 02 '25 09:11 strange-v

Works great for me! Thank you

RyanEwen avatar Nov 02 '25 21:11 RyanEwen