-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Liquidated librishka SDK file implementations.
- Loading branch information
Showing
11 changed files
with
743 additions
and
567 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,27 @@ | ||
/* | ||
* This file is part of the Rishka distribution (https://github.com/rishka-esp32/rishka-sdk). | ||
* Copyright (c) 2024 Nathanne Isip. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "librishka.h" | ||
#include "librishka_impl.hpp" | ||
|
||
u8 Args::count() { | ||
return (u32) rishka_sc_0(RISHKA_SC_ARG_COUNT); | ||
} | ||
|
||
string Args::value(u8 index) { | ||
return get_rt_string(rishka_sc_1(RISHKA_SC_ARG_STR, (i64) index)); | ||
} |
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,127 @@ | ||
/* | ||
* This file is part of the Rishka distribution (https://github.com/rishka-esp32/rishka-sdk). | ||
* Copyright (c) 2024 Nathanne Isip. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "librishka.h" | ||
#include "librishka_impl.hpp" | ||
|
||
File::File(i32 _handle) { | ||
this->handle = _handle; | ||
} | ||
|
||
File File::open(string file, string mode) { | ||
return File((i32) rishka_sc_2(RISHKA_SC_FS_OPEN, (i64) file, (i64) mode)); | ||
} | ||
|
||
bool File::is_file() { | ||
return (bool) rishka_sc_1(RISHKA_SC_FS_ISFILE, (i64) this->handle); | ||
} | ||
|
||
bool File::is_dir() { | ||
return (bool) rishka_sc_1(RISHKA_SC_FS_ISDIR, (i64) this->handle); | ||
} | ||
|
||
i32 File::available() { | ||
return (i32) rishka_sc_1(RISHKA_SC_FS_AVAILABLE, (i64) this->handle); | ||
} | ||
|
||
i32 File::peek() { | ||
return (i32) rishka_sc_1(RISHKA_SC_FS_PEEK, (i64) this->handle); | ||
} | ||
|
||
bool File::seek(u32 pos) { | ||
return (bool) rishka_sc_2(RISHKA_SC_FS_SEEK, (i64) this->handle, (i64) pos); | ||
} | ||
|
||
usize File::size() { | ||
return (usize) rishka_sc_1(RISHKA_SC_FS_SIZE, (i64) this->handle); | ||
} | ||
|
||
usize File::position() { | ||
return (usize) rishka_sc_1(RISHKA_SC_FS_POS, (i64) this->handle); | ||
} | ||
|
||
i32 File::read() { | ||
return (i32) rishka_sc_1(RISHKA_SC_FS_READ, (i64) this->handle); | ||
} | ||
|
||
void File::write(u8 data) { | ||
rishka_sc_2(RISHKA_SC_FS_WRITEB, (i64) this->handle, (i64) data); | ||
} | ||
|
||
void File::write(string data) { | ||
rishka_sc_2(RISHKA_SC_FS_WRITES, (i64) this->handle, (i64) data); | ||
} | ||
|
||
string File::path() { | ||
return get_rt_string(rishka_sc_1(RISHKA_SC_FS_PATH, (i64) this->handle)); | ||
} | ||
|
||
string File::name() { | ||
return get_rt_string(rishka_sc_1(RISHKA_SC_FS_NAME, (i64) this->handle)); | ||
} | ||
|
||
File File::next() { | ||
return File(rishka_sc_1(RISHKA_SC_FS_NEXT, (i64) this->handle)); | ||
} | ||
|
||
bool File::is_ok() { | ||
return rishka_sc_1(RISHKA_SC_FS_IS_OK, (i64) this->handle); | ||
} | ||
|
||
void File::flush() { | ||
rishka_sc_1(RISHKA_SC_FS_FLUSH, (i64) this->handle); | ||
} | ||
|
||
void File::close() { | ||
rishka_sc_1(RISHKA_SC_FS_CLOSE, (i64) this->handle); | ||
} | ||
|
||
bool File::bufsize(usize size) { | ||
return (bool) rishka_sc_2(RISHKA_SC_FS_BUFSIZE, (i64) this->handle, (i64) size); | ||
} | ||
|
||
u64 File::lastwrite() { | ||
return (u64) rishka_sc_1(RISHKA_SC_FS_LASTWRITE, (i64) this->handle); | ||
} | ||
|
||
bool File::seek_dir(u64 position) { | ||
return (bool) rishka_sc_2(RISHKA_SC_FS_SEEKDIR, (i64) this->handle, (i64) position); | ||
} | ||
|
||
string File::next_name() { | ||
return get_rt_string(rishka_sc_1(RISHKA_SC_FS_NEXT_NAME, (i64) this->handle)); | ||
} | ||
|
||
void File::rewind() { | ||
rishka_sc_1(RISHKA_SC_FS_REWIND, (i64) this->handle); | ||
} | ||
|
||
bool FS::mkdir(const char* path) { | ||
return (bool) rishka_sc_1(RISHKA_SC_FS_MKDIR, (i64) path); | ||
} | ||
|
||
bool FS::rmdir(const char* path) { | ||
return (bool) rishka_sc_1(RISHKA_SC_FS_RMDIR, (i64) path); | ||
} | ||
|
||
bool FS::remove(const char* path) { | ||
return (bool) rishka_sc_1(RISHKA_SC_FS_DELETE, (i64) path); | ||
} | ||
|
||
bool FS::exists(const char* path) { | ||
return (bool) rishka_sc_1(RISHKA_SC_FS_EXISTS, (i64) path); | ||
} |
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,63 @@ | ||
/* | ||
* This file is part of the Rishka distribution (https://github.com/rishka-esp32/rishka-sdk). | ||
* Copyright (c) 2024 Nathanne Isip. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "librishka.h" | ||
#include "librishka_impl.hpp" | ||
|
||
void Gpio::pin_mode(u8 pin, gpio_pin_mode_t mode) { | ||
rishka_sc_2(RISHKA_SC_GPIO_PIN_MODE, (i64) pin, (i64) mode); | ||
} | ||
|
||
gpio_mode_t Gpio::digital_read(u8 pin) { | ||
return (gpio_mode_t) rishka_sc_1(RISHKA_SC_GPIO_DIGITAL_READ, (i64) pin); | ||
} | ||
|
||
void Gpio::digital_write(u8 pin, gpio_mode_t mode) { | ||
rishka_sc_2(RISHKA_SC_GPIO_DIGITAL_WRITE, (i64) pin, (i64) mode); | ||
} | ||
|
||
u16 Gpio::analog_read(u8 pin) { | ||
return (i32) rishka_sc_1(RISHKA_SC_GPIO_ANALOG_READ, (i64) pin); | ||
} | ||
|
||
void Gpio::analog_write(u8 pin, u16 value) { | ||
rishka_sc_2(RISHKA_SC_GPIO_ANALOG_WRITE, (i64) pin, (i64) value); | ||
} | ||
|
||
u64 Gpio::pulse_in(u8 pin, u8 state, u64 timeout) { | ||
return (u64) rishka_sc_3(RISHKA_SC_GPIO_PULSE_IN, (i64) pin, (i64) state, (i64) timeout); | ||
} | ||
|
||
u64 Gpio::pulse_in_long(u8 pin, u8 state, u64 timeout) { | ||
return (u64) rishka_sc_3(RISHKA_SC_GPIO_PULSE_IN_LONG, (i64) pin, (i64) state, (i64) timeout); | ||
} | ||
|
||
u8 Gpio::shift_in(u8 data, u8 clock, u8 bit_order) { | ||
return (u8) rishka_sc_3(RISHKA_SC_GPIO_SHIFT_IN, (i64) data, (i64) clock, (i64) bit_order); | ||
} | ||
|
||
void Gpio::shift_out(u8 data, u8 clock, u8 bit_order, u8 value) { | ||
rishka_sc_4(RISHKA_SC_GPIO_SHIFT_OUT, (i64) data, (i64) clock, (i64) bit_order, (i64) value); | ||
} | ||
|
||
void Gpio::tone(u32 frequency, u64 duration) { | ||
rishka_sc_2(RISHKA_SC_GPIO_TONE, (i64) frequency, (i64) duration); | ||
} | ||
|
||
void Gpio::no_tone() { | ||
rishka_sc_0(RISHKA_SC_GPIO_NO_TONE); | ||
} |
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,95 @@ | ||
/* | ||
* This file is part of the Rishka distribution (https://github.com/rishka-esp32/rishka-sdk). | ||
* Copyright (c) 2024 Nathanne Isip. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, version 3. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include "librishka.h" | ||
#include "librishka_impl.hpp" | ||
|
||
bool I2C::begin(u8 address) { | ||
return (bool) rishka_sc_1(RISHKA_SC_I2C_BEGIN, (i64) address); | ||
} | ||
|
||
bool I2C::end() { | ||
return (bool) rishka_sc_0(RISHKA_SC_I2C_END); | ||
} | ||
|
||
bool I2C::pins(u8 sda, u8 scl) { | ||
return (bool) rishka_sc_2(RISHKA_SC_I2C_PINS, (i64) sda, (i64) scl); | ||
} | ||
|
||
void I2C::flush() { | ||
rishka_sc_0(RISHKA_SC_I2C_FLUSH); | ||
} | ||
|
||
void I2C::begin_transmission(u8 address) { | ||
rishka_sc_1(RISHKA_SC_I2C_BEGIN_TRANSMISSION, (i64) address); | ||
} | ||
|
||
u8 I2C::end_transmission(bool stop_bit) { | ||
return (u8) rishka_sc_1(RISHKA_SC_I2C_END_TRANSMISSION, (i64) stop_bit); | ||
} | ||
|
||
usize I2C::write(u8* data, usize size) { | ||
return (usize) rishka_sc_2(RISHKA_SC_I2C_WRITE, (i64) data, (usize) size); | ||
} | ||
|
||
usize I2C::slave_write(u8* data, usize size) { | ||
return (usize) rishka_sc_2(RISHKA_SC_I2C_SLAVE_WRITE, (i64) data, (usize) size); | ||
} | ||
|
||
usize I2C::set_buffersize(usize size) { | ||
return (usize) rishka_sc_1(RISHKA_SC_I2C_BUFSIZE, (i64) size); | ||
} | ||
|
||
i32 I2C::read() { | ||
return (i32) rishka_sc_0(RISHKA_SC_I2C_READ); | ||
} | ||
|
||
i32 I2C::peek() { | ||
return (i32) rishka_sc_0(RISHKA_SC_I2C_PEEK); | ||
} | ||
|
||
i32 I2C::available() { | ||
return (i32) rishka_sc_0(RISHKA_SC_I2C_AVAILABLE); | ||
} | ||
|
||
usize I2C::request(u8 address, usize size, bool stop_bit) { | ||
return (usize) rishka_sc_3(RISHKA_SC_I2C_REQUEST, (i64) address, (i64) size, (i64) stop_bit); | ||
} | ||
|
||
void I2C::on_receive(void (*callback)(int)) { | ||
rishka_sc_1(RISHKA_SC_I2C_ON_RECEIVE, (i64) callback); | ||
} | ||
|
||
void I2C::on_request(void (*callback)(void)) { | ||
rishka_sc_1(RISHKA_SC_I2C_ON_RECEIVE, (i64) callback); | ||
} | ||
|
||
void I2C::set_timeout(u16 timeout) { | ||
rishka_sc_1(RISHKA_SC_I2C_SET_TIMEOUT, (i64) timeout); | ||
} | ||
|
||
u16 I2C::get_timeout() { | ||
return (u16) rishka_sc_0(RISHKA_SC_I2C_GET_TIMEOUT); | ||
} | ||
|
||
bool I2C::set_clock(u32 clock) { | ||
return (bool) rishka_sc_1(RISHKA_SC_I2C_SET_CLOCK, (i64) clock); | ||
} | ||
|
||
u32 I2C::get_clock() { | ||
return (u32) rishka_sc_0(RISHKA_SC_I2C_GET_CLOCK); | ||
} |
Oops, something went wrong.