Finished
This commit is contained in:
parent
730785a7c0
commit
eb78d86d15
4 changed files with 193411 additions and 18 deletions
|
@ -1,5 +1,4 @@
|
|||
# askiiart/marlin-auto-animation
|
||||
|
||||
1. Make your video into images. Make it the right resolution and framerate using Handbrake (or ffmpeg), don't use RF=0. Then, make it into images using ffmpeg (`mkdir images; ffmpeg -i video.mp4 images/%05d.png`).
|
||||
2. Adjust the variables near the start of `animator.py`
|
||||
3. Run `python3 animator.py`
|
||||
1. Specify the video path (must already be 5 fps) in `animator.py`
|
||||
2. Run `python3 animator.py`
|
||||
|
|
193328
_Bootscreen.h
Normal file
193328
_Bootscreen.h
Normal file
File diff suppressed because one or more lines are too long
34
_Bootscreen.h.bak
Normal file
34
_Bootscreen.h.bak
Normal file
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#define CUSTOM_BOOTSCREEN_ANIMATED
|
||||
#define CUSTOM_BOOTSCREEN_TIMEOUT 0 // (ms) Extra timeout after the animation
|
||||
|
||||
/**
|
||||
* Enable one of the following two options depending on your needs.
|
||||
* Also edit the "custom_bootscreen_animation" at the bottom of this file.
|
||||
*/
|
||||
#define CUSTOM_BOOTSCREEN_FRAME_TIME 200 // (ms) Same time for all frames
|
||||
//#define CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME // Each frame also has a duration
|
||||
|
||||
#define CUSTOM_BOOTSCREEN_BMPWIDTH 128
|
62
animator.py
62
animator.py
|
@ -1,8 +1,6 @@
|
|||
from subprocess import getoutput
|
||||
import os
|
||||
import random
|
||||
|
||||
output = '/home/ben/Documents/bad_apple_Bootscreen.h'
|
||||
output = './_Bootscreen.h'
|
||||
video = '/home/ben/Videos/bad_apple_5fps.mp4'
|
||||
|
||||
# Make video into xbm files
|
||||
|
@ -11,29 +9,63 @@ os.mkdir('temp/pngs')
|
|||
os.mkdir('temp/xbms')
|
||||
|
||||
# Convert video to pngs
|
||||
getoutput(f'ffmpeg -i {video} temp/pngs/%d.png')
|
||||
os.system(f'ffmpeg -i {video} temp/pngs/%05d.png')
|
||||
|
||||
# Remove duplicates and rename files
|
||||
files = sorted(os.listdir('temp/pngs'))
|
||||
for item in files:
|
||||
i = files.index(item)
|
||||
if (i + 1) % 6 != 1:
|
||||
os.remove(f'temp/pngs/{item}')
|
||||
files = sorted(os.listdir('temp/pngs'))
|
||||
for item in files:
|
||||
os.rename(f'temp/pngs/{item}', f'temp/pngs/{files.index(item)+1}.png')
|
||||
|
||||
# Convert pngs to xbms
|
||||
pngs = os.listdir('temp/pngs')
|
||||
filenames = [os.path.splitext(os.path.basename(filename))[0] for filename in pngs]
|
||||
|
||||
for filename in filenames:
|
||||
getoutput(f'convert temp/pngs/{filename}.png temp/xbms/{filename}.xbm')
|
||||
os.system(f'convert temp/pngs/{filename}.png temp/xbms/{filename}.xbm')
|
||||
|
||||
# make some pngs for debugging
|
||||
# Make some pngs for debugging
|
||||
debug = True
|
||||
if debug:
|
||||
from random import random
|
||||
os.mkdir('temp/debug_pngs')
|
||||
for filename in filenames:
|
||||
if random.random() < 0.01:
|
||||
getoutput(f'convert temp/xbms/{filename}.xbm temp/debug_pngs/{filename}.png')
|
||||
if random() < 0.01: # Takes a long time, so only convert 1% of the images
|
||||
os.system(f'convert temp/xbms/{filename}.xbm temp/debug_pngs/{filename}.png')
|
||||
|
||||
|
||||
'''
|
||||
for filename in filenames:
|
||||
f = open(f'temp/xbms/{filename}.xbm', 'r')
|
||||
lines = [line.strip() for line in f.readlines()[3:]]
|
||||
os.touch(f'{output}')
|
||||
lines = f.readlines()
|
||||
for line in lines:
|
||||
line = ' ' + line.strip().replace(', }; ', ' };')
|
||||
if filename == '1':
|
||||
lines.insert(0, 'const unsigned char custom_start_bmp[] PROGMEM = {')
|
||||
else:
|
||||
lines.insert(0, f'const unsigned char custom_start_bmp{int(filename) - 2}[] PROGMEM = {{')
|
||||
f.close()
|
||||
exit()
|
||||
'''
|
||||
#os.rmdir('temp')
|
||||
f = open(output, 'a')
|
||||
f.write('\n')
|
||||
f.write('\n'.join(lines))
|
||||
f.write('\n')
|
||||
f.close()
|
||||
|
||||
start_of_ending = ['#ifdef CUSTOM_BOOTSCREEN_ANIMATED_FRAME_TIME', '', ' // Each frame has its own custom duration', ' const boot_frame_t custom_bootscreen_animation[] PROGMEM = {', ' { custom_start_bmp1, 2000 }, // 2.0s', ' { custom_start_bmp1, 100 }, // 0.1s x 5 frames', ' { custom_start_bmp2, 100 },', ' { custom_start_bmp3, 100 },', ' { custom_start_bmp4, 100 },', ' { custom_start_bmp5, 100 },', ' { custom_start_bmp6, 100 },', ' { custom_start_bmp, 500 }, // 0.5s', ' };', '', '#else', '', ' // Each frame shows for CUSTOM_BOOTSCREEN_FRAME_TIME', ' const unsigned char * const custom_bootscreen_animation[] PROGMEM = {']
|
||||
middle_of_ending = ' custom_start_bmp, '
|
||||
for i in range(len(filenames))[:-2]:
|
||||
middle_of_ending += f'custom_start_bmp{i}, '
|
||||
end_of_ending = [' };', '', '#endif', '']
|
||||
|
||||
f = open(output, 'a')
|
||||
f.write('\n')
|
||||
for line in start_of_ending:
|
||||
f.write(line + '\n')
|
||||
f.write(middle_of_ending)
|
||||
for line in end_of_ending:
|
||||
f.write(line + '\n')
|
||||
f.close()
|
||||
|
||||
#os.system('rm -r temp/')
|
||||
|
|
Loading…
Reference in a new issue