Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. #define REMOTEXY_MODE__ESP8266WIFI_LIB_POINT
  2. #include <ESP8266WiFi.h>
  3.  
  4. #include <RemoteXY.h>
  5.  
  6. // RemoteXY connection settings
  7. #define REMOTEXY_WIFI_SSID "Maturita"
  8. #define REMOTEXY_WIFI_PASSWORD "maturita"
  9. #define REMOTEXY_SERVER_PORT 6377
  10.  
  11.  
  12. // RemoteXY configurate
  13. #pragma pack(push, 1)
  14. uint8_t RemoteXY_CONF[] =
  15. { 255,4,0,0,0,36,0,8,24,2,
  16. 6,0,4,5,50,50,7,2,50,50,
  17. 24,24,2,1,60,23,34,16,4,63,
  18. 55,21,1,8,31,31,79,78,0,79,
  19. 70,70,0 };
  20.  
  21. // this structure defines all the variables of your control interface
  22. struct {
  23.  
  24. // input variable
  25. uint8_t LOOL_r; // =0..255 Red color value
  26. uint8_t LOOL_g; // =0..255 Green color value
  27. uint8_t LOOL_b; // =0..255 Blue color value
  28. uint8_t switch_1; // =1 if switch ON and =0 if OFF
  29.  
  30.  
  31. // other variable
  32. uint8_t connect_flag; // =1 if wire connected, else =0
  33.  
  34.  
  35. } RemoteXY;
  36. #pragma pack(pop)
  37.  
  38. /////////////////////////////////////////////
  39. // END RemoteXY include //
  40. /////////////////////////////////////////////
  41. #include <Adafruit_NeoPixel.h>
  42.  
  43.  
  44. #define PIN 14
  45. #define NUMPIXELS 100
  46. #define LED_COUNT 60
  47.  
  48. Adafruit_NeoPixel strip(LED_COUNT, PIN, NEO_GRB + NEO_KHZ400);
  49. int rain;
  50. int stav;
  51. void setup()
  52. {
  53. RemoteXY_Init ();
  54. strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
  55. strip.show(); // Turn OFF all pixels ASAP
  56. strip.setBrightness(150); // Set BRIGHTNESS to about 1/5 (max = 255)
  57. }
  58.  
  59. void loop() {
  60. {
  61. RemoteXY_Handler();
  62.  
  63. static uint8_t prevR = RemoteXY.LOOL_r;
  64. static uint8_t prevG = RemoteXY.LOOL_g;
  65. static uint8_t prevB = RemoteXY.LOOL_b;
  66.  
  67. if (RemoteXY.switch_1!=0) {
  68. rain = 1;
  69. stav = 1;
  70. goto skoc;
  71. } else {
  72. stav = 0;
  73. if ( RemoteXY.LOOL_r != prevR || RemoteXY.LOOL_g != prevG || RemoteXY.LOOL_b != prevB )
  74. {
  75. prevR = RemoteXY.LOOL_r;
  76. prevG = RemoteXY.LOOL_g;
  77. prevB = RemoteXY.LOOL_b;
  78. colorWipe( strip.Color( RemoteXY.LOOL_r, RemoteXY.LOOL_g, RemoteXY.LOOL_b ));
  79. }
  80. }
  81. }
  82.  
  83. skoc:
  84. switch(rain) {
  85. case 1:
  86. for(long firstPixelHue = 0; firstPixelHue < 2*65536; firstPixelHue += 256) {
  87. if (RemoteXY.switch_1==0) { break;}
  88. for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
  89. int pixelHue = firstPixelHue + (i * 65536L / strip.numPixels());
  90. strip.setPixelColor(i, strip.gamma32(strip.ColorHSV(pixelHue)));
  91. }
  92. strip.show(); // Update strip with new contents
  93. }
  94. break;
  95. }
  96. }
  97.  
  98.  
  99. void colorWipe(uint32_t color) {
  100. for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
  101. strip.setPixelColor(i, color); // Set pixel's color (in RAM)
  102. strip.show(); // Update strip to match
  103. }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement