-
大小: 35KB文件类型: .rar金币: 1下载: 0 次发布日期: 2021-06-02
- 语言: 其他
- 标签: Adafruit_Neo Adafruit NeoPixel
资源简介
Adafruit_NeoPixel库+实例程序,绝对好用,你值值得拥有
代码片段和文件信息
/*-------------------------------------------------------------------------
Arduino library to control a wide variety of WS2811- and WS2812-based RGB
LED devices such as Adafruit FLORA RGB Smart Pixels and NeoPixel strips.
Currently handles 400 and 800 KHz bitstreams on 8 12 and 16 MHz ATmega
MCUs with LEDs wired for RGB or GRB color order. 8 MHz MCUs provide
output on PORTB and PORTD while 16 MHz chips can handle most output pins
(possible exception with upper PORT registers on the Arduino Mega).
Written by Phil Burgess / Paint Your Dragon for Adafruit Industries
contributions by PJRC and other members of the open source community.
Adafruit invests time and resources providing this open source code
please support Adafruit and open-source hardware by purchasing products
from Adafruit!
-------------------------------------------------------------------------
This file is part of the Adafruit NeoPixel library.
NeoPixel is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation either version 3 of
the License or (at your option) any later version.
NeoPixel is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with NeoPixel. If not see
.
-------------------------------------------------------------------------*/
#include “Adafruit_NeoPixel.h“
Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t n uint8_t p uint8_t t) : numLEDs(n) numBytes(n * 3) pin(p) pixels(NULL)
#if defined(NEO_RGB) || defined(NEO_KHZ400)
type(t)
#endif
#ifdef __AVR__
port(portOutputRegister(digitalPinToPort(p)))
pinMask(digitalPinToBitMask(p))
#endif
{
if((pixels = (uint8_t *)malloc(numBytes))) {
memset(pixels 0 numBytes);
}
}
Adafruit_NeoPixel::~Adafruit_NeoPixel() {
if(pixels) free(pixels);
pinMode(pin INPUT);
}
void Adafruit_NeoPixel::begin(void) {
pinMode(pin OUTPUT);
digitalWrite(pin LOW);
}
void Adafruit_NeoPixel::show(void) {
if(!pixels) return;
// Data latch = 50+ microsecond pause in the output stream. Rather than
// put a delay at the end of the function the ending time is noted and
// the function will simply hold off (if needed) on issuing the
// subsequent round of data until the latch time has elapsed. This
// allows the mainline code to start generating the next frame of data
// rather than stalling for the latch.
while((micros() - endTime) < 50L);
// endTime is a private member (rather than global var) so that mutliple
// instances on different pins can be quickly issued in succession (each
// instance doesn‘t delay the next).
// In order to make this code ru
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 37492 2016-05-09 09:41 Adafruit_NeoPixel\Adafruit_NeoPixel.cpp
文件 37496 2016-05-09 09:41 Adafruit_NeoPixel\Adafruit_NeoPixel.cpp.bak
文件 2771 2016-05-09 09:41 Adafruit_NeoPixel\Adafruit_NeoPixel.h
文件 40145 2016-05-09 09:41 Adafruit_NeoPixel\COPYING
文件 9231 2016-05-09 09:41 Adafruit_NeoPixel\examples\goggles\goggles.pde
文件 4590 2016-06-12 09:41 Adafruit_NeoPixel\examples\strandtest\strandtest.ino
文件 787 2016-05-09 09:41 Adafruit_NeoPixel\README.md
目录 0 2016-05-09 10:38 Adafruit_NeoPixel\examples\goggles
目录 0 2016-06-12 09:41 Adafruit_NeoPixel\examples\strandtest
目录 0 2016-05-09 10:38 Adafruit_NeoPixel\examples
目录 0 2016-05-09 10:38 Adafruit_NeoPixel
----------- --------- ---------- ----- ----
132512 11
评论
共有 条评论