Added debugging mode to gif2c, where it will print overviews of which pixels of each frame changed.

This commit is contained in:
Fabian Schlenz 2019-06-04 05:59:32 +02:00
parent 1d693f34e9
commit bfaf1a9d7a
1 changed files with 14 additions and 1 deletions

View File

@ -9,6 +9,8 @@ require 'pp'
# The data format is described in animations.h
###
DEBUG = true
def compress(data, use_cutoff=true)
cutoff = 3
escape = 255
@ -106,6 +108,7 @@ puts "uint8_t animation_#{name}_colors[] PROGMEM = {#{colors[2..-1].map{|c| [c>>
p_frame = nil
frames_data = []
times = []
frames.each_with_index do |frame, index|
data = []
if index==0 # first frame
@ -144,6 +147,16 @@ frames.each_with_index do |frame, index|
times << old_time + time
end
p_frame = frame
if DEBUG
puts "Frame ##{index}:"
total_y.times do |y|
total_x.times do |x|
print data[x + y*total_x]==0 ? "." : "X"
end
puts
end
end
end
data = frames_data.map{|d| compress(d, true)}
@ -153,7 +166,7 @@ puts "uint16_t animation_#{name}_delays[] = {#{times.join(",")}};"
s=0
puts "uint16_t animation_#{name}_offsets[] = {#{(data.map{|d| t=s; s+=d.count; t} + [s]).join(",")}};"
puts "AnimationData animation_#{name} = {&animation_#{name}_colors[0], &animation_#{name}_data[0], &animation_#{name}_offsets[0], &animation_#{name}_delays[0], #{individual_frame_times}, #{colors.count-2}, #{frames_data.count}, #{frames.first.columns}, #{frames.first.rows}};"
puts "AnimationData animation_#{name} = {&animation_#{name}_colors[0], &animation_#{name}_data[0], &animation_#{name}_offsets[0], &animation_#{name}_delays[0], #{individual_frame_times}, #{colors.count-2}, #{frames_data.count}, #{total_x}, #{total_y}};"
puts
STDERR.puts
STDERR.puts "Space usage:"