-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: add Lua buzzer docs
- Loading branch information
Showing
6 changed files
with
56 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
``buzzer`` - П'єзо-динамік | ||
-------------------------- | ||
|
||
Функції для роботи з п'єзо-динаміком. | ||
|
||
.. note:: Ці функції не блокують виконання програми: всі звуки та мелодії відтворюються в фоновому режимі. | ||
|
||
.. lua:autoclass:: buzzer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,4 +14,5 @@ Lua API | |
geometry | ||
gpio | ||
util | ||
buzzer | ||
state |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
---@meta | ||
|
||
---@class buzzer | ||
buzzer = {} | ||
|
||
---Відтворює звук заданої частоти. | ||
--- | ||
---Якщо передати другий аргумент, звук буде відтворено впродовж цього часу (в мілісекундах). | ||
--- | ||
---@param frequency number частота тону | ||
---@param size? number тривалість звуку (в мілісекундах) | ||
function buzzer.play(frequency, size) end | ||
|
||
---Відтворює мелодію. | ||
--- | ||
---Мелодія - це масив з пар частота-розмірність. | ||
--- | ||
---Наприклад, ноту з тоном ``523`` Гц (нота "до" п'ятої октави) і тривалістю 1/4 можна представити як ``{523, 4}``. | ||
--- | ||
---Від'ємна тривалість означає ноту з крапкою, наприклад: | ||
--- | ||
---* ``-1`` - ціла нота з крапкою (1 + 1/2) | ||
---* ``-2`` - половина з крапкою (1/2 + 1/4) | ||
---* ``-4`` - чверть з крапкою (1/4 + 1/8) | ||
---...і так далі. | ||
--- | ||
---@param melody table мелодія (масив пар частота-розмірність) | ||
---@param tempo number темп мелодії (кількість ударів на хвилину) | ||
---@usage | ||
--- -- Мелодія "до-ре-мі-фа-соль" п'ятої октави | ||
--- local melody = { | ||
--- {523, 2}, | ||
--- {587, 4}, | ||
--- {659, 2}, | ||
--- {698, 4}, | ||
--- {784, 1}, | ||
--- } | ||
--- buzzer.play_melody(melody, 60) -- Відтворює мелодію з темпом 60 ударів на хвилину | ||
function buzzer.play_melody(melody, tempo) end | ||
|
||
---Зупиняє відтворення всіх звуків. | ||
---@return nil | ||
function buzzer.stop() end | ||
|
||
return buzzer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters