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,320 @@
|
|
|
1
|
+
from sys import modules
|
|
2
|
+
from Common import socket_stream
|
|
3
|
+
from Files import list_fs, ilist_fs, remove_file, remove_dir, OSPath, path_join, is_protected
|
|
4
|
+
from Auth import sudo
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
#############################################
|
|
8
|
+
# Safe file system handler functions #
|
|
9
|
+
#############################################
|
|
10
|
+
|
|
11
|
+
def ls(path="/", content='*', raw=False, select='*', core=False):
|
|
12
|
+
"""
|
|
13
|
+
Linux like ls command - list app resources and app folders
|
|
14
|
+
:param path: path to list, default: /
|
|
15
|
+
:param content: content type, default all, f-file, d-dir can be selected
|
|
16
|
+
:param raw: keep raw output [(is_app, type), ...]
|
|
17
|
+
:param select: select specific app resource: LM or IO, default: all
|
|
18
|
+
:param core: include core system files
|
|
19
|
+
"""
|
|
20
|
+
items = list_fs(path, content, select=select, core=core)
|
|
21
|
+
if raw:
|
|
22
|
+
return items
|
|
23
|
+
|
|
24
|
+
# Build a formatted output (just like `ls -l` style index)
|
|
25
|
+
lines = ""
|
|
26
|
+
for i, f in enumerate(items):
|
|
27
|
+
spacer = " " * (4 - len(str(i+1)))
|
|
28
|
+
if content == "*":
|
|
29
|
+
lines += f"{i+1}{spacer}{f[0]} {f[1]}\n"
|
|
30
|
+
else:
|
|
31
|
+
lines += f"{i + 1}{spacer}{f}\n"
|
|
32
|
+
return lines
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@sudo(_force_only=(True, 1))
|
|
36
|
+
def rm(path, force=False):
|
|
37
|
+
"""
|
|
38
|
+
Linux like rm command - delete app resources and folders
|
|
39
|
+
:param path: app resource name/path, ex.: LM_robustness.py
|
|
40
|
+
:param force: bypasses protection check - sudo mode
|
|
41
|
+
"""
|
|
42
|
+
return remove_file(path, force)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@sudo(_force_only=(True, 1))
|
|
46
|
+
def rmdir(path, force=False):
|
|
47
|
+
"""
|
|
48
|
+
Linux like rmdir command for directory deletion
|
|
49
|
+
:param path: app resource folder path, ex.: /lib/myapp
|
|
50
|
+
:param force: bypasses protection check - sudo mode
|
|
51
|
+
"""
|
|
52
|
+
return remove_dir(path, force)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def dirtree(path="/", raw=False, core=False):
|
|
56
|
+
"""Return only directories from a given path."""
|
|
57
|
+
path = path if path.endswith('/') else f"{path}/"
|
|
58
|
+
folders = [path_join(path, item) for item in ilist_fs(path, type_filter='d', core=core)]
|
|
59
|
+
folder_contents = {folder:list_fs(folder) for folder in folders}
|
|
60
|
+
if raw:
|
|
61
|
+
return folder_contents
|
|
62
|
+
formatted_output = ""
|
|
63
|
+
for k, v in folder_contents.items():
|
|
64
|
+
formatted_output += f"{k}\n"
|
|
65
|
+
for val in v:
|
|
66
|
+
formatted_output += f"\t{val[0]} {val[1]}\n"
|
|
67
|
+
return formatted_output
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def cat(path):
|
|
71
|
+
"""
|
|
72
|
+
Dump any file content
|
|
73
|
+
"""
|
|
74
|
+
if is_protected(path):
|
|
75
|
+
return f'Read not allowed'
|
|
76
|
+
with open(path, 'r') as f:
|
|
77
|
+
content = f.read()
|
|
78
|
+
return content
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def install(ref=None):
|
|
82
|
+
"""
|
|
83
|
+
Unified mip-based installer for micrOS.
|
|
84
|
+
Automatically detects:
|
|
85
|
+
1. Official MicroPython packages (from https://micropython.org/pi/v2)
|
|
86
|
+
Example: pacman install "umqtt.simple"
|
|
87
|
+
2. Single-file load modules (LM_/IO_ names or URLs)
|
|
88
|
+
Example: pacman install "https://github.com/BxNxM/micrOS/blob/master/toolkit/workspace/precompiled/modules/LM_rgb.mpy"
|
|
89
|
+
pacman install "github.com/BxNxM/micrOS/blob/master/toolkit/workspace/precompiled/modules/LM_rgb.mpy"
|
|
90
|
+
3. GitHub packages (folders via tree/blob URLs or github: form)
|
|
91
|
+
Example: pacman install "github:peterhinch/micropython-mqtt"
|
|
92
|
+
pacman install "https://github.com/peterhinch/micropython-mqtt/tree/master"
|
|
93
|
+
pacman install "https://github.com/peterhinch/micropython-mqtt/blob/master/package.json"
|
|
94
|
+
pacman install "https://github.com/peterhinch/micropython-mqtt"
|
|
95
|
+
[NOK] pacman install "https://github.com/basanovase/sim7600/tree/main/sim7600" -> Package not found: github:basanovase/sim7600/package.json
|
|
96
|
+
4. Install from local /config/requirements.txt file
|
|
97
|
+
Example: pacman install "requirements.txt"
|
|
98
|
+
"""
|
|
99
|
+
from Pacman import install as pm_install
|
|
100
|
+
return pm_install(ref)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@sudo
|
|
104
|
+
def uninstall(name=None):
|
|
105
|
+
"""
|
|
106
|
+
Delete package by name from /lib
|
|
107
|
+
:param name: None (default) show installed package name
|
|
108
|
+
OR package name to delete (str)
|
|
109
|
+
"""
|
|
110
|
+
if name is None:
|
|
111
|
+
return list_fs(path=OSPath.LIB, type_filter='d')
|
|
112
|
+
from Pacman import uninstall as pm_uninstall
|
|
113
|
+
return pm_uninstall(name)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def upgrade(name=None, force=False):
|
|
117
|
+
"""
|
|
118
|
+
Upgrade package by name from /lib
|
|
119
|
+
:param name: None (default) show installed package name
|
|
120
|
+
OR package name to upgrade (str)
|
|
121
|
+
:param force: skip version check
|
|
122
|
+
"""
|
|
123
|
+
if name is None:
|
|
124
|
+
return list_fs(path=OSPath.LIB, type_filter='d')
|
|
125
|
+
from Pacman import upgrade as pm_upgrade
|
|
126
|
+
return pm_upgrade(name, force)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def del_duplicates(migrate=True):
|
|
130
|
+
"""
|
|
131
|
+
Load module package manager (Not just load modules)
|
|
132
|
+
- delete duplicated .mpy and .py resources, keep .mpy resource!
|
|
133
|
+
"""
|
|
134
|
+
modules_path = OSPath.MODULES
|
|
135
|
+
msg_buf = []
|
|
136
|
+
files = list_fs(path=modules_path, type_filter='f', select='LM')
|
|
137
|
+
py = list((res.split('.')[0] for res in files if res.endswith('.py'))) # Normally smaller list
|
|
138
|
+
mpy = (res.split('.')[0] for res in files if res.endswith('.mpy'))
|
|
139
|
+
for m in mpy:
|
|
140
|
+
# Iterate over mpy resources
|
|
141
|
+
state = True
|
|
142
|
+
if m in py and m != 'main':
|
|
143
|
+
to_delete = f'{m}.py'
|
|
144
|
+
try:
|
|
145
|
+
verdict = remove_file(path_join(modules_path, to_delete))
|
|
146
|
+
except:
|
|
147
|
+
verdict = "n/a"
|
|
148
|
+
state = False
|
|
149
|
+
msg_buf.append(f' Delete {to_delete} {state} - {verdict}')
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
# MIGRATE /ROOT/LMs & IOs -> /modules
|
|
153
|
+
def _migrate_from_root(_rf):
|
|
154
|
+
nonlocal _deleted, files
|
|
155
|
+
if _rf in files:
|
|
156
|
+
remove_file(path_join(OSPath._ROOT, _rf))
|
|
157
|
+
if _rf in ("LM_pacman.mpy", "LM_system.mpy"):
|
|
158
|
+
# Delete protected LMs from root
|
|
159
|
+
remove(path_join(OSPath._ROOT, _rf))
|
|
160
|
+
_deleted += 1
|
|
161
|
+
else:
|
|
162
|
+
rename(path_join(OSPath._ROOT, _rf), path_join(modules_path, _rf))
|
|
163
|
+
msg_buf.append(f' Move /{_rf} -> modules/{_rf}')
|
|
164
|
+
if migrate:
|
|
165
|
+
from uos import rename, remove
|
|
166
|
+
_deleted = 0
|
|
167
|
+
files = files + list_fs(path=OSPath._ROOT, type_filter='f', select='IO')
|
|
168
|
+
for rf in ilist_fs(path=OSPath._ROOT, type_filter='f', select='LM'):
|
|
169
|
+
_migrate_from_root(rf)
|
|
170
|
+
for rf in ilist_fs(path=OSPath._ROOT, type_filter='f', select='IO'):
|
|
171
|
+
_migrate_from_root(rf)
|
|
172
|
+
if _deleted > 0:
|
|
173
|
+
msg_buf.append(f' Purged (/): {_deleted}')
|
|
174
|
+
|
|
175
|
+
return '\n'.join(msg_buf) if len(msg_buf) > 0 else 'Nothing to delete.'
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def moduls(unload=None):
|
|
179
|
+
"""
|
|
180
|
+
List / unload loaded upython Load Modules
|
|
181
|
+
:param unload: module name to unload
|
|
182
|
+
:param unload: None - list active modules
|
|
183
|
+
:return str: verdict
|
|
184
|
+
"""
|
|
185
|
+
if unload is None:
|
|
186
|
+
return list(modules.keys())
|
|
187
|
+
if unload in modules.keys():
|
|
188
|
+
del modules[unload]
|
|
189
|
+
return f"Module unload {unload} done."
|
|
190
|
+
return f"Module unload {unload} failed."
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
@socket_stream
|
|
194
|
+
def cachedump(delete=None, ext="cache", msgobj=None):
|
|
195
|
+
"""
|
|
196
|
+
Cache system persistent data storage files (.cache)
|
|
197
|
+
:param delete: cache name to delete
|
|
198
|
+
:param ext: cache file extension (default: cache)
|
|
199
|
+
"""
|
|
200
|
+
data_dir = OSPath.DATA
|
|
201
|
+
if delete is None:
|
|
202
|
+
# List cache files aka application cache
|
|
203
|
+
msg_buf = []
|
|
204
|
+
for cache in (c for c in ilist_fs(data_dir, type_filter='f') if c.endswith('.cache')):
|
|
205
|
+
_path = path_join(data_dir, cache)
|
|
206
|
+
with open(_path, 'r') as f:
|
|
207
|
+
if msgobj is None:
|
|
208
|
+
msg_buf.append(f'{_path}: {f.read()}')
|
|
209
|
+
else:
|
|
210
|
+
msgobj(f'{_path}: {f.read()}')
|
|
211
|
+
return msg_buf if len(msg_buf) > 0 else ''
|
|
212
|
+
# Remove given cache file
|
|
213
|
+
try:
|
|
214
|
+
delete_cache = path_join(data_dir, f"{delete}.cache")
|
|
215
|
+
verdict = remove_file(delete_cache)
|
|
216
|
+
return f'{delete_cache} delete done.: {verdict}'
|
|
217
|
+
except:
|
|
218
|
+
return f'{delete}.{ext} not exists'
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def datdump():
|
|
222
|
+
"""
|
|
223
|
+
Generic .dat file dump
|
|
224
|
+
- logged data from LMs, sensor data, etc...
|
|
225
|
+
"""
|
|
226
|
+
data_dir = OSPath.DATA
|
|
227
|
+
dats = (f for f in ilist_fs(data_dir, type_filter='f') if f.endswith('.dat'))
|
|
228
|
+
out = {}
|
|
229
|
+
for dat in dats:
|
|
230
|
+
with open(path_join(data_dir, dat), 'r') as f:
|
|
231
|
+
out[dat] = f.read()
|
|
232
|
+
return out
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def makedir(path):
|
|
236
|
+
"""
|
|
237
|
+
Create directory command
|
|
238
|
+
"""
|
|
239
|
+
from uos import mkdir
|
|
240
|
+
try:
|
|
241
|
+
mkdir(path)
|
|
242
|
+
return f"{path} dir created."
|
|
243
|
+
except Exception as e:
|
|
244
|
+
return f"{path} failed to create: {e}"
|
|
245
|
+
|
|
246
|
+
#############################################
|
|
247
|
+
# Legacy features #
|
|
248
|
+
#############################################
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
@socket_stream
|
|
252
|
+
def listmods(msgobj=None):
|
|
253
|
+
"""
|
|
254
|
+
Load module package manager
|
|
255
|
+
- list all load modules
|
|
256
|
+
"""
|
|
257
|
+
# Dump available LMs
|
|
258
|
+
msg_buf = []
|
|
259
|
+
for k in (res.replace('LM_', '') for res in ilist_fs(path=OSPath.MODULES, type_filter='f', select='LM')):
|
|
260
|
+
if msgobj is None:
|
|
261
|
+
msg_buf.append(f' {k}')
|
|
262
|
+
else:
|
|
263
|
+
msgobj(f' {k}')
|
|
264
|
+
return msg_buf if len(msg_buf) > 0 else ''
|
|
265
|
+
|
|
266
|
+
|
|
267
|
+
@sudo
|
|
268
|
+
def delmod(mod):
|
|
269
|
+
"""
|
|
270
|
+
Module package manager
|
|
271
|
+
:param mod:
|
|
272
|
+
Delete Load Module with full name: module.py or module.mpy
|
|
273
|
+
OR delete any web resource: *.js, *.css, *.html
|
|
274
|
+
"""
|
|
275
|
+
if mod.endswith('py'):
|
|
276
|
+
to_remove = f'LM_{mod}'
|
|
277
|
+
else:
|
|
278
|
+
return f'Invalid {mod}, must ends with .py or .mpy'
|
|
279
|
+
try:
|
|
280
|
+
return remove_file(path_join(OSPath.MODULES, to_remove))
|
|
281
|
+
except Exception as e:
|
|
282
|
+
return f'Cannot delete: {mod}: {e}'
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@socket_stream
|
|
286
|
+
def micros_checksum(msgobj=None):
|
|
287
|
+
from hashlib import sha1
|
|
288
|
+
from binascii import hexlify
|
|
289
|
+
from Config import cfgget
|
|
290
|
+
|
|
291
|
+
for f_name in ilist_fs(path=OSPath.MODULES, type_filter='f', select='LM'):
|
|
292
|
+
with open(f_name, 'rb') as f:
|
|
293
|
+
cs = hexlify(sha1(f.read()).digest()).decode('utf-8')
|
|
294
|
+
msgobj(f"{cs} {f_name}")
|
|
295
|
+
# GC collect?
|
|
296
|
+
return f"micrOS version: {cfgget('version')}"
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
def help(widgets=False):
|
|
300
|
+
"""
|
|
301
|
+
[i] micrOS LM naming convention - built-in help message
|
|
302
|
+
:return tuple:
|
|
303
|
+
(widgets=False) list of functions implemented by this application
|
|
304
|
+
(widgets=True) list of widget json for UI generation
|
|
305
|
+
"""
|
|
306
|
+
return ('listmods', 'delmod mod=<module>.py/.mpy', 'del_duplicates',
|
|
307
|
+
'moduls unload="LM_rgb/None"',
|
|
308
|
+
'cachedump delete=None',
|
|
309
|
+
'datdump',
|
|
310
|
+
# Package commands
|
|
311
|
+
'install url="BxNxM/micrOS/master/toolkit/workspace/precompiled/LM_robustness.py"',
|
|
312
|
+
'uninstall name=None',
|
|
313
|
+
'upgrade name=None',
|
|
314
|
+
# File system commands
|
|
315
|
+
'micros_checksum',
|
|
316
|
+
'ls path="/" content="*/f/d" select="*/LM/IO"',
|
|
317
|
+
'rm <path>',
|
|
318
|
+
'rmdir <path>',
|
|
319
|
+
'dirtree path="/"',
|
|
320
|
+
'makedir <path>')
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
from microIO import
|
|
2
|
-
from Common import SmartADC, micro_task, notify, syslog
|
|
3
|
-
import uasyncio as asyncio
|
|
1
|
+
from microIO import bind_pin, pinmap_search
|
|
2
|
+
from Common import SmartADC, micro_task, notify, syslog, exec_cmd
|
|
4
3
|
from utime import ticks_ms
|
|
5
|
-
|
|
6
|
-
import LM_intercon as InterCon
|
|
7
|
-
except:
|
|
8
|
-
InterCon = None
|
|
4
|
+
|
|
9
5
|
|
|
10
6
|
class Data:
|
|
11
7
|
TASK_TAG = 'presence._capture'
|
|
12
8
|
|
|
13
|
-
MIC_TYPES={'NONE':
|
|
9
|
+
MIC_TYPES = {'NONE':0, 'ADC':1, 'I2S':2}
|
|
14
10
|
MIC_TYPE = MIC_TYPES['NONE'] # Enable/Disable MIC periphery ('ADC', 'I2S', None)
|
|
15
11
|
RAW_DATA = [] # format [[<time>, <amplitude>, <trigger>],...]
|
|
16
12
|
MIC_ADC = None # Initialized by micro task if sampled by ADC
|
|
@@ -26,7 +22,8 @@ class Data:
|
|
|
26
22
|
OFF_INTERCON_CLBK = None # Intercon OFF callback
|
|
27
23
|
|
|
28
24
|
I2S_MIC = None # Optional LM_i2s_mic import
|
|
29
|
-
|
|
25
|
+
|
|
26
|
+
ENABLE_NOTIFY = False
|
|
30
27
|
|
|
31
28
|
|
|
32
29
|
#######################################
|
|
@@ -68,9 +65,9 @@ def __run_intercon(state):
|
|
|
68
65
|
try:
|
|
69
66
|
cmd = Data.ON_INTERCON_CLBK.split()
|
|
70
67
|
host = cmd[0]
|
|
71
|
-
cmd =
|
|
72
|
-
# Send CMD to other device
|
|
73
|
-
|
|
68
|
+
cmd = cmd[1:]
|
|
69
|
+
# Send CMD to other device
|
|
70
|
+
state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True)
|
|
74
71
|
except Exception as e:
|
|
75
72
|
syslog(f"__run_intercon error: {e}")
|
|
76
73
|
if state.lower() == "off":
|
|
@@ -79,9 +76,9 @@ def __run_intercon(state):
|
|
|
79
76
|
try:
|
|
80
77
|
cmd = Data.OFF_INTERCON_CLBK.split()
|
|
81
78
|
host = cmd[0]
|
|
82
|
-
cmd =
|
|
83
|
-
# Send CMD to other device
|
|
84
|
-
|
|
79
|
+
cmd = cmd[1:]
|
|
80
|
+
# Send CMD to other device
|
|
81
|
+
state, _ = exec_cmd(cmd + [f">>{host}"], jsonify=True)
|
|
85
82
|
except Exception as e:
|
|
86
83
|
syslog(f"__run_intercon error: {e}")
|
|
87
84
|
|
|
@@ -91,18 +88,17 @@ def __run_intercon(state):
|
|
|
91
88
|
####################################
|
|
92
89
|
|
|
93
90
|
async def __task(ms_period, buff_size):
|
|
94
|
-
if Data.
|
|
95
|
-
|
|
96
|
-
syslog("Motion detect. notify, error...")
|
|
91
|
+
if Data.ENABLE_NOTIFY and not notify("Motion detected"):
|
|
92
|
+
syslog("Motion detect. notify, error...")
|
|
97
93
|
|
|
98
94
|
if Data.MIC_TYPE == Data.MIC_TYPES['ADC']:
|
|
99
95
|
# Create ADC object
|
|
100
|
-
Data.MIC_ADC = SmartADC.
|
|
96
|
+
Data.MIC_ADC = SmartADC.get_instance(bind_pin('mic'))
|
|
101
97
|
elif Data.MIC_TYPE == Data.MIC_TYPES['I2S']:
|
|
102
98
|
if Data.I2S_MIC is None:
|
|
103
99
|
import LM_i2s_mic
|
|
104
100
|
Data.I2S_MIC = LM_i2s_mic
|
|
105
|
-
Data.I2S_MIC.
|
|
101
|
+
Data.I2S_MIC.load(sampling_rate=2000) # High frequencies can result in slow performance
|
|
106
102
|
Data.I2S_MIC.background_capture()
|
|
107
103
|
|
|
108
104
|
# ASYNC TASK ADAPTER [*2] with automatic state management
|
|
@@ -115,7 +111,7 @@ async def __task(ms_period, buff_size):
|
|
|
115
111
|
my_task.out = f"{int(Data.OFF_EV_TIMER)-1} sec until off event"
|
|
116
112
|
Data.OFF_EV_TIMER -= round(ms_period / 1000, 3)
|
|
117
113
|
# Async sleep - feed event loop
|
|
118
|
-
await
|
|
114
|
+
await my_task.feed(sleep_ms=ms_period)
|
|
119
115
|
|
|
120
116
|
# RUN OFF CALLBACK (local + remote)
|
|
121
117
|
__exec_local_callbacks(Data.OFF_CALLBACKS)
|
|
@@ -186,18 +182,20 @@ def __mic_sample(buff_size, mytask):
|
|
|
186
182
|
# PRESENCE PUBLIC FUNCTIONS #
|
|
187
183
|
##############################
|
|
188
184
|
|
|
189
|
-
def
|
|
185
|
+
def load(threshold=Data.TRIG_THRESHOLD, timer=Data.TIMER_VALUE, mic=Data.MIC_TYPE, enable_notify=False):
|
|
190
186
|
"""
|
|
191
187
|
Initialize presence module
|
|
192
188
|
:param threshold: trigger on relative noice change in percent
|
|
193
189
|
:param timer: off timer in sec
|
|
194
190
|
:param mic: enable / disable mic sampling (bool)
|
|
191
|
+
:param enable_notify: enable (True) / disable (False) telegram notifications
|
|
195
192
|
"""
|
|
196
193
|
threshold = threshold if threshold > 1 else 1
|
|
197
194
|
Data.TRIG_THRESHOLD = threshold
|
|
198
195
|
Data.TIMER_VALUE = timer
|
|
199
196
|
Data.MIC_TYPE = mic
|
|
200
|
-
|
|
197
|
+
Data.ENABLE_NOTIFY = enable_notify
|
|
198
|
+
return f"Init presence module: th: {threshold} timer: {timer} mic: {mic} notify: {enable_notify}"
|
|
201
199
|
|
|
202
200
|
|
|
203
201
|
def motion_trig(sample_ms=15, buff_size=10):
|
|
@@ -215,8 +213,7 @@ def motion_trig(sample_ms=15, buff_size=10):
|
|
|
215
213
|
|
|
216
214
|
# [3] Start mic sampling in async task
|
|
217
215
|
# [!] ASYNC TASK CREATION [1*] with async task callback + taskID (TAG) handling
|
|
218
|
-
|
|
219
|
-
return "Starting" if state else "Already running"
|
|
216
|
+
return micro_task(tag=Data.TASK_TAG, task=__task(ms_period=sample_ms, buff_size=buff_size))
|
|
220
217
|
|
|
221
218
|
|
|
222
219
|
def subscribe_intercon(on, off):
|
|
@@ -231,14 +228,6 @@ def subscribe_intercon(on, off):
|
|
|
231
228
|
return {'on': Data.ON_INTERCON_CLBK, 'off': Data.OFF_INTERCON_CLBK}
|
|
232
229
|
|
|
233
230
|
|
|
234
|
-
def notification(state=None):
|
|
235
|
-
"""Enable/Disable motion detection notifications"""
|
|
236
|
-
if state is None:
|
|
237
|
-
return f"Notifications: {'enabled' if Data.NOTIFY else 'disabled'}"
|
|
238
|
-
Data.NOTIFY = True if state else False
|
|
239
|
-
return f"Set notifications: {'ON' if Data.NOTIFY else 'OFF'}"
|
|
240
|
-
|
|
241
|
-
|
|
242
231
|
def get_samples():
|
|
243
232
|
"""
|
|
244
233
|
[DEBUG] Return measured data set
|
|
@@ -257,7 +246,7 @@ def pinmap():
|
|
|
257
246
|
- info which pins to use for this application
|
|
258
247
|
:return dict: pin name (str) - pin value (int) pairs
|
|
259
248
|
"""
|
|
260
|
-
return
|
|
249
|
+
return pinmap_search(['mic', 'irq1'])
|
|
261
250
|
|
|
262
251
|
|
|
263
252
|
def help(widgets=False):
|
|
@@ -267,8 +256,7 @@ def help(widgets=False):
|
|
|
267
256
|
(widgets=False) list of functions implemented by this application
|
|
268
257
|
(widgets=True) list of widget json for UI generation
|
|
269
258
|
"""
|
|
270
|
-
return '
|
|
259
|
+
return 'load threshold=<percent> timer=<sec> mic=0 (0: None, 1: ADC, 2: I2S) enable_notify=False',\
|
|
271
260
|
'motion_trig sample_ms=15 buff_size=10', 'get_samples',\
|
|
272
261
|
'subscribe_intercon on="host cmd" off="host cmd"',\
|
|
273
|
-
'notification state=None/True/False',\
|
|
274
262
|
'pinmap'
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"""
|
|
2
|
+
A simple driver for the QMI8658 IMU.
|
|
3
|
+
https://github.com/echo-lalia/qmi8658-micropython/blob/main/qmi8685.py
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import struct
|
|
7
|
+
import time
|
|
8
|
+
from machine import Pin, I2C
|
|
9
|
+
from micropython import const
|
|
10
|
+
from microIO import bind_pin, pinmap_search
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# Sensor constants
|
|
14
|
+
_QMI8685_PARTID = const(0x05)
|
|
15
|
+
_REG_PARTID = const(0x00)
|
|
16
|
+
_REG_REVISION = const(0x01)
|
|
17
|
+
|
|
18
|
+
_REG_CTRL1 = const(0x02) # Serial interface and sensor enable
|
|
19
|
+
_REG_CTRL2 = const(0x03) # Accelerometer settings
|
|
20
|
+
_REG_CTRL3 = const(0x04) # Gyroscope settings
|
|
21
|
+
_REG_CTRL4 = const(0x05) # Magnetomer settings (support not implemented in this driver yet)
|
|
22
|
+
_REG_CTRL5 = const(0x06) # Sensor data processing settings
|
|
23
|
+
_REG_CTRL6 = const(0x07) # Attitude Engine ODR and Motion on Demand
|
|
24
|
+
_REG_CTRL7 = const(0x08) # Enable Sensors and Configure Data Reads
|
|
25
|
+
|
|
26
|
+
_REG_TEMP = const(0x33) # Temperature sensor.
|
|
27
|
+
|
|
28
|
+
_REG_AX_L = const(0x35) # Read accelerometer
|
|
29
|
+
_REG_AX_H = const(0x36)
|
|
30
|
+
_REG_AY_L = const(0x37)
|
|
31
|
+
_REG_AY_H = const(0x38)
|
|
32
|
+
_REG_AZ_L = const(0x39)
|
|
33
|
+
_REG_AZ_H = const(0x3A)
|
|
34
|
+
|
|
35
|
+
_REG_GX_L = const(0x3B) # read gyro
|
|
36
|
+
_REG_GX_H = const(0x3C)
|
|
37
|
+
_REG_GY_L = const(0x3D)
|
|
38
|
+
_REG_GY_H = const(0x3E)
|
|
39
|
+
_REG_GZ_L = const(0x3F)
|
|
40
|
+
_REG_GZ_H = const(0x40)
|
|
41
|
+
|
|
42
|
+
_QMI8658_I2CADDR_DEFAULT = const(0X6B)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
_ACCELSCALE_RANGE_2G = const(0b00)
|
|
46
|
+
_ACCELSCALE_RANGE_4G = const(0b01)
|
|
47
|
+
_ACCELSCALE_RANGE_8G = const(0b10)
|
|
48
|
+
_ACCELSCALE_RANGE_16G = const(0b11)
|
|
49
|
+
|
|
50
|
+
_GYROSCALE_RANGE_16DPS = const(0b000)
|
|
51
|
+
_GYROSCALE_RANGE_32DPS = const(0b001)
|
|
52
|
+
_GYROSCALE_RANGE_64DPS = const(0b010)
|
|
53
|
+
_GYROSCALE_RANGE_128DPS = const(0b011)
|
|
54
|
+
_GYROSCALE_RANGE_256DPS = const(0b100)
|
|
55
|
+
_GYROSCALE_RANGE_512DPS = const(0b101)
|
|
56
|
+
_GYROSCALE_RANGE_1024DPS = const(0b110)
|
|
57
|
+
_GYROSCALE_RANGE_2048DPS = const(0b111)
|
|
58
|
+
|
|
59
|
+
_ODR_8000HZ = const(0b0000)
|
|
60
|
+
_ODR_4000HZ = const(0b0001)
|
|
61
|
+
_ODR_2000HZ = const(0b0010)
|
|
62
|
+
_ODR_1000HZ = const(0b0011)
|
|
63
|
+
_ODR_500HZ = const(0b0100)
|
|
64
|
+
_ODR_250HZ = const(0b0101)
|
|
65
|
+
_ODR_125HZ = const(0b0110)
|
|
66
|
+
_ODR_62_5HZ = const(0b0111)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class QMI8658:
|
|
70
|
+
"""QMI8658 inertial measurement unit."""
|
|
71
|
+
INSTANCE = None
|
|
72
|
+
|
|
73
|
+
def __init__(
|
|
74
|
+
self,
|
|
75
|
+
i2c_bus: I2C,
|
|
76
|
+
address: int = _QMI8658_I2CADDR_DEFAULT,
|
|
77
|
+
accel_scale: int = _ACCELSCALE_RANGE_8G,
|
|
78
|
+
gyro_scale: int = _GYROSCALE_RANGE_256DPS):
|
|
79
|
+
"""Read from a sensor on the given I2C bus, at the given address."""
|
|
80
|
+
self.i2c = i2c_bus
|
|
81
|
+
self.address = address
|
|
82
|
+
# Cache the sensor instance globally for easy access
|
|
83
|
+
QMI8658.INSTANCE = self
|
|
84
|
+
|
|
85
|
+
# Verify sensor part ID
|
|
86
|
+
if self._read_u8(_REG_PARTID) != _QMI8685_PARTID:
|
|
87
|
+
raise AttributeError("Cannot find a QMI8658")
|
|
88
|
+
|
|
89
|
+
# Setup initial configuration
|
|
90
|
+
self._configure_sensor(accel_scale, gyro_scale)
|
|
91
|
+
|
|
92
|
+
# Configure scales/divisors for the driver
|
|
93
|
+
self.acc_scale_divisor = {
|
|
94
|
+
_ACCELSCALE_RANGE_2G: 1 << 14,
|
|
95
|
+
_ACCELSCALE_RANGE_4G: 1 << 13,
|
|
96
|
+
_ACCELSCALE_RANGE_8G: 1 << 12,
|
|
97
|
+
_ACCELSCALE_RANGE_16G: 1 << 11,
|
|
98
|
+
}[accel_scale]
|
|
99
|
+
|
|
100
|
+
self.gyro_scale_divisor = {
|
|
101
|
+
_GYROSCALE_RANGE_16DPS: 2048,
|
|
102
|
+
_GYROSCALE_RANGE_32DPS: 1024,
|
|
103
|
+
_GYROSCALE_RANGE_64DPS: 512,
|
|
104
|
+
_GYROSCALE_RANGE_128DPS: 256,
|
|
105
|
+
_GYROSCALE_RANGE_256DPS: 128,
|
|
106
|
+
_GYROSCALE_RANGE_512DPS: 64,
|
|
107
|
+
_GYROSCALE_RANGE_1024DPS: 32,
|
|
108
|
+
_GYROSCALE_RANGE_2048DPS: 16,
|
|
109
|
+
}[gyro_scale]
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _configure_sensor(self, accel_scale: int, gyro_scale: int):
|
|
113
|
+
# Initialize accelerometer and gyroscope settings
|
|
114
|
+
self._write_u8(_REG_CTRL1, 0x60) # Set SPI auto increment and big endian (Ctrl 1)
|
|
115
|
+
self._write_u8(_REG_CTRL2, (accel_scale << 4) | _ODR_1000HZ) # Accel Config
|
|
116
|
+
self._write_u8(_REG_CTRL3, (gyro_scale << 4) | _ODR_1000HZ) # Gyro Config
|
|
117
|
+
self._write_u8(_REG_CTRL5, 0x01) # Low-pass filter enable
|
|
118
|
+
self._write_u8(_REG_CTRL7, 0x03) # Enable accel and gyro
|
|
119
|
+
time.sleep_ms(100)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
# Helper functions for register operations
|
|
123
|
+
def _read_u8(self, reg:int) -> int:
|
|
124
|
+
return self.i2c.readfrom_mem(self.address, reg, 1)[0]
|
|
125
|
+
|
|
126
|
+
def _read_xyz(self, reg:int) -> tuple[int, int, int]:
|
|
127
|
+
data = self.i2c.readfrom_mem(self.address, reg, 6)
|
|
128
|
+
return struct.unpack('<hhh', data)
|
|
129
|
+
|
|
130
|
+
def _write_u8(self, reg: int, value: int):
|
|
131
|
+
self.i2c.writeto_mem(self.address, reg, bytes([value]))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
@property
|
|
135
|
+
def temperature(self) -> float:
|
|
136
|
+
"""Get the device temperature."""
|
|
137
|
+
temp_raw = self._read_u8(_REG_TEMP)
|
|
138
|
+
return temp_raw / 256
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def acceleration(self) -> tuple[float, float, float]:
|
|
142
|
+
"""Get current acceleration reading."""
|
|
143
|
+
raw_accel = self._read_xyz(_REG_AX_L)
|
|
144
|
+
return tuple(val / self.acc_scale_divisor for val in raw_accel)
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def gyro(self) -> tuple[float, float, float]:
|
|
148
|
+
"""Get current gyroscope reading."""
|
|
149
|
+
raw_gyro = self._read_xyz(_REG_GX_L)
|
|
150
|
+
return tuple(val / self.gyro_scale_divisor for val in raw_gyro)
|
|
151
|
+
|
|
152
|
+
#######################
|
|
153
|
+
# Public functions #
|
|
154
|
+
#######################
|
|
155
|
+
|
|
156
|
+
def load():
|
|
157
|
+
"""
|
|
158
|
+
Load the QMI8658 sensor instance.
|
|
159
|
+
The QMI8658 is a motion sensor that measures acceleration, angular velocity (gyroscope), and temperature
|
|
160
|
+
"""
|
|
161
|
+
if QMI8658.INSTANCE is None:
|
|
162
|
+
QMI8658(I2C(0, sda=Pin(bind_pin('i2c_sda')), scl=Pin(bind_pin('i2c_scl'))))
|
|
163
|
+
return QMI8658.INSTANCE
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def temperature():
|
|
167
|
+
return load().temperature
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
def acceleration():
|
|
171
|
+
return load().acceleration
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def gyro():
|
|
175
|
+
return load().gyro
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def measure():
|
|
179
|
+
inst = load()
|
|
180
|
+
return {"temp": inst.temperature, "accel": inst.acceleration, "gyro": inst.gyro}
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
#######################
|
|
184
|
+
# LM helper functions #
|
|
185
|
+
#######################
|
|
186
|
+
|
|
187
|
+
def pinmap():
|
|
188
|
+
"""
|
|
189
|
+
[i] micrOS LM naming convention
|
|
190
|
+
Shows logical pins - pin number(s) used by this Load module
|
|
191
|
+
- info which pins to use for this application
|
|
192
|
+
:return dict: pin name (str) - pin value (int) pairs
|
|
193
|
+
"""
|
|
194
|
+
return pinmap_search(['i2c_scl', 'i2c_sda'])
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def help(widgets=False):
|
|
198
|
+
"""
|
|
199
|
+
[i] micrOS LM naming convention - built-in help message
|
|
200
|
+
:return tuple:
|
|
201
|
+
(widgets=False) list of functions implemented by this application
|
|
202
|
+
(widgets=True) list of widget json for UI generation
|
|
203
|
+
"""
|
|
204
|
+
return 'load', 'temperature', 'acceleration', 'gyro', 'measure', 'pinmap'
|