Forked PololuLedStrip and modified it to work with the KL25Z. Renamed it to Adafruit_NeoPixel.
Dependents: idd_hw3 idd_fa15_hw3_lauren_bill_tomas idd_fa15_hw3_lauren_bill_tomas Raiden ... more
Fork of PololuLedStrip by
PololuLedStrip.cpp
- Committer:
- DavidEGrayson
- Date:
- 2013-03-01
- Revision:
- 7:9a088f042ee0
- Parent:
- 6:9d0530b7dae2
- Child:
- 8:1578776ceac5
File content as of revision 7:9a088f042ee0:
#include "PololuLedStrip.h" bool PololuLedStrip::interruptFriendly = false; uint8_t led_strip_write_delays[3]; void PololuLedStrip::calculateDelays() { int fmhz = SystemCoreClock / 1000000; led_strip_write_delays[0] = 700*fmhz/1000 - 25; led_strip_write_delays[1] = 600*fmhz/1000 - 19; led_strip_write_delays[2] = 1200*fmhz/1000 - 24; } PololuLedStrip::PololuLedStrip(PinName pinName) { gpio_init(&gpio, pinName, PIN_OUTPUT); calculateDelays(); // Assumption } void PololuLedStrip::write(rgb_color * colors, unsigned int count) { __disable_irq(); // Disable interrupts temporarily because we don't want our pulse timing to be messed up. while(count--) { led_strip_write_color(colors++, gpio.reg_set, gpio.reg_clr, gpio.mask); if (interruptFriendly) { __enable_irq(); __nop(); __nop(); __nop(); __disable_irq(); } } __enable_irq(); // Re-enable interrupts now that we are done. wait_us(24); // Hold the line low for 24 microseconds to send the reset signal. }