RISC-V

 
 
RISC-V is an open standard instruction set architecture (ISA) based on established reduced instruction set computer (RISC) principles. The RISC-V ISA is provided under open source licenses that do not require fees to use.

More information about RISC-V can be found at:
https://riscv.org/








How to create bmp.bin and logo.bin files to be displayed on the Sipeed Logan Nano TFT display.



Information
none

Operating system used
Windows 10 Pro

Software prerequisites
Python 3
PyCharm

Procedure
  • In tutorial How to display the Bad Apple video and Sipeed logo on the Sipeed Longan Nano TFT display I mentioned that the binary file bmp.bin contains the Bad Apple animation and the logo.bin contains the Sipeed logo.
    In this tutorial I will explain how to create the animation (bmp.bin) and logo (logo.bin) binary files.

    Herebelow you can see several examples:

    Sipeed Longan Nano TFT displays the Mobilefish logo
    The Mobilefish logo can be found at https://github.com/robertlie/video_capture

    Mobilefish logo

    Sipeed Longan Nano displays a short Waterfall video
    The waterfall video can be found at https://www.pexels.com/video/waterfall-in-the-forest-6394054/

    Waterfall video

    Sipeed Longan Nano displays the full Bad Apple animation
    The Bad Apple video can be found at https://archive.org/details/TouhouBadApple

    Bad Apple animation

    Sipeed Longan Nano displays a toy promotion video
    The toy promotion video can be found at https://github.com/robertlie/video_capture

    Toy promotion video

    Sipeed Longan Nano displays the full Big Buck Bunny animation
    The Big Buck Bunny animation video can be found at
    https://archive.org/details/BigBuckBunnyFULLHD60FPS

    Big Buck Bunny animation

  • In this tutorial I assume you are familiar with Python programming.

    • In this tutorial I am using PyCharm Community IDE:
      https://www.jetbrains.com/pycharm/download/

    • Type: git clone https://github.com/robertlie/video_capture

    • Create a PyCharm project and select the video_capture folder.

      PyCharm project: video_capture

    • Add the src folder as its context root.

      PyCharm project: video_capture add context root

    • I have setup a pyenv virtual environment using Python 3.8 and installed the opencv-python (4.5.3.56) package.
      The numpy package is automatically installed because it is a dependency of opencv-python.
      The other two packages, pip and setuptools, are automatically installed and needed by PyCharm.

      Note: It will take approx. 20 min for package opencv-python to be installed. Be patient!

      PyCharm project: video_capture packages

  • A demonstration video can be found in:
    video_capture/src/input_video/toy_1280x740_48mb.mov

    Toy promotion video

    The following video formats are supported: mov, mp4
    I have only tested these two video formats but it might support other video formats.

    Place your videos in this folder.

  • A demonstration logo can be found in:
    video_capture/src/input_logo/logo.bmp

    Mobilefish logo

    Use this logo (320x160) as a template.
    It is recommended to use an aspect ratio of 2.
    The Sipeed Longan Nano TFT diplay has an aspect ratio of 2 (= width / height = 160 / 80)
    Use your favourite image editor, for example photoshop or gimp, and create your own logo.
    Save the image as a bmp file.

  • Update file video_capture/src/settings.py
    Change video_filename and logo_filename.

    video_filename = 'your_video_filename.mov'
    logo_filename = 'your_logo_filename.bmp'

  • Execute get_video_information.py and get the Frame Per Second (FPS) value.
    For video_filename = 'toy_1280x740_48mb.mov' you will see:

    FPS = 29
    The number of frames = 1446
    Video width x height = 1280 x 720
    Video duration (sec) = 49.862


  • Update file settings.py again.
    When using toy_1280x740_48mb.mov, change fps_new to 29 or lower.
    If the generated bmp.bin does not fit your micro SD card capacity, lower the fps_new value.

    fps_new = 29

    Allowed values for fps_new: >= 1 and <= actual fps value.

  • To convert only a part of a video, the start_time_sec and stop_time_sec can be set in settings.py.
    If stop_time_sec = 0.0, it means the video end time is used.

    Additional video capture settings

    start_time_sec = 0.0
    stop_time_sec = 0.0


  • The video will be converted to a series of bitmap images: image1.bmp, image2.bmp, image3.bmp etc.
    See folder video_capture/src/output_images
    The generated bitmap images will always have an aspect ratio of 2.

    If a video has a resolution smaller than 2 (for example: width / height = 480 / 360 = 1.3) it means a left and right border in landscape orientation will be added in the generated bitmap images.

    Left and right border added. Border color is black: border_color = [0, 0, 0]

    Left and right border added

    If a video has a resolution greater than 2 (for example: width / height = 2048 / 820 = 2.4) it means a top and bottom border in landscape orientation will be added in the generated bitmap images.

    Top and bottom border added. Border color is red: border_color = [0, 0, 255]

    Top and bottom border added

  • After settings.py is changed, run program video_capture/src/convert_video_and_logo_to_bin_files.py
    This program will:
    • Process the video found in video_capture/src/input_video

    • Generate a sequence of bitmap images: image1.bmp, image2.bmp etc. in folder video_capture/src/output_images

    • Automatically execute program bmp2hex.py, which processes each bitmap image and stores them in file video_capture/src/bmp.bin

      The bmp2hex.py program was copied from:
      https://dl.sipeed.com/LONGAN/Nano/Firmware/badapple_demo_tools/ (tools_bmp2hex.zip)

      I have made NO modification to this program.

    • The generated video_capture/src/bmp.bin file is moved to video_capture/src/output_bin/bmp.bin

    • After the video is processed, convert_video_and_logo_to_bin_files.py will process the logo bitmap file found in video_capture/src/input_logo

    • The logo image will be converted into: logo_modified.bmp in folder video_capture/src/output_images

    • Automatically execute program bmp2hex.py, which processes the logo_modified.bmp and stores it in file video_capture/src/bmp.bin

    • The generated video_capture/src/bmp.bin file is moved to folder video_capture/src/output_bin/logo.bin

  • The two binary files bmp.bin and logo.bin can now be stored in a micro SD card.

  • How to display your video and Sipeed logo on the Sipeed Longan Nano TFT display is further explained in tutorial:
    How to display the Bad Apple video and Sipeed logo on the Sipeed Longan Nano TFT display

  • If you find my tutorial too complex, try another tutorial, created by Sipeed developers.
    You can find their tutorial at:
    https://longan.sipeed.com/zh/examples/badapple.html
    Note: Google translate this page.