-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc: add docs for sdcard, wifi & transforms (closes #107)
keira: rename imageTransform to transforms, construct transform with transforms.new() keira: fix FTP app crashing when WiFi is down keira: lua: add gpio.INPUT_PULLDOWN keira: fix Lua sample scripts
- Loading branch information
Showing
19 changed files
with
316 additions
and
30 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 |
---|---|---|
|
@@ -8,11 +8,14 @@ Lua API | |
|
||
lilka | ||
display | ||
transform | ||
controller | ||
resources | ||
math | ||
geometry | ||
gpio | ||
util | ||
buzzer | ||
sdcard | ||
state | ||
wifi |
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,16 @@ | ||
``sdcard`` - Робота з SD-картою | ||
------------------------------- | ||
|
||
Функції для роботи читання/запису файлів на SD-карті. | ||
|
||
Приклад: | ||
|
||
.. code-block:: lua | ||
:linenos: | ||
local file = sdcard.open("file.txt", "w") | ||
file:write("Hello, world!") | ||
.. lua:autoclass:: sdcard | ||
.. lua:autoclass:: File |
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,18 @@ | ||
``transform`` - Перетворення зображень | ||
-------------------------------------- | ||
|
||
Функції для обертання та масштабування зображень. | ||
|
||
Приклад: | ||
|
||
.. code-block:: lua | ||
local image = resource.load_image("face.bmp", display.color565(0, 0, 0)) | ||
local transform = transforms.new() | ||
transform = transform:scale(1.5, 0.5) | ||
transform = transform:rotate(45) | ||
display.draw_image(image, 50, 80, transform) -- малює зображення в точці (50, 80) з перетвореннями | ||
.. lua:autoclass:: transforms | ||
.. lua:autoclass:: Transform |
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,18 @@ | ||
``wifi`` - Робота з WiFi-мережами | ||
--------------------------------- | ||
|
||
Функції для роботи з WiFi-мережами. | ||
|
||
Приклад: | ||
|
||
.. code-block:: lua | ||
:linenos: | ||
local networks = wifi.scan() | ||
for i = 0, #networks do | ||
print(networks[i]) | ||
print('Сила сигналу: ', wifi.get_rssi(i)) | ||
print('Тип шифрування: ', wifi.get_encryption_type(i)) | ||
end | ||
.. lua:autoclass:: wifi |
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 |
---|---|---|
@@ -1,19 +1,15 @@ | ||
local file_dir = sdcard.ls("/") | ||
|
||
print(#file_dir) | ||
|
||
for i = 0, #file_dir do | ||
print(file_dir[i]) | ||
for i = 0, #file_dir do | ||
print('*', file_dir[i]) | ||
end | ||
|
||
file = file("/test.txt", "a+") | ||
|
||
file:write("HELLOWORLD") | ||
local file = sdcard.open("/test.txt", "a+") | ||
file:write("HELLOWORLD") | ||
|
||
text = file:read(5) | ||
local text = file:read(5) | ||
print(text) | ||
|
||
print(text) | ||
|
||
size = file:size() | ||
local size = file:size() | ||
print(size) | ||
|
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 |
---|---|---|
@@ -1,18 +1,16 @@ | ||
status = wifi.get_status() | ||
local status = wifi.get_status() | ||
print(status) | ||
|
||
wifi.disconnect() | ||
|
||
status = wifi.get_status() | ||
print(status) | ||
|
||
scan = wifi.scan() | ||
local scan = wifi.scan() | ||
|
||
print(#scan) | ||
for i = 1, #scan do -- This will cycle through and print each element of the array | ||
print(scan[i]) | ||
rssi = wifi.get_rssi(i) | ||
print(rssi) | ||
rssi = wifi.get_encryption_type(i) | ||
print(rssi) | ||
local rssi = wifi.get_rssi(i) | ||
local enc_type = wifi.get_encryption_type(i) | ||
print(scan[i], rssi, enc_type) | ||
end |
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
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
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
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
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,72 @@ | ||
---@meta | ||
|
||
---@class sdcard | ||
sdcard = {} | ||
|
||
---Повернути таблицю зі списком файлів та директорій за вказаним шляхом. | ||
--- | ||
---@param path string шлях до директорії (відносно кореня SD-картки) | ||
---@return table | ||
---@usage | ||
--- local entries = sdcard.ls("/folder") | ||
--- for i = 0, #entries do | ||
--- print(entries[i]) | ||
--- end | ||
function sdcard.ls(path) end | ||
|
||
---Видалити файл або директорію за вказаним шляхом. | ||
--- | ||
---@param path string шлях до файлу або директорії (відносно кореня SD-картки) | ||
---@usage | ||
--- sdcard.remove("/folder/file.txt") | ||
function sdcard.remove(path) end | ||
|
||
---Перейменувати файл або директорію. | ||
--- | ||
---@param old_path string старий шлях до файлу або директорії (відносно кореня SD-картки) | ||
---@param new_path string новий шлях до файлу або директорії (відносно кореня SD-картки) | ||
--- | ||
---@usage | ||
--- sdcard.rename("/folder/file.txt", "/folder/file2.txt") | ||
function sdcard.rename(old_path, new_path) end | ||
|
||
---@class File | ||
File = {} | ||
|
||
---Відкрити файл за вказаним шляхом. | ||
--- | ||
---@param path string шлях до файлу (відносно кореня SD-картки) | ||
---@param mode string режим відкриття файлу (див. функцію ``fopen`` у документації ANSI C) | ||
---@return File | ||
--- | ||
---@usage | ||
--- local file = sdcard.open("/file.txt", "a+") -- Відкриває файл для додавання тексту | ||
--- file:write("Hello, world!\n") -- Дописує текст в кінець файлу | ||
function sdcard.open(path, mode) end | ||
|
||
---Повернути розмір файлу. | ||
--- | ||
---@return integer | ||
function File:size() end | ||
|
||
---Перемістити вказівник файлу на певну позицію. | ||
--- | ||
---@param pos integer позиція в файлі | ||
function File:seek(pos) end | ||
|
||
---Прочитати з файлу. | ||
--- | ||
---@param count integer максимальна кількість байт, які потрібно прочитати | ||
---@return string | ||
function File:read(count) end | ||
|
||
---Записати у файл. | ||
--- | ||
---@param content string дані, які потрібно записати | ||
---@usage | ||
--- local file = sdcard.open("/file.txt", "w") -- Відкриває файл для запису | ||
--- file:write("Hello, world!\n") -- Записує текст у файл | ||
--- file:write("Привіт, світ!\n") -- Дописує текст у файл | ||
function File:write(content) end | ||
|
||
return sdcard |
Oops, something went wrong.