Code Monkey home page Code Monkey logo

stm32_tiny_monitor's Introduction

STM32 Tiny Monitor

A super tiny monitor for your PC, suitable for your pet ant.

A python script sends the captured screen over USB to the STM32 microcontroller, then that data is displayed on ST7789 display. FPS is not that high, but I made it good enough after several optimizations.

TinyMonitor demo

I made this project because I'm learning USB now and this is a fun project to practice USB stuffs. I still know almost nothing about USB. To get started, follow this tutorial: https://medium.com/@manuel.bl/usb-for-microcontrollers-part-1-basic-usb-concepts-519a33372cc9

Parts:

  • STM32F103 MCU (Bluepill)
  • ST7789 SPI Display (240x240 resolution)

Pin mapping:

ST7789 STM32
SDA PA7
SCL PA5
RESETn PA4
D/Cn PA2
BLK PA3 (unused)

How to use:

  1. Compile the firmware and flash the microcontroller
  2. Follow the instruction in host_python_scripts folder to run the host software.
  3. Connect microcontroller to PC using USB cable. Host software will start the stream.
  4. Enjoy your tiny monitor :)

Demo:

  1. https://youtu.be/5AGjsRObFtk
  2. https://youtu.be/oFxuoMdBxJk

TODO:

  • Optimize the device (mcu) firmware. Buffer the incoming packets befoe sending to SPI bus.
  • Write host software in C/C++ to get higher performance

Feel free to modify the code and do whatever you want with this useless project.

stm32_tiny_monitor's People

Contributors

abhra0897 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

stm32_tiny_monitor's Issues

Speed

What is the bottleneck? I thought that these displays could refresh faster! And stm32 has JPEG codec.

fast_host.py and slow_host.py don't work on Arch Linux

fast_host.py

------------- [ initialize ] -------------

Device not found... Connect device
Device Found!!
Setting device configuration...
ERROR: USBError occured. Re-connect the device...

---------------- [ end ] ----------------


------------- [ handshake ] -------------

ERROR: USBError occured. Re-connect the device...

---------------- [ end ] ----------------


------------- [ stream start ] -------------

Streaming started...
Traceback (most recent call last):
  File "/home/enginar/git-repos/stm32_tiny_monitor/host_python_scripts/fast_host/start_host.py", line 1, in <module>
    import fast_host
  File "fast_host.pyx", line 146, in init fast_host
    initialize()
  File "fast_host.pyx", line 141, in fast_host.initialize
    stream_out(usb_device)
  File "fast_host.pyx", line 101, in fast_host.stream_out
    img = Image.frombytes('RGB', (w, h), sct.grab(monitor).rgb)                 # <-- mss is way fater than pyautogui
  File "/usr/lib/python3.10/site-packages/mss/base.py", line 88, in grab
    return self._grab_impl(monitor)
  File "/usr/lib/python3.10/site-packages/mss/linux.py", line 446, in _grab_impl
    ximage = self.xlib.XGetImage(
  File "/usr/lib/python3.10/site-packages/mss/linux.py", line 191, in validate
    raise ScreenShotError(err, details=details)
mss.exception.ScreenShotError: XGetImage() failed
~/git-repos/stm32_tiny_monitor/host_python_scripts/f

slow_host.py

------------- [ initialize ] -------------

TinyMonitor Found... :)
Setting device configuration...
ERROR: USBError occured. Re-connect the device...

---------------- [ end ] ----------------


------------- [ handshake ] -------------

ERROR: USBError occured. Re-connect the device...

---------------- [ end ] ----------------


------------- [ stream start ] -------------

Streaming started...
Traceback (most recent call last):
  File "/home/enginar/git-repos/stm32_tiny_monitor/host_python_scripts/slow_host/host.py", line 144, in <module>
    initialize()
  File "/home/enginar/git-repos/stm32_tiny_monitor/host_python_scripts/slow_host/host.py", line 139, in initialize
    stream_out(usb_device)
  File "/home/enginar/git-repos/stm32_tiny_monitor/host_python_scripts/slow_host/host.py", line 99, in stream_out
    img = Image.frombytes('RGB', (w, h), sct.grab(monitor).rgb)                 # <-- mss is way fater than pyautogui
  File "/usr/lib/python3.10/site-packages/mss/base.py", line 88, in grab
    return self._grab_impl(monitor)
  File "/usr/lib/python3.10/site-packages/mss/linux.py", line 446, in _grab_impl
    ximage = self.xlib.XGetImage(
  File "/usr/lib/python3.10/site-packages/mss/linux.py", line 191, in validate
    raise ScreenShotError(err, details=details)
mss.exception.ScreenShotError: XGetImage() failed

Discussing about ESP32 C3 support?

ESP32-C3 is a single-core, 32-bit, RISC-V-based MCU with 400KB of SRAM, which is capable of running at 160MHz. It has integrated 2.4 GHz Wi-Fi and Bluetooth 5 (LE) with a long-range support. It has 22 programmable GPIOs with support for ADC, SPI, UART, I2C, I2S, RMT, TWAI, and PWM.

image

image

image

image

esp32-c3-devkitm-1-v1-pinout

Official introduction address

https://www.espressif.com/en/news/ESP32_C3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.