Berry tasmota.micros() to get time in microseconds (#24192)

* Remove tab from json

* Berry `tasmota.micros()` to get time in microseconds
This commit is contained in:
s-hadinger 2025-12-06 14:46:05 +01:00 committed by GitHub
parent 58e608b383
commit 7d0f351798
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View File

@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
- Support for ESP32-P4 rev.3 (#24146)
- Support for Analog Gauges (#24153)
- Support for MakeSkyBlue Solar Charger Energy Monitor (#24151)
- Berry `tasmota.micros()` to get time in microseconds
### Breaking Changed

View File

@ -21,6 +21,7 @@ extern int l_publish_rule(bvm *vm);
extern int l_cmd(bvm *vm);
extern int l_getoption(bvm *vm);
extern int l_millis(bvm *vm);
extern int l_micros(bvm *vm);
extern int l_timereached(bvm *vm);
extern int l_rtc(bvm *vm);
extern int l_rtc_utc(bvm *vm);
@ -114,7 +115,8 @@ class be_class_tasmota (scope: global, name: Tasmota) {
publish_rule, func(l_publish_rule)
_cmd, func(l_cmd)
get_option, func(l_getoption)
millis, func(l_millis)
millis, static_func(l_millis)
micros, static_func(l_micros)
time_reached, func(l_timereached)
rtc, static_func(l_rtc)
rtc_utc, func(l_rtc_utc)

View File

@ -119,10 +119,10 @@ extern "C" {
int32_t l_millis(struct bvm *vm);
int32_t l_millis(struct bvm *vm) {
int32_t top = be_top(vm); // Get the number of arguments
if (top == 1 || (top == 2 && be_isint(vm, 2))) { // only 1 argument of type string accepted
if (top == 0 || (top == 1 && be_isint(vm, 1))) { // only 1 argument of type string accepted
uint32_t delay = 0;
if (top == 2) {
delay = be_toint(vm, 2);
delay = be_toint(vm, 1);
}
uint32_t ret_millis = millis() + delay;
be_pushint(vm, ret_millis);
@ -131,6 +131,14 @@ extern "C" {
be_raise(vm, kTypeError, nullptr);
}
// Berry: tasmota.micros() -> int
//
int32_t l_micros(struct bvm *vm);
int32_t l_micros(struct bvm *vm) {
be_pushint(vm, micros());
be_return(vm); // Return
}
// Berry: tasmota.get_option(index:int) -> int
//
int32_t l_getoption(struct bvm *vm);