Skip to content

Commit

Permalink
frame code generation
Browse files Browse the repository at this point in the history
  • Loading branch information
rambo committed Mar 23, 2013
1 parent 975b08d commit ab7e423
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion software/pc/animationbuilder/animationbuilder.html
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,26 @@ <h2>Generated code</h2>
animation_code += " "+jQuery('#animation_name').val()+"_frames,\n};\n";

// TODO: Generate frame data too
frames_code = "const uint8_t "+jQuery('#animation_name').val()+"_frames[] PROGMEM = {\n";
jQuery('#frames tbody tr').each(function(){
frames_code += " ";
row = jQuery(this);
row.find('input.rgbinput').each(function(){
input = jQuery(this);
rgb = input.val();
r = "0x" + rgb.substr(0,2);
g = "0x" + rgb.substr(2,2);
b = "0x" + rgb.substr(4,2);
frames_code += r+", "+g+", "+b+", ";
});
frame_duration = parseInt(row.find('td.duration input').val());
hi_nibble = Math.floor(frame_duration / 256);
low_nibble = frame_duration % 256;
frames_code += "0x"+hi_nibble.toString(16)+", 0x"+low_nibble.toString(16)+",\n";
});
frames_code += "};\n";

jQuery('#generated textarea').val(animation_code);
jQuery('#generated textarea').val(frames_code+animation_code);

// Scroll to and focus the textarea
jQuery('html, body').animate({
Expand Down

0 comments on commit ab7e423

Please sign in to comment.