micrOSDevToolKit 2.1.5__py3-none-any.whl → 2.26.1__py3-none-any.whl
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.
- env/driver_cp210x/.DS_Store +0 -0
- env/driver_cp210x/macOS_VCP_Driver/SiLabsUSBDriverDisk.dmg +0 -0
- env/driver_cp210x/macOS_VCP_Driver/macOS_VCP_Driver_Release_Notes.txt +17 -1
- micrOS/micropython/esp32-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32c3-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32c6-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32s2-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32s2-LOLIN_MINI-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32s3-4MBflash-20241129-v1.24.1.bin +0 -0
- micrOS/micropython/esp32s3-8MBflash-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/esp32s3_spiram_oct-20251209-v1.27.0.bin +0 -0
- micrOS/micropython/rpi-pico-w-20251209-v1.27.0.uf2 +0 -0
- micrOS/micropython/tinypico-20251209-v1.27.0.bin +0 -0
- micrOS/release_info/micrOS_ReleaseInfo/system_analysis_sum.json +191 -151
- micrOS/source/Auth.py +37 -0
- micrOS/source/Common.py +376 -102
- micrOS/source/Config.py +55 -25
- micrOS/source/Debug.py +54 -193
- micrOS/source/Espnow.py +404 -0
- micrOS/source/Files.py +207 -0
- micrOS/source/Hooks.py +88 -16
- micrOS/source/InterConnect.py +130 -46
- micrOS/source/Interrupts.py +8 -8
- micrOS/source/Logger.py +131 -0
- micrOS/source/Network.py +41 -21
- micrOS/source/Notify.py +74 -198
- micrOS/source/Pacman.py +326 -0
- micrOS/source/Scheduler.py +18 -55
- micrOS/source/Server.py +84 -217
- micrOS/source/Shell.py +103 -93
- micrOS/source/Tasks.py +239 -173
- micrOS/source/Time.py +21 -22
- micrOS/source/Types.py +89 -54
- micrOS/source/Web.py +485 -0
- micrOS/source/__pycache__/Common.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Debug.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Files.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Logger.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Scheduler.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Server.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/Shell.cpython-312.pyc +0 -0
- micrOS/source/__pycache__/replhelper.cpython-312.pyc +0 -0
- micrOS/source/helpers.py +132 -0
- micrOS/source/micrOS.py +25 -21
- micrOS/source/micrOSloader.py +14 -23
- micrOS/source/microIO.py +94 -57
- toolkit/simulator_lib/LP_darwin.py → micrOS/source/modules/IO_esp32.py +22 -11
- micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +6 -1
- micrOS/source/modules/IO_esp32c6.py +38 -0
- micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +6 -1
- micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +43 -2
- micrOS/source/modules/IO_m5stamp.py +86 -0
- micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +28 -18
- micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +48 -3
- micrOS/source/modules/LM_L298N.py +161 -0
- {toolkit/workspace/precompiled → micrOS/source/modules}/LM_L9110_DCmotor.py +4 -4
- micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +53 -42
- micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
- micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +12 -4
- micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +13 -25
- micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +42 -40
- micrOS/source/{LM_cct.py → modules/LM_cct.py} +22 -27
- micrOS/source/modules/LM_cluster.py +255 -0
- micrOS/source/{LM_co2.py → modules/LM_co2.py} +13 -6
- micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +13 -29
- micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +13 -28
- micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +19 -16
- micrOS/source/modules/LM_distance.py +135 -0
- micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +12 -4
- micrOS/source/{LM_esp32.py → modules/LM_esp32.py} +16 -4
- micrOS/source/modules/LM_espnow.py +53 -0
- micrOS/source/modules/LM_fileserver.py +265 -0
- micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +5 -5
- micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +49 -35
- micrOS/source/modules/LM_haptic.py +111 -0
- micrOS/source/modules/LM_i2c.py +61 -0
- micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +20 -23
- micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +3 -3
- micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +22 -26
- micrOS/source/modules/LM_mh_z19c.py +198 -0
- micrOS/source/modules/LM_neoeffects.py +284 -0
- micrOS/source/{LM_neopixel.py → modules/LM_neopixel.py} +26 -31
- micrOS/source/{LM_oled.py → modules/LM_oled.py} +28 -20
- micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +28 -24
- micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +132 -174
- micrOS/source/modules/LM_pacman.py +320 -0
- micrOS/source/{LM_presence.py → modules/LM_presence.py} +24 -36
- micrOS/source/modules/LM_qmi8658.py +204 -0
- micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
- micrOS/source/modules/LM_rest.py +81 -0
- micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +25 -34
- micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +5 -5
- micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +37 -45
- micrOS/source/modules/LM_robustness.py +137 -0
- micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
- micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
- micrOS/source/{LM_servo.py → modules/LM_servo.py} +4 -4
- micrOS/source/modules/LM_sound_event.py +751 -0
- micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +8 -8
- micrOS/source/{LM_switch.py → modules/LM_switch.py} +21 -18
- micrOS/source/{LM_system.py → modules/LM_system.py} +96 -59
- micrOS/source/modules/LM_tcs3472.py +187 -0
- micrOS/source/modules/LM_telegram.py +388 -0
- micrOS/source/modules/LM_trackball.py +287 -0
- micrOS/source/modules/LM_veml7700.py +159 -0
- micrOS/source/modules/LM_web.py +38 -0
- micrOS/source/urequests.py +204 -91
- {toolkit/workspace/precompiled → micrOS/source/web}/dashboard.html +9 -4
- micrOS/source/web/editor.js +440 -0
- micrOS/source/web/filesui.html +178 -0
- micrOS/source/web/filesui.js +338 -0
- micrOS/source/{index.html → web/index.html} +44 -2
- micrOS/source/web/uapi.js +103 -0
- micrOS/source/web/udashboard.js +129 -0
- micrOS/source/web/ustyle.css +55 -0
- micrOS/source/web/uwidgets.js +172 -0
- micrOS/source/web/uwidgets_pro.js +99 -0
- micrOS/utests/__init__.py +0 -0
- micrOS/utests/test_scheduler.py +435 -0
- {micrOSDevToolKit-2.1.5.data → microsdevtoolkit-2.26.1.data}/scripts/devToolKit.py +47 -4
- {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/METADATA +392 -279
- microsdevtoolkit-2.26.1.dist-info/RECORD +396 -0
- {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/WHEEL +1 -1
- toolkit/DevEnvCompile.py +63 -33
- toolkit/DevEnvOTA.py +72 -22
- toolkit/DevEnvUSB.py +147 -77
- toolkit/Gateway.py +9 -9
- toolkit/LM_to_compile.dat +12 -4
- toolkit/MicrOSDevEnv.py +129 -51
- toolkit/WebRepl.py +73 -0
- toolkit/dashboard_apps/BackupRestore.py +171 -0
- toolkit/dashboard_apps/CCTDemo.py +12 -17
- toolkit/dashboard_apps/CCTTest.py +20 -24
- toolkit/dashboard_apps/CamStream.py +2 -6
- toolkit/dashboard_apps/CatGame.py +14 -16
- toolkit/dashboard_apps/Dimmer.py +11 -21
- toolkit/dashboard_apps/GetVersion.py +11 -19
- toolkit/dashboard_apps/MicrophoneTest.py +2 -7
- toolkit/dashboard_apps/NeoEffectsDemo.py +22 -35
- toolkit/dashboard_apps/NeopixelTest.py +20 -25
- toolkit/dashboard_apps/PresenceTest.py +2 -8
- toolkit/dashboard_apps/QMI8685_GYRO.py +68 -0
- toolkit/dashboard_apps/RGBTest.py +20 -24
- toolkit/dashboard_apps/RoboArm.py +24 -32
- toolkit/dashboard_apps/SED_test.py +10 -14
- toolkit/dashboard_apps/SensorsTest.py +61 -0
- toolkit/dashboard_apps/SystemTest.py +219 -117
- toolkit/dashboard_apps/Template_app.py +12 -19
- toolkit/dashboard_apps/_app_base.py +34 -0
- toolkit/dashboard_apps/_gyro_visualizer.py +78 -0
- toolkit/dashboard_apps/uLightDemo.py +15 -24
- toolkit/index.html +6 -5
- toolkit/lib/LocalMachine.py +6 -1
- toolkit/lib/MicrosFiles.py +46 -0
- toolkit/lib/Repository.py +64 -0
- toolkit/lib/TerminalColors.py +4 -0
- toolkit/lib/macroScript.py +371 -0
- toolkit/lib/micrOSClient.py +124 -51
- toolkit/lib/micrOSClientHistory.py +156 -0
- toolkit/lib/pip_package_installer.py +31 -4
- toolkit/micrOSdashboard.py +16 -21
- toolkit/micrOSlint.py +28 -10
- toolkit/simulator_lib/.DS_Store +0 -0
- micrOS/source/IO_esp32.py → toolkit/simulator_lib/IO_darwin.py +3 -0
- toolkit/simulator_lib/__pycache__/IO_darwin.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/aioespnow.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/camera.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/framebuf.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/machine.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/micropython.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/mip.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/neopixel.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/network.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/sim_common.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/simgc.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/simulator.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/uasyncio.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/uos.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/urandom.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/usocket.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/ussl.cpython-312.pyc +0 -0
- toolkit/simulator_lib/aioespnow.py +28 -0
- toolkit/simulator_lib/camera.py +84 -0
- toolkit/simulator_lib/dht.py +1 -1
- toolkit/simulator_lib/framebuf.py +49 -1
- toolkit/simulator_lib/machine.py +32 -2
- toolkit/simulator_lib/micropython.py +3 -3
- toolkit/simulator_lib/mip.py +165 -0
- toolkit/simulator_lib/neopixel.py +3 -2
- toolkit/simulator_lib/network.py +2 -1
- toolkit/simulator_lib/node_config.json +2 -3
- toolkit/simulator_lib/ntptime.py +1 -1
- toolkit/simulator_lib/{sim_console.py → sim_common.py} +2 -3
- toolkit/simulator_lib/simgc.py +6 -2
- toolkit/simulator_lib/simulator.py +138 -46
- toolkit/simulator_lib/uasyncio.py +34 -3
- toolkit/simulator_lib/uos.py +147 -0
- toolkit/simulator_lib/urandom.py +4 -0
- toolkit/simulator_lib/usocket.py +5 -1
- toolkit/simulator_lib/view01.jpg +0 -0
- toolkit/simulator_lib/view02.jpg +0 -0
- toolkit/socketClient.py +43 -23
- toolkit/user_data/webhooks/generic.py +1 -1
- toolkit/user_data/webhooks/macro.py +44 -0
- toolkit/user_data/webhooks/template.macro +20 -0
- toolkit/user_data/webhooks/template.py +1 -1
- toolkit/workspace/precompiled/Auth.mpy +0 -0
- toolkit/workspace/precompiled/Common.mpy +0 -0
- toolkit/workspace/precompiled/Config.mpy +0 -0
- toolkit/workspace/precompiled/Debug.mpy +0 -0
- toolkit/workspace/precompiled/Espnow.mpy +0 -0
- toolkit/workspace/precompiled/Files.mpy +0 -0
- toolkit/workspace/precompiled/Hooks.mpy +0 -0
- toolkit/workspace/precompiled/InterConnect.mpy +0 -0
- toolkit/workspace/precompiled/Interrupts.mpy +0 -0
- toolkit/workspace/precompiled/Logger.mpy +0 -0
- toolkit/workspace/precompiled/Network.mpy +0 -0
- toolkit/workspace/precompiled/Notify.mpy +0 -0
- toolkit/workspace/precompiled/Pacman.mpy +0 -0
- toolkit/workspace/precompiled/Scheduler.mpy +0 -0
- toolkit/workspace/precompiled/Server.mpy +0 -0
- toolkit/workspace/precompiled/Shell.mpy +0 -0
- toolkit/workspace/precompiled/Tasks.mpy +0 -0
- toolkit/workspace/precompiled/Time.mpy +0 -0
- toolkit/workspace/precompiled/Types.mpy +0 -0
- toolkit/workspace/precompiled/Web.mpy +0 -0
- toolkit/workspace/precompiled/_mpy.version +1 -1
- toolkit/workspace/precompiled/config/_git.keep +0 -0
- toolkit/workspace/precompiled/helpers.mpy +0 -0
- toolkit/workspace/precompiled/micrOS.mpy +0 -0
- toolkit/workspace/precompiled/micrOSloader.mpy +0 -0
- toolkit/workspace/precompiled/microIO.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32c3.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32s2.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32s3.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_m5stamp.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_qtpy.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_rp2.mpy +0 -0
- toolkit/workspace/precompiled/modules/IO_tinypico.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_L298N.mpy +0 -0
- {micrOS/source → toolkit/workspace/precompiled/modules}/LM_L9110_DCmotor.py +4 -4
- toolkit/workspace/precompiled/modules/LM_OV2640.mpy +0 -0
- toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +5 -5
- toolkit/workspace/precompiled/modules/LM_aht10.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_bme280.mpy +0 -0
- toolkit/workspace/precompiled/{LM_buzzer.mpy → modules/LM_buzzer.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_cct.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_cluster.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_co2.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_dht11.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_dht22.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_dimmer.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_distance.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_ds18.mpy +0 -0
- toolkit/workspace/precompiled/{LM_esp32.py → modules/LM_esp32.py} +16 -4
- toolkit/workspace/precompiled/modules/LM_espnow.py +53 -0
- toolkit/workspace/precompiled/modules/LM_fileserver.mpy +0 -0
- toolkit/workspace/precompiled/{LM_gameOfLife.mpy → modules/LM_gameOfLife.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_genIO.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_haptic.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_i2c.py +61 -0
- toolkit/workspace/precompiled/modules/LM_i2s_mic.mpy +0 -0
- toolkit/workspace/precompiled/{LM_ld2410.mpy → modules/LM_ld2410.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_light_sensor.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_mh_z19c.py +198 -0
- toolkit/workspace/precompiled/modules/LM_neoeffects.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_neopixel.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_oled.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_oled_sh1106.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_oled_ui.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_pacman.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_presence.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_qmi8658.py +204 -0
- toolkit/workspace/precompiled/{LM_rencoder.py → modules/LM_rencoder.py} +40 -11
- toolkit/workspace/precompiled/modules/LM_rest.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_rgb.mpy +0 -0
- toolkit/workspace/precompiled/{LM_rgbcct.mpy → modules/LM_rgbcct.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_roboarm.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_robustness.py +137 -0
- toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +3 -0
- toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +3 -0
- toolkit/workspace/precompiled/{LM_servo.mpy → modules/LM_servo.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_sound_event.mpy +0 -0
- toolkit/workspace/precompiled/{LM_stepper.mpy → modules/LM_stepper.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_switch.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_system.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_tcs3472.py +187 -0
- toolkit/workspace/precompiled/modules/LM_telegram.mpy +0 -0
- toolkit/workspace/precompiled/{LM_tinyrgb.mpy → modules/LM_tinyrgb.mpy} +0 -0
- toolkit/workspace/precompiled/modules/LM_trackball.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_veml7700.mpy +0 -0
- toolkit/workspace/precompiled/modules/LM_web.mpy +0 -0
- toolkit/workspace/precompiled/urequests.mpy +0 -0
- {micrOS/source → toolkit/workspace/precompiled/web}/dashboard.html +9 -4
- toolkit/workspace/precompiled/web/editor.js +440 -0
- toolkit/workspace/precompiled/web/filesui.html +178 -0
- toolkit/workspace/precompiled/web/filesui.js +338 -0
- toolkit/workspace/precompiled/{index.html → web/index.html} +44 -2
- toolkit/workspace/precompiled/web/uapi.js +103 -0
- toolkit/workspace/precompiled/web/udashboard.js +129 -0
- toolkit/workspace/precompiled/web/ustyle.css +55 -0
- toolkit/workspace/precompiled/web/uwidgets.js +172 -0
- toolkit/workspace/precompiled/web/uwidgets_pro.js +99 -0
- env/driver_cp210x/CH34XSER_MAC/CH34X_DRV_INSTALL_INSTRUCTIONS.pdf +0 -0
- env/driver_cp210x/CH34XSER_MAC/CH34xVCPDriver.pkg +0 -0
- micrOS/micropython/esp32-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/esp32c3-GENERIC-20240105-v1.22.1.bin +0 -0
- micrOS/micropython/esp32c3-GENERIC-20240222-v1.22.2.bin +0 -0
- micrOS/micropython/esp32s2-GENERIC-20240105-v1.22.1.bin +0 -0
- micrOS/micropython/esp32s2-LOLIN_MINI-20220618-v1.19.1.bin +0 -0
- micrOS/micropython/esp32s3-GENERIC-20240105-v1.22.1.bin +0 -0
- micrOS/micropython/esp32s3_spiram_oct-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/rpi-pico-w-20231005-v1.21.0.uf2 +0 -0
- micrOS/micropython/tinypico-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/tinypico-usbc-UM-20240105-v1.22.1.bin +0 -0
- micrOS/source/LM_L298N_DCmotor.py +0 -86
- micrOS/source/LM_catgame.py +0 -74
- micrOS/source/LM_dashboard_be.py +0 -37
- micrOS/source/LM_demo.py +0 -85
- micrOS/source/LM_distance.py +0 -88
- micrOS/source/LM_i2c.py +0 -44
- micrOS/source/LM_intercon.py +0 -57
- micrOS/source/LM_keychain.py +0 -318
- micrOS/source/LM_lmpacman.py +0 -126
- micrOS/source/LM_neoeffects.py +0 -327
- micrOS/source/LM_pet_feeder.py +0 -76
- micrOS/source/LM_ph_sensor.py +0 -51
- micrOS/source/LM_rest.py +0 -40
- micrOS/source/LM_robustness.py +0 -73
- micrOS/source/LM_telegram.py +0 -96
- micrOS/source/reset.py +0 -11
- micrOS/source/uapi.js +0 -76
- micrOS/source/udashboard.js +0 -137
- micrOS/source/ustyle.css +0 -28
- micrOS/source/uwidgets.js +0 -179
- micrOSDevToolKit-2.1.5.dist-info/RECORD +0 -337
- toolkit/dashboard_apps/AirQualityBME280.py +0 -36
- toolkit/dashboard_apps/AirQualityDHT22_CO2.py +0 -36
- toolkit/lib/file_extensions.py +0 -16
- toolkit/simulator_lib/__pycache__/LP_darwin.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/LP_darwin.cpython-38.pyc +0 -0
- toolkit/simulator_lib/__pycache__/LP_darwin.cpython-39.pyc +0 -0
- toolkit/simulator_lib/__pycache__/sim_console.cpython-312.pyc +0 -0
- toolkit/simulator_lib/__pycache__/sim_console.cpython-38.pyc +0 -0
- toolkit/simulator_lib/__pycache__/sim_console.cpython-39.pyc +0 -0
- toolkit/workspace/precompiled/IO_esp32.mpy +0 -0
- toolkit/workspace/precompiled/IO_esp32c3.mpy +0 -0
- toolkit/workspace/precompiled/IO_esp32s2.mpy +0 -0
- toolkit/workspace/precompiled/IO_esp32s3.mpy +0 -0
- toolkit/workspace/precompiled/IO_qtpy.mpy +0 -0
- toolkit/workspace/precompiled/IO_rp2.mpy +0 -0
- toolkit/workspace/precompiled/IO_tinypico.mpy +0 -0
- toolkit/workspace/precompiled/LM_L298N_DCmotor.mpy +0 -0
- toolkit/workspace/precompiled/LM_OV2640.mpy +0 -0
- toolkit/workspace/precompiled/LM_aht10.mpy +0 -0
- toolkit/workspace/precompiled/LM_bme280.mpy +0 -0
- toolkit/workspace/precompiled/LM_catgame.py +0 -74
- toolkit/workspace/precompiled/LM_cct.mpy +0 -0
- toolkit/workspace/precompiled/LM_co2.mpy +0 -0
- toolkit/workspace/precompiled/LM_dashboard_be.py +0 -37
- toolkit/workspace/precompiled/LM_demo.py +0 -85
- toolkit/workspace/precompiled/LM_dht11.mpy +0 -0
- toolkit/workspace/precompiled/LM_dht22.mpy +0 -0
- toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
- toolkit/workspace/precompiled/LM_distance.py +0 -88
- toolkit/workspace/precompiled/LM_ds18.mpy +0 -0
- toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
- toolkit/workspace/precompiled/LM_i2c.py +0 -44
- toolkit/workspace/precompiled/LM_i2s_mic.mpy +0 -0
- toolkit/workspace/precompiled/LM_intercon.mpy +0 -0
- toolkit/workspace/precompiled/LM_keychain.mpy +0 -0
- toolkit/workspace/precompiled/LM_light_sensor.mpy +0 -0
- toolkit/workspace/precompiled/LM_lmpacman.mpy +0 -0
- toolkit/workspace/precompiled/LM_neoeffects.mpy +0 -0
- toolkit/workspace/precompiled/LM_neopixel.mpy +0 -0
- toolkit/workspace/precompiled/LM_oled.mpy +0 -0
- toolkit/workspace/precompiled/LM_oled_sh1106.mpy +0 -0
- toolkit/workspace/precompiled/LM_oled_ui.mpy +0 -0
- toolkit/workspace/precompiled/LM_pet_feeder.py +0 -76
- toolkit/workspace/precompiled/LM_ph_sensor.py +0 -51
- toolkit/workspace/precompiled/LM_presence.mpy +0 -0
- toolkit/workspace/precompiled/LM_rest.mpy +0 -0
- toolkit/workspace/precompiled/LM_rgb.mpy +0 -0
- toolkit/workspace/precompiled/LM_roboarm.mpy +0 -0
- toolkit/workspace/precompiled/LM_robustness.py +0 -73
- toolkit/workspace/precompiled/LM_switch.mpy +0 -0
- toolkit/workspace/precompiled/LM_system.mpy +0 -0
- toolkit/workspace/precompiled/LM_telegram.mpy +0 -0
- toolkit/workspace/precompiled/reset.mpy +0 -0
- toolkit/workspace/precompiled/uapi.js +0 -76
- toolkit/workspace/precompiled/udashboard.js +0 -137
- toolkit/workspace/precompiled/ustyle.css +0 -28
- toolkit/workspace/precompiled/uwidgets.js +0 -179
- /toolkit/user_data/node_config_archive/.include → /micrOS/source/config/_git.keep +0 -0
- /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
- /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
- {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info/licenses}/LICENSE +0 -0
- {micrOSDevToolKit-2.1.5.dist-info → microsdevtoolkit-2.26.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"""
|
|
2
|
+
MH-Z19 Co2 sensor driver for MicroPython (supports MH-Z19B and MH-Z19C)
|
|
3
|
+
|
|
4
|
+
Provides a simple interface to read:
|
|
5
|
+
- Co2 concentration (PPM)
|
|
6
|
+
- Temperature
|
|
7
|
+
- Status
|
|
8
|
+
|
|
9
|
+
Calibration (MH-Z19C)
|
|
10
|
+
---------------------
|
|
11
|
+
There are two ways to calibrate the zero point on MH-Z19C:
|
|
12
|
+
|
|
13
|
+
1) Apply a low-level signal for more than 7 seconds.
|
|
14
|
+
|
|
15
|
+
2) Send the calibration command:
|
|
16
|
+
FF 01 87 00 00 00 00 00 78
|
|
17
|
+
On success the sensor returns:
|
|
18
|
+
FF 87 01 00 00 00 00 00 78
|
|
19
|
+
|
|
20
|
+
Auto-calibration (ABC) period
|
|
21
|
+
-----------------------------
|
|
22
|
+
Set 7-day automatic calibration period:
|
|
23
|
+
Command: FF 01 AF 01 07 00 00 00 48
|
|
24
|
+
Confirmation: FF AF 01 07 00 00 00 00 49
|
|
25
|
+
|
|
26
|
+
Set 1-day automatic calibration period:
|
|
27
|
+
Command: FF 01 AF 01 01 00 00 00 4E
|
|
28
|
+
Confirmation: FF AF 01 01 00 00 00 00 4F
|
|
29
|
+
|
|
30
|
+
Notes
|
|
31
|
+
-----
|
|
32
|
+
- Use a well-ventilated environment (around 400 ppm) for command-based zero calibration
|
|
33
|
+
|
|
34
|
+
:author: Florian Mandl
|
|
35
|
+
:version: 1.0
|
|
36
|
+
:date: 2025-12-06
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
import time
|
|
40
|
+
import json
|
|
41
|
+
from machine import Pin, UART
|
|
42
|
+
from microIO import bind_pin, pinmap_search
|
|
43
|
+
from Common import micro_task, manage_task, console, notify
|
|
44
|
+
from Types import resolve
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class MHZ19:
|
|
48
|
+
INSTANCE = None
|
|
49
|
+
|
|
50
|
+
SENSOR_TASK = 'mh_z19c.sensor'
|
|
51
|
+
CALIBRATE_TASK = 'mh_z19c.calibrate'
|
|
52
|
+
|
|
53
|
+
def __init__(self):
|
|
54
|
+
self.uart_no = 1
|
|
55
|
+
self.ppm = 0
|
|
56
|
+
self.temp = 0
|
|
57
|
+
self.co2status = 0
|
|
58
|
+
self.tx_pin = Pin(bind_pin('mh_z19c_tx',16))
|
|
59
|
+
self.rx_pin = Pin(bind_pin('mh_z19c_rx',17))
|
|
60
|
+
self.hd_pin = Pin(bind_pin('mh_z19c_hd',19), Pin.OUT, Pin.PULL_UP)
|
|
61
|
+
self.start()
|
|
62
|
+
|
|
63
|
+
def start(self):
|
|
64
|
+
self.uart = UART(self.uart_no, baudrate=9600, tx=self.tx_pin, rx=self.rx_pin)
|
|
65
|
+
self.uart.init(9600, bits=8, parity=None, stop=1, timeout=10)
|
|
66
|
+
|
|
67
|
+
def stop(self):
|
|
68
|
+
while self.uart.any():
|
|
69
|
+
self.uart.read()
|
|
70
|
+
self.uart.deinit()
|
|
71
|
+
|
|
72
|
+
def get_data(self):
|
|
73
|
+
# Clear buffer
|
|
74
|
+
while self.uart.any():
|
|
75
|
+
self.uart.read()
|
|
76
|
+
|
|
77
|
+
self.uart.write(b"\xff\x01\x86\x00\x00\x00\x00\x00\x79")
|
|
78
|
+
time.sleep(0.1)
|
|
79
|
+
s = self.uart.read(9)
|
|
80
|
+
if not s or len(s) < 9:
|
|
81
|
+
return False
|
|
82
|
+
if self._crc8(s) != s[8]:
|
|
83
|
+
self.stop()
|
|
84
|
+
time.sleep(0.1)
|
|
85
|
+
self.start()
|
|
86
|
+
return False
|
|
87
|
+
self.ppm = s[2] * 256 + s[3]
|
|
88
|
+
self.temp = s[4] - 40
|
|
89
|
+
self.co2status = s[5]
|
|
90
|
+
return True
|
|
91
|
+
|
|
92
|
+
async def calibrate(self):
|
|
93
|
+
with micro_task(tag=self.CALIBRATE_TASK) as my_task:
|
|
94
|
+
try:
|
|
95
|
+
self.stop()
|
|
96
|
+
self.hd_pin.value(0)
|
|
97
|
+
await my_task.feed(sleep_ms=8000)
|
|
98
|
+
self.hd_pin.value(1)
|
|
99
|
+
self.start()
|
|
100
|
+
console("Calibration finished")
|
|
101
|
+
except Exception as e:
|
|
102
|
+
console(f"Calibration error: {e}")
|
|
103
|
+
|
|
104
|
+
@staticmethod
|
|
105
|
+
def _crc8(a):
|
|
106
|
+
crc = sum(bytearray(a)[1:8]) % 256
|
|
107
|
+
crc = (~crc & 0xFF) + 1
|
|
108
|
+
return crc
|
|
109
|
+
|
|
110
|
+
#########################
|
|
111
|
+
# Application functions #
|
|
112
|
+
#########################
|
|
113
|
+
|
|
114
|
+
def load():
|
|
115
|
+
"""
|
|
116
|
+
Create MH-Z19 CO2 sensor (over UART)
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
if MHZ19.INSTANCE is None:
|
|
120
|
+
MHZ19.INSTANCE = MHZ19()
|
|
121
|
+
return MHZ19.INSTANCE
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def measure():
|
|
125
|
+
"""
|
|
126
|
+
Measure with MH-Z19 CO2 sensor
|
|
127
|
+
"""
|
|
128
|
+
mhz19 = load()
|
|
129
|
+
mhz19.get_data()
|
|
130
|
+
return {"ppm": mhz19.ppm,
|
|
131
|
+
"temp": mhz19.temp,
|
|
132
|
+
"status": mhz19.co2status}
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def calibrate():
|
|
136
|
+
"""
|
|
137
|
+
Calibrate MH-Z19 sensor
|
|
138
|
+
"""
|
|
139
|
+
mhz19 = load()
|
|
140
|
+
return micro_task(tag=MHZ19.CALIBRATE_TASK, task=mhz19.calibrate())
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
async def _run_sensor_loop(interval, topic, channels):
|
|
144
|
+
channels = [] if channels is None else channels
|
|
145
|
+
with micro_task(tag=MHZ19.SENSOR_TASK) as my_task:
|
|
146
|
+
while True:
|
|
147
|
+
my_task.out = "Start measurement"
|
|
148
|
+
out = notify(json.dumps(measure()), topic=topic, channels=channels)
|
|
149
|
+
my_task.out = f"Measurement published: {out}, wait {interval}ms"
|
|
150
|
+
await my_task.feed(sleep_ms=interval)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def start(interval:int=5000, topic:str="MH_Z19C", channels:list=None):
|
|
154
|
+
"""
|
|
155
|
+
Start sensor measurement loop and publish results over micros notify feature
|
|
156
|
+
:param interval: update interval in milliseconds
|
|
157
|
+
:param topic: for MQTT channel, default: MH_Z19C
|
|
158
|
+
:param channels: selected notification channels, ex.: ["MQTT"], default: None (all)
|
|
159
|
+
"""
|
|
160
|
+
load()
|
|
161
|
+
return micro_task(tag=MHZ19.SENSOR_TASK, task=_run_sensor_loop(interval, topic, channels))
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def stop():
|
|
165
|
+
"""
|
|
166
|
+
Stop sensor measurement loop and publish, delete MHZ19.INSTANCE
|
|
167
|
+
"""
|
|
168
|
+
mhz19 = load()
|
|
169
|
+
manage_task(MHZ19.SENSOR_TASK, "kill")
|
|
170
|
+
if mhz19:
|
|
171
|
+
mhz19.stop()
|
|
172
|
+
MHZ19.INSTANCE = None
|
|
173
|
+
return f"{MHZ19.SENSOR_TASK}: Stopped"
|
|
174
|
+
|
|
175
|
+
#######################
|
|
176
|
+
# LM helper functions #
|
|
177
|
+
#######################
|
|
178
|
+
|
|
179
|
+
def pinmap():
|
|
180
|
+
"""
|
|
181
|
+
[i] micrOS LM naming convention
|
|
182
|
+
Shows logical pins - pin number(s) used by this Load module
|
|
183
|
+
- info which pins to use for this application
|
|
184
|
+
:return dict: pin name (str) - pin value (int) pairs
|
|
185
|
+
"""
|
|
186
|
+
return pinmap_search(['mh_z19c_tx', 'mh_z19c_rx', 'mh_z19c_hd'])
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def help(widgets=False):
|
|
190
|
+
"""
|
|
191
|
+
[i] micrOS LM naming convention - built-in help message
|
|
192
|
+
:return tuple:
|
|
193
|
+
(widgets=False) list of functions implemented by this application
|
|
194
|
+
(widgets=True) list of widget json for UI generation
|
|
195
|
+
"""
|
|
196
|
+
return resolve(('load',
|
|
197
|
+
'BUTTON start interval=5000',
|
|
198
|
+
'BUTTON stop', 'TEXTBOX measure', 'calibrate', 'pinmap'), widgets=widgets)
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
from LM_neopixel import load as neoload, segment, Data, status, pinmap as pm
|
|
2
|
+
from random import randint
|
|
3
|
+
from Types import resolve
|
|
4
|
+
from Common import manage_task, AnimationPlayer
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
#################################
|
|
8
|
+
# NEOPIXEL EFFECT DRAWER CLASS #
|
|
9
|
+
#################################
|
|
10
|
+
|
|
11
|
+
class DrawEffectV2(AnimationPlayer):
|
|
12
|
+
INSTANCE = None
|
|
13
|
+
|
|
14
|
+
def __init__(self, pix_cnt=24):
|
|
15
|
+
super().__init__(tag="neoeffects")
|
|
16
|
+
neoload(ledcnt=pix_cnt)
|
|
17
|
+
DrawEffectV2.INSTANCE = self
|
|
18
|
+
|
|
19
|
+
@staticmethod
|
|
20
|
+
def normalize_index(value) -> int:
|
|
21
|
+
return value % Data.NEOPIXEL_OBJ.n
|
|
22
|
+
|
|
23
|
+
@staticmethod
|
|
24
|
+
def color_code(r:int=None, g:int=None, b:int=None) -> tuple[float, float, float]:
|
|
25
|
+
_r, _g, _b, _ = Data.DCACHE
|
|
26
|
+
r = _r if r is None else r
|
|
27
|
+
g = _g if g is None else g
|
|
28
|
+
b = _b if b is None else b
|
|
29
|
+
return r, g, b
|
|
30
|
+
|
|
31
|
+
def update(self, index:int, r:int|float, g:int|float, b:int|float):
|
|
32
|
+
# Animation player will call this method to update pixels.
|
|
33
|
+
segment(r=int(r), g=int(g), b=int(b), s=index, cache=False, write=False)
|
|
34
|
+
|
|
35
|
+
def draw(self):
|
|
36
|
+
# Animation player will call this method to update pixels.
|
|
37
|
+
Data.NEOPIXEL_OBJ.write()
|
|
38
|
+
|
|
39
|
+
def clear(self):
|
|
40
|
+
# Animation player will call this method to update pixels.
|
|
41
|
+
for i in range(0, Data.NEOPIXEL_OBJ.n):
|
|
42
|
+
self.update(i, 0, 0, 0)
|
|
43
|
+
self.draw()
|
|
44
|
+
|
|
45
|
+
##################################################################################
|
|
46
|
+
# EFFECTS #
|
|
47
|
+
##################################################################################
|
|
48
|
+
|
|
49
|
+
def meteor(speed_ms:int=60, shift:bool=True, batch:bool=True):
|
|
50
|
+
"""
|
|
51
|
+
Meteor effect
|
|
52
|
+
:param speed_ms: animation speed in milliseconds
|
|
53
|
+
:param shift: automatic effect rotation
|
|
54
|
+
:param batch: batch mode
|
|
55
|
+
:return str: verdict
|
|
56
|
+
"""
|
|
57
|
+
def effect_meteor():
|
|
58
|
+
"""
|
|
59
|
+
Describe one full length color map
|
|
60
|
+
:return: yield tuple with r,g,b
|
|
61
|
+
"""
|
|
62
|
+
nonlocal shift, pix_cnt
|
|
63
|
+
max_offset = pix_cnt if shift else 1
|
|
64
|
+
for offset in range(0, max_offset):
|
|
65
|
+
r, g, b = DrawEffectV2.color_code()
|
|
66
|
+
for pixel in range(0, pix_cnt):
|
|
67
|
+
br, norm = 0.6, pixel/pix_cnt
|
|
68
|
+
fade = br * norm ** 0.9 # exponent < 1 simulates log-like curve
|
|
69
|
+
yield DrawEffectV2.normalize_index(pixel+offset), r*fade, g*fade, b*fade
|
|
70
|
+
|
|
71
|
+
neoeffect = load()
|
|
72
|
+
pix_cnt = Data.NEOPIXEL_OBJ.n
|
|
73
|
+
return neoeffect.play(effect_meteor, speed_ms=speed_ms, bt_draw=batch, bt_size=pix_cnt)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def cycle(speed_ms:int=60, shift:bool=True, batch:bool=True):
|
|
77
|
+
"""
|
|
78
|
+
Cycle effect
|
|
79
|
+
:param speed_ms: animation speed in milliseconds
|
|
80
|
+
:param shift: automatic effect rotation
|
|
81
|
+
:param batch: enable/disable batch update mode
|
|
82
|
+
"""
|
|
83
|
+
def effect_cycle():
|
|
84
|
+
"""
|
|
85
|
+
Describe one full length color map
|
|
86
|
+
:return: yield tuple with index, r,g,b
|
|
87
|
+
"""
|
|
88
|
+
nonlocal shift
|
|
89
|
+
max_offset = Data.NEOPIXEL_OBJ.n if shift else 1
|
|
90
|
+
for offset in range(0, max_offset):
|
|
91
|
+
r, g, b = DrawEffectV2.color_code()
|
|
92
|
+
lr, lg, lb = int(r * 0.1), int(g * 0.1), int(b * 0.1)
|
|
93
|
+
# Clean last pixel
|
|
94
|
+
yield DrawEffectV2.normalize_index(offset-1), 0, 0, 0
|
|
95
|
+
# Draw pattern
|
|
96
|
+
yield DrawEffectV2.normalize_index(offset), lr, lg, lb
|
|
97
|
+
yield DrawEffectV2.normalize_index(offset + 1), r, g, b
|
|
98
|
+
yield DrawEffectV2.normalize_index(offset + 2), lr, lg, lb
|
|
99
|
+
|
|
100
|
+
return load().play(effect_cycle, speed_ms=speed_ms, bt_draw=batch, bt_size=4)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def rainbow(speed_ms=50, br=15, batch=True):
|
|
104
|
+
"""
|
|
105
|
+
Rainbow effect animation
|
|
106
|
+
:param speed_ms: animation speed in milliseconds
|
|
107
|
+
:param br: Brightness of the pixels (0-100)
|
|
108
|
+
:param batch: Batch drawing of pixels (True/False)
|
|
109
|
+
"""
|
|
110
|
+
def _wheel(pos):
|
|
111
|
+
# Input a value 0 to 255 to get a color value.
|
|
112
|
+
# The colours are a transition r - g - b - back to r.
|
|
113
|
+
if pos < 0 or pos > 255:
|
|
114
|
+
return 0, 0, 0
|
|
115
|
+
if pos < 85:
|
|
116
|
+
return 255 - pos * 3, pos * 3, 0
|
|
117
|
+
if pos < 170:
|
|
118
|
+
pos -= 85
|
|
119
|
+
return 0, 255 - pos * 3, pos * 3
|
|
120
|
+
pos -= 170
|
|
121
|
+
return pos * 3, 0, 255 - pos * 3
|
|
122
|
+
|
|
123
|
+
def effect_rainbow():
|
|
124
|
+
"""
|
|
125
|
+
:param cnt: led segment count
|
|
126
|
+
:param br: max brightness 0-100%
|
|
127
|
+
:param step: step size
|
|
128
|
+
"""
|
|
129
|
+
nonlocal pix_cnt, br
|
|
130
|
+
for color_wheel in range(0, 255):
|
|
131
|
+
for index in range(0, pix_cnt):
|
|
132
|
+
rc_index = (index * 256 // pix_cnt) + color_wheel
|
|
133
|
+
r, g, b = _wheel(rc_index & 255)
|
|
134
|
+
yield DrawEffectV2.normalize_index(index+color_wheel), round(r*br*0.01), round(g*br*0.01), round(b*br*0.01)
|
|
135
|
+
|
|
136
|
+
neoeffect = load()
|
|
137
|
+
pix_cnt = Data.NEOPIXEL_OBJ.n
|
|
138
|
+
return neoeffect.play(effect_rainbow, speed_ms=speed_ms, bt_draw=batch, bt_size=pix_cnt)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def fire(speed_ms:int=150, br:int=30, batch:bool=True):
|
|
142
|
+
"""
|
|
143
|
+
Fire effect
|
|
144
|
+
:param speed_ms: animation speed in milliseconds
|
|
145
|
+
:param br: max brightness 0-100%
|
|
146
|
+
:param batch: batch update
|
|
147
|
+
"""
|
|
148
|
+
def effect_fire():
|
|
149
|
+
nonlocal pix_cnt, br
|
|
150
|
+
max_value = int(255 * (br/100))
|
|
151
|
+
for index in range(pix_cnt):
|
|
152
|
+
r, g, b = DrawEffectV2.color_code()
|
|
153
|
+
rand_percent = float(round(randint(1, max_value)/max_value, 2))
|
|
154
|
+
new_r = min(max(int(r * rand_percent), 0), max_value)
|
|
155
|
+
new_g = min(max(int(g * rand_percent), 0), max_value)
|
|
156
|
+
new_b = min(max(int(b * rand_percent), 0), max_value)
|
|
157
|
+
yield index, new_r, new_g, new_b
|
|
158
|
+
|
|
159
|
+
neoeffect = load()
|
|
160
|
+
pix_cnt = Data.NEOPIXEL_OBJ.n
|
|
161
|
+
return neoeffect.play(effect_fire, speed_ms=speed_ms, bt_draw=batch, bt_size=pix_cnt)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def shader(offset=0, size=6):
|
|
165
|
+
"""
|
|
166
|
+
Shader effect on neopixel ring.
|
|
167
|
+
:param offset: start pixel index
|
|
168
|
+
:param size: shader size (number of pixels)
|
|
169
|
+
"""
|
|
170
|
+
def effect_shader():
|
|
171
|
+
nonlocal size, offset, neoeffect
|
|
172
|
+
pix_cnt = Data.NEOPIXEL_OBJ.n
|
|
173
|
+
# Conditional value load - with neopixel cache
|
|
174
|
+
r, g, b = DrawEffectV2.color_code()
|
|
175
|
+
# calculate 0->24 range
|
|
176
|
+
_slice1 = pix_cnt if size + offset > pix_cnt else size + offset
|
|
177
|
+
# calculate 24->0-> range (overflow)
|
|
178
|
+
_slice2 = size + offset - pix_cnt if size + offset > pix_cnt else 0
|
|
179
|
+
for i in range(0, pix_cnt):
|
|
180
|
+
if offset <= i < _slice1 or 0 <= i < _slice2:
|
|
181
|
+
neoeffect.update(i, 0, 0, 0)
|
|
182
|
+
else:
|
|
183
|
+
neoeffect.update(i, r, g, b)
|
|
184
|
+
neoeffect.draw()
|
|
185
|
+
|
|
186
|
+
neoeffect = load()
|
|
187
|
+
effect_shader()
|
|
188
|
+
return "Shader was set."
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def color(r:int=None, g:int=None, b:int=None):
|
|
192
|
+
"""
|
|
193
|
+
Set color buffer - for runtime effect color change
|
|
194
|
+
:param r: red channel 0-255 (default: None - cached value)
|
|
195
|
+
:param g: green channel 0-255 (default: None - cached value)
|
|
196
|
+
:param b: blue channel 0-255 (default: None - cached value)
|
|
197
|
+
:return dict: rgb status - states: R, G, B, S
|
|
198
|
+
"""
|
|
199
|
+
# Conditional value load - with neopixel cache
|
|
200
|
+
r, g, b = DrawEffectV2.color_code(r, g, b)
|
|
201
|
+
Data.DCACHE[0] = r
|
|
202
|
+
Data.DCACHE[1] = g
|
|
203
|
+
Data.DCACHE[2] = b
|
|
204
|
+
return status()
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def random(max_val=255):
|
|
208
|
+
"""
|
|
209
|
+
Demo function: implements random color change
|
|
210
|
+
:param max_val: set channel maximum generated value: 0-255
|
|
211
|
+
:return str: rgb status - states: R, G, B
|
|
212
|
+
"""
|
|
213
|
+
r = randint(0, max_val)
|
|
214
|
+
g = randint(0, max_val)
|
|
215
|
+
b = randint(0, max_val)
|
|
216
|
+
Data.DCACHE[0] = r
|
|
217
|
+
Data.DCACHE[1] = g
|
|
218
|
+
Data.DCACHE[2] = b
|
|
219
|
+
return "Set random: R:{} G: B:{}".format(r, g, b)
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def stop():
|
|
223
|
+
"""
|
|
224
|
+
Stop all running (neo)effects tasks
|
|
225
|
+
"""
|
|
226
|
+
player_info = load().stop()
|
|
227
|
+
random_task = manage_task("neoeffects.random", "kill")
|
|
228
|
+
return f"{player_info}\n{random_task}"
|
|
229
|
+
|
|
230
|
+
def control(speed_ms=None, batch:bool=None):
|
|
231
|
+
"""
|
|
232
|
+
Change the speed of frame generation for animations.
|
|
233
|
+
"""
|
|
234
|
+
data = load().control(play_speed_ms=speed_ms, bt_draw=batch)
|
|
235
|
+
_speed_ms = data.get("player_speed", None)
|
|
236
|
+
return f"Control state: {data} (speed: {_speed_ms}ms)"
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def load(pixel_cnt=24):
|
|
240
|
+
"""
|
|
241
|
+
Load LM_neopixel and DrawEffectV2
|
|
242
|
+
"""
|
|
243
|
+
if DrawEffectV2.INSTANCE is None:
|
|
244
|
+
DrawEffectV2(pix_cnt=pixel_cnt)
|
|
245
|
+
return DrawEffectV2.INSTANCE
|
|
246
|
+
|
|
247
|
+
#######################
|
|
248
|
+
# LM helper functions #
|
|
249
|
+
#######################
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def pinmap():
|
|
253
|
+
"""
|
|
254
|
+
[i] micrOS LM naming convention
|
|
255
|
+
Shows logical pins - pin number(s) used by this Load module
|
|
256
|
+
- info which pins to use for this application
|
|
257
|
+
:return dict: pin name (str) - pin value (int) pairs
|
|
258
|
+
"""
|
|
259
|
+
return pm()
|
|
260
|
+
|
|
261
|
+
|
|
262
|
+
def help(widgets=False):
|
|
263
|
+
"""
|
|
264
|
+
[i] micrOS LM naming convention - built-in help message
|
|
265
|
+
:return tuple:
|
|
266
|
+
(widgets=False) list of functions implemented by this application
|
|
267
|
+
(widgets=True) list of widget json for UI generation
|
|
268
|
+
"""
|
|
269
|
+
return resolve(('load pixel_cnt=24',
|
|
270
|
+
'meteor speed_ms=60 shift=True batch=True',
|
|
271
|
+
'BUTTON meteor speed_ms=60',
|
|
272
|
+
'cycle speed_ms=60 shift=True batch=True',
|
|
273
|
+
'BUTTON cycle speed_ms=60',
|
|
274
|
+
'rainbow speed_ms=50 br=15 batch=True',
|
|
275
|
+
'BUTTON rainbow',
|
|
276
|
+
'fire speed_ms=150 br=30 batch=True',
|
|
277
|
+
'BUTTON fire speed_ms=150',
|
|
278
|
+
'BUTTON stop',
|
|
279
|
+
'shader offset=0 size=6',
|
|
280
|
+
'SLIDER control speed_ms=<1-200> batch=None',
|
|
281
|
+
'random max_val=255',
|
|
282
|
+
'pinmap',
|
|
283
|
+
'COLOR color r=<0-255-10> g b'
|
|
284
|
+
), widgets=widgets)
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
from neopixel import NeoPixel
|
|
2
2
|
from machine import Pin
|
|
3
|
-
from sys import platform
|
|
4
3
|
from utime import sleep_ms
|
|
5
|
-
from Common import transition_gen, micro_task
|
|
6
|
-
import
|
|
7
|
-
from microIO import physical_pin, pinmap_dump
|
|
4
|
+
from Common import transition_gen, micro_task, data_dir
|
|
5
|
+
from microIO import bind_pin, pinmap_search
|
|
8
6
|
from random import randint
|
|
9
7
|
from Types import resolve
|
|
10
8
|
|
|
@@ -20,6 +18,7 @@ class Data:
|
|
|
20
18
|
PERSISTENT_CACHE = False
|
|
21
19
|
RGB_TASK_TAG = "neopixel._tran"
|
|
22
20
|
TASK_STATE = False
|
|
21
|
+
FILE_CACHE = data_dir('neopixel.cache')
|
|
23
22
|
|
|
24
23
|
|
|
25
24
|
#########################################
|
|
@@ -27,13 +26,13 @@ class Data:
|
|
|
27
26
|
#########################################
|
|
28
27
|
|
|
29
28
|
|
|
30
|
-
def __init_NEOPIXEL(n=24):
|
|
29
|
+
def __init_NEOPIXEL(pin=None, n=24):
|
|
31
30
|
"""
|
|
32
31
|
Init NeoPixel module
|
|
33
32
|
n - number of led fragments
|
|
34
33
|
"""
|
|
35
34
|
if Data.NEOPIXEL_OBJ is None:
|
|
36
|
-
neopixel_pin = Pin(
|
|
35
|
+
neopixel_pin = Pin(bind_pin('neop', number=pin)) # Get Neopixel pin from LED PIN pool
|
|
37
36
|
Data.NEOPIXEL_OBJ = NeoPixel(neopixel_pin, n) # initialize for max 8 segments
|
|
38
37
|
del neopixel_pin
|
|
39
38
|
return Data.NEOPIXEL_OBJ
|
|
@@ -41,7 +40,7 @@ def __init_NEOPIXEL(n=24):
|
|
|
41
40
|
|
|
42
41
|
def __persistent_cache_manager(mode):
|
|
43
42
|
"""
|
|
44
|
-
|
|
43
|
+
File cache
|
|
45
44
|
modes:
|
|
46
45
|
r - recover, s - save
|
|
47
46
|
"""
|
|
@@ -49,12 +48,12 @@ def __persistent_cache_manager(mode):
|
|
|
49
48
|
return
|
|
50
49
|
if mode == 's':
|
|
51
50
|
# SAVE CACHE
|
|
52
|
-
with open(
|
|
51
|
+
with open(Data.FILE_CACHE, 'w') as f:
|
|
53
52
|
f.write(','.join([str(k) for k in Data.DCACHE]))
|
|
54
53
|
return
|
|
55
54
|
try:
|
|
56
55
|
# RESTORE CACHE
|
|
57
|
-
with open(
|
|
56
|
+
with open(Data.FILE_CACHE, 'r') as f:
|
|
58
57
|
Data.DCACHE = [float(data) for data in f.read().strip().split(',')]
|
|
59
58
|
except:
|
|
60
59
|
pass
|
|
@@ -73,20 +72,17 @@ def __state_machine(r, g, b):
|
|
|
73
72
|
# USER FUNCTIONS #
|
|
74
73
|
#########################################
|
|
75
74
|
|
|
76
|
-
def
|
|
75
|
+
def load(ledcnt=24, pin=None, cache=True):
|
|
77
76
|
"""
|
|
78
77
|
Initiate NeoPixel RGB module
|
|
79
|
-
:param
|
|
80
|
-
|
|
81
|
-
|
|
78
|
+
:param ledcnt: number of led segments
|
|
79
|
+
:param pin: optional number to overwrite default pin
|
|
80
|
+
:param cache: default True, store stages on disk + Load (.cache)
|
|
82
81
|
:return str: Cache state
|
|
83
82
|
"""
|
|
84
|
-
|
|
85
|
-
Data.PERSISTENT_CACHE = False if platform == 'esp8266' else True
|
|
86
|
-
else:
|
|
87
|
-
Data.PERSISTENT_CACHE = cache
|
|
83
|
+
Data.PERSISTENT_CACHE = cache
|
|
88
84
|
__persistent_cache_manager('r') # recover data cache
|
|
89
|
-
_ledcnt = __init_NEOPIXEL(n=ledcnt).n
|
|
85
|
+
_ledcnt = __init_NEOPIXEL(pin=pin, n=ledcnt).n
|
|
90
86
|
if Data.PERSISTENT_CACHE and Data.DCACHE[3] == 1:
|
|
91
87
|
Data.DCACHE[3] = 0 # Force ON at boot
|
|
92
88
|
toggle(True)
|
|
@@ -186,13 +182,13 @@ def segment(r=None, g=None, b=None, s=0, cache=False, write=True):
|
|
|
186
182
|
:param g: green value 0-255
|
|
187
183
|
:param b: blue value 0-255
|
|
188
184
|
:param s: segment - index 0-ledcnt
|
|
189
|
-
:param cache: cache color (update .
|
|
185
|
+
:param cache: cache color (update .cache file)
|
|
190
186
|
:param write: send color buffer to neopixel (update LEDs)
|
|
191
187
|
:return dict: rgb status - states: R, G, B, S
|
|
192
188
|
"""
|
|
193
|
-
r = Data.DCACHE[0] if r is None else r
|
|
194
|
-
g = Data.DCACHE[1] if g is None else g
|
|
195
|
-
b = Data.DCACHE[2] if b is None else b
|
|
189
|
+
r = int(Data.DCACHE[0]) if r is None else r
|
|
190
|
+
g = int(Data.DCACHE[1]) if g is None else g
|
|
191
|
+
b = int(Data.DCACHE[2]) if b is None else b
|
|
196
192
|
neo_n = __init_NEOPIXEL().n
|
|
197
193
|
if s <= neo_n:
|
|
198
194
|
Data.NEOPIXEL_OBJ[s] = (r, g, b)
|
|
@@ -269,7 +265,7 @@ def transition(r=None, g=None, b=None, sec=1.0, wake=False):
|
|
|
269
265
|
Data.DCACHE[1] = g_val if g_val > 5 else 5 # SAVE VALUE TO CACHE > 5 ! because toggle
|
|
270
266
|
Data.DCACHE[2] = b_val if b_val > 5 else 5 # SAVE VALUE TO CACHE > 5 ! because toggle
|
|
271
267
|
my_task.out = f"Dimming: R:{r_val} G:{g_val} B:{b_val}"
|
|
272
|
-
await
|
|
268
|
+
await my_task.feed(sleep_ms=ms_period)
|
|
273
269
|
if Data.DCACHE[3] == 1 or wake:
|
|
274
270
|
__state_machine(r=r_val, g=g_val, b=b_val)
|
|
275
271
|
my_task.out = f"Dimming DONE: R:{r_val} G:{g_val} B:{b_val}"
|
|
@@ -282,8 +278,7 @@ def transition(r=None, g=None, b=None, sec=1.0, wake=False):
|
|
|
282
278
|
# Create transition generator and calculate step_ms
|
|
283
279
|
rgb_gen, step_ms = transition_gen(r_from, r_to, g_from, g_to, b_from, b_to, interval_sec=sec)
|
|
284
280
|
# [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
|
|
285
|
-
|
|
286
|
-
return "Starting transition" if state else "Transition already running"
|
|
281
|
+
return micro_task(tag=Data.RGB_TASK_TAG, task=_task(ms_period=step_ms, iterable=rgb_gen))
|
|
287
282
|
|
|
288
283
|
|
|
289
284
|
def random(smooth=True, max_val=255):
|
|
@@ -332,7 +327,7 @@ def pinmap():
|
|
|
332
327
|
- info which pins to use for this application
|
|
333
328
|
:return dict: pin name (str) - pin value (int) pairs
|
|
334
329
|
"""
|
|
335
|
-
return
|
|
330
|
+
return pinmap_search('neop')
|
|
336
331
|
|
|
337
332
|
|
|
338
333
|
def help(widgets=False):
|
|
@@ -342,12 +337,12 @@ def help(widgets=False):
|
|
|
342
337
|
(widgets=False) list of functions implemented by this application
|
|
343
338
|
(widgets=True) list of widget json for UI generation
|
|
344
339
|
"""
|
|
345
|
-
return resolve(('COLOR color r=<0-255> g b smooth=True force=True',
|
|
346
|
-
'
|
|
347
|
-
'
|
|
340
|
+
return resolve(('COLOR color r=<0-255-5> g b smooth=True force=True',
|
|
341
|
+
'BUTTON toggle state=<True,False> smooth=True',
|
|
342
|
+
'load ledcnt=24',
|
|
348
343
|
'SLIDER brightness percent=<0-100> smooth=True wake=True',
|
|
349
|
-
'
|
|
350
|
-
'transition r
|
|
344
|
+
'segment r g b s=<0-n>',
|
|
345
|
+
'transition r g b sec=1.0 wake=False',
|
|
351
346
|
'BUTTON random smooth=True max_val=254',
|
|
352
347
|
'status',
|
|
353
348
|
'subscribe_presence',
|