Fix small things and expand README

This commit is contained in:
Marco Thomas
2022-04-18 15:03:50 +02:00
parent 7727f01fd2
commit a944f704d0
6 changed files with 17506 additions and 8 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
/target
/assets/output
/assets/ascii.txt

View File

@@ -5,7 +5,7 @@ chip = "STM32F303ZETx"
halt_afterwards = false
[default.rtt]
enabled = true
enabled = false
[default.gdb]
enabled = false

View File

@@ -4,18 +4,26 @@
Why? Because I wanted to and because Rust rocks!
* Demo
#+html: <p align="center"><img src="assets/bad_apple.gif" /></p>
A full demo can be found [[https://www.youtube.com/watch?v=Jn2qinh5Zyo][here]].
* Features
This project was built using an =STM32-F303ZE= with a simple =ssd1306= OLED display.
It draws 21x10 with (almost perfectly) stable 8 frames per second and
This project was built using an =STM32F303ZE= with a simple =ssd1306= OLED display.
On my chip it can draw 21x10 characters (83x60 pixels) with stable 8 frames per second and
was designed and built to play Bad Apple, but anything else would also work.
Frame timings and length of the video can be adjusted, too high frames per second can lead to slowed down playback due to the render time being larger than the desired one.
Faster render times are being adjusted for.
Faster render times (lower fps) are being adjusted for.
* How to use
1. Convert a video to an ASCII file, using =video-to-ascii.py=
2. Adjust frame timing in the main program (draw time per picture, width, height, total frames)
3. Flash and enjoy!
Don't forget to adjust the HAL and I2C pins in the code.
The lastest =ascii.txt= I used is also present in this repository.
* Input format
The screen renders video through ASCII characters. It takes in a long text file, containing all the images in a contiguous stream, which is then read in =IMAGE_LEN=-sized (height * width + newline chars) chunks in the main program.
If these parameters don't match up, the end result won't either.
@@ -25,5 +33,5 @@ The =video-to-ascii.py= conversion script uses [[https://github.com/ivanl-exe/im
It is assumed to be located on the same height as this project and that it is build in release-mode (due to performance).
* TODO
- [X] Fix timing in draw
- [ ] Rewrite ascii conversion in Rust or Haskell (with an own implementation of =ascii-to-text=)
- [X] Fix timing in draw (still a tiny bit off, but it's fine)
- [ ] Rewrite ASCII conversion in Rust or Haskell (with an own implementation of =ascii-to-text=)

17490
assets/ascii.txt Normal file

File diff suppressed because it is too large Load Diff

BIN
assets/bad_apple.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 MiB

View File

@@ -14,7 +14,7 @@ use embedded_time::fixed_point::FixedPoint as _;
use hal::{i2c::I2c, timer::MonoTimer};
use pac::{CorePeripherals, Peripherals};
use panic_rtt_target as _;
use rtt_target::{rprintln, rtt_init_print};
use rtt_target::rtt_init_print;
use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
use stm32f3xx_hal::prelude::_embedded_hal_digital_InputPin;
use stm32f3xx_hal::{self as hal, pac, prelude::*};
@@ -101,6 +101,7 @@ fn main() -> ! {
// WARNING: don't do anything after elapsed() has been calculated,
// otherwise it will delay the frame being drawn, which will
// knock it off sync
// It's still a tiny, wheensy bit off, but it's fine
let freq: f64 = monotimer.frequency().0.into();
let ms_per_draw: f64 = f64::from(1000 ) / (freq / f64::from(monotimer_instant.elapsed()));
match DRAW_TIME.checked_sub(ms_per_draw as usize) {