introduction_tour.ino 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. ____ ___ ____ _ _ ____ ____ ____ _ ____ _ _ _ ____ _ _ _ ___ ____ ____ /
  3. | | |__] |___ |\ | [__ |___ |__/ | |__| | |\/| | | |\ | | | | | |__/ /
  4. |__| | |___ | \| ___] |___ | \ | | | |___ | | |__| | \| | | |__| | \ .
  5. (115200 Baud)
  6. */
  7. void title(){
  8. Serial.println(F("----------------------------------"));
  9. Serial.println(F(" Lixie II Introduction Tour "));
  10. Serial.println(F(" by Connor Nishijima "));
  11. Serial.println(F(" November 1st, 2019 "));
  12. Serial.println();
  13. Serial.println(F(" Released under the GPLv3 License "));
  14. Serial.println(F("----------------------------------"));
  15. }
  16. #include "Lixie_II.h" // Include Lixie Library
  17. #define DATA_PIN 13 // Pin to drive Lixies (D7 on Wemos)
  18. #define NUM_LIXIES 4 // How many Lixies you have
  19. Lixie_II lix(DATA_PIN, NUM_LIXIES);
  20. uint16_t function_wait = 8000;
  21. void setup() {
  22. Serial.begin(115200);
  23. lix.begin(); // Initialize LEDs
  24. lix.white_balance(Tungsten100W); // Default
  25. // Can be: Tungsten40W, Tungsten100W,
  26. // Halogen, CarbonArc,
  27. // HighNoonSun, DirectSunlight,
  28. // OvercastSky, ClearBlueSky
  29. // 2,600K - 20,000K
  30. delay(1000);
  31. }
  32. void loop() {
  33. title();
  34. run_demo();
  35. }
  36. void run_demo(){
  37. lix.color_all(ON, CRGB(0,255,255)); // Start with cyan color
  38. delay(1000);
  39. Serial.println("This is a tour of the basic and advanced features of the Lixie II library!\n");
  40. delay(2000);
  41. Serial.println("Let's begin!\n");
  42. delay(3000);
  43. Serial.println("Lixie II can take integers, char arrays, or floats as input with lix.write() and lix.write_float(). (Any non-numeric chars are ignored)\n");
  44. lix.write_float(2.0, 1);
  45. delay(function_wait);
  46. Serial.println("For the Nixie fans, Lixie II offers the lix.nixie() function to shortcut you to pleasant Nixie tube colors!\n");
  47. lix.nixie();
  48. lix.write(222222);
  49. delay(function_wait);
  50. Serial.println("Lixie II operates with 'ON' and 'OFF' colors.");
  51. Serial.println("Currently, the ON color is orange, and the OFF");
  52. Serial.println("color is a dark blue.\n");
  53. delay(function_wait);
  54. Serial.println("They can be configured independently in the lix.color_all(<ON/OFF>, CRGB col) function.");
  55. Serial.println("I've now used color_all(OFF, CRGB(0,8,0)); to change the blue to a dark green!\n");
  56. lix.color_all(OFF, CRGB(0,10,0));
  57. delay(function_wait);
  58. Serial.println("Lixies can also have two colors per digit by using lix.color_all_dual(ON, CRGB col1, CRGB col2);!\n");
  59. lix.color_all_dual(ON, CRGB(255,0,0), CRGB(0,0,255));
  60. delay(function_wait);
  61. Serial.println("Individual displays can also be colored with lix.color_display(index, <ON/OFF>, CRGB col)!\n");
  62. lix.color_display(1, ON, CRGB(255,0,0));
  63. lix.color_display(1, OFF, CRGB(0,0,10));
  64. delay(function_wait);
  65. Serial.println("Gradients are possible with lix.gradient_rgb(<ON/OFF>, CRGB col1, CRGB col2)!\n");
  66. lix.color_all(OFF, CRGB(0,0,0)); // Remove OFF color
  67. lix.gradient_rgb(ON, CRGB(255,0,255), CRGB(0,255,255));
  68. delay(function_wait);
  69. Serial.println("Lixies can also show 'streaks' at any position between left (0.0) and");
  70. Serial.println("right (1.0) with lix.streak(CRGB col, float pos, uint8_t blur);\n");
  71. lix.stop_animation(); // Necessary to prevent rendering of current numbers
  72. float iter = 0;
  73. uint32_t t_start = millis();
  74. while(millis() < t_start+function_wait){
  75. float pos = (sin(iter) + 1)/2.0;
  76. lix.streak(CRGB(0,255,0), pos, 8);
  77. iter += 0.02;
  78. delay(1);
  79. }
  80. Serial.println("Here's lix.streak() with 'blur' of '1' (none)\n");
  81. t_start = millis();
  82. while(millis() < t_start+function_wait){
  83. float pos = (sin(iter) + 1)/2.0;
  84. lix.streak(CRGB(0,255,0), pos, 1);
  85. iter += 0.02;
  86. delay(1);
  87. }
  88. Serial.println("These can be used to show a progress percentage, or 'busy' indicator while WiFi connects.\n");
  89. delay(3000);
  90. Serial.println("One shortcut to this functionality is lix.sweep_color(CRGB col, uint16_t speed, uint8_t blur);\n");
  91. for(uint8_t i = 0; i < 5; i++){
  92. lix.sweep_color(CRGB(0,0,255), 20, 5);
  93. }
  94. lix.start_animation(); // This resumes "number mode" after we stopped it above
  95. lix.nixie();
  96. Serial.println("Transitions between numbers can also be modified.");
  97. Serial.println("By default Lixie II uses a 250ms crossfade, but this can");
  98. Serial.println("be changed with lix.transition_time(ms) or lix.transition_type(<INSTANT/CROSSFADE>);\n");
  99. Serial.println("CROSSFADE...");
  100. for(uint8_t i = 0; i < 30; i++){
  101. lix.write(i);
  102. delay(250);
  103. }
  104. Serial.println("INSTANT!\n");
  105. lix.transition_type(INSTANT);
  106. for(uint8_t i = 0; i < 30; i++){
  107. lix.write(i);
  108. delay(250);
  109. }
  110. Serial.println("And to end our guided tour, here's a floating point of seconds elapsing, using lix.rainbow(uint8_t hue, uint8_t separation);");
  111. delay(3000);
  112. t_start = millis();
  113. float hue = 0;
  114. while(millis() < t_start+10000){
  115. uint32_t millis_passed = millis()-t_start;
  116. float seconds = millis_passed / 1000.0;
  117. lix.write_float(seconds, 2);
  118. lix.rainbow(hue, 20);
  119. hue += 0.1;
  120. delay(1);
  121. }
  122. lix.write_float(10.0, 2);
  123. delay(function_wait);
  124. Serial.println("\n\n");
  125. }