『IQ246〜華麗なる事件簿〜』(織田裕二)
ん〜頭の良さがよく分からない。今のところ、金持ちの刑事コロンボって感じです。いや、きっと頭が良すぎる人は、凡人から見ると頭が良いように見えないんですね。
一話では、「謎解きはティータイムの後で」 とか、他ドラマのタイトルっぽいセリフがよく分からず出てきますが、「振り返れば奴がいない」というセリフを聞いた時は、『振り返れば奴がいる』の織田裕二と石黒賢を思い出して嬉しくなりました。
より生産性の高いソフトウェア開発のメソッドは、きっと頭の良い人たちが考えて、 それを使う側、つまりソフトウェア開発は、突き詰めていくと、コピペになる気がします。 でもって生産性は、コンピュータの操作で決まる。 素早い操作のためには、キーボード、つまり、コマンドライン。
まあ、極端な発想ですが。
ではコピペで生産してみましょう。ラズパイからATtiny2313へ書き込むソフトmakefile一式は、githubに格納してありますが、これをコピーして、ATtiny85用の一式を作りコミットしてみます。
まずは、clone。実機確認するためラズパイからcloneします。
root@raspberrypi:~# git clone https://github.com/takkete/bread.git Cloning into 'bread'... remote: Counting objects: 26, done. remote: Compressing objects: 100% (7/7), done. remote: Total 26 (delta 0), reused 0 (delta 0), pack-reused 17 Unpacking objects: 100% (26/26), done. Checking connectivity... done. root@raspberrypi:~# cd bread/mcu/avr root@raspberrypi:~/bread/mcu/avr#
さっそくコピペ
root@raspberrypi:~/bread/mcu/avr# ls attiny2313 root@raspberrypi:~/bread/mcu/avr# cp -r attiny2313 attiny85 root@raspberrypi:~/bread/mcu/avr# cd attiny85 root@raspberrypi:~/bread/mcu/avr/attiny85#
置換する箇所を検索します。2313で検索。
root@raspberrypi:~/bread/mcu/avr/attiny85# grep 2313 -r * makefile: avr-gcc -O2 -mmcu=attiny2313 -DF_CPU=1000000UL -c -o test.o test.c makefile: avr-gcc -O2 -mmcu=attiny2313 test.o -o test makefile: avrdude -p t2313 -c linuxgpio -U flash:w:test.hex test.c: DDRB = 0b00001000; //ATtiny2313 pin.15 PB3 OUT test.c: ATtiny2313 root@raspberrypi:~/bread/mcu/avr/attiny85#
一通り置換しても問題ないことを確認したら、検索結果をファイル名のみにするため-lオプションを付けます。^^^を使えば置換して再実施できます。
root@raspberrypi:~/bread/mcu/avr/attiny85# ^-r^-rl^ grep 2313 -rl * makefile test.c root@raspberrypi:~/bread/mcu/avr/attiny85#
対象ファイルの2313という文字列を85に置換します。前回のコマンドは!!に格納されているので、活用します。
root@raspberrypi:~/bread/mcu/avr/attiny85# sed 's/2313/85/g' -i `!!` sed 's/2313/85/g' -i `grep 2313 -rl *` root@raspberrypi:~/bread/mcu/avr/attiny85#
置換後の差分を確認します。
root@raspberrypi:~/bread/mcu/avr/attiny85# diff ../attiny2313 . diff ../attiny2313/makefile ./makefile 2,3c2,3 < avr-gcc -O2 -mmcu=attiny2313 -DF_CPU=1000000UL -c -o test.o test.c < avr-gcc -O2 -mmcu=attiny2313 test.o -o test --- > avr-gcc -O2 -mmcu=attiny85 -DF_CPU=1000000UL -c -o test.o test.c > avr-gcc -O2 -mmcu=attiny85 test.o -o test 7c7 < avrdude -p t2313 -c linuxgpio -U flash:w:test.hex --- > avrdude -p t85 -c linuxgpio -U flash:w:test.hex diff ../attiny2313/test.c ./test.c 6c6 < DDRB = 0b00001000; //ATtiny2313 pin.15 PB3 OUT --- > DDRB = 0b00001000; //ATtiny85 pin.15 PB3 OUT 17c17 < ATtiny2313 --- > ATtiny85 root@raspberrypi:~/bread/mcu/avr/attiny85#
問題なさそうです。
後は、ATtiny85のピン配に合わせて各ファイルを修正します。
(test.c,breadboard.sh 詳細は省略)
root@raspberrypi:~/bread/mcu/avr# git status On branch master Your branch is up-to-date with 'origin/master'. Untracked files: (use "git add <file>..." to include in what will be committed) attiny85/ nothing added to commit but untracked files present (use "git add" to track) root@raspberrypi:~/bread/mcu/avr#
addしてcommit。
root@raspberrypi:~/bread/mcu/avr# git add attiny85 root@raspberrypi:~/bread/mcu/avr# git commit -m ATtiny85 [master 43db245] ATtiny85 3 files changed, 97 insertions(+) create mode 100644 mcu/avr/attiny85/breadboard.sh create mode 100644 mcu/avr/attiny85/makefile create mode 100644 mcu/avr/attiny85/test.c root@raspberrypi:~/bread/mcu/avr#
これでAVRマイコン用のテストプログラムが2個になりました。レポジトリが肥えてくるとモチベーションも上がりますね。
Write more, thats all I have to say. Literally,
it seems as though you relied on the video to make your point.
You definitely know what youre talking about, why waste your intelligence on just posting videos to your site when you could
be giving us something informative to read?