Skip to content

Conversation

Copy link

Copilot AI commented Aug 5, 2025

Adds a new tile_viewer.py module that provides functionality to process and render tiles from binary data (.bin files) with support for custom line widths in drawing commands.

Overview

This implementation addresses the need to process binary tile data with enhanced line width support for LINE and POLYLINE drawing commands, while maintaining compatibility with existing LVGL binary image files used throughout the project.

Key Features

Dual Format Support

  • LVGL Binary Images: Parses existing .bin files (arrow.bin, altit.bin, speed.bin, etc.) used by the GUI components
  • Custom Drawing Commands: Processes binary data containing drawing commands with line width attributes

Custom Line Width Implementation

The render_tile_surface() method now includes line width processing for drawing commands:

# LINE command with custom width
draw.line([start_pos, end_pos], fill=color, width=line_width)

# POLYLINE command with custom width  
for i in range(len(points) - 1):
    draw.line([points[i], points[i + 1]], fill=color, width=line_width)

Drawing Commands Supported

  • CMD_LINE: Draws lines between two points with custom line width
  • CMD_POLYLINE: Draws connected line segments with custom line width
  • CMD_RECT, CMD_CIRCLE, CMD_POLYGON: Use current line width for outlines
  • CMD_POINT: Renders points with size based on current line width

Color Format Support

  • RGB565 ↔ RGB888 conversion methods
  • ARGB8888 support with alpha channel handling
  • Automatic format detection for LVGL binary images

Usage Example

from tile_viewer import TileViewer

# Process existing LVGL binary files
viewer = TileViewer(256)
image = viewer.process_tile('data/arrow.bin', 'arrow_output.png')

# Process custom drawing commands with line widths
binary_data = create_drawing_commands_with_line_widths()
image = viewer.render_tile_surface(binary_data, 'custom_output.png')

Implementation Details

  • Minimal Changes: Only adds necessary functionality for line width support without modifying existing code structure
  • Backward Compatibility: Existing .bin files continue to work unchanged
  • Error Handling: Robust parsing with graceful fallbacks for malformed data
  • Format Detection: Automatically detects LVGL vs. drawing command formats

Testing

The implementation has been validated with:

  • Existing project .bin files (arrow.bin, altit.bin, speed.bin)
  • Custom test cases demonstrating different line widths (1px, 3px, 5px, 4px polylines)
  • Error handling for malformed binary data

This enhancement enables more sophisticated drawing capabilities while maintaining full compatibility with the existing IceNav-v3 graphics pipeline.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@jgauchia jgauchia closed this Aug 5, 2025
Copilot AI changed the title [WIP] Actualizar tile_viewer.py para incluir soporte de grosor de línea Implement tile_viewer.py with custom line width support for binary drawing commands Aug 5, 2025
Copilot AI requested a review from jgauchia August 5, 2025 22:27
Copilot finished work on behalf of jgauchia August 5, 2025 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants