1
0
mirror of git://projects.qi-hardware.com/antorcha.git synced 2024-12-22 18:34:14 +02:00

tornado/fw/txt: xbm2tornado to create #include-able tornado binary; -g for t

This commit is contained in:
Werner Almesberger 2012-12-04 07:23:24 -03:00
parent a5694eba05
commit 2161eec066
2 changed files with 45 additions and 1 deletions

View File

@ -1,2 +1,9 @@
#!/bin/sh
./txt2xbm TEST | ./stretch 6 | ./xbm2gp "$@" | ./plot
T="TEST"
F=6
if [ "$1" = -g ]; then
shift
./txt2xbm "$T" | ./stretch $F | ./xbm2gp "$@" | ./plot
else
./txt2xbm "$T" | ./stretch $F | ./xbm2tornado
fi

37
tornado/fw/txt/xbm2tornado Executable file
View File

@ -0,0 +1,37 @@
#!/usr/bin/perl
sub pick
{
local ($x, $y) = @_;
my $i = $x+$y*$X;
return ((hex $p[$i >> 3]) >> ($i & 7)) & 1;
}
while (<>) {
chop;
if (/#define\s+\S+_width\s+(\d+)/) {
$X = $1;
next;
}
if (/#define\s+\S+_height\s+(\d+)/) {
$Y = $1;
next;
}
next unless /\s*0x/;
s/^\s*//;
s/(,|};)$//;
push(@p, split /,/);
}
for ($x = 0; $x != $X; $x++) {
for ($y = 0; $y != $Y; $y += 8) {
$v = 0;
for ($i = 0; $i != 8; $i++) {
$v |= 1 << $i if &pick($x, $y+$i);
}
print sprintf("0x%02x, ", $v);
}
}
print "\n";