From 340e342f1978005b5a222a6a3791c1028c690048 Mon Sep 17 00:00:00 2001 From: Evgeny Date: Thu, 2 Sep 2021 13:29:12 +0300 Subject: [PATCH] add vibrate and alarm functions --- README.md | 2 ++ README_ru.md | 2 ++ samples/alarm-sample.lua | 11 +++++++++++ 3 files changed, 15 insertions(+) create mode 100644 samples/alarm-sample.lua diff --git a/README.md b/README.md index 33a19fc..ad4be45 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,8 @@ When you click on any menu item, the collab `on_context_menu_click(item_idx)` wi * `system:get_location()` - returns the location in the table with two values (location request is NOT executed, the value previously saved by the system is used); * `system:copy_to_clipboard(string)` - copies the string to the clipboard; * `system:get_from_clipboard()` - returns a string from the clipboard: +* `system:vibrate(milliseconds)` - vibrate; +* `system:alarm_sound(seconds)` - make alarm sound; * `system:share_text(string)` - opens the "Share" system dialog; * `system:get_lang()` - returns the language selected in the system; * `system:get_tz_offset()` - returns TimeZone offset in seconds; diff --git a/README_ru.md b/README_ru.md index 87f2529..7f20a71 100644 --- a/README_ru.md +++ b/README_ru.md @@ -84,6 +84,8 @@ ui:show_context_menu({ * `system:copy_to_clipboard(string)` - копирует строку в буфер обмена; * `system:get_from_clipboard()` - возвращает строку из буфера обмена: * `system:share_text(string)` - открывает системный диалог "Поделиться"; +* `system:vibrate(milliseconds)` - вибрация; +* `system:alarm_sound(seconds)` - издать звук будильника; * `system:get_lang()` - возвращает выбранный в системе язык; * `system:get_tz_offset()` - возвращает time zone offset в секундах. * `system:get_battery_info()` - возвращает таблицу с информацией о состоянии батареи; diff --git a/samples/alarm-sample.lua b/samples/alarm-sample.lua new file mode 100644 index 0000000..1955883 --- /dev/null +++ b/samples/alarm-sample.lua @@ -0,0 +1,11 @@ +function on_resume() + ui:show_lines({ "Vibrate", "Alarm" }) +end + +function on_click(idx) + if idx == 1 then + system:vibrate(500) + else + system:alarm_sound(5) + end +end