/* * Max7219.h - 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. */ #ifndef _DUINOPLUSMAX7219_H_ #define _DUINOPLUSMAX7219_H_ #include #if (ARDUINO >= 100) #include #else #include #endif /* ������ϵ����ֺ���ĸ */ const static byte charTable [] PROGMEM = { B01111110,B00110000,B01101101,B01111001,B00110011,B01011011,B01011111,B01110000, B01111111,B01111011,B01110111,B00011111,B00001101,B00111101,B01001111,B01000111, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, B00000000,B00000000,B00000000,B00000000,B10000000,B00000001,B10000000,B00000000, B01111110,B00110000,B01101101,B01111001,B00110011,B01011011,B01011111,B01110000, B01111111,B01111011,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, B00000000,B01110111,B00011111,B00001101,B00111101,B01001111,B01000111,B00000000, B00110111,B00000000,B00000000,B00000000,B00001110,B00000000,B00000000,B00000000, B01100111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00001000, B00000000,B01110111,B00011111,B00001101,B00111101,B01001111,B01000111,B00000000, B00110111,B00000000,B00000000,B00000000,B00001110,B00000000,B00010101,B00011101, B01100111,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000, B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000,B00000000 }; class Max7219 { private : int SPI_MOSI; int SPI_CLK; int SPI_CS; byte status[64]; byte spidata[16]; /*��ʱ������������SPI����*/ void spiTransfer(int addr, byte opcode, byte data); /*�������ݴ���*/ public: int maxDevices; /*��༶���豸*/ Max7219(int csPin, int dataPin, int clkPin, int numDevices=1); /* ȱʡ�����豸��Ϊ1 */ int getDeviceCount(); /*��ȡ�����豸�� */ void shutdown(bool status); /*���� */ void setScanLimit(int limit); /* */ void setIntensity(int intensity); /*�������� */ void clearDisplay(void); void update(byte *buff); /*������Ļ���ѻ������������͵�оƬ*/ void setDigit(int addr, int digit, byte value, boolean dp); /*�������ʾ����*/ void setChar(int addr, int digit, char value, boolean dp); /*�������ʾ�ַ�*/ }; #endif /*_MAX7219_H_*/