2 Copyright (C) 2012 jaseg <s@jaseg.de>
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 version 3 as published by the Free Software Foundation.
10 #include <util/delay.h>
12 ${modulevar("raw_buffer", "uint8_t", "7B", 7)};
14 //FIXME this is *definitely* not elegant.
15 ${modulevar("buffer", "uint8_t", "28B", 28, callbacks=(0, 1))};
16 void ${setter("buffer")}(const comm_callback_descriptor* cb, void* argbuf_end){
18 for(uint8_t i = 7; i>0; i--){
19 ${modulevar("raw_buffer")}[i-1] = 0;
20 for(uint8_t j = 0; j<i; j++){
21 ${modulevar("raw_buffer")}[i-1] |= ${modulevar("buffer")}[t]<<j;
29 void ${loop_function()} (){
31 static uint8_t row = 2; //selects the currently active "row" of the matrix. On the
32 //protoboards I make, this more or less corresponds to physical traces.
33 uint8_t data = ${modulevar("raw_buffer")}[i];
34 DDR${member["port"]} = 0; //FIXME This is supposed to prevent "ghosting". Is it really necessary?
35 PORT${member["port"]} = 0;
36 % if member.get("inverted", False):
37 PORT${member["port"]} = ~data | row;
39 PORT${member["port"]} = data;
41 DDR${member["port"]} = data | row;