fastled 1.2.41__tar.gz → 1.2.42__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. {fastled-1.2.41 → fastled-1.2.42}/PKG-INFO +1 -1
  2. {fastled-1.2.41 → fastled-1.2.42}/compiler/init_runtime.py +7 -3
  3. fastled-1.2.42/src/fastled/__init__.py +219 -0
  4. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/app.py +6 -0
  5. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/parse_args.py +4 -0
  6. {fastled-1.2.41 → fastled-1.2.42}/src/fastled.egg-info/PKG-INFO +1 -1
  7. {fastled-1.2.41 → fastled-1.2.42}/src/fastled.egg-info/SOURCES.txt +0 -4
  8. fastled-1.2.41/compiler/Arduino.cpp +0 -11
  9. fastled-1.2.41/compiler/Arduino.h +0 -162
  10. fastled-1.2.41/src/fastled/__init__.py +0 -423
  11. fastled-1.2.41/tests/test_build_from_docker.py +0 -49
  12. fastled-1.2.41/tests/test_build_from_github.py +0 -49
  13. {fastled-1.2.41 → fastled-1.2.42}/.aiderignore +0 -0
  14. {fastled-1.2.41 → fastled-1.2.42}/.github/workflows/build_multi_docker_image.yml +0 -0
  15. {fastled-1.2.41 → fastled-1.2.42}/.github/workflows/build_webpage.yml +0 -0
  16. {fastled-1.2.41 → fastled-1.2.42}/.github/workflows/lint.yml +0 -0
  17. {fastled-1.2.41 → fastled-1.2.42}/.github/workflows/publish_release.yml +0 -0
  18. {fastled-1.2.41 → fastled-1.2.42}/.github/workflows/test_build_exe.yml +0 -0
  19. {fastled-1.2.41 → fastled-1.2.42}/.github/workflows/test_macos.yml +0 -0
  20. {fastled-1.2.41 → fastled-1.2.42}/.github/workflows/test_ubuntu.yml +0 -0
  21. {fastled-1.2.41 → fastled-1.2.42}/.github/workflows/test_win.yml +0 -0
  22. {fastled-1.2.41 → fastled-1.2.42}/.gitignore +0 -0
  23. {fastled-1.2.41 → fastled-1.2.42}/.pylintrc +0 -0
  24. {fastled-1.2.41 → fastled-1.2.42}/.vscode/launch.json +0 -0
  25. {fastled-1.2.41 → fastled-1.2.42}/.vscode/settings.json +0 -0
  26. {fastled-1.2.41 → fastled-1.2.42}/.vscode/tasks.json +0 -0
  27. {fastled-1.2.41 → fastled-1.2.42}/Dockerfile +0 -0
  28. {fastled-1.2.41 → fastled-1.2.42}/LICENSE +0 -0
  29. {fastled-1.2.41 → fastled-1.2.42}/MANIFEST.in +0 -0
  30. {fastled-1.2.41 → fastled-1.2.42}/README.md +0 -0
  31. {fastled-1.2.41 → fastled-1.2.42}/RELEASE.md +0 -0
  32. {fastled-1.2.41 → fastled-1.2.42}/TODO.md +0 -0
  33. {fastled-1.2.41 → fastled-1.2.42}/build_exe.py +0 -0
  34. {fastled-1.2.41 → fastled-1.2.42}/build_site.py +0 -0
  35. {fastled-1.2.41 → fastled-1.2.42}/clean +0 -0
  36. {fastled-1.2.41 → fastled-1.2.42}/compiler/.dockerignore +0 -0
  37. {fastled-1.2.41 → fastled-1.2.42}/compiler/CMakeLists.txt +0 -0
  38. {fastled-1.2.41 → fastled-1.2.42}/compiler/__init__.py +0 -0
  39. {fastled-1.2.41 → fastled-1.2.42}/compiler/arduino-pre-process.sh +0 -0
  40. {fastled-1.2.41 → fastled-1.2.42}/compiler/build.sh +0 -0
  41. {fastled-1.2.41 → fastled-1.2.42}/compiler/build_archive.sh +0 -0
  42. {fastled-1.2.41 → fastled-1.2.42}/compiler/build_fast.sh +0 -0
  43. {fastled-1.2.41 → fastled-1.2.42}/compiler/code_sync.py +0 -0
  44. {fastled-1.2.41 → fastled-1.2.42}/compiler/compile.py +0 -0
  45. {fastled-1.2.41 → fastled-1.2.42}/compiler/compile_lock.py +0 -0
  46. {fastled-1.2.41 → fastled-1.2.42}/compiler/entrypoint.sh +0 -0
  47. {fastled-1.2.41 → fastled-1.2.42}/compiler/extra/100dots.html +0 -0
  48. {fastled-1.2.41 → fastled-1.2.42}/compiler/extra/demo_threejs.html +0 -0
  49. {fastled-1.2.41 → fastled-1.2.42}/compiler/extra/webgl_postprocessing_unreal_bloom.html +0 -0
  50. {fastled-1.2.41 → fastled-1.2.42}/compiler/final_prewarm.sh +0 -0
  51. {fastled-1.2.41 → fastled-1.2.42}/compiler/index.css +0 -0
  52. {fastled-1.2.41 → fastled-1.2.42}/compiler/index.html +0 -0
  53. {fastled-1.2.41 → fastled-1.2.42}/compiler/index.js +0 -0
  54. {fastled-1.2.41 → fastled-1.2.42}/compiler/install-arduino-cli.sh +0 -0
  55. {fastled-1.2.41 → fastled-1.2.42}/compiler/modules/graphics_manager.js +0 -0
  56. {fastled-1.2.41 → fastled-1.2.42}/compiler/modules/graphics_manager_threejs.js +0 -0
  57. {fastled-1.2.41 → fastled-1.2.42}/compiler/modules/ui_manager.js +0 -0
  58. {fastled-1.2.41 → fastled-1.2.42}/compiler/platformio.ini +0 -0
  59. {fastled-1.2.41 → fastled-1.2.42}/compiler/pre-process.sh +0 -0
  60. {fastled-1.2.41 → fastled-1.2.42}/compiler/prewarm.sh +0 -0
  61. {fastled-1.2.41 → fastled-1.2.42}/compiler/process-ino.py +0 -0
  62. {fastled-1.2.41 → fastled-1.2.42}/compiler/requirements.txt +0 -0
  63. {fastled-1.2.41 → fastled-1.2.42}/compiler/run.py +0 -0
  64. {fastled-1.2.41 → fastled-1.2.42}/compiler/server.py +0 -0
  65. {fastled-1.2.41 → fastled-1.2.42}/compiler/sketch_hasher.py +0 -0
  66. {fastled-1.2.41 → fastled-1.2.42}/compiler/wasm_compiler_flags.py +0 -0
  67. {fastled-1.2.41 → fastled-1.2.42}/docker-compose.yml +0 -0
  68. {fastled-1.2.41 → fastled-1.2.42}/install +0 -0
  69. {fastled-1.2.41 → fastled-1.2.42}/install_linux.sh +0 -0
  70. {fastled-1.2.41 → fastled-1.2.42}/lint +0 -0
  71. {fastled-1.2.41 → fastled-1.2.42}/pyproject.toml +0 -0
  72. {fastled-1.2.41 → fastled-1.2.42}/requirements.testing.txt +0 -0
  73. {fastled-1.2.41 → fastled-1.2.42}/setup.cfg +0 -0
  74. {fastled-1.2.41 → fastled-1.2.42}/setup.py +0 -0
  75. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/assets/example.txt +0 -0
  76. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/cli.py +0 -0
  77. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/client_server.py +0 -0
  78. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/compile_server.py +0 -0
  79. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/compile_server_impl.py +0 -0
  80. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/docker_manager.py +0 -0
  81. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/filewatcher.py +0 -0
  82. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/interactive_srcs.py +0 -0
  83. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/keyboard.py +0 -0
  84. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/live_client.py +0 -0
  85. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/open_browser.py +0 -0
  86. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/open_browser2.py +0 -0
  87. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/paths.py +0 -0
  88. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/project_init.py +0 -0
  89. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/select_sketch_directory.py +0 -0
  90. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/settings.py +0 -0
  91. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/site/build.py +0 -0
  92. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/sketch.py +0 -0
  93. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/spinner.py +0 -0
  94. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/string_diff.py +0 -0
  95. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/test/can_run_local_docker_tests.py +0 -0
  96. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/test/examples.py +0 -0
  97. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/types.py +0 -0
  98. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/util.py +0 -0
  99. {fastled-1.2.41 → fastled-1.2.42}/src/fastled/web_compile.py +0 -0
  100. {fastled-1.2.41 → fastled-1.2.42}/src/fastled.egg-info/dependency_links.txt +0 -0
  101. {fastled-1.2.41 → fastled-1.2.42}/src/fastled.egg-info/entry_points.txt +0 -0
  102. {fastled-1.2.41 → fastled-1.2.42}/src/fastled.egg-info/requires.txt +0 -0
  103. {fastled-1.2.41 → fastled-1.2.42}/src/fastled.egg-info/top_level.txt +0 -0
  104. {fastled-1.2.41 → fastled-1.2.42}/test +0 -0
  105. {fastled-1.2.41 → fastled-1.2.42}/tests/html/index.html +0 -0
  106. {fastled-1.2.41 → fastled-1.2.42}/tests/test_api.py +0 -0
  107. {fastled-1.2.41 → fastled-1.2.42}/tests/test_bad_ino.py +0 -0
  108. {fastled-1.2.41 → fastled-1.2.42}/tests/test_build_examples.py +0 -0
  109. {fastled-1.2.41 → fastled-1.2.42}/tests/test_cli.py +0 -0
  110. {fastled-1.2.41 → fastled-1.2.42}/tests/test_compile_server.py +0 -0
  111. {fastled-1.2.41 → fastled-1.2.42}/tests/test_docker_linux_on_windows.py +0 -0
  112. {fastled-1.2.41 → fastled-1.2.42}/tests/test_embedded_data.py +0 -0
  113. {fastled-1.2.41 → fastled-1.2.42}/tests/test_examples.py +0 -0
  114. {fastled-1.2.41 → fastled-1.2.42}/tests/test_filechanger.py +0 -0
  115. {fastled-1.2.41 → fastled-1.2.42}/tests/test_http_server.py +0 -0
  116. {fastled-1.2.41 → fastled-1.2.42}/tests/test_ino/bad/bad.ino +0 -0
  117. {fastled-1.2.41 → fastled-1.2.42}/tests/test_ino/bad_platformio/bad_platformio.ino +0 -0
  118. {fastled-1.2.41 → fastled-1.2.42}/tests/test_ino/bad_platformio/platformio.ini +0 -0
  119. {fastled-1.2.41 → fastled-1.2.42}/tests/test_ino/embedded/data/bigdata.dat +0 -0
  120. {fastled-1.2.41 → fastled-1.2.42}/tests/test_ino/embedded/wasm.ino +0 -0
  121. {fastled-1.2.41 → fastled-1.2.42}/tests/test_ino/wasm/wasm.ino +0 -0
  122. {fastled-1.2.41 → fastled-1.2.42}/tests/test_project_init.py +0 -0
  123. {fastled-1.2.41 → fastled-1.2.42}/tests/test_server_and_client_seperatly.py +0 -0
  124. {fastled-1.2.41 → fastled-1.2.42}/tests/test_webcompile.py +0 -0
  125. {fastled-1.2.41 → fastled-1.2.42}/upload_package.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fastled
