File tree Expand file tree Collapse file tree 3 files changed +23
-9
lines changed
internal_filesystem/lib/mpos/audio Expand file tree Collapse file tree 3 files changed +23
-9
lines changed Original file line number Diff line number Diff line change 110.5.1
22=====
3- - Fri3d Camp 2024 Badge: workaround ADC2+WiFi conflict by temporarily disable WiFi to measure battery level
4- - Fri3d Camp 2024 Badge: improve battery monitor calibration to fix 0.1V delta
3+ - Fri3d Camp 2024 Board: add startup light and sound
4+ - Fri3d Camp 2024 Board: workaround ADC2+WiFi conflict by temporarily disable WiFi to measure battery level
5+ - Fri3d Camp 2024 Board: improve battery monitor calibration to fix 0.1V delta
56- API: improve and cleanup animations
67- API: SharedPreferences: add erase_all() function
78- API: add defaults handling to SharedPreferences and only save non-defaults
Original file line number Diff line number Diff line change 77import time
88import sys
99
10- # Volume scaling function - regular Python version
11- # Note: Viper optimization removed because @micropython.viper decorator
12- # causes cross-compiler errors on Unix/macOS builds even inside conditionals
13- def _scale_audio (buf , num_bytes , scale_fixed ):
14- """Volume scaling for 16-bit audio samples."""
10+ # Volume scaling function - Viper-optimized for ESP32 performance
11+ # NOTE: The line below is automatically commented out by build_mpos.sh during
12+ # Unix/macOS builds (cross-compiler doesn't support Viper), then uncommented after build.
13+ import micropython
14+ @micropython .viper
15+ def _scale_audio (buf : ptr8 , num_bytes : int , scale_fixed : int ):
16+ """Fast volume scaling for 16-bit audio samples using Viper (ESP32 native code emitter)."""
1517 for i in range (0 , num_bytes , 2 ):
16- lo = buf [i ]
17- hi = buf [i + 1 ]
18+ lo = int ( buf [i ])
19+ hi = int ( buf [i + 1 ])
1820 sample = (hi << 8 ) | lo
1921 if hi & 128 :
2022 sample -= 65536
Original file line number Diff line number Diff line change @@ -101,12 +101,23 @@ if [ "$target" == "esp32" ]; then
101101elif [ " $target " == " unix" -o " $target " == " macOS" ]; then
102102 manifest=$( readlink -f " $codebasedir " /manifests/manifest.py)
103103 frozenmanifest=" FROZEN_MANIFEST=$manifest "
104+
105+ # Comment out @micropython.viper decorator for Unix/macOS builds
106+ # (cross-compiler doesn't support Viper native code emitter)
107+ echo " Temporarily commenting out @micropython.viper decorator for Unix/macOS build..."
108+ stream_wav_file=" $codebasedir " /internal_filesystem/lib/mpos/audio/stream_wav.py
109+ sed -i ' s/^@micropython\.viper$/#@micropython.viper/' " $stream_wav_file "
110+
104111 # LV_CFLAGS are passed to USER_C_MODULES
105112 # STRIP= makes it so that debug symbols are kept
106113 pushd " $codebasedir " /lvgl_micropython/
107114 # USER_C_MODULE doesn't seem to work properly so there are symlinks in lvgl_micropython/extmod/
108115 python3 make.py " $target " LV_CFLAGS=" -g -O0 -ggdb -ljpeg" STRIP= DISPLAY=sdl_display INDEV=sdl_pointer INDEV=sdl_keyboard " $frozenmanifest "
109116 popd
117+
118+ # Restore @micropython.viper decorator after build
119+ echo " Restoring @micropython.viper decorator..."
120+ sed -i ' s/^#@micropython\.viper$/@micropython.viper/' " $stream_wav_file "
110121else
111122 echo " invalid target $target "
112123fi
You can’t perform that action at this time.
0 commit comments