Novo

Dependencies:   mbed

Fork of LukaIElmir by tim003 tim003

Committer:
tim003
Date:
Mon Jun 02 15:35:11 2014 +0000
Revision:
6:dd675b967b60
Parent:
3:43648fa57d55
LIE26

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tim003 2:e4d483d82cd8 1 #include "MatrixSPI.h"
tim003 2:e4d483d82cd8 2
tim003 2:e4d483d82cd8 3 void MatrixSPI::setup () {
tim003 2:e4d483d82cd8 4 // initiation of the max 7219
tim003 2:e4d483d82cd8 5 // SPI setup: 8 bits, mode 0
tim003 2:e4d483d82cd8 6 max72_spi.format(8, 0);
tim003 2:e4d483d82cd8 7
tim003 2:e4d483d82cd8 8 // going by the datasheet, min clk is 100ns so theoretically 10MHz should work...
tim003 2:e4d483d82cd8 9 // max72_spi.frequency(10*MHZ);
tim003 2:e4d483d82cd8 10
tim003 2:e4d483d82cd8 11 sendSingle(scanLimit, 0x07);
tim003 2:e4d483d82cd8 12 sendSingle(decodeMode, 0x00); // using an led matrix (not digits)
tim003 2:e4d483d82cd8 13 sendSingle(shutdown, 0x01); // not in shutdown mode
tim003 2:e4d483d82cd8 14 sendSingle(displayTest, 0x00); // no display test
tim003 2:e4d483d82cd8 15 for (int e=1; e<=8; e++) { // empty registers, turn all LEDs off
tim003 2:e4d483d82cd8 16 sendSingle(e,0);
tim003 2:e4d483d82cd8 17 }
tim003 2:e4d483d82cd8 18 sendSingle(intensity, 0x0f & 0x0f); // the first 0x0f is the value you can set
tim003 2:e4d483d82cd8 19 // range: 0x00 to 0x0f
tim003 3:43648fa57d55 20 }
tim003 3:43648fa57d55 21 void MatrixSPI::sendSingle(int reg, int data) {
tim003 3:43648fa57d55 22 load = LOW; // begin
tim003 3:43648fa57d55 23 max72_spi.write(reg); // specify register
tim003 3:43648fa57d55 24 max72_spi.write(data); // put data
tim003 3:43648fa57d55 25 load = HIGH; // make sure data is loaded (on rising edge of LOAD/CS)
tim003 3:43648fa57d55 26 }
tim003 3:43648fa57d55 27
tim003 3:43648fa57d55 28 void MatrixSPI::sendCol(int col, int data) {
tim003 3:43648fa57d55 29 sendSingle(col + 1, data);
tim003 3:43648fa57d55 30 }