3
- Version: 1.2.41
3
+ Version: 1.2.42
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -9,9 +9,10 @@ HERE = Path(__file__).parent
9
9
 
10
10
 
11
11
  _COMPILER_DIR = Path("/js/compiler")
12
+ _FASTLED_SRC_DIR = Path("/js/fastled/src")
13
+ _WASM_DIR = _FASTLED_SRC_DIR / "platforms" / "wasm"
12
14
 
13
-
14
- def task(src: str | Path) -> None:
15
+ def copy_task(src: str | Path) -> None:
15
16
  src = Path(src)
16
17
  if "entrypoint.sh" in str(src):
17
18
  return
@@ -49,9 +50,12 @@ def make_links() -> None:
49
50
  for pattern in patterns:
50
51
  files.extend(glob.glob(str(_COMPILER_DIR / pattern)))
51
52
 
53
+ for pattern in patterns:
54
+ files.extend(glob.glob(str(_WASM_DIR / pattern)))
55
+
52
56
  # Process files in parallel using ThreadPoolExecutor
53
57
  with ThreadPoolExecutor(max_workers=16) as executor:
54
- executor.map(task, files)
58
+ executor.map(copy_task, files)
55
59
 
56
60
 
57
61
  def init_runtime() -> None:
@@ -0,0 +1,219 @@
1
+ """FastLED Wasm Compiler package."""
2
+
3
+ from contextlib import contextmanager
4
+ from multiprocessing import Process
5
+ from pathlib import Path
6
+ from typing import Generator
7
+
8
+ from .compile_server import CompileServer
9
+ from .live_client import LiveClient
10
+ from .site.build import build
11
+ from .types import BuildMode, CompileResult, CompileServerError
12
+
13
+ # IMPORTANT! There's a bug in github which will REJECT any version update
14
+ # that has any other change in the repo. Please bump the version as the
15
+ # ONLY change in a commit, or else the pypi update and the release will fail.
16
+ __version__ = "1.2.42"
17
+
18
+ DOCKER_FILE = (
19
+ "https://raw.githubusercontent.com/zackees/fastled-wasm/refs/heads/main/Dockerfile"
20
+ )
21
+
22
+
23
+ class Api:
24
+ @staticmethod
25
+ def get_examples(host: str | CompileServer | None = None) -> list[str]:
26
+ from fastled.project_init import get_examples
27
+
28
+ if isinstance(host, CompileServer):
29
+ host = host.url()
30
+
31
+ return get_examples(host=host)
32
+
33
+ @staticmethod
34
+ def project_init(
35
+ example=None, outputdir=None, host: str | CompileServer | None = None
36
+ ) -> Path:
37
+ from fastled.project_init import project_init
38
+
39
+ if isinstance(host, CompileServer):
40
+ host = host.url()
41
+ return project_init(example, outputdir, host)
42
+
43
+ @staticmethod
44
+ def web_compile(
45
+ directory: Path | str,
46
+ host: str | CompileServer | None = None,
47
+ build_mode: BuildMode = BuildMode.QUICK,
48
+ profile: bool = False, # When true then profile information will be enabled and included in the zip.
49
+ ) -> CompileResult:
50
+ from fastled.web_compile import web_compile
51
+
52
+ if isinstance(host, CompileServer):
53
+ host = host.url()
54
+ if isinstance(directory, str):
55
+ directory = Path(directory)
56
+ out: CompileResult = web_compile(
57
+ directory, host, build_mode=build_mode, profile=profile
58
+ )
59
+ return out
60
+
61
+ @staticmethod
62
+ def live_client(
63
+ sketch_directory: Path,
64
+ host: str | CompileServer | None = None,
65
+ auto_updates: bool = True,
66
+ auto_start=True,
67
+ open_web_browser=True,
68
+ keep_running=True,
69
+ build_mode=BuildMode.QUICK,
70
+ profile=False,
71
+ ) -> LiveClient:
72
+ return LiveClient(
73
+ sketch_directory=sketch_directory,
74
+ host=host,
75
+ auto_updates=auto_updates,
76
+ auto_start=auto_start,
77
+ open_web_browser=open_web_browser,
78
+ keep_running=keep_running,
79
+ build_mode=build_mode,
80
+ profile=profile,
81
+ )
82
+
83
+ @staticmethod
84
+ def spawn_server(
85
+ interactive=False,
86
+ auto_updates=None,
87
+ auto_start=True,
88
+ mapped_dir: Path | None = None, # Sketch directory.
89
+ container_name: str | None = None, # Specific docker container name.
90
+ remove_previous: bool = False,
91
+ ) -> CompileServer:
92
+ """Uses docker to spawn a compile server from the given name."""
93
+ from fastled.compile_server import CompileServer
94
+
95
+ out = CompileServer(
96
+ container_name=container_name,
97
+ interactive=interactive,
98
+ auto_updates=auto_updates,
99
+ mapped_dir=mapped_dir,
100
+ auto_start=auto_start,
101
+ remove_previous=remove_previous,
102
+ )
103
+ return out
104
+
105
+ @staticmethod
106
+ @contextmanager
107
+ def server(
108
+ interactive=False,
109
+ auto_updates=None,
110
+ auto_start=True,
111
+ mapped_dir: Path | None = None, # Sketch directory.
112
+ container_name: str | None = None, # Specific docker container name.
113
+ remove_previous=False,
114
+ ) -> Generator[CompileServer, None, None]:
115
+ server = Api.spawn_server(
116
+ interactive=interactive,
117
+ auto_updates=auto_updates,
118
+ auto_start=auto_start,
119
+ mapped_dir=mapped_dir,
120
+ container_name=container_name,
121
+ remove_previous=remove_previous,
122
+ )
123
+ try:
124
+ yield server
125
+ finally:
126
+ server.stop()
127
+
128
+
129
+ class Docker:
130
+ @staticmethod
131
+ def is_installed() -> bool:
132
+ from fastled.docker_manager import DockerManager
133
+
134
+ return DockerManager.is_docker_installed()
135
+
136
+ @staticmethod
137
+ def is_running() -> bool:
138
+ from fastled.docker_manager import DockerManager
139
+
140
+ return DockerManager.is_running()
141
+
142
+ @staticmethod
143
+ def is_container_running(container_name: str | None = None) -> bool:
144
+ # from fastled.docker import is_container_running
145
+ from fastled.docker_manager import DockerManager
146
+ from fastled.settings import CONTAINER_NAME
147
+
148
+ docker_mgr = DockerManager()
149
+ container_name = container_name or CONTAINER_NAME
150
+ return docker_mgr.is_container_running(container_name)
151
+
152
+ @staticmethod
153
+ def purge() -> None:
154
+ from fastled.docker_manager import DockerManager
155
+ from fastled.settings import IMAGE_NAME
156
+
157
+ docker_mgr = DockerManager()
158
+ docker_mgr.purge(image_name=IMAGE_NAME)
159
+
160
+
161
+ class Tools:
162
+ @staticmethod
163
+ def string_diff(needle: str, haystack: list[str]) -> list[tuple[float, str]]:
164
+ """Returns a sorted list with the top matches at the beginning."""
165
+ from fastled.string_diff import string_diff
166
+
167
+ return string_diff(needle, haystack)
168
+
169
+
170
+ class Test:
171
+ __test__ = False # This prevents unittest from recognizing it as a test class.
172
+
173
+ @staticmethod
174
+ def can_run_local_docker_tests() -> bool:
175
+ from fastled.test.can_run_local_docker_tests import can_run_local_docker_tests
176
+
177
+ return can_run_local_docker_tests()
178
+
179
+ @staticmethod
180
+ def test_examples(
181
+ examples: list[str] | None = None, host: str | CompileServer | None = None
182
+ ) -> dict[str, Exception]:
183
+ from fastled.test.examples import test_examples
184
+
185
+ if isinstance(host, CompileServer):
186
+ host = host.url()
187
+
188
+ return test_examples(examples=examples, host=host)
189
+
190
+ @staticmethod
191
+ def build_site(outputdir: Path, fast: bool | None = None, check: bool = True):
192
+ """Builds the FastLED compiler site."""
193
+ build(outputdir=outputdir, fast=fast, check=check)
194
+
195
+ @staticmethod
196
+ def spawn_http_server(
197
+ directory: Path | str = Path("."),
198
+ port: int | None = None,
199
+ open_browser: bool = True,
200
+ ) -> Process:
201
+ from fastled.open_browser import open_browser_process
202
+
203
+ if isinstance(directory, str):
204
+ directory = Path(directory)
205
+ proc: Process = open_browser_process(
206
+ directory, port=port, open_browser=open_browser
207
+ )
208
+ return proc
209
+
210
+
211
+ __all__ = [
212
+ "Api",
213
+ "Test",
214
+ "Build",
215
+ "CompileServer",
216
+ "CompileResult",
217
+ "CompileServerError",
218
+ "BuildMode",
219
+ ]
@@ -60,6 +60,11 @@ def main() -> int:
60
60
  return 0
