micrOSDevToolKit 2.9.1__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/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-20241129-v1.24.1.bin → 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 +167 -163
- micrOS/source/Auth.py +37 -0
- micrOS/source/Common.py +361 -116
- micrOS/source/Config.py +32 -22
- micrOS/source/Debug.py +50 -94
- micrOS/source/Espnow.py +377 -100
- micrOS/source/Files.py +207 -0
- micrOS/source/Hooks.py +48 -20
- micrOS/source/InterConnect.py +126 -42
- micrOS/source/Interrupts.py +6 -6
- micrOS/source/Logger.py +63 -26
- micrOS/source/Network.py +41 -21
- micrOS/source/Notify.py +48 -22
- micrOS/source/Pacman.py +326 -0
- micrOS/source/Scheduler.py +14 -54
- micrOS/source/Server.py +67 -69
- micrOS/source/Shell.py +99 -91
- micrOS/source/Tasks.py +141 -95
- micrOS/source/Time.py +19 -18
- micrOS/source/Types.py +53 -9
- micrOS/source/Web.py +381 -76
- 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/config/_git.keep +0 -0
- micrOS/source/helpers.py +132 -0
- micrOS/source/micrOS.py +17 -7
- micrOS/source/micrOSloader.py +5 -12
- micrOS/source/microIO.py +44 -20
- micrOS/source/modules/IO_esp32c6.py +38 -0
- micrOS/source/{IO_esp32s3.py → modules/IO_esp32s3.py} +37 -1
- micrOS/source/{IO_m5stamp.py → modules/IO_m5stamp.py} +35 -1
- micrOS/source/{IO_qtpy.py → modules/IO_qtpy.py} +22 -17
- micrOS/source/{IO_tinypico.py → modules/IO_tinypico.py} +38 -0
- micrOS/source/modules/LM_L298N.py +161 -0
- {toolkit/workspace/precompiled → micrOS/source/modules}/LM_L9110_DCmotor.py +3 -3
- micrOS/source/{LM_OV2640.py → modules/LM_OV2640.py} +45 -27
- micrOS/source/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +3 -3
- micrOS/source/{LM_aht10.py → modules/LM_aht10.py} +2 -2
- micrOS/source/{LM_bme280.py → modules/LM_bme280.py} +3 -3
- micrOS/source/{LM_buzzer.py → modules/LM_buzzer.py} +18 -25
- micrOS/source/{LM_cct.py → modules/LM_cct.py} +17 -21
- micrOS/source/modules/LM_cluster.py +255 -0
- micrOS/source/{LM_co2.py → modules/LM_co2.py} +3 -3
- micrOS/source/{LM_dht11.py → modules/LM_dht11.py} +2 -2
- micrOS/source/{LM_dht22.py → modules/LM_dht22.py} +2 -2
- micrOS/source/{LM_dimmer.py → modules/LM_dimmer.py} +9 -9
- micrOS/source/{LM_distance.py → modules/LM_distance.py} +4 -6
- micrOS/source/{LM_ds18.py → modules/LM_ds18.py} +2 -2
- micrOS/source/{LM_esp32.py → modules/LM_esp32.py} +5 -0
- micrOS/source/modules/LM_espnow.py +53 -0
- micrOS/source/modules/LM_fileserver.py +265 -0
- micrOS/source/{LM_genIO.py → modules/LM_genIO.py} +52 -37
- micrOS/source/{LM_haptic.py → modules/LM_haptic.py} +2 -2
- {toolkit/workspace/precompiled → micrOS/source/modules}/LM_i2c.py +5 -4
- micrOS/source/{LM_i2s_mic.py → modules/LM_i2s_mic.py} +6 -7
- micrOS/source/{LM_ld2410.py → modules/LM_ld2410.py} +2 -2
- micrOS/source/{LM_light_sensor.py → modules/LM_light_sensor.py} +10 -21
- 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} +19 -23
- micrOS/source/{LM_oled.py → modules/LM_oled.py} +2 -2
- micrOS/source/{LM_oled_sh1106.py → modules/LM_oled_sh1106.py} +3 -3
- micrOS/source/{LM_oled_ui.py → modules/LM_oled_ui.py} +72 -64
- micrOS/source/modules/LM_pacman.py +320 -0
- micrOS/source/{LM_presence.py → modules/LM_presence.py} +11 -15
- micrOS/source/modules/LM_qmi8658.py +204 -0
- micrOS/source/{LM_rencoder.py → modules/LM_rencoder.py} +2 -2
- micrOS/source/{LM_rest.py → modules/LM_rest.py} +4 -6
- micrOS/source/{LM_rgb.py → modules/LM_rgb.py} +21 -29
- micrOS/source/{LM_roboarm.py → modules/LM_roboarm.py} +8 -8
- micrOS/source/modules/LM_robustness.py +137 -0
- micrOS/source/{LM_servo.py → modules/LM_servo.py} +3 -3
- micrOS/source/{LM_stepper.py → modules/LM_stepper.py} +5 -5
- micrOS/source/{LM_switch.py → modules/LM_switch.py} +11 -9
- micrOS/source/{LM_system.py → modules/LM_system.py} +38 -32
- micrOS/source/modules/LM_tcs3472.py +187 -0
- micrOS/source/{LM_telegram.py → modules/LM_telegram.py} +164 -116
- micrOS/source/{LM_trackball.py → modules/LM_trackball.py} +3 -3
- micrOS/source/{LM_veml7700.py → modules/LM_veml7700.py} +2 -2
- micrOS/source/modules/LM_web.py +38 -0
- micrOS/source/urequests.py +39 -15
- {toolkit/workspace/precompiled → micrOS/source/web}/dashboard.html +4 -0
- micrOS/source/web/editor.js +440 -0
- micrOS/source/web/filesui.html +178 -0
- micrOS/source/web/filesui.js +338 -0
- {toolkit/workspace/precompiled → micrOS/source/web}/index.html +44 -2
- micrOS/source/{uapi.js → web/uapi.js} +48 -7
- micrOS/source/{ustyle.css → web/ustyle.css} +6 -3
- micrOS/utests/__init__.py +0 -0
- micrOS/utests/test_scheduler.py +435 -0
- {micrOSDevToolKit-2.9.1.data → microsdevtoolkit-2.26.1.data}/scripts/devToolKit.py +33 -3
- {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info}/METADATA +327 -268
- microsdevtoolkit-2.26.1.dist-info/RECORD +396 -0
- {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info}/WHEEL +1 -1
- toolkit/DevEnvCompile.py +63 -33
- toolkit/DevEnvOTA.py +58 -22
- toolkit/DevEnvUSB.py +110 -55
- toolkit/Gateway.py +6 -6
- toolkit/LM_to_compile.dat +6 -4
- toolkit/MicrOSDevEnv.py +127 -57
- toolkit/WebRepl.py +73 -0
- toolkit/dashboard_apps/BackupRestore.py +20 -35
- 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 +1 -6
- 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 +202 -105
- toolkit/dashboard_apps/Template_app.py +11 -23
- 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 +4 -4
- 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 +6 -0
- toolkit/lib/micrOSClient.py +123 -50
- toolkit/lib/micrOSClientHistory.py +156 -0
- toolkit/lib/pip_package_installer.py +5 -2
- toolkit/micrOSdashboard.py +12 -17
- toolkit/micrOSlint.py +20 -8
- 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__/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/dht.py +1 -1
- toolkit/simulator_lib/framebuf.py +49 -1
- toolkit/simulator_lib/machine.py +17 -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 +137 -59
- toolkit/simulator_lib/uasyncio.py +33 -2
- toolkit/simulator_lib/uos.py +147 -0
- toolkit/simulator_lib/urandom.py +4 -0
- toolkit/socketClient.py +43 -23
- toolkit/user_data/webhooks/generic.py +1 -1
- toolkit/user_data/webhooks/macro.py +1 -1
- 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/{IO_esp32.mpy → modules/IO_esp32.mpy} +0 -0
- toolkit/workspace/precompiled/{IO_esp32c3.mpy → modules/IO_esp32c3.mpy} +0 -0
- toolkit/workspace/precompiled/modules/IO_esp32c6.mpy +0 -0
- toolkit/workspace/precompiled/{IO_esp32s2.mpy → 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 +3 -3
- toolkit/workspace/precompiled/modules/LM_OV2640.mpy +0 -0
- toolkit/workspace/precompiled/{LM_VL53L0X.py → modules/LM_VL53L0X.py} +3 -3
- toolkit/workspace/precompiled/{LM_aht10.mpy → modules/LM_aht10.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_bme280.mpy → 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/{LM_co2.mpy → modules/LM_co2.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_dht11.mpy → modules/LM_dht11.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_dht22.mpy → 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/{LM_ds18.mpy → modules/LM_ds18.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_esp32.py → modules/LM_esp32.py} +5 -0
- 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/{LM_haptic.mpy → modules/LM_haptic.mpy} +0 -0
- {micrOS/source → toolkit/workspace/precompiled/modules}/LM_i2c.py +5 -4
- 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/{LM_oled.mpy → modules/LM_oled.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_oled_sh1106.mpy → 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} +2 -2
- 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_servo.mpy → modules/LM_servo.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_sound_event.mpy → 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/{LM_trackball.mpy → modules/LM_trackball.mpy} +0 -0
- toolkit/workspace/precompiled/{LM_veml7700.mpy → 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 +4 -0
- toolkit/workspace/precompiled/web/editor.js +440 -0
- toolkit/workspace/precompiled/web/filesui.html +178 -0
- toolkit/workspace/precompiled/web/filesui.js +338 -0
- {micrOS/source → toolkit/workspace/precompiled/web}/index.html +44 -2
- toolkit/workspace/precompiled/{uapi.js → web/uapi.js} +48 -7
- toolkit/workspace/precompiled/{ustyle.css → web/ustyle.css} +6 -3
- micrOS/micropython/esp32-20241129-v1.24.1.bin +0 -0
- micrOS/micropython/esp32c3-20240222-v1.22.2.bin +0 -0
- micrOS/micropython/esp32s2-20240602-v1.23.0.bin +0 -0
- micrOS/micropython/esp32s2-LOLIN_MINI-20220618-v1.19.1.bin +0 -0
- micrOS/micropython/esp32s2-LOLIN_MINI-20240602-v1.23.0.bin +0 -0
- micrOS/micropython/esp32s3-20240105-v1.22.1.bin +0 -0
- micrOS/micropython/esp32s3_spiram_oct-20231005-v1.21.0.bin +0 -0
- micrOS/micropython/esp32s3_spiram_oct-20241129-v1.24.1.bin +0 -0
- micrOS/micropython/rpi-pico-w-20241129-v1.24.1.uf2 +0 -0
- micrOS/micropython/tinypico-20241129-v1.24.1.bin +0 -0
- micrOS/source/LM_L298N_DCmotor.py +0 -86
- micrOS/source/LM_catgame.py +0 -75
- micrOS/source/LM_dashboard_be.py +0 -37
- micrOS/source/LM_demo.py +0 -97
- micrOS/source/LM_espnow.py +0 -23
- micrOS/source/LM_intercon.py +0 -57
- micrOS/source/LM_keychain.py +0 -322
- micrOS/source/LM_lmpacman.py +0 -126
- micrOS/source/LM_neoeffects.py +0 -331
- micrOS/source/LM_oledui.py +0 -972
- micrOS/source/LM_pet_feeder.py +0 -78
- micrOS/source/LM_ph_sensor.py +0 -51
- micrOS/source/LM_robustness.py +0 -74
- micrOS/source/reset.py +0 -11
- micrOSDevToolKit-2.9.1.dist-info/RECORD +0 -365
- 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__/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_esp32s3.mpy +0 -0
- toolkit/workspace/precompiled/IO_m5stamp.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_catgame.py +0 -75
- toolkit/workspace/precompiled/LM_cct.mpy +0 -0
- toolkit/workspace/precompiled/LM_dashboard_be.py +0 -37
- toolkit/workspace/precompiled/LM_demo.py +0 -97
- toolkit/workspace/precompiled/LM_dimmer.mpy +0 -0
- toolkit/workspace/precompiled/LM_distance.mpy +0 -0
- toolkit/workspace/precompiled/LM_espnow.py +0 -23
- toolkit/workspace/precompiled/LM_genIO.mpy +0 -0
- 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_ui.mpy +0 -0
- toolkit/workspace/precompiled/LM_oledui.mpy +0 -0
- toolkit/workspace/precompiled/LM_pet_feeder.py +0 -78
- 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 -74
- 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/node_config.json +0 -1
- toolkit/workspace/precompiled/reset.mpy +0 -0
- /micrOS/source/{IO_esp32.py → modules/IO_esp32.py} +0 -0
- /micrOS/source/{IO_esp32c3.py → modules/IO_esp32c3.py} +0 -0
- /micrOS/source/{IO_esp32s2.py → modules/IO_esp32s2.py} +0 -0
- /micrOS/source/{IO_rp2.py → modules/IO_rp2.py} +0 -0
- /micrOS/source/{LM_gameOfLife.py → modules/LM_gameOfLife.py} +0 -0
- /micrOS/source/{LM_rgbcct.py → modules/LM_rgbcct.py} +0 -0
- /micrOS/source/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
- /micrOS/source/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
- /micrOS/source/{LM_sound_event.py → modules/LM_sound_event.py} +0 -0
- /micrOS/source/{LM_tinyrgb.py → modules/LM_tinyrgb.py} +0 -0
- /micrOS/source/{udashboard.js → web/udashboard.js} +0 -0
- /micrOS/source/{uwidgets.js → web/uwidgets.js} +0 -0
- /micrOS/source/{uwidgets_pro.js → web/uwidgets_pro.js} +0 -0
- {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info/licenses}/LICENSE +0 -0
- {micrOSDevToolKit-2.9.1.dist-info → microsdevtoolkit-2.26.1.dist-info}/top_level.txt +0 -0
- /toolkit/workspace/precompiled/{LM_rp2w.py → modules/LM_rp2w.py} +0 -0
- /toolkit/workspace/precompiled/{LM_sdcard.py → modules/LM_sdcard.py} +0 -0
- /toolkit/workspace/precompiled/{udashboard.js → web/udashboard.js} +0 -0
- /toolkit/workspace/precompiled/{uwidgets.js → web/uwidgets.js} +0 -0
- /toolkit/workspace/precompiled/{uwidgets_pro.js → web/uwidgets_pro.js} +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,9 +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
|
-
from microIO import
|
|
4
|
+
from Common import transition_gen, micro_task, data_dir
|
|
5
|
+
from microIO import bind_pin, pinmap_search
|
|
7
6
|
from random import randint
|
|
8
7
|
from Types import resolve
|
|
9
8
|
|
|
@@ -19,6 +18,7 @@ class Data:
|
|
|
19
18
|
PERSISTENT_CACHE = False
|
|
20
19
|
RGB_TASK_TAG = "neopixel._tran"
|
|
21
20
|
TASK_STATE = False
|
|
21
|
+
FILE_CACHE = data_dir('neopixel.cache')
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
#########################################
|
|
@@ -26,13 +26,13 @@ class Data:
|
|
|
26
26
|
#########################################
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
def __init_NEOPIXEL(n=24):
|
|
29
|
+
def __init_NEOPIXEL(pin=None, n=24):
|
|
30
30
|
"""
|
|
31
31
|
Init NeoPixel module
|
|
32
32
|
n - number of led fragments
|
|
33
33
|
"""
|
|
34
34
|
if Data.NEOPIXEL_OBJ is None:
|
|
35
|
-
neopixel_pin = Pin(
|
|
35
|
+
neopixel_pin = Pin(bind_pin('neop', number=pin)) # Get Neopixel pin from LED PIN pool
|
|
36
36
|
Data.NEOPIXEL_OBJ = NeoPixel(neopixel_pin, n) # initialize for max 8 segments
|
|
37
37
|
del neopixel_pin
|
|
38
38
|
return Data.NEOPIXEL_OBJ
|
|
@@ -40,7 +40,7 @@ def __init_NEOPIXEL(n=24):
|
|
|
40
40
|
|
|
41
41
|
def __persistent_cache_manager(mode):
|
|
42
42
|
"""
|
|
43
|
-
|
|
43
|
+
File cache
|
|
44
44
|
modes:
|
|
45
45
|
r - recover, s - save
|
|
46
46
|
"""
|
|
@@ -48,12 +48,12 @@ def __persistent_cache_manager(mode):
|
|
|
48
48
|
return
|
|
49
49
|
if mode == 's':
|
|
50
50
|
# SAVE CACHE
|
|
51
|
-
with open(
|
|
51
|
+
with open(Data.FILE_CACHE, 'w') as f:
|
|
52
52
|
f.write(','.join([str(k) for k in Data.DCACHE]))
|
|
53
53
|
return
|
|
54
54
|
try:
|
|
55
55
|
# RESTORE CACHE
|
|
56
|
-
with open(
|
|
56
|
+
with open(Data.FILE_CACHE, 'r') as f:
|
|
57
57
|
Data.DCACHE = [float(data) for data in f.read().strip().split(',')]
|
|
58
58
|
except:
|
|
59
59
|
pass
|
|
@@ -72,20 +72,17 @@ def __state_machine(r, g, b):
|
|
|
72
72
|
# USER FUNCTIONS #
|
|
73
73
|
#########################################
|
|
74
74
|
|
|
75
|
-
def load(
|
|
75
|
+
def load(ledcnt=24, pin=None, cache=True):
|
|
76
76
|
"""
|
|
77
77
|
Initiate NeoPixel RGB module
|
|
78
|
-
:param
|
|
79
|
-
|
|
80
|
-
|
|
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)
|
|
81
81
|
:return str: Cache state
|
|
82
82
|
"""
|
|
83
|
-
|
|
84
|
-
Data.PERSISTENT_CACHE = False if platform == 'esp8266' else True
|
|
85
|
-
else:
|
|
86
|
-
Data.PERSISTENT_CACHE = cache
|
|
83
|
+
Data.PERSISTENT_CACHE = cache
|
|
87
84
|
__persistent_cache_manager('r') # recover data cache
|
|
88
|
-
_ledcnt = __init_NEOPIXEL(n=ledcnt).n
|
|
85
|
+
_ledcnt = __init_NEOPIXEL(pin=pin, n=ledcnt).n
|
|
89
86
|
if Data.PERSISTENT_CACHE and Data.DCACHE[3] == 1:
|
|
90
87
|
Data.DCACHE[3] = 0 # Force ON at boot
|
|
91
88
|
toggle(True)
|
|
@@ -185,13 +182,13 @@ def segment(r=None, g=None, b=None, s=0, cache=False, write=True):
|
|
|
185
182
|
:param g: green value 0-255
|
|
186
183
|
:param b: blue value 0-255
|
|
187
184
|
:param s: segment - index 0-ledcnt
|
|
188
|
-
:param cache: cache color (update .
|
|
185
|
+
:param cache: cache color (update .cache file)
|
|
189
186
|
:param write: send color buffer to neopixel (update LEDs)
|
|
190
187
|
:return dict: rgb status - states: R, G, B, S
|
|
191
188
|
"""
|
|
192
|
-
r = Data.DCACHE[0] if r is None else r
|
|
193
|
-
g = Data.DCACHE[1] if g is None else g
|
|
194
|
-
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
|
|
195
192
|
neo_n = __init_NEOPIXEL().n
|
|
196
193
|
if s <= neo_n:
|
|
197
194
|
Data.NEOPIXEL_OBJ[s] = (r, g, b)
|
|
@@ -281,8 +278,7 @@ def transition(r=None, g=None, b=None, sec=1.0, wake=False):
|
|
|
281
278
|
# Create transition generator and calculate step_ms
|
|
282
279
|
rgb_gen, step_ms = transition_gen(r_from, r_to, g_from, g_to, b_from, b_to, interval_sec=sec)
|
|
283
280
|
# [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
|
|
284
|
-
|
|
285
|
-
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))
|
|
286
282
|
|
|
287
283
|
|
|
288
284
|
def random(smooth=True, max_val=255):
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from micropython import const
|
|
4
4
|
import framebuf
|
|
5
5
|
from machine import Pin, SoftI2C
|
|
6
|
-
from microIO import
|
|
6
|
+
from microIO import bind_pin, pinmap_search
|
|
7
7
|
from Types import resolve
|
|
8
8
|
|
|
9
9
|
__INVERT = False
|
|
@@ -165,7 +165,7 @@ def load(width=128, height=64, brightness=50):
|
|
|
165
165
|
:param brightness: percentage
|
|
166
166
|
"""
|
|
167
167
|
if SSD1306_I2C.OLED_OBJ is None:
|
|
168
|
-
i2c = SoftI2C(Pin(
|
|
168
|
+
i2c = SoftI2C(Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')))
|
|
169
169
|
# TODO: scan device - abort if no device is available
|
|
170
170
|
SSD1306_I2C.OLED_OBJ = SSD1306_I2C(width, height, i2c)
|
|
171
171
|
SSD1306_I2C.OLED_OBJ.contrast(percent=brightness)
|
|
@@ -16,7 +16,7 @@ from micropython import const
|
|
|
16
16
|
import utime as time
|
|
17
17
|
import framebuf
|
|
18
18
|
from machine import Pin, I2C
|
|
19
|
-
from microIO import
|
|
19
|
+
from microIO import bind_pin, pinmap_search
|
|
20
20
|
from Types import resolve
|
|
21
21
|
|
|
22
22
|
__INVERT = False
|
|
@@ -224,8 +224,8 @@ class SH1106_I2C(SH1106):
|
|
|
224
224
|
|
|
225
225
|
def load(width=128, height=64, brightness=50, rotate=180):
|
|
226
226
|
if SH1106_I2C.OLED_OBJ is None:
|
|
227
|
-
#i2c = SoftI2C(Pin(
|
|
228
|
-
i2c = I2C(scl=Pin(
|
|
227
|
+
#i2c = SoftI2C(Pin(bind_pin('i2c_scl')), Pin(bind_pin('i2c_sda')))
|
|
228
|
+
i2c = I2C(scl=Pin(bind_pin('i2c_scl')), sda=Pin(bind_pin('i2c_sda')), freq=400000)
|
|
229
229
|
# TODO: scan device - abort if no device is available
|
|
230
230
|
SH1106_I2C.OLED_OBJ = SH1106_I2C(width, height, i2c, rotate=rotate)
|
|
231
231
|
SH1106_I2C.OLED_OBJ.contrast(percent=brightness)
|