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.

166 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 <cstring>
  9. #include "led.h"
  10. // Scans input string with format
  11. // '<on1>,<off1>,<repeats1> <on2>,<off2>,<repeats2> ...'
  12. // Directly changing `led.pattern.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. led.pattern.delays.clear();
  21. loop:
  22. const char *yyt1;const char *yyt2;const char *yyt3;
  23. #line 37 "led_pattern.h"
  24. {
  25. char yych;
  26. static const unsigned char yybm[] = {
  27. 0, 0, 0, 0, 0, 0, 0, 0,
  28. 0, 64, 0, 0, 0, 0, 0, 0,
  29. 0, 0, 0, 0, 0, 0, 0, 0,
  30. 0, 0, 0, 0, 0, 0, 0, 0,
  31. 64, 0, 0, 0, 0, 0, 0, 0,
  32. 0, 0, 0, 0, 0, 0, 0, 0,
  33. 128, 128, 128, 128, 128, 128, 128, 128,
  34. 128, 128, 0, 0, 0, 0, 0, 0,
  35. 0, 0, 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. };
  60. yych = (char)*p;
  61. if (yybm[0+yych] & 64) {
  62. goto yy4;
  63. }
  64. if (yych <= '/') goto yy2;
  65. if (yych <= '9') {
  66. yyt1 = p;
  67. goto yy7;
  68. }
  69. yy2:
  70. ++p;
  71. yy3:
  72. #line 45 "led_pattern.h.in"
  73. { return; }
  74. #line 88 "led_pattern.h"
  75. yy4:
  76. yych = (char)*++p;
  77. if (yybm[0+yych] & 64) {
  78. goto yy4;
  79. }
  80. #line 46 "led_pattern.h.in"
  81. { goto loop; }
  82. #line 96 "led_pattern.h"
  83. yy7:
  84. yych = (char)*(marker = ++p);
  85. if (yybm[0+yych] & 128) {
  86. goto yy10;
  87. }
  88. if (yych != ',') goto yy3;
  89. yy8:
  90. yych = (char)*++p;
  91. if (yych <= '/') goto yy9;
  92. if (yych <= '9') {
  93. yyt2 = p;
  94. goto yy12;
  95. }
  96. yy9:
  97. p = marker;
  98. goto yy3;
  99. yy10:
  100. yych = (char)*++p;
  101. if (yybm[0+yych] & 128) {
  102. goto yy10;
  103. }
  104. if (yych == ',') goto yy8;
  105. goto yy9;
  106. yy12:
  107. yych = (char)*++p;
  108. if (yych == ',') goto yy14;
  109. if (yych <= '/') goto yy9;
  110. if (yych <= '9') goto yy12;
  111. goto yy9;
  112. yy14:
  113. yych = (char)*++p;
  114. if (yych <= '/') goto yy9;
  115. if (yych >= ':') goto yy9;
  116. yyt3 = p;
  117. yy15:
  118. yych = (char)*++p;
  119. if (yych <= '/') goto yy17;
  120. if (yych <= '9') goto yy15;
  121. yy17:
  122. d1 = yyt1;
  123. d2 = yyt2;
  124. d3 = yyt3;
  125. #line 47 "led_pattern.h.in"
  126. {
  127. unsigned long on;
  128. unsigned long off;
  129. unsigned char repeats;
  130. memcpy(buffer, d1, int(d2 - d1));
  131. buffer[int(d2 - d1 - 1)] = '\0';
  132. on = strtoul(buffer, nullptr, 10);
  133. memcpy(buffer, d2, int(d3 - d2));
  134. buffer[int(d3 - d2 - 1)] = '\0';
  135. off = strtoul(buffer, nullptr, 10);
  136. memcpy(buffer, d3, int(p - d3));
  137. buffer[int(p - d3)] = '\0';
  138. repeats = strtoul(buffer, nullptr, 10);
  139. led.pattern.delays.emplace_back(
  140. on, off, repeats
  141. );
  142. goto loop;
  143. }
  144. #line 163 "led_pattern.h"
  145. }
  146. #line 70 "led_pattern.h.in"
  147. }