Root/
| Source at commit 352779a78fc12cd1126f41080771649890927e81 created 10 years 11 months ago. By Werner Almesberger, tornado/led/: layout for new LED board version | |
|---|---|
| 1 | #!/usr/bin/perl |
| 2 | # |
| 3 | # tools/xbm2ant - Convert X bitmap file to Antorcha image binary |
| 4 | # |
| 5 | # Written 2012 by Werner Almesberger |
| 6 | # Copyright 2012 Werner Almesberger |
| 7 | # |
| 8 | # This program is free software; you can redistribute it and/or modify |
| 9 | # it under the terms of the GNU General Public License as published by |
| 10 | # the Free Software Foundation; either version 2 of the License, or |
| 11 | # (at your option) any later version. |
| 12 | # |
| 13 | |
| 14 | sub add |
| 15 | { |
| 16 | local $v = $_[0]; |
| 17 | |
| 18 | for (my $i = 0; $i != 8; $i++) { |
| 19 | push(@v, ($v >> $i) & 1); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | |
| 24 | while (<>) { |
| 25 | if (/width (\d+)/) { |
| 26 | $xm = $1; |
| 27 | next; |
| 28 | } |
| 29 | if (/height (\d+)/) { |
| 30 | $ym = $1; |
| 31 | die "no more than 16 rows" if $ym > 16; |
| 32 | next; |
| 33 | } |
| 34 | next unless /^\s*(0x.*[0-9abcdef])/; |
| 35 | for (split(/,\s*/, $1)) { |
| 36 | &add(hex($_)); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | $span = ($xm+7) & ~7; |
| 41 | for ($x = 0; $x != $xm; $x++) { |
| 42 | $v = 0; |
| 43 | for ($y = 0; $y != 16; $y++) { |
| 44 | $v |= 1 << $y if $v[$x+$y*$span]; |
| 45 | } |
| 46 | print pack("v", $v); |
| 47 | } |
| 48 | |
Branches:
master
tornado-v1
