Make Wim Hof reminders follow the breath hold

Use one optional 30- or 60-second hold reminder and keep the normal last-breath bell automatic. Preserve the existing saved keys, simplify the wording in every locale, and resolve Wim Hof modules through declared source roots.
This commit is contained in:
waozi committed 2026-10-24 15:05:59 -03:00
1 parent b9cdf450bf
commit d5dc80c5b6
29 files changed
+280 -314

No files matched your search

+1 -1
View File
@@ -396,7 +396,7 @@ EMBEDDED_ASSET_FILES := apps/publishers.json $(INBE_BUNDLE) build/apps-ui/apps.z
KRY_GEN_DIR := $(BUILD_DIR)/kryon/generated
# Dependencies are imported as PACKAGE/Module through their linked packages.
ZI_PACKAGE_PATHS := $(shell sh scripts/package-paths.sh)
ZI_SRCS := $(shell find src -type f -name '*.zi' 2>/dev/null | LC_ALL=C sort) apps/practice/downloads_view.zi $(wildcard apps/practice/astral_projection*.zi) $(wildcard apps/practice/workout*.zi) $(wildcard apps/practice/sun_salutation*.zi)
ZI_SRCS := $(shell find src -type f -name '*.zi' 2>/dev/null | LC_ALL=C sort) apps/practice/downloads_view.zi apps/practice/hold_reminder.zi $(wildcard apps/practice/astral_projection*.zi) $(wildcard apps/practice/workout*.zi) $(wildcard apps/practice/sun_salutation*.zi)
GAME2D_DIR := build/packages/game2d
GAME2D_MODULES := $(wildcard $(GAME2D_DIR)/src/*/*.zi)
DAOCHI_CLIENT_MODULES := $(wildcard build/packages/daochi-client/*.zi)
+28
View File
@@ -0,0 +1,28 @@
// Reminders follow the elapsed hold, independently of the breathing rounds.
HoldReminderResult :: struct {
last_bucket: s32
ring: bool
}
HoldReminderSeconds :: (seconds: s32) -> s32 {
if seconds == 30 || seconds == 60 {
return seconds
}
return 0
}
HoldReminderAdvance :: (holding: bool, seconds: s32,
interval: s32, last_bucket: s32) -> HoldReminderResult {
result: HoldReminderResult
interval = HoldReminderSeconds(interval)
if !holding || interval == 0 || seconds < 0 {
return result
}
result.last_bucket = last_bucket
bucket := seconds / interval
if bucket > 0 && bucket > last_bucket {
result.last_bucket = bucket
result.ring = true
}
return result
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+2 -1
View File
@@ -85,7 +85,8 @@ add_custom_command(
set(APP_ZIRAN_GEN_DIR "${CMAKE_BINARY_DIR}/ziran/generated")
set(APP_ZIRAN_MANIFEST "${CMAKE_BINARY_DIR}/ziran/generated-sources.cmake")
file(GLOB_RECURSE APP_ZIRAN_SOURCES CONFIGURE_DEPENDS "${SRC_DIR}/*.zi")
list(APPEND APP_ZIRAN_SOURCES "${REPO_ROOT}/apps/practice/downloads_view.zi")
list(APPEND APP_ZIRAN_SOURCES "${REPO_ROOT}/apps/practice/downloads_view.zi"
"${REPO_ROOT}/apps/practice/hold_reminder.zi")
file(GLOB_RECURSE APP_LIBRARY_ZIRAN_SOURCES CONFIGURE_DEPENDS
"${KRYON_DIR}/src/ui/*.zi" "${KRYON_DIR}/src/backend/*.zi"
"${REPO_ROOT}/build/packages/kss/src/*.zi" "${REPO_ROOT}/build/packages/oqs/src/*.zi" "${REPO_ROOT}/build/packages/game2d/src/*.zi"
+6 -12
View File
@@ -463,23 +463,17 @@ Znovu inicializovat zvuk
[music_volume_label]
Hlasitost hudby
---
[whm_time_signals_label]
Časové signály
[whm_hold_reminder_label]
Připomenutí při zadržení dechu
---
[whm_time_signals_off]
[whm_hold_reminder_off]
Vypnuto
---
[whm_time_signals_minute]
Každou minutu
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
Každých 30 sekund
---
[whm_time_signals_both]
Oba
---
[whm_time_signals_hint]
Třicetisekundové signály zaznívají při zadržování dechu. Minutové signály odměřují aktivní čas relace.
[whm_hold_reminder_60s]
Každou minutu
---
[reset_to_defaults_label]
Obnovit výchozí
+6 -12
View File
@@ -463,23 +463,17 @@ Ausgabepegel
[music_volume_label]
Musiklautstärke
---
[whm_time_signals_label]
Zeitsignale
[whm_hold_reminder_label]
Erinnerung beim Atemanhalten
---
[whm_time_signals_off]
[whm_hold_reminder_off]
Aus
---
[whm_time_signals_minute]
Jede Minute
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
Alle 30 Sekunden
---
[whm_time_signals_both]
Beide
---
[whm_time_signals_hint]
Die 30-Sekunden-Signale ertönen beim Atemanhalten. Minutensignale zählen die aktive Übungszeit.
[whm_hold_reminder_60s]
Jede Minute
---
[reset_to_defaults_label]
Auf Standard zurücksetzen
+6 -12
View File
@@ -580,23 +580,17 @@ Remove
[music_volume_label]
Music volume
---
[whm_time_signals_label]
Time signals
[whm_hold_reminder_label]
Breath-hold reminder
---
[whm_time_signals_off]
[whm_hold_reminder_off]
Off
---
[whm_time_signals_minute]
Every minute
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
Every 30 seconds
---
[whm_time_signals_both]
Both
---
[whm_time_signals_hint]
30-second signals play during breath holds. Minute signals count active session time.
[whm_hold_reminder_60s]
Every minute
---
[reset_to_defaults_label]
Reset to defaults
+7 -13
View File
@@ -463,23 +463,17 @@ Nivel de salida
[music_volume_label]
Volumen de música
---
[whm_time_signals_label]
Señales de tiempo
[whm_hold_reminder_label]
Aviso al retener la respiración
---
[whm_time_signals_off]
Desactivadas
[whm_hold_reminder_off]
Desactivado
---
[whm_time_signals_minute]
Cada minuto
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
Cada 30 segundos
---
[whm_time_signals_both]
Ambas
---
[whm_time_signals_hint]
Las señales de 30 segundos suenan durante las retenciones. Las señales de un minuto cuentan el tiempo activo de la sesión.
[whm_hold_reminder_60s]
Cada minuto
---
[reset_to_defaults_label]
Restablecer valores predeterminados
+7 -13
View File
@@ -463,23 +463,17 @@ Niveau de sortie
[music_volume_label]
Volume de la musique
---
[whm_time_signals_label]
Signaux de temps
[whm_hold_reminder_label]
Rappel en retenant son souffle
---
[whm_time_signals_off]
Désactivés
[whm_hold_reminder_off]
Désactivé
---
[whm_time_signals_minute]
Toutes les minutes
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
Toutes les 30 secondes
---
[whm_time_signals_both]
Les deux
---
[whm_time_signals_hint]
Les signaux de 30 secondes rythment les rétentions. Les signaux d’une minute comptent le temps actif de la séance.
[whm_hold_reminder_60s]
Toutes les minutes
---
[reset_to_defaults_label]
Réinitialiser
+6 -12
View File
@@ -463,23 +463,17 @@ Level keluaran
[music_volume_label]
Volume musik
---
[whm_time_signals_label]
Sinyal waktu
[whm_hold_reminder_label]
Pengingat saat menahan napas
---
[whm_time_signals_off]
[whm_hold_reminder_off]
Nonaktif
---
[whm_time_signals_minute]
Setiap menit
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
Setiap 30 detik
---
[whm_time_signals_both]
Keduanya
---
[whm_time_signals_hint]
Sinyal 30 detik berbunyi saat menahan napas. Sinyal menit menghitung waktu aktif sesi.
[whm_hold_reminder_60s]
Setiap menit
---
[reset_to_defaults_label]
Reset ke default
+7 -13
View File
@@ -487,23 +487,17 @@ Livello uscita
[music_volume_label]
Volume musica
---
[whm_time_signals_label]
Segnali di tempo
[whm_hold_reminder_label]
Promemoria a respiro trattenuto
---
[whm_time_signals_off]
Disattivati
[whm_hold_reminder_off]
Disattivato
---
[whm_time_signals_minute]
Ogni minuto
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
Ogni 30 secondi
---
[whm_time_signals_both]
Entrambi
---
[whm_time_signals_hint]
I segnali di 30 secondi accompagnano le ritenzioni. I segnali di un minuto contano il tempo attivo della sessione.
[whm_hold_reminder_60s]
Ogni minuto
---
[reset_to_defaults_label]
Ripristina predefiniti
+6 -12
View File
@@ -463,23 +463,17 @@ OK
[music_volume_label]
音楽の音量
---
[whm_time_signals_label]
時間の合図
[whm_hold_reminder_label]
息止め中の合図
---
[whm_time_signals_off]
[whm_hold_reminder_off]
オフ
---
[whm_time_signals_minute]
1分ごと
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
30秒ごと
---
[whm_time_signals_both]
両方
---
[whm_time_signals_hint]
30秒ごとの合図は息を止めている間に鳴ります。1分ごとの合図は一時停止を除くセッション全体の時間を刻みます。
[whm_hold_reminder_60s]
1分ごと
---
[reset_to_defaults_label]
デフォルトに戻す
+6 -12
View File
@@ -487,23 +487,17 @@ PIP 모드
[music_volume_label]
음악 음량
---
[whm_time_signals_label]
시간 알림
[whm_hold_reminder_label]
숨 참기 알림
---
[whm_time_signals_off]
[whm_hold_reminder_off]
끄기
---
[whm_time_signals_minute]
1분마다
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
30초마다
---
[whm_time_signals_both]
둘 다
---
[whm_time_signals_hint]
30초 알림은 숨을 참는 동안 울립니다. 1분 알림은 일시 정지를 제외한 전체 세션 시간을 기준으로 울립니다.
[whm_hold_reminder_60s]
1분마다
---
[reset_to_defaults_label]
기본값으로 재설정
+7 -13
View File
@@ -463,23 +463,17 @@ Nível de saída
[music_volume_label]
Volume da música
---
[whm_time_signals_label]
Sinais de tempo
[whm_hold_reminder_label]
Lembrete ao prender a respiração
---
[whm_time_signals_off]
Desativados
[whm_hold_reminder_off]
Desativado
---
[whm_time_signals_minute]
A cada minuto
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
A cada 30 segundos
---
[whm_time_signals_both]
Ambos
---
[whm_time_signals_hint]
Os sinais de 30 segundos soam durante as retenções. Os sinais de um minuto contam o tempo ativo da sessão.
[whm_hold_reminder_60s]
A cada minuto
---
[reset_to_defaults_label]
Restaurar padrões
+7 -13
View File
@@ -490,23 +490,17 @@ OK
[music_volume_label]
Громкость музыки
---
[whm_time_signals_label]
Сигналы времени
[whm_hold_reminder_label]
Сигнал при задержке дыхания
---
[whm_time_signals_off]
Выключены
[whm_hold_reminder_off]
Выключен
---
[whm_time_signals_minute]
Каждую минуту
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
Каждые 30 секунд
---
[whm_time_signals_both]
Оба
---
[whm_time_signals_hint]
30-секундные сигналы звучат во время задержки дыхания. Минутные сигналы отсчитывают время всей практики без пауз.
[whm_hold_reminder_60s]
Каждую минуту
---
[reset_to_defaults_label]
Сбросить настройки
+6 -12
View File
@@ -463,23 +463,17 @@ Wim Hof 呼吸
[music_volume_label]
音乐音量
---
[whm_time_signals_label]
计时提示
[whm_hold_reminder_label]
屏息提醒
---
[whm_time_signals_off]
[whm_hold_reminder_off]
关闭
---
[whm_time_signals_minute]
每分钟
---
[whm_time_signals_retention]
[whm_hold_reminder_30s]
每30秒
---
[whm_time_signals_both]
两者
---
[whm_time_signals_hint]
30秒提示在屏息时响起,分钟提示按整个练习的有效时间响起。
[whm_hold_reminder_60s]
每分钟
---
[reset_to_defaults_label]
恢复默认
+1
View File
@@ -17,6 +17,7 @@ client = root / "build/packages/daochi-client"
game2d = root / "build/packages/game2d/src"
sources = sorted((root / "src").rglob("*.zi"))
sources.append(root / "apps/practice/downloads_view.zi")
sources.append(root / "apps/practice/hold_reminder.zi")
legacy = sorted((root / "src").rglob("*.kry"))
if legacy:
+1
View File
@@ -17,6 +17,7 @@ root = args.root.resolve()
kryon = args.kryon.resolve()
sources = sorted((root / "src").rglob("*.zi"))
sources.append(root / "apps/practice/downloads_view.zi")
sources.append(root / "apps/practice/hold_reminder.zi")
if list((root / "src").rglob("*.c")) or list((root / "src").rglob("*.kry")):
raise SystemExit("Android application implementation must be current Zi")
if args.output.exists():
+16 -3
View File
@@ -1,8 +1,21 @@
#!/bin/sh
# Prints --module-path NAME=DIR for every linked dependency, so Inbe's builds
# import a package's modules as NAME/Module. scripts/packages.sh links each
# package under build/packages.
# Prints the app's source roots and each linked dependency's named module
# paths. scripts/packages.sh links dependencies under build/packages.
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
# Read the app's source roots from its manifest so every platform resolves
# the same named modules without file-relative imports.
python3 - "$root" <<'PY'
from pathlib import Path
import sys
import tomllib
root = Path(sys.argv[1])
manifest = tomllib.loads((root / "ziran.toml").read_text())
for directory in manifest["package"]["module_roots"]:
print("--module-path")
print(root / directory)
PY
packages=${1:-build/packages}
for path in kryon=kryon/src/ui kryon=kryon/src/backend apps=apps/src \
crypto=crypto/src entity=entity/src plot=plot/src qrcode=qrcode/src \
+9 -6
View File
@@ -252,9 +252,9 @@ save_settings :: (app: *InnerBreeze) {
save_setting_int("guide_narration_muted", app.guide_narration_muted)
AudioSettingsSave(app)
save_setting_int("retention_marker_enabled",
ifx app.retention_marker_enabled != 0 then 1 else 0)
ifx app.hold_reminder_seconds == 30 then 1 else 0)
save_setting_int("minute_bell_enabled",
ifx app.minute_bell_enabled != 0 then 1 else 0)
ifx app.hold_reminder_seconds == 60 then 1 else 0)
save_setting_int("tutorial_seen", ifx app.tutorial_seen != 0 then 1 else 0)
save_setting_int("tutorial_step", app.tutorial_step)
save_setting_int("habits_guide_seen", ifx app.habits_guide_seen != 0 then 1 else 0)
@@ -572,10 +572,13 @@ app_load_settings :: (app: *InnerBreeze) -> s32 {
"double_tap_to_breathe", 0)
load_bool_setting(*app.meditation.show_extend_controls,
"meditation_show_extend_controls", 1)
load_bool_setting(*app.retention_marker_enabled,
"retention_marker_enabled", 0)
load_bool_setting(*app.minute_bell_enabled,
"minute_bell_enabled", 0)
// Keep the existing saved keys while the practice uses one interval.
app.hold_reminder_seconds = 0
if SettingsCacheInt("retention_marker_enabled", 0) != 0 {
app.hold_reminder_seconds = 30
} else if SettingsCacheInt("minute_bell_enabled", 0) != 0 {
app.hold_reminder_seconds = 60
}
load_bool_setting(*app.breaks_enabled,
"breaks_enabled", app.breaks_enabled)
if WebPlatform() != 0 {
+2 -5
View File
@@ -519,11 +519,8 @@ InnerBreeze :: struct {
audio_custom_music_count: s32
audio_custom_sounds: [AUDIO_CUSTOM_SOUND_MAX] AudioLibraryItem
audio_custom_music: [AUDIO_CUSTOM_MUSIC_MAX] AudioLibraryItem
retention_marker_enabled: s32
retention_marker_last_bucket: s32
minute_bell_enabled: s32
minute_bell_ticks: s32
minute_bell_last_minute: s32
hold_reminder_seconds: s32
hold_reminder_last_bucket: s32
sound_last_screen: s32
sound_last_phase: s32
sound_last_dir: s32
+39 -59
View File
@@ -1,35 +1,35 @@
c :: #system_library "c";
GetFrameTime :: () -> float32 #foreign c;
#import, file "../../app/modal_rules.zi";
#import, file "../../app/app_types.zi";
#import, file "../../core/types.zi";
#import, file "../../core/breath_timing.zi";
#import "modal_rules"
#import "app_types"
#import "types"
#import "breath_timing"
#import "geometry"
#import "layout"
#import "scroll"
#import "scroll_props"
#import "scroll_widget"
#import "tree"
#import, file "../../app/app.zi";
#import, file "../../app/app_settings.zi";
#import, file "../../app/app_modal_state.zi";
#import, file "../../app/app_nav_state.zi";
#import, file "../../app/locale.zi";
#import, file "../../app/widgets.zi";
#import, file "../meditation/meditation_music.zi";
#import, file "whm_session.zi";
#import "app"
#import "app_settings"
#import "app_modal_state"
#import "app_nav_state"
#import "locale"
#import "widgets"
#import "meditation_music"
#import "whm_session"
#import, file "../../screens/practice_screen_calls.zi";
#import, file "../../screens/practice_subscreen_layout.zi";
#import, file "../../screens/settings/settings_ui.zi";
#import "practice_screen_calls"
#import "practice_subscreen_layout"
#import "settings_ui"
#import "control_props"
#import "input_props"
#import "text_props"
#import, file "../../app/exercise_types.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/color.zi";
#import, file "../../app/current_app.zi";
#import "exercise_types"
#import "metrics"
#import "color"
#import "current_app"
#import "box_props"
#import "box_widget"
#import "button_widget"
@@ -37,7 +37,6 @@ GetFrameTime :: () -> float32 #foreign c;
#import "modal_frame_widget"
#import "modal_props"
#import "text_widget"
#import "text_measure"
#import "toggle_widget"
#import "drawing_props"
#import "session"
@@ -226,14 +225,8 @@ whm_config_session_card_height :: () -> s32 {
return AppScale(82) * 3 + AppScale(24)
}
whm_config_options_card_height :: (content_w: s32) -> s32 {
hint_height := TextHeight(CurrentApp().ui.session, TextProps.{
.bounds = Rectangle.{0.0, 0.0,
cast(float32)(content_w - AppScale(44)), 0.0},
.text = LocaleText("whm_time_signals_hint"),
.font = AppScale(14)})
return AppScale(22) * 2 + AppScale(88) * 2 +
AppScale(26 + 48 + 12) + cast(s32)hint_height
whm_config_options_card_height :: () -> s32 {
return AppScale(22) * 2 + AppScale(88) * 2 + AppScale(26 + 48)
}
whm_config_draw_breath_card :: (app: *InnerBreeze, content_x: s32, content_w: s32,
@@ -432,20 +425,18 @@ whm_config_draw_options_card :: (app: *InnerBreeze, content_x: s32, content_w: s
y: s32) -> s32 {
double_tap_to_breathe := app.double_tap_to_breathe
advanced_session_controls := app.advanced_session_controls
retention_marker_enabled := app.retention_marker_enabled
signal_index: s32 = 0
if app.minute_bell_enabled != 0 {
signal_index += 1
reminder_index: s32 = 0
if app.hold_reminder_seconds == 30 {
reminder_index = 1
} else if app.hold_reminder_seconds == 60 {
reminder_index = 2
}
if retention_marker_enabled != 0 {
signal_index += 2
}
signal_options: [4]DropdownOption
signal_options[0] = DropdownOption.{.label = LocaleText("whm_time_signals_off")}
signal_options[1] = DropdownOption.{.label = LocaleText("whm_time_signals_minute")}
signal_options[2] = DropdownOption.{.label = LocaleText("whm_time_signals_retention")}
signal_options[3] = DropdownOption.{.label = LocaleText("whm_time_signals_both")}
card_h := whm_config_options_card_height(content_w)
reminder_seconds: [3]s32 = .[0, 30, 60]
reminder_options: [3]DropdownOption
reminder_options[0] = DropdownOption.{.label = LocaleText("whm_hold_reminder_off")}
reminder_options[1] = DropdownOption.{.label = LocaleText("whm_hold_reminder_30s")}
reminder_options[2] = DropdownOption.{.label = LocaleText("whm_hold_reminder_60s")}
card_h := whm_config_options_card_height()
card_pad := AppScale(22)
inner_x := content_x + card_pad
inner_w := content_w - card_pad * 2
@@ -500,30 +491,19 @@ whm_config_draw_options_card :: (app: *InnerBreeze, content_x: s32, content_w: s
Text(CurrentApp().ui.session, TextProps.{
.bounds = Rectangle.{cast(float32)(inner_x), cast(float32)(inner_y), 0, 0},
.text = LocaleText("whm_time_signals_label"),
.text = LocaleText("whm_hold_reminder_label"),
.wrap = cast(TextWrap)TextWrapNone
})
signal_pick := Dropdown(CurrentApp().ui.session, DropdownProps.{.id = 1203,
reminder_pick := Dropdown(CurrentApp().ui.session, DropdownProps.{.id = 1203,
.bounds = Rectangle.{cast(float32)inner_x,
cast(float32)(inner_y + AppScale(26)),
cast(float32)inner_w, cast(float32)AppScale(48)},
.selected_index = signal_index}, signal_options[:])
if signal_pick.changed {
app.minute_bell_enabled = ifx (signal_pick.selected_index == 1 ||
signal_pick.selected_index == 3) then (1) else (0)
app.retention_marker_enabled = ifx (signal_pick.selected_index == 2 ||
signal_pick.selected_index == 3) then (1) else (0)
if app.retention_marker_enabled != retention_marker_enabled {
app.retention_marker_last_bucket = 0
}
.selected_index = reminder_index}, reminder_options[:])
if reminder_pick.changed {
app.hold_reminder_seconds = reminder_seconds[reminder_pick.selected_index]
app.hold_reminder_last_bucket = 0
app.settings_dirty = 1
}
Text(CurrentApp().ui.session, TextProps.{
.bounds = Rectangle.{cast(float32)inner_x,
cast(float32)(inner_y + AppScale(86)),
cast(float32)inner_w, 0.0},
.text = LocaleText("whm_time_signals_hint"),
.font = AppScale(14)})
return y + card_h + AppScale(16)
}
@@ -587,7 +567,7 @@ whm_config_content_height :: (app: *InnerBreeze, content_w: s32) -> s32 {
app.modal.type != cast(ModalType)ModalPracticeConfig
bottom_padding := (ifx (integrated) then (app_content_bottom_reserved(app)) else (0)) + AppScale(24)
return whm_config_breath_card_height(app) + AppScale(16) + whm_config_session_card_height() + AppScale(16) + whm_config_options_card_height(content_w) + AppScale(40) + meditation_music_measure_practice_settings(app, EXERCISE_WIM_HOF,
return whm_config_breath_card_height(app) + AppScale(16) + whm_config_session_card_height() + AppScale(16) + whm_config_options_card_height() + AppScale(40) + meditation_music_measure_practice_settings(app, EXERCISE_WIM_HOF,
content_w, 0, 1) + AppScale(12) + AppScale(48) + AppScale(24) + bottom_padding
}
+39 -77
View File
@@ -1,6 +1,7 @@
#import, file "../../cells/shared_state.zi";
#import, file "../../cells/module_host.zi";
#import, file "../../cells/practice_types.zi";
#import "shared_state"
#import "module_host"
#import "practice_types"
#import "hold_reminder"
c :: #system_library "c";
PI :: 3.14159265358979f;
WHM_LOG_INFO :: 3;
@@ -17,8 +18,6 @@ sync_habits_for_activity :: (app: *InnerBreeze, activity: s32) #foreign c;
practice_update_session_sounds :: (app: *InnerBreeze) #foreign c;
practice_background_start :: (app: *InnerBreeze, id: s32) #foreign c;
practice_active_background_stop :: (app: *InnerBreeze) #foreign c;
// The breath engine advances 60 ticks per second.
MINUTE_BELL_TICKS :: 3600;
clampi :: (value: s32, min_value: s32, max_value: s32) -> s32 {
if value < min_value {
return min_value
@@ -35,40 +34,40 @@ GetFrameTime :: () -> float32 #foreign c;
IsMouseButtonReleased :: (button: s32) -> bool #foreign c;
MOUSE_BUTTON_LEFT :: 0;
GetTime :: () -> float64 #foreign c;
#import, file "../../app/modal_rules.zi";
#import, file "../../app/app_types.zi";
#import, file "../../app/session_screen.zi";
#import, file "../../core/types.zi";
#import, file "../../core/breath_timing.zi";
#import "modal_rules"
#import "app_types"
#import "session_screen"
#import "types"
#import "breath_timing"
#import "layout"
#import "layout_props"
#import "layout_widget"
#import "tree"
#import, file "../../app/app_notifications.zi";
#import, file "../../app/app_settings.zi";
#import, file "../../app/app_modal_state.zi";
#import, file "../../storage/data.zi";
#import "app_notifications"
#import "app_settings"
#import "app_modal_state"
#import "data"
#import, file "../../app/app_nav_state.zi";
#import, file "../../app/practice_title_bar.zi";
#import, file "../../app/widgets.zi";
#import, file "../../app/text_buffers.zi";
#import, file "../../app/locale.zi";
#import "app_nav_state"
#import "practice_title_bar"
#import "widgets"
#import "text_buffers"
#import "locale"
#import, file "../meditation/meditation_music.zi";
#import, file "../practice_audio_controls.zi";
#import, file "../session_results.zi";
#import, file "../practice_window.zi";
#import "meditation_music"
#import "practice_audio_controls"
#import "session_results"
#import "practice_window"
#import "control_props"
#import "text_align"
#import "kss_parser"
#import "text_props"
#import, file "../../app/exercise_types.zi";
#import, file "../../app/metrics.zi";
#import, file "../../app/color.zi";
#import, file "../../app/current_app.zi";
#import "exercise_types"
#import "metrics"
#import "color"
#import "current_app"
#import "button_widget"
#import "text_widget"
#import "drawing_props"
@@ -95,7 +94,7 @@ using ButtonEmphasis;
ANDROID :: #defined(ANDROID_BUILD)
#if ANDROID {
#import, file "../../platform/android/android_wakelock.zi";
#import "android_wakelock"
}
whm_log :: (level: s32, message: string) {
@@ -251,7 +250,7 @@ remember_sound_state :: (app: *InnerBreeze) {
// The practice may run in its small window while another app is open.
screen := app_session_screen(app)
if screen != ScreenSession || app.breathing.phase != BreathPhaseHold {
app.retention_marker_last_bucket = 0
app.hold_reminder_last_bucket = 0
}
app.sound_last_screen = screen
app.sound_last_phase = app.breathing.phase
@@ -260,52 +259,22 @@ remember_sound_state :: (app: *InnerBreeze) {
app.sound_last_count[1] = app.breathing.count[1]
app.sound_last_count[2] = app.breathing.count[2]
app.sound_last_count[3] = 0
// Minutes passed while cues were silent never ring later.
app.minute_bell_last_minute = app.minute_bell_ticks / MINUTE_BELL_TICKS
}
update_retention_marker :: (app: *InnerBreeze, phase_changed: s32) -> bool {
seconds: s32
bucket: s32
update_hold_reminder :: (app: *InnerBreeze, phase_changed: bool) {
if app == null {
return false
}
if app.retention_marker_enabled == 0 || app.breathing.phase != BreathPhaseHold {
app.retention_marker_last_bucket = 0
return false
}
if phase_changed != 0 {
app.retention_marker_last_bucket = 0
}
seconds = BreathDigitsRead(app.breathing.count[:])
bucket = seconds / 30
if bucket <= 0 || bucket <= app.retention_marker_last_bucket {
return false
}
app.retention_marker_last_bucket = bucket
app_play_bell_cue(app, 0.45f)
return true
}
// Rings once for each whole minute of running practice time, counted from
// the start; paused time does not count. When another bell rings at the
// same moment, that bell marks the minute.
update_minute_bell :: (app: *InnerBreeze, bell_played: bool) {
if app == null || app.minute_bell_enabled == 0 {
return
}
minute := app.minute_bell_ticks / MINUTE_BELL_TICKS
if minute <= app.minute_bell_last_minute {
return
if phase_changed {
app.hold_reminder_last_bucket = 0
}
app.minute_bell_last_minute = minute
if bell_played {
return
reminder := HoldReminderAdvance(app.breathing.phase == BreathPhaseHold,
BreathDigitsRead(app.breathing.count[:]), app.hold_reminder_seconds,
app.hold_reminder_last_bucket)
app.hold_reminder_last_bucket = reminder.last_bucket
if reminder.ring {
app_play_bell_cue(app, 0.45f)
}
app_play_bell_cue(app, 0.85f)
}
FormatLocaleCount :: (out: []u8, key: string, count: s32) {
@@ -390,7 +359,6 @@ update_session_sounds :: (app: *InnerBreeze) {
count_changed := !(app.sound_last_count[0] == app.breathing.count[0] &&
app.sound_last_count[1] == app.breathing.count[1] &&
app.sound_last_count[2] == app.breathing.count[2])
bell_played := false
if app.breathing.phase == BreathPhaseBreathe {
if screen_changed || phase_changed || dir_changed {
@@ -401,7 +369,6 @@ update_session_sounds :: (app: *InnerBreeze) {
maxbreaths_value: s32 = BreathDigitsRead(app.breathing.maxbreaths[:])
if count_value == maxbreaths_value - 1 {
app_play_bell_cue(app, 0.8f)
bell_played = true
}
}
} else if phase_changed {
@@ -410,10 +377,7 @@ update_session_sounds :: (app: *InnerBreeze) {
}
}
if update_retention_marker(app, ifx (phase_changed) then (1) else (0)) {
bell_played = true
}
update_minute_bell(app, bell_played)
update_hold_reminder(app, phase_changed)
remember_sound_state(app)
}
@@ -451,7 +415,6 @@ session_advance_seconds :: (app: *InnerBreeze, seconds: float64) {
return
}
app.breathing = step.breathing
app.minute_bell_ticks += 1
if app.breathing.completed != 0 {
session_complete(app)
break
@@ -498,8 +461,7 @@ session_start :: (app: *InnerBreeze) {
app.session_paused = 0
app.results_saved = 0
app.results_path[0] = cast(u8)0
app.retention_marker_last_bucket = 0
app.minute_bell_ticks = 0
app.hold_reminder_last_bucket = 0
remember_sound_state(app)
#if ANDROID {
+58 -8
View File
@@ -1,26 +1,76 @@
#import, file "../src/core/types.zi";
#import, file "../src/core/breath_timing.zi";
#import "hold_reminder"
using BreathAnimation;
CheckHoldReminders :: () -> bool {
intervals: [2]s32 = .[30, 60]
for index: 0..1 {
interval := intervals[index]
bucket: s32 = 0
rings: s32 = 0
// Starting, breathing, and recovery do not accumulate reminders.
before_hold := HoldReminderAdvance(false, 120, interval, 3)
if before_hold.ring || before_hold.last_bucket != 0 {
return false
}
for second: cast(s32)0..125 {
reminder := HoldReminderAdvance(true, second, interval, bucket)
if reminder.ring {
if second == 0 || second % interval != 0 {
return false
}
rings += 1
}
bucket = reminder.last_bucket
// Multiple frames, or a pause at a boundary, never repeat it.
repeated := HoldReminderAdvance(true, second, interval, bucket)
if repeated.ring || repeated.last_bucket != bucket {
return false
}
}
if rings != 120 / interval {
return false
}
next_round := HoldReminderAdvance(false, 0, interval, bucket)
if next_round.ring || next_round.last_bucket != 0 ||
HoldReminderAdvance(true, 0, interval, next_round.last_bucket).ring {
return false
}
}
skipped := HoldReminderAdvance(true, 61, 60, 0)
if !skipped.ring || skipped.last_bucket != 1 ||
HoldReminderAdvance(true, 61, 60, skipped.last_bucket).ring ||
HoldReminderAdvance(true, 120, 0, 0).ring ||
HoldReminderAdvance(true, 120, 17, 0).ring ||
HoldReminderAdvance(true, -1, 60, 0).ring {
return false
}
return true
}
#program_export
Answer :: () -> s32 {
if !CheckHoldReminders() {
return -30
}
if BreathHalfTicksForSpeed(0) != 180 ||
BreathHalfTicksForSpeed(6) != 108 ||
BreathHalfTicksForSpeed(9) != 74 { return -1 }
digits: [CountSize]u8
if !BreathDigitsWrite(digits[:], 37) ||
BreathDigitsRead(digits[:]) != 37 || digits[0] != cast(u8)48 ||
digits[1] != cast(u8)51 || digits[2] != cast(u8)55 ||
digits[3] != 0 {
BreathDigitsRead(digits[:]) != 37 || digits[0] != cast(u8)48 ||
digits[1] != cast(u8)51 || digits[2] != cast(u8)55 ||
digits[3] != 0 {
return -21
}
if !BreathDigitsWrite(digits[:], -10) ||
BreathDigitsRead(digits[:]) != 0 ||
!BreathDigitsWrite(digits[:], 2000) ||
BreathDigitsRead(digits[:]) != 999 ||
BreathDigitsWrite(digits[0:3], 10) {
BreathDigitsRead(digits[:]) != 0 ||
!BreathDigitsWrite(digits[:], 2000) ||
BreathDigitsRead(digits[:]) != 999 ||
BreathDigitsWrite(digits[0:3], 10) {
return -22
}
@@ -37,7 +87,7 @@ Answer :: () -> s32 {
bounds.count[2] = cast(u8)50
bounds = BreathResetRoundBreathe(bounds)
if bounds.phase != BreathPhaseBreathe || bounds.r != bounds.rmin ||
BreathCountValue(bounds) != 0 {
BreathCountValue(bounds) != 0 {
return -24
}
+6 -4
View File
@@ -8,7 +8,7 @@ source=$root/tests/breath_timing_behavior.zi
include=${ZIRAN_INCLUDE:-"$root/build/packages/ziran/include"}
mkdir -p "$work/ir"
"$bin/zi2zir" --root "$root/tests" --module-path "$root/src" \
"$bin/zi2zir" --root "$root/tests" --module-path "$root/src" --module-path "$root/apps/practice" \
-o "$work/ir" "$source"
for input in source saved; do
@@ -16,22 +16,24 @@ for input in source saved; do
file=$source
module_root=$root/tests
library_path=$root/src
practice_path=$root/apps/practice
else
file=$work/ir/breath_timing_behavior.zir
module_root=$work/ir
library_path=$work/ir
practice_path=$work/ir
fi
output=$work/$input
rm -rf "$output/c" "$output/go"
mkdir -p "$output/c" "$output/go"
"$bin/zi2zx" bundle --root "$module_root" \
--module-path "$library_path" \
--module-path "$library_path" --module-path "$practice_path" \
--entry breath_timing_behavior:Answer \
-o "$output/breath.zx" "$file"
[ "$("$bin/zi2zx" run "$output/breath.zx")" = 42 ]
"$bin/zi2c" --no-main --root "$module_root" \
--module-path "$library_path" -o "$output/c" "$file"
--module-path "$library_path" --module-path "$practice_path" -o "$output/c" "$file"
cat > "$output/c/main.c" <<'C'
#include "breath_timing_behavior.h"
int main(void) { return Answer() == 42 ? 0 : 1; }
@@ -41,7 +43,7 @@ C
env -u DISPLAY -u WAYLAND_DISPLAY "$output/c/test"
"$bin/zi2go" --no-main --root "$module_root" \
--module-path "$library_path" -o "$output/go" "$file"
--module-path "$library_path" --module-path "$practice_path" -o "$output/go" "$file"
cat > "$output/go/breath_timing_behavior_test.go" <<'GO'
package ziran
import "testing"
+1 -1
View File
@@ -1,7 +1,7 @@
[package]
name = "Inbe"
entry = "src/main.zi"
module_roots = ["src", "src/cells"]
module_roots = ["src", "src/cells", "src/app", "src/core", "src/habits", "src/practices", "src/practices/whm", "src/practices/meditation", "src/screens", "src/storage", "src/platform/android", "apps/practice"]
[toolchain]
git = "https://github.com/ziranlang/ziran.git"