mirror of https://github.com/arendst/Tasmota.git
Added assign_rmt
This commit is contained in:
parent
7a4108ef93
commit
da783abaef
|
@ -59,6 +59,7 @@ extern const bcstring be_const_str_INTERNAL_PDM;
|
|||
extern const bcstring be_const_str_LVG_X3A_X20call_X20to_X20unsupported_X20callback;
|
||||
extern const bcstring be_const_str_LVG_X3A_X20object_X3A;
|
||||
extern const bcstring be_const_str_Leds;
|
||||
extern const bcstring be_const_str_MAX_RMT;
|
||||
extern const bcstring be_const_str_MD5;
|
||||
extern const bcstring be_const_str_None;
|
||||
extern const bcstring be_const_str_OPTION_A;
|
||||
|
@ -220,6 +221,7 @@ extern const bcstring be_const_str__persist_X2Ejson;
|
|||
extern const bcstring be_const_str__ptr;
|
||||
extern const bcstring be_const_str__read;
|
||||
extern const bcstring be_const_str__request_from;
|
||||
extern const bcstring be_const_str__rmt;
|
||||
extern const bcstring be_const_str__rules;
|
||||
extern const bcstring be_const_str__settings_def;
|
||||
extern const bcstring be_const_str__settings_ptr;
|
||||
|
@ -258,6 +260,7 @@ extern const bcstring be_const_str_argument_X20must_X20be_X20a_X20list;
|
|||
extern const bcstring be_const_str_as;
|
||||
extern const bcstring be_const_str_asin;
|
||||
extern const bcstring be_const_str_assert;
|
||||
extern const bcstring be_const_str_assign_rmt;
|
||||
extern const bcstring be_const_str_asstring;
|
||||
extern const bcstring be_const_str_atan;
|
||||
extern const bcstring be_const_str_atan2;
|
||||
|
@ -510,6 +513,7 @@ extern const bcstring be_const_str_instance_size;
|
|||
extern const bcstring be_const_str_int;
|
||||
extern const bcstring be_const_str_internal_error;
|
||||
extern const bcstring be_const_str_introspect;
|
||||
extern const bcstring be_const_str_invalid_X20GPIO_X20number;
|
||||
extern const bcstring be_const_str_invalidate;
|
||||
extern const bcstring be_const_str_io_error;
|
||||
extern const bcstring be_const_str_ip;
|
||||
|
@ -595,6 +599,7 @@ extern const bcstring be_const_str_next;
|
|||
extern const bcstring be_const_str_next_cron;
|
||||
extern const bcstring be_const_str_nil;
|
||||
extern const bcstring be_const_str_no_X20GPIO_X20specified_X20for_X20neopixelbus;
|
||||
extern const bcstring be_const_str_no_X20more_X20RMT_X20channel_X20available;
|
||||
extern const bcstring be_const_str_now;
|
||||
extern const bcstring be_const_str_null_cb;
|
||||
extern const bcstring be_const_str_number;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -52,6 +52,44 @@ class Leds : Leds_ntv
|
|||
|
||||
end
|
||||
|
||||
# assign RMT
|
||||
static def assign_rmt(gpio_phy)
|
||||
gpio_phy = int(gpio_phy)
|
||||
if gpio_phy < 0 raise "value_error", "invalid GPIO number" end
|
||||
|
||||
import global
|
||||
var rmt
|
||||
# if "_rmt" is not initialized, set to an array of GPIO of size MAX_RMT
|
||||
if !global.contains("_rmt")
|
||||
rmt = []
|
||||
global._rmt = rmt
|
||||
for i:0..gpio.MAX_RMT-1
|
||||
rmt.push(-1)
|
||||
end
|
||||
# if default WS2812 is set, assign RMT0
|
||||
if gpio.pin_used(gpio.WS2812, 0)
|
||||
rmt[0] = gpio.pin(gpio.WS2812, 0)
|
||||
end
|
||||
end
|
||||
|
||||
rmt = global._rmt
|
||||
# find an already assigned slot or try to assign a new one
|
||||
var i = 0
|
||||
var first_free = -1
|
||||
while i < gpio.MAX_RMT
|
||||
var elt = rmt[i]
|
||||
if elt == gpio_phy return i end # already assigned
|
||||
if elt < 0 && first_free < 0 first_free = i end # found a free slot
|
||||
i += 1
|
||||
end
|
||||
if first_free >= 0
|
||||
rmt[first_free] = gpio_phy
|
||||
return first_free
|
||||
end
|
||||
# no more slot
|
||||
raise "internal_error", "no more RMT channel available"
|
||||
end
|
||||
|
||||
def clear()
|
||||
self.clear_to(0x000000)
|
||||
self.show()
|
||||
|
|
Loading…
Reference in New Issue