61
61
 
62
62
  if build:
63
+ print("Building is disabled")
64
+ build = False
65
+
66
+ if build:
67
+ raise NotImplementedError("Building is not yet supported.")
63
68
  file_watcher_set(False)
64
69
  project_root = Path(".").absolute()
65
70
  print(f"Building Docker image at {project_root}")
@@ -110,6 +115,7 @@ def main() -> int:
110
115
  if __name__ == "__main__":
111
116
  # Note that the entry point for the exe is in cli.py
112
117
  try:
118
+ sys.argv.append("-i")
113
119
  sys.argv.append("-b")
114
120
  # sys.argv.append("examples/wasm")
115
121
  # sys.argv.append()
@@ -155,6 +155,10 @@ def parse_args() -> Args:
155
155
  os.chdir(fastled_dir)
156
156
  if args.directory is None:
157
157
  args.directory = str(Path("examples/wasm").absolute())
158
+ if args.interactive:
159
+ if not args.build:
160
+ print("Adding --build flag when using --interactive")
161
+ args.build = True
158
162
  return Args.from_namespace(args)
159
163
 
160
164
  if not args.update:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: fastled
3
- Version: 1.2.41
3
+ Version: 1.2.42
4
4
  Summary: FastLED Wasm Compiler
5
5
  Home-page: https://github.com/zackees/fastled-wasm
