资源简介
米思齐Max7219库文件,图形化编程官方文件,可以扩展Max7219模块
代码片段和文件信息
/*
* LedControl.cpp - A library for controling Leds with a MAX7219/MAX7221
* Copyright (c) 2007 Eberhard Fahle
*
* Permission is hereby granted free of charge to any person
* obtaining a copy of this software and associated documentation
* files (the “Software“) to deal in the Software without
* restriction including without limitation the rights to use
* copy modify merge publish distribute sublicense and/or sell
* copies of the Software and to permit persons to whom the
* Software is furnished to do so subject to the following
* conditions:
*
* This permission notice shall be included in all copies or
* substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS“ WITHOUT WARRANTY OF ANY KIND
* EXPRESS OR IMPLIED INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM DAMAGES OR OTHER LIABILITY
* WHETHER IN AN ACTION OF CONTRACT TORT OR OTHERWISE ARISING
* FROM OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include “LedControl.h“
//the opcodes for the MAX7221 and MAX7219
#define OP_NOOP 0
#define OP_DIGIT0 1
#define OP_DIGIT1 2
#define OP_DIGIT2 3
#define OP_DIGIT3 4
#define OP_DIGIT4 5
#define OP_DIGIT5 6
#define OP_DIGIT6 7
#define OP_DIGIT7 8
#define OP_DECODEMODE 9
#define OP_INTENSITY 10
#define OP_SCANLIMIT 11
#define OP_SHUTDOWN 12
#define OP_DISPLAYTEST 15
LedControl::LedControl(int dataPin int clkPin int csPin int numDevices) {
SPI_MOSI=dataPin;
SPI_CLK=clkPin;
SPI_CS=csPin;
if(numDevices<=0 || numDevices>8 )
numDevices=8;
maxDevices=numDevices;
pinMode(SPI_MOSIOUTPUT);
pinMode(SPI_CLKOUTPUT);
pinMode(SPI_CSOUTPUT);
digitalWrite(SPI_CSHIGH);
SPI_MOSI=dataPin;
for(int i=0;i<64;i++)
status[i]=0x00;
for(int i=0;i spiTransfer(iOP_DISPLAYTEST0);
//scanlimit is set to max on startup
setScanLimit(i7);
//decode is done in source
spiTransfer(iOP_DECODEMODE0);
clearDisplay(i);
//we go into shutdown-mode on startup
shutdown(itrue);
}
}
int LedControl::getDeviceCount() {
return maxDevices;
}
void LedControl::shutdown(int addr bool b) {
if(addr<0 || addr>=maxDevices)
return;
if(b)
spiTransfer(addr OP_SHUTDOWN0);
else
spiTransfer(addr OP_SHUTDOWN1);
}
void LedControl::setScanLimit(int addr int limit) {
if(addr<0 || addr>=maxDevices)
return;
if(limit>=0 && limit<8)
spiTransfer(addr OP_SCANLIMITlimit);
}
void LedControl::setIntensity(int addr int intensity) {
if(addr<0 || addr>=maxDevices)
return;
if(intensity>=0 && intensity<16)
spiTransfer(addr OP_INTENSITYintensity)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2016-07-19 12:21 Max7219\
目录 0 2016-07-19 11:07 Max7219\block\
文件 1353 2016-07-19 13:09 Max7219\block\Max7219.js
目录 0 2016-07-19 11:08 Max7219\generator\
文件 2429 2016-07-19 13:09 Max7219\generator\Max7219.js
目录 0 2016-07-19 12:21 Max7219\LedControl\
目录 0 2016-07-19 12:21 Max7219\LedControl\examples\
目录 0 2016-07-19 12:21 Max7219\LedControl\examples\LCDemo7Segment\
文件 1690 2015-04-27 02:28 Max7219\LedControl\examples\LCDemo7Segment\LCDemo7Segment.ino
目录 0 2016-07-19 12:21 Max7219\LedControl\examples\LCDemoCascadedDevices\
文件 1483 2015-04-27 02:28 Max7219\LedControl\examples\LCDemoCascadedDevices\LCDemoCascadedDevices.ino
目录 0 2016-07-19 12:21 Max7219\LedControl\examples\LCDemoMatrix\
文件 4125 2015-04-27 02:28 Max7219\LedControl\examples\LCDemoMatrix\LCDemoMatrix.ino
文件 637 2015-04-27 02:28 Max7219\LedControl\keywords.txt
文件 391 2015-04-27 02:28 Max7219\LedControl\library.properties
文件 1101 2015-04-27 02:28 Max7219\LedControl\LICENSE
文件 638 2015-04-27 02:28 Max7219\LedControl\README.md
目录 0 2016-07-19 12:21 Max7219\LedControl\src\
文件 5741 2015-04-27 02:28 Max7219\LedControl\src\LedControl.cpp
文件 7180 2015-04-27 02:28 Max7219\LedControl\src\LedControl.h
文件 2372 2016-07-19 12:21 Max7219\Max7219.xm
评论
共有 条评论