babblebots
Advanced tools
| /*------------------------------------------------------------------------- | ||
| Spark Core and Photon library to control WS2811/WS2812 based RGB | ||
| Spark Core, Photon, P1 and Electron library to control WS2811/WS2812 based RGB | ||
| LED devices such as Adafruit NeoPixel strips. | ||
| Currently handles 800 KHz and 400kHz bitstream on Spark Core and Photon, | ||
| Currently handles 800 KHz and 400kHz bitstream on Spark Core and Photon, | ||
| WS2812, WS2812B and WS2811. | ||
@@ -10,6 +10,6 @@ | ||
| - TM1829 pixels | ||
| PLEASE NOTE that the NeoPixels require 5V level inputs | ||
| and the Spark Core and Photon only have 3.3V level outputs. | ||
| Level shifting is necessary, but will require a fast device such as one | ||
| PLEASE NOTE that the NeoPixels require 5V level inputs | ||
| and the Spark Core, Photon, P1 and Electron only have 3.3V level outputs. | ||
| Level shifting is necessary, but will require a fast device such as one | ||
| of the following: | ||
@@ -20,7 +20,7 @@ | ||
| [SN74HCT245N] | ||
| [SN74HCT245N] | ||
| http://www.digikey.com/product-detail/en/SN74HCT245N/296-1612-5-ND/277258 | ||
| Written by Phil Burgess / Paint Your Dragon for Adafruit Industries. | ||
| Modified to work with Spark Core and Photon by Technobly. | ||
| Modified to work with Particle devices by Technobly. | ||
| Contributions by PJRC and other members of the open source community. | ||
@@ -57,3 +57,3 @@ | ||
| #define pinHI(_pin) (PIN_MAP[_pin].gpio_peripheral->BSRR = PIN_MAP[_pin].gpio_pin) | ||
| #elif PLATFORM_ID == 6 // Photon | ||
| #elif (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| STM32_Pin_Info* PIN_MAP2 = HAL_Pin_Map(); // Pointer required for highest access speed | ||
@@ -63,3 +63,3 @@ #define pinLO(_pin) (PIN_MAP2[_pin].gpio_peripheral->BSRRH = PIN_MAP2[_pin].gpio_pin) | ||
| #else | ||
| #error "*** PLATFORM_ID not supported by this library. PLATFORM should be Core or Photon ***" | ||
| #error "*** PLATFORM_ID not supported by this library. PLATFORM should be Core, Photon, or P1 ***" | ||
| #endif | ||
@@ -69,4 +69,4 @@ // fast pin access | ||
| Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t n, uint8_t p, uint8_t t) : | ||
| numLEDs(n), numBytes(n*3), pin(p), brightness(0), pixels(NULL), type(t), endTime(0) | ||
| Adafruit_NeoPixel::Adafruit_NeoPixel(uint16_t n, uint8_t p, uint8_t t) : | ||
| numLEDs(n), numBytes(n*3), type(t), pin(p), brightness(0), pixels(NULL), endTime(0) | ||
| { | ||
@@ -155,3 +155,3 @@ if((pixels = (uint8_t *)malloc(numBytes))) { | ||
| "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -174,3 +174,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "mov r0, r0" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -192,3 +192,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "mov r0, r0" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -213,3 +213,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -234,3 +234,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| else if(type == WS2812B2) { // WS2812B with DWT timer | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| #define CYCLES_800_T0H 25 // 312ns (meas. 300ns) | ||
@@ -302,3 +302,3 @@ #define CYCLES_800_T0L 70 // 938ns (meas. 940ns) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -337,3 +337,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -365,3 +365,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -403,3 +403,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -466,3 +466,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -493,3 +493,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -519,3 +519,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -549,3 +549,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -594,3 +594,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -616,3 +616,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| "mov r0, r0" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -631,3 +631,3 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| // This lib on Photon (meas. 300ns) | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| asm volatile( | ||
@@ -654,3 +654,3 @@ "mov r0, r0" "\n\t" | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| #if PLATFORM_ID == 6 // Photon | ||
| #if (PLATFORM_ID == 6) || (PLATFORM_ID == 8) || (PLATFORM_ID == 10) // Photon (6) or P1 (8) or Electron (10) | ||
| "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
@@ -756,2 +756,20 @@ "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" "nop" "\n\t" | ||
| void Adafruit_NeoPixel::setColor(uint16_t aLedNumber, byte aRed, byte aGreen, byte aBlue) { | ||
| return setPixelColor(aLedNumber, (uint8_t) aRed, (uint8_t) aGreen, (uint8_t) aBlue); | ||
| } | ||
| void Adafruit_NeoPixel::setColorScaled(uint16_t aLedNumber, byte aRed, byte aGreen, byte aBlue, byte aScaling) { | ||
| // scale RGB with a common brightness parameter | ||
| setColor(aLedNumber, (aRed*aScaling)>>8, (aGreen*aScaling)>>8, (aBlue*aScaling)>>8); | ||
| } | ||
| byte Adafruit_NeoPixel::brightnessToPWM(byte aBrightness) { | ||
| static const byte pwmLevels[16] = { 0, 1, 2, 3, 4, 6, 8, 12, 23, 36, 48, 70, 95, 135, 190, 255 }; | ||
| return pwmLevels[aBrightness>>4]; | ||
| } | ||
| void Adafruit_NeoPixel::setColorDimmed(uint16_t aLedNumber, byte aRed, byte aGreen, byte aBlue, byte aBrightness) { | ||
| setColorScaled(aLedNumber, aRed, aGreen, aBlue, brightnessToPWM(aBrightness)); | ||
| } | ||
| // Convert separate R,G,B into packed 32-bit RGB color. | ||
@@ -807,2 +825,6 @@ // Packed format is always RGB, regardless of LED strand color order. | ||
| uint16_t Adafruit_NeoPixel::getNumLeds(void) const { | ||
| return numPixels(); | ||
| } | ||
| // Adjust output brightness; 0=darkest (off), 255=brightest. This does | ||
@@ -809,0 +831,0 @@ // NOT immediately affect what's currently displayed on the LEDs. The |
| /*------------------------------------------------------------------------- | ||
| Spark Core and Photon library to control WS2811/WS2812 based RGB | ||
| Spark Core, Photon, P1 and Electron library to control WS2811/WS2812 based RGB | ||
| LED devices such as Adafruit NeoPixel strips. | ||
| Currently handles 800 KHz and 400kHz bitstream on Spark Core and Photon, | ||
| Currently handles 800 KHz and 400kHz bitstream on Spark Core and Photon, | ||
| WS2812, WS2812B and WS2811. | ||
@@ -10,6 +10,6 @@ | ||
| - TM1829 pixels | ||
| PLEASE NOTE that the NeoPixels require 5V level inputs | ||
| and the Spark Core and Photon only have 3.3V level outputs. | ||
| Level shifting is necessary, but will require a fast device such as one | ||
| PLEASE NOTE that the NeoPixels require 5V level inputs | ||
| and the Spark Core, Photon, P1 and Electron only have 3.3V level outputs. | ||
| Level shifting is necessary, but will require a fast device such as one | ||
| of the following: | ||
@@ -20,7 +20,7 @@ | ||
| [SN74HCT245N] | ||
| [SN74HCT245N] | ||
| http://www.digikey.com/product-detail/en/SN74HCT245N/296-1612-5-ND/277258 | ||
| Written by Phil Burgess / Paint Your Dragon for Adafruit Industries. | ||
| Modified to work with Spark Core and Photon by Technobly. | ||
| Modified to work with Particle devices by Technobly. | ||
| Contributions by PJRC and other members of the open source community. | ||
@@ -32,4 +32,4 @@ | ||
| --------------------------------------------------------------------*/ | ||
| /* ======================= Adafruit_NeoPixel.h ======================= */ | ||
| /* ======================= Adafruit_NeoPixel.h ======================= */ | ||
| /*-------------------------------------------------------------------- | ||
@@ -52,3 +52,3 @@ This file is part of the Adafruit NeoPixel library. | ||
| --------------------------------------------------------------------*/ | ||
| #ifndef SPARK_NEOPIXEL_H | ||
@@ -66,3 +66,3 @@ #define SPARK_NEOPIXEL_H | ||
| #define WS2812B2 0x05 // 800 KHz datastream (NeoPixel) | ||
| class Adafruit_NeoPixel { | ||
@@ -83,2 +83,5 @@ | ||
| setBrightness(uint8_t), | ||
| setColor(uint16_t aLedNumber, byte aRed, byte aGreen, byte aBlue), | ||
| setColorScaled(uint16_t aLedNumber, byte aRed, byte aGreen, byte aBlue, byte aScaling), | ||
| setColorDimmed(uint16_t aLedNumber, byte aRed, byte aGreen, byte aBlue, byte aBrightness), | ||
| clear(void); | ||
@@ -89,3 +92,4 @@ uint8_t | ||
| uint16_t | ||
| numPixels(void) const; | ||
| numPixels(void) const, | ||
| getNumLeds(void) const; | ||
| static uint32_t | ||
@@ -95,2 +99,4 @@ Color(uint8_t r, uint8_t g, uint8_t b); | ||
| getPixelColor(uint16_t n) const; | ||
| byte | ||
| brightnessToPWM(byte aBrightness); | ||
@@ -97,0 +103,0 @@ private: |
@@ -12,3 +12,3 @@ module.exports = { | ||
| { | ||
| name: "neopixels", | ||
| name: "neopixels1", | ||
| type: "neopixels", | ||
@@ -15,0 +15,0 @@ pins: { |
+1
-1
| { | ||
| "name": "babblebots", | ||
| "version": "0.2.61", | ||
| "version": "0.2.63", | ||
| "description": "BabbleBots allows you to declaratively generate thin NodeBots clients in appropriate languages for IoT microcontrollers\"", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
| var fs = require('fs'); | ||
| var path = require('path'); | ||
| var ejs = require('ejs'); | ||
| var _ = require('lodash'); | ||
| var Platform = require('../../../../lib/Platform.js'); | ||
| var Component = require('../../../../lib/component.js'); | ||
| var Neopixels = { | ||
@@ -15,3 +16,3 @@ name: 'neopixels', | ||
| 'neopixel.h': 'https://raw.githubusercontent.com/technobly/SparkCore-NeoPixel/master/firmware/neopixel.h', | ||
| 'neopixel.cpp': 'https://raw.githubusercontent.com/technobly/SparkCore-NeoPixel/master/firmware/neopixel.cpp': | ||
| 'neopixel.cpp': 'https://raw.githubusercontent.com/technobly/SparkCore-NeoPixel/master/firmware/neopixel.cpp' | ||
| }, | ||
@@ -23,11 +24,11 @@ includes:[ | ||
| pixels: 'templates/pixels.tmpl' | ||
| } | ||
| }, | ||
| preInit: function(build, component){ | ||
| build.map.preInit.push('#define PIXEL_PIN ' + component.pins.data + | ||
| '\n#define PIXEL_COUNT ' + component.options.length + | ||
| '\n#define PIXEL_TYPE ' + component.options.type + '\n\n' + | ||
| 'Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);'); | ||
| build.map.preInit.push('#define PIXEL_PIN_' + component.name.toUpperCase() + ' ' + component.pins.data + | ||
| '\n#define PIXEL_COUNT_' + component.name.toUpperCase() + ' ' + component.options.length + | ||
| '\n#define PIXEL_TYPE_' + component.name.toUpperCase() + ' ' + component.options.type + '\n\n' + | ||
| 'Adafruit_NeoPixel strip_' + component.name + ' = Adafruit_NeoPixel(PIXEL_COUNT_' + component.name.toUpperCase() + ', PIXEL_PIN_' + component.name.toUpperCase() + ', PIXEL_TYPE_' + component.name.toUpperCase() + ');'); | ||
| }, | ||
| init: function(build){ | ||
| build.map.init.push('\tstrip.begin();\n\tstrip.show();'); | ||
| init: function(build, component){ | ||
| build.map.init.push('\tstrip_' + component.name + '.begin();\n\tstrip_' + component.name + '.show();'); | ||
| }, | ||
@@ -46,3 +47,3 @@ loop: function(build){ | ||
| build.map.init.push('\n\tParticle.function("' + func + '", ' + func + ');'); | ||
| build.map.init.push('\n\tParticle.function("' + func + '_' + component.name + '", ' + func + '_' + component.name + ');'); | ||
@@ -57,2 +58,4 @@ var result = fs.readFileSync(path.join(__dirname, Neopixels.compFunctions[func])); | ||
| _.extend(Neopixels, Component); | ||
| module.exports = Neopixels; |
@@ -1,2 +0,2 @@ | ||
| int pixels(String color){ | ||
| int pixels_<%= name %>(String color){ | ||
| int bar = color.indexOf('|'); | ||
@@ -3,0 +3,0 @@ String index = color.substring(0, bar); |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
153559
2.19%427
0.71%