6
6
  Maintainer: Zachary Vorhies
@@ -31,8 +31,6 @@ upload_package.sh
31
31
  .vscode/settings.json
32
32
  .vscode/tasks.json
33
33
  compiler/.dockerignore
34
- compiler/Arduino.cpp
35
- compiler/Arduino.h
36
34
  compiler/CMakeLists.txt
37
35
  compiler/__init__.py
38
36
  compiler/arduino-pre-process.sh
@@ -101,8 +99,6 @@ src/fastled/test/examples.py
101
99
  tests/test_api.py
102
100
  tests/test_bad_ino.py
103
101
  tests/test_build_examples.py
104
- tests/test_build_from_docker.py
105
- tests/test_build_from_github.py
106
102
  tests/test_cli.py
107
103
  tests/test_compile_server.py
108
104
  tests/test_docker_linux_on_windows.py
@@ -1,11 +0,0 @@
1
-
2
- #ifdef __EMSCRIPTEN__
3
-
4
- #include "./Arduino.h"
5
-
6
- SerialEmulation Serial;
7
- SerialEmulation Serial1;
8
- SerialEmulation Serial2;
9
- SerialEmulation Serial3;
10
-
11
- #endif
@@ -1,162 +0,0 @@
1
- // Arduino.h emulation for the WebAssembly platform.
2
- // This allows us to compile sketches as is for the WebAssembly platform.
3
-
4
- #pragma once
5
-
6
- #include "fl/str.h"
7
- #include <algorithm>
8
- #include <random>
9
- #include <stdint.h>
10
- #include <stdio.h>
11
- #include <string>
12
-
13
- #include "fl/namespace.h"
14
-
15
- FASTLED_USING_NAMESPACE
16
-
17
- using std::max;
18
- using std::min;
19
-
20
-
21
- namespace fl {
22
- class Str;
23
- inline long map(long x, long in_min, long in_max, long out_min, long out_max) {
24
- const long run = in_max - in_min;
25
- if (run == 0) {
26
- return 0; // AVR returns -1, SAM returns 0
27
- }
28
- const long rise = out_max - out_min;
29
- const long delta = x - in_min;
30
- return (delta * rise) / run + out_min;
31
- }
32
-
33
- // constrain
34
- template <typename T> T constrain(T x, T a, T b) {
35
- return x < a ? a : (x > b ? b : x);
36
- }
37
- } // namespace fl
38
-
39
-
40
- using fl::map;
41
- using fl::constrain;
42
-
43
-
44
- inline long random(long min, long max) {
45
- std::random_device rd;
46
- std::mt19937 gen(rd());
47
- // Arduino random is exclusive of the max value, but
48
- // std::uniform_int_distribution is inclusive. So we subtract 1 from the max
49
- // value.
50
- std::uniform_int_distribution<> dis(min, max - 1);
51
- return dis(gen);
52
- }
53
-
54
-
55
- inline int analogRead(int) { return random(0, 1023); }
56
-
57
- inline long random(long max) { return random(0, max); }
58
-
59
- template <typename T> struct PrintHelper {};
60
-
61
- #define DEFINE_PRINT_HELPER(type, format) \
62
- template <> struct PrintHelper<type> { \
63
- static void print(type val) { printf(format, val); } \
64
- static void println(type val) { \
65
- printf(format, val); \
66
- printf("\n"); \
67
- } \
68
- }
69
-
70
- #define DEFINE_PRINT_HELPER_EXT(type, format, val_opp) \
71
- template <> struct PrintHelper<type> { \
72
- static void print(type val) { printf(format, val_opp); } \
73
- static void println(type val) { \
74
- printf(format, val_opp); \
75
- printf("\n"); \
76
- } \
77
- }
78
-
79
- // gcc push options
80
- #pragma GCC diagnostic push
81
- #pragma GCC diagnostic ignored "-Wformat"
82
-
83
- DEFINE_PRINT_HELPER(double, "%f");
84
- DEFINE_PRINT_HELPER(float, "%f");
85
- DEFINE_PRINT_HELPER(const char *, "%s");
86
- DEFINE_PRINT_HELPER(uint64_t, "%lu");
87
- DEFINE_PRINT_HELPER(uint32_t, "%u");
88
- DEFINE_PRINT_HELPER(uint16_t, "%u");
89
- DEFINE_PRINT_HELPER(uint8_t, "%u");
90
- DEFINE_PRINT_HELPER(int64_t, "%ld");
91
- DEFINE_PRINT_HELPER(int32_t, "%d");
92
- DEFINE_PRINT_HELPER(int16_t, "%d");
93
- DEFINE_PRINT_HELPER(int8_t, "%d");
94
- DEFINE_PRINT_HELPER(bool, "%d");
95
- DEFINE_PRINT_HELPER_EXT(std::string, "%s", val.c_str());
96
- DEFINE_PRINT_HELPER_EXT(fl::Str, "%s", val.c_str());
97
-
98
- #ifdef __EMSCRIPTEN__
99
- DEFINE_PRINT_HELPER(unsigned long, "%lu"); // Not sure why this is needed in emscripten
100
- #endif
101
-
102
- #define A0 0
103
- #define A1 1
104
- #define A2 2
105
- #define A3 3
106
- #define A4 4
107
- #define A5 5
108
-
109
-
110
- // gcc pop options
111
- #pragma GCC diagnostic pop
112
-
113
- struct SerialEmulation {
114
- void begin(int) {}
115
- template <typename T> void print(T val) { PrintHelper<T>::print(val); }
116
- template <typename T> void println(T val) { PrintHelper<T>::println(val); }
117
- void println() { printf("\n"); }
118
- int available() { return 0; }
119
- int read() { return 0; }
120
- void write(uint8_t) {}
121
- void write(const char *s) { printf("%s", s); }
122
- void write(const uint8_t *s, size_t n) { fwrite(s, 1, n, stdout); }
123
- void write(const char *s, size_t n) { fwrite(s, 1, n, stdout); }
124
- void flush() {}
125
- void end() {}
126
- uint8_t peek() { return 0; }
127
- };
128
-
129
- #define LED_BUILTIN 13
130
- #define HIGH 1
131
- #define LOW 0
132
- #define INPUT 0
133
- #define OUTPUT 1
134
- #define INPUT_PULLUP 2
135
-
136
-
137
- inline void digitalWrite(int, int) {}
138
- inline void analogWrite(int, int) {}
139
- inline int digitalRead(int) { return LOW; }
140
- inline void pinMode(int, int) {}
141
-
142
- // avr flash memory macro is disabled.
143
- #ifdef F
144
- #undef F
145
- #endif
146
-
147
- #define F(x) x
148
-
149
- // Found in the wild for scintillating example
150
- #ifdef FL_PGM_READ_PTR_NEAR
151
- #undef FL_PGM_READ_PTR_NEAR
152
- #endif
153
-
154
- #define FL_PGM_READ_PTR_NEAR(addr) (*(addr))
155
- typedef unsigned char byte;
156
-
157
- extern SerialEmulation Serial;
158
- extern SerialEmulation Serial1;
159
- extern SerialEmulation Serial2;
160
- extern SerialEmulation Serial3;
161
- typedef SerialEmulation HardwareSerial;
162
- typedef SerialEmulation SoftwareSerial;