i took the new raw function and tested it again. It does not work at the moment.
Here is the actual code:
SPI2.setup({mosi:B15, sck:B13});
var max7219 = function(/*=SPI*/_spi,/*=PIN*/_cs) {
var spi = _spi;
var cs = _cs;
spi.send ([0xA,0xF],cs); // intensity -full
spi.send ([0xB,0x7],cs); // scan limit - all 8 chars
spi.send ([0xC,0],cs); // shutdown
return {
raw1 : function(val) {
digitalWrite(cs,0);
spi.send ([0x9,0]); // output raw data
for (var i=0;i<val.length;i++) {
spi.send([(i&7)+1,val[i]]);
}
spi.send([0x0C,1]); // no shutdown
digitalWrite(cs,1);
},
raw2 : function(val) {
digitalWrite(cs,0);
spi.send ([0x9,0]); // output raw data
digitalWrite(cs,1);
for (var row=0;row<val.length&7;row++) {
print ("row " + row + " " + val.length + " " + (row<val.length&7));
digitalWrite(cs,0);
for (var i=row;i<val.length;i+=8) {
spi.send([row,val[i]]);
print ("val " + row + " " + val[i]);
}
spi.send([0x0C,1]); // no shutdown
digitalWrite(cs,1);
}
},
off : function() { spi.send([0xC,0],cs); },
intensity : function(i) { spi.send([0xA,E.clip(i*15,0,15)],cs); }
};
};
function doSomerhingStupid() {
setData();
if (count > 0)
run();
count ++;
}
function setData()
{
for (var i = 0; i < 64; i ++)
{
data[i] = 0;
if (i % 2 === 0)
{
if (i < 16) data[i] = 0;
else if (i < 32) data[i] = 1;
else if (i < 48) data[i] = 2;
else data[i] = 3;
} else {
data[i] = (i * 4) - 1;
}
print ("data " + i + " " + data[i]);
}
}
function run () {
digitalWrite (LED3, 1);
digitalWrite (LED2, on);
max.raw2(data);
on = !on;
}
var on = 1;
digitalWrite (LED1, 1);
digitalWrite (LED2, 0);
digitalWrite (LED3, 0);
clearInterval();
var count = 0;
var data = new Array (64);
var max = max7219 (SPI2,B14);
setWatch(doSomerhingStupid, BTN1, {repeat:true,edge:"rising", debounce:1});
To see more details about the send-data, i added some print statements.
The output looks like follows. I am not sure, but it doesn't look correct.
Connected
=undefined
=undefined
data 0 0
data 1 3
data 2 0
data 3 11
data 4 0
data 5 19
data 6 0
data 7 27
data 8 0
data 9 35
data 10 0
data 11 43
data 12 0
data 13 51
data 14 0
data 15 59
data 16 1
data 17 67
data 18 1
data 19 75
data 20 1
data 21 83
data 22 1
data 23 91
data 24 1
data 25 99
data 26 1
data 27 107
data 28 1
data 29 115
data 30 1
data 31 123
data 32 2
data 33 131
data 34 2
data 35 139
data 36 2
data 37 147
data 38 2
data 39 155
data 40 2
data 41 163
data 42 2
data 43 171
data 44 2
data 45 179
data 46 2
data 47 187
data 48 3
data 49 195
data 50 3
data 51 203
data 52 3
data 53 211
data 54 3
data 55 219
data 56 3
data 57 227
data 58 3
data 59 235
data 60 3
data 61 243
data 62 3
data 63 251
row 0 64 1
val 0 0
val 0 0
val 0 1
val 0 1
val 0 2
val 0 2
val 0 3
val 0 3
row 1 64 1
val 1 3
val 1 35
val 1 67
val 1 99
val 1 131
val 1 163
val 1 195
val 1 227
row 2 64 1
val 2 0
val 2 0
val 2 1
val 2 1
val 2 2
val 2 2
val 2 3
val 2 3
row 3 64 1
val 3 11
val 3 43
val 3 75
val 3 107
val 3 139
val 3 171
val 3 203
val 3 235
row 4 64 1
val 4 0
val 4 0
val 4 1
val 4 1
val 4 2
val 4 2
val 4 3
val 4 3
row 5 64 1
val 5 19
val 5 51
val 5 83
val 5 115
val 5 147
val 5 179
val 5 211
val 5 243
row 6 64 1
val 6 0
val 6 0
val 6 1
val 6 1
val 6 2
val 6 2
val 6 3
val 6 3
row 7 64 1
val 7 27
val 7 59
val 7 91
val 7 123
val 7 155
val 7 187
val 7 219
val 7 251
row 8 64 1
val 8 0
val 8 1
val 8 1
val 8 2
val 8 2
val 8 3
val 8 3
row 9 64 1
val 9 35
val 9 67
val 9 99
val 9 131
val 9 163
val 9 195
val 9 227
row 10 64 1
val 10 0
val 10 1
val 10 1
val 10 2
val 10 2
val 10 3
val 10 3
row 11 64 1
val 11 43
val 11 75
val 11 107
val 11 139
val 11 171
val 11 203
val 11 235
row 12 64 1
val 12 0
val 12 1
val 12 1
val 12 2
val 12 2
val 12 3
val 12 3
row 13 64 1
val 13 51
val 13 83
val 13 115
val 13 147
val 13 179
val 13 211
val 13 243
row 14 64 1
val 14 0
val 14 1
val 14 1
val 14 2
val 14 2
val 14 3
val 14 3
row 15 64 1
val 15 59
val 15 91
val 15 123
val 15 155
val 15 187
val 15 219
val 15 251
row 16 64 1
val 16 1
val 16 1
val 16 2
val 16 2
val 16 3
val 16 3
row 17 64 1
val 17 67
val 17 99
val 17 131
val 17 163
val 17 195
val 17 227
row 18 64 1
val 18 1
val 18 1
val 18 2
val 18 2
val 18 3
val 18 3
row 19 64 1
val 19 75
val 19 107
val 19 139
val 19 171
val 19 203
val 19 235
row 20 64 1
val 20 1
val 20 1
val 20 2
val 20 2
val 20 3
val 20 3
row 21 64 1
val 21 83
val 21 115
val 21 147
val 21 179
val 21 211
val 21 243
row 22 64 1
val 22 1
val 22 1
val 22 2
val 22 2
val 22 3
val 22 3
row 23 64 1
val 23 91
val 23 123
val 23 155
val 23 187
val 23 219
val 23 251
row 24 64 1
val 24 1
val 24 2
val 24 2
val 24 3
val 24 3
row 25 64 1
val 25 99
val 25 131
val 25 163
val 25 195
val 25 227
row 26 64 1
val 26 1
val 26 2
val 26 2
val 26 3
val 26 3
row 27 64 1
val 27 107
val 27 139
val 27 171
val 27 203
val 27 235
row 28 64 1
val 28 1
val 28 2
val 28 2
val 28 3
val 28 3
row 29 64 1
val 29 115
val 29 147
val 29 179
val 29 211
val 29 243
row 30 64 1
val 30 1
val 30 2
val 30 2
val 30 3
val 30 3
row 31 64 1
val 31 123
val 31 155
val 31 187
val 31 219
val 31 251
row 32 64 1
val 32 2
val 32 2
val 32 3
val 32 3
row 33 64 1
val 33 131
val 33 163
val 33 195
val 33 227
row 34 64 1
val 34 2
val 34 2
val 34 3
val 34 3
row 35 64 1
val 35 139
val 35 171
val 35 203
val 35 235
row 36 64 1
val 36 2
val 36 2
val 36 3
val 36 3
row 37 64 1
val 37 147
val 37 179
val 37 211
val 37 243
row 38 64 1
val 38 2
val 38 2
val 38 3
val 38 3
row 39 64 1
val 39 155
val 39 187
val 39 219
val 39 251
row 40 64 1
val 40 2
val 40 3
val 40 3
row 41 64 1
val 41 163
val 41 195
val 41 227
row 42 64 1
val 42 2
val 42 3
val 42 3
row 43 64 1
val 43 171
val 43 203
val 43 235
row 44 64 1
val 44 2
val 44 3
val 44 3
row 45 64 1
val 45 179
val 45 211
val 45 243
row 46 64 1
val 46 2
val 46 3
val 46 3
row 47 64 1
val 47 187
val 47 219
val 47 251
row 48 64 1
val 48 3
val 48 3
row 49 64 1
val 49 195
val 49 227
row 50 64 1
val 50 3
val 50 3
row 51 64 1
val 51 203
val 51 235
row 52 64 1
val 52 3
val 52 3
row 53 64 1
val 53 211
val 53 243
row 54 64 1
val 54 3
val 54 3
row 55 64 1
val 55 219
val 55 251
row 56 64 1
val 56 3
row 57 64 1
val 57 227
row 58 64 1
val 58 3
row 59 64 1
val 59 235
row 60 64 1
val 60 3
row 61 64 1
val 61 243
row 62 64 1
val 62 3
row 63 64 1
val 63 251
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi,
i took the new raw function and tested it again. It does not work at the moment.
Here is the actual code:
To see more details about the send-data, i added some print statements.
The output looks like follows. I am not sure, but it doesn't look correct.