Fork of the espurna firmware for `mhsw` switches
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
3.9 KiB

  1. /* Generated by re2c 1.3 on Wed Mar 4 13:32:28 2020 */
  2. #line 1 "led_pattern.h.in"
  3. /*
  4. LED MODULE
  5. Copyright (C) 2020 by Maxim Prokhorov <prokhorov dot max at outlook dot com>
  6. */
  7. #pragma once
  8. #include "led.h"
  9. #include <cstring>
  10. // Scans input string with format
  11. // '<on1>,<off1>,<repeats1> <on2>,<off2>,<repeats2> ...'
  12. // Directly changing `LedPattern::delays` contents
  13. void _ledLoadPattern(led_t& led, const char* input) {
  14. char buffer[16];
  15. const char* d1;
  16. const char* d2;
  17. const char* d3;
  18. const char* p = input;
  19. const char* marker;
  20. auto& pattern = led.pattern();
  21. pattern.delays.clear();
  22. loop:
  23. const char *yyt1;const char *yyt2;const char *yyt3;
  24. #line 37 "led_pattern.h"
  25. {
  26. char yych;
  27. static const unsigned char yybm[] = {
  28. 0, 0, 0, 0, 0, 0, 0, 0,
  29. 0, 64, 0, 0, 0, 0, 0, 0,
  30. 0, 0, 0, 0, 0, 0, 0, 0,
  31. 0, 0, 0, 0, 0, 0, 0, 0,
  32. 64, 0, 0, 0, 0, 0, 0, 0,
  33. 0, 0, 0, 0, 0, 0, 0, 0,
  34. 128, 128, 128, 128, 128, 128, 128, 128,
  35. 128, 128, 0, 0, 0, 0, 0, 0,
  36. 0, 0, 0, 0, 0, 0, 0, 0,
  37. 0, 0, 0, 0, 0, 0, 0, 0,
  38. 0, 0, 0, 0, 0, 0, 0, 0,
  39. 0, 0, 0, 0, 0, 0, 0, 0,
  40. 0, 0, 0, 0, 0, 0, 0, 0,
  41. 0, 0, 0, 0, 0, 0, 0, 0,
  42. 0, 0, 0, 0, 0, 0, 0, 0,
  43. 0, 0, 0, 0, 0, 0, 0, 0,
  44. 0, 0, 0, 0, 0, 0, 0, 0,
  45. 0, 0, 0, 0, 0, 0, 0, 0,
  46. 0, 0, 0, 0, 0, 0, 0, 0,
  47. 0, 0, 0, 0, 0, 0, 0, 0,
  48. 0, 0, 0, 0, 0, 0, 0, 0,
  49. 0, 0, 0, 0, 0, 0, 0, 0,
  50. 0, 0, 0, 0, 0, 0, 0, 0,
  51. 0, 0, 0, 0, 0, 0, 0, 0,
  52. 0, 0, 0, 0, 0, 0, 0, 0,
  53. 0, 0, 0, 0, 0, 0, 0, 0,
  54. 0, 0, 0, 0, 0, 0, 0, 0,
  55. 0, 0, 0, 0, 0, 0, 0, 0,
  56. 0, 0, 0, 0, 0, 0, 0, 0,
  57. 0, 0, 0, 0, 0, 0, 0, 0,
  58. 0, 0, 0, 0, 0, 0, 0, 0,
  59. 0, 0, 0, 0, 0, 0, 0, 0,
  60. };
  61. yych = (char)*p;
  62. if (yybm[0+yych] & 64) {
  63. goto yy4;
  64. }
  65. if (yych <= '/') goto yy2;
  66. if (yych <= '9') {
  67. yyt1 = p;
  68. goto yy7;
  69. }
  70. yy2:
  71. ++p;
  72. yy3:
  73. #line 45 "led_pattern.h.in"
  74. { return; }
  75. #line 88 "led_pattern.h"
  76. yy4:
  77. yych = (char)*++p;
  78. if (yybm[0+yych] & 64) {
  79. goto yy4;
  80. }
  81. #line 46 "led_pattern.h.in"
  82. { goto loop; }
  83. #line 96 "led_pattern.h"
  84. yy7:
  85. yych = (char)*(marker = ++p);
  86. if (yybm[0+yych] & 128) {
  87. goto yy10;
  88. }
  89. if (yych != ',') goto yy3;
  90. yy8:
  91. yych = (char)*++p;
  92. if (yych <= '/') goto yy9;
  93. if (yych <= '9') {
  94. yyt2 = p;
  95. goto yy12;
  96. }
  97. yy9:
  98. p = marker;
  99. goto yy3;
  100. yy10:
  101. yych = (char)*++p;
  102. if (yybm[0+yych] & 128) {
  103. goto yy10;
  104. }
  105. if (yych == ',') goto yy8;
  106. goto yy9;
  107. yy12:
  108. yych = (char)*++p;
  109. if (yych == ',') goto yy14;
  110. if (yych <= '/') goto yy9;
  111. if (yych <= '9') goto yy12;
  112. goto yy9;
  113. yy14:
  114. yych = (char)*++p;
  115. if (yych <= '/') goto yy9;
  116. if (yych >= ':') goto yy9;
  117. yyt3 = p;
  118. yy15:
  119. yych = (char)*++p;
  120. if (yych <= '/') goto yy17;
  121. if (yych <= '9') goto yy15;
  122. yy17:
  123. d1 = yyt1;
  124. d2 = yyt2;
  125. d3 = yyt3;
  126. #line 47 "led_pattern.h.in"
  127. {
  128. unsigned long on;
  129. unsigned long off;
  130. unsigned char repeats;
  131. memcpy(buffer, d1, int(d2 - d1));
  132. buffer[int(d2 - d1 - 1)] = '\0';
  133. on = strtoul(buffer, nullptr, 10);
  134. memcpy(buffer, d2, int(d3 - d2));
  135. buffer[int(d3 - d2 - 1)] = '\0';
  136. off = strtoul(buffer, nullptr, 10);
  137. memcpy(buffer, d3, int(p - d3));
  138. buffer[int(p - d3)] = '\0';
  139. repeats = strtoul(buffer, nullptr, 10);
  140. pattern.delays.emplace_back(on, off, repeats);
  141. goto loop;
  142. }
  143. #line 163 "led_pattern.h"
  144. }
  145. #line 70 "led_pattern.h.in"
  146. }