proyectos:vestuario_aqa
Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anteriorRevisión previa | Próxima revisiónAmbos lados, revisión siguiente | ||
proyectos:vestuario_aqa [2019/12/03 01:53] – kz | proyectos:vestuario_aqa [2019/12/04 02:35] – [Código para el proyecto del corazon] brolin | ||
---|---|---|---|
Línea 359: | Línea 359: | ||
FastLED.show(); | FastLED.show(); | ||
} | } | ||
+ | |||
+ | |||
</ | </ | ||
+ | |||
+ | ==== Leds con plantower ==== | ||
+ | |||
+ | === platformio.ini === | ||
+ | |||
+ | <code c++> | ||
+ | ;PlatformIO Project Configuration File | ||
+ | ; | ||
+ | ; Build options: build flags, source filter | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; | ||
+ | ; Please visit documentation for the other options and examples | ||
+ | ; https:// | ||
+ | |||
+ | [env: | ||
+ | platform = espressif8266 | ||
+ | board = d1_mini | ||
+ | framework = arduino | ||
+ | lib_deps = FastLED, PMS Library, https:// | ||
+ | </ | ||
+ | |||
+ | === main.cpp === | ||
+ | <code c++> | ||
+ | /** | ||
+ | | ||
+ | This demo does the Knight Rider scanner effect with just a few lines of code | ||
+ | The speed and fadespeed need to be adjusted for different processor speeds | ||
+ | | ||
+ | */ | ||
+ | |||
+ | #include " | ||
+ | #include < | ||
+ | #include " | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | #define P_TOWER_RX D2 | ||
+ | #define P_TOWER_TX 6 | ||
+ | // Plantower | ||
+ | SoftwareSerial plantower_serial(P_TOWER_RX, | ||
+ | PMS pms(plantower_serial); | ||
+ | PMS::DATA data; | ||
+ | |||
+ | // Leds | ||
+ | #define DATA_PIN | ||
+ | #define CLK_PIN | ||
+ | #define LED_TYPE | ||
+ | #define COLOR_ORDER BGR | ||
+ | #define NUM_LEDS | ||
+ | #define BRIGHTNESS | ||
+ | CRGB leds[NUM_LEDS]; | ||
+ | |||
+ | //create one canvas and one brush with global scope | ||
+ | FastLEDPainterCanvas pixelcanvas = FastLEDPainterCanvas(NUM_LEDS); | ||
+ | FastLEDPainterBrush pixelbrush = FastLEDPainterBrush(& | ||
+ | |||
+ | CHSV brushcolor; //the brush and the canvas operate on HSV color space only | ||
+ | |||
+ | void setup() { | ||
+ | //initilize FastLED library | ||
+ | FastLED.addLeds< | ||
+ | |||
+ | plantower_serial.begin(9600); | ||
+ | Serial.begin(115200); | ||
+ | Serial.println(" | ||
+ | Serial.println(F(" | ||
+ | |||
+ | //check if ram allocation of brushes and canvases was successful (painting will not work if unsuccessful, | ||
+ | //this check is optional but helps to check if something does not work, especially on low ram chips like the Arduino Uno | ||
+ | if (pixelcanvas.isvalid() == false) Serial.println(F(" | ||
+ | else Serial.println(F(" | ||
+ | |||
+ | if (pixelbrush.isvalid() == false) Serial.println(F(" | ||
+ | else Serial.println(F(" | ||
+ | |||
+ | // | ||
+ | |||
+ | brushcolor.h = 0; //zero is red in HSV. Library uses 0-255 instead of 0-360 for colors (see https:// | ||
+ | brushcolor.s = 255; //full color saturation | ||
+ | brushcolor.v = 130; //about half the full brightness | ||
+ | |||
+ | pixelbrush.setSpeed(1200); | ||
+ | pixelbrush.setColor(brushcolor); | ||
+ | pixelbrush.setFadeSpeed(130); | ||
+ | pixelbrush.setFadeout(true); | ||
+ | pixelbrush.setBounce(true); | ||
+ | |||
+ | //this sets up the brush to paint pixels in red, the pixels fade out after they are painted (the brush is the size of one pixel and can only one pixel per brush update, see other examples to paint multiple pixels at once) | ||
+ | |||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | |||
+ | Serial.println(" | ||
+ | if (pms.readUntil(data)){ | ||
+ | Serial.print(" | ||
+ | // brushcolor.h = data.PM_AE_UG_2_5; | ||
+ | // pixelbrush.setColor(brushcolor); | ||
+ | // // pixelbrush.setFadeSpeed(data.PM_AE_UG_2_5*3); | ||
+ | Serial.print(" | ||
+ | // saveDataForAverage(data.PM_AE_UG_2_5, | ||
+ | } | ||
+ | else Serial.println(" | ||
+ | |||
+ | Serial.println(" | ||
+ | FastLED.clear(); | ||
+ | |||
+ | pixelbrush.paint(); | ||
+ | pixelcanvas.transfer(); | ||
+ | |||
+ | FastLED.show(); | ||
+ | } | ||
+ | </ | ||
proyectos/vestuario_aqa.txt · Última modificación: 2021/10/30 23:38 por kz