Merge branch 'development' into prerelease-15.1.0
This commit is contained in:
commit
d335e04876
1013
.doc_for_ai/BERRY_LANGUAGE_REFERENCE.md
Normal file
1013
.doc_for_ai/BERRY_LANGUAGE_REFERENCE.md
Normal file
File diff suppressed because it is too large
Load Diff
743
.doc_for_ai/BERRY_TASMOTA.md
Normal file
743
.doc_for_ai/BERRY_TASMOTA.md
Normal file
@ -0,0 +1,743 @@
|
|||||||
|
# Berry for Tasmota
|
||||||
|
|
||||||
|
This document covers Tasmota-specific Berry features and extensions, complementing the general Berry language reference.
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
Berry is the next generation scripting language for Tasmota, embedded by default in all ESP32 based firmwares (NOT supported on ESP8266). It is used for advanced scripting, superseding Rules, and enables building drivers, automations, and UI extensions.
|
||||||
|
|
||||||
|
## Tasmota-Specific Modules
|
||||||
|
|
||||||
|
Beyond standard Berry modules, Tasmota provides additional modules:
|
||||||
|
|
||||||
|
| Module | Description | Import |
|
||||||
|
|--------|-------------|--------|
|
||||||
|
| `tasmota` | Core integration module | Automatically imported |
|
||||||
|
| `light` | Light control | Automatically imported |
|
||||||
|
| `mqtt` | MQTT operations | `import mqtt` |
|
||||||
|
| `webserver` | Web server extensions | `import webserver` |
|
||||||
|
| `gpio` | GPIO control | `import gpio` |
|
||||||
|
| `persist` | Data persistence | `import persist` |
|
||||||
|
| `path` | File system operations | `import path` |
|
||||||
|
| `energy` | Energy monitoring | Automatically imported |
|
||||||
|
| `display` | Display driver integration | `import display` |
|
||||||
|
| `crypto` | Cryptographic functions | `import crypto` |
|
||||||
|
| `re` | Regular expressions | `import re` |
|
||||||
|
| `mdns` | mDNS/Bonjour support | `import mdns` |
|
||||||
|
| `ULP` | Ultra Low Power coprocessor | `import ULP` |
|
||||||
|
| `uuid` | UUID generation | `import uuid` |
|
||||||
|
| `crc` | CRC calculations | `import crc` |
|
||||||
|
|
||||||
|
## Additional Resources
|
||||||
|
|
||||||
|
For Tasmota-specific Berry features and extensions, please refer to the companion document `BERRY_TASMOTA.md`.
|
||||||
|
|
||||||
|
### Tasmota Constants and Enums
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# GPIO constants (gpio module)
|
||||||
|
gpio.INPUT, gpio.OUTPUT, gpio.PULLUP, gpio.PULLDOWN
|
||||||
|
gpio.HIGH, gpio.LOW
|
||||||
|
gpio.REL1, gpio.KEY1, gpio.LED1, gpio.I2C_SCL, gpio.I2C_SDA
|
||||||
|
# ... many more GPIO function constants
|
||||||
|
|
||||||
|
# Serial constants
|
||||||
|
serial.SERIAL_8N1, serial.SERIAL_7E1, etc.
|
||||||
|
|
||||||
|
# Webserver constants
|
||||||
|
webserver.HTTP_GET, webserver.HTTP_POST, webserver.HTTP_OPTIONS, webserver.HTTP_ANY
|
||||||
|
webserver.HTTP_OFF, webserver.HTTP_USER, webserver.HTTP_ADMIN, webserver.HTTP_MANAGER
|
||||||
|
webserver.HTTP_MANAGER_RESET_ONLY
|
||||||
|
webserver.BUTTON_MAIN, webserver.BUTTON_CONFIGURATION, webserver.BUTTON_INFORMATION
|
||||||
|
webserver.BUTTON_MANAGEMENT, webserver.BUTTON_MODULE
|
||||||
|
```
|
||||||
|
|
||||||
|
### Console and REPL
|
||||||
|
|
||||||
|
Access Berry console via *Configuration* → *Berry Scripting Console*. The console supports:
|
||||||
|
- Multi-line input (press Enter twice or click "Run")
|
||||||
|
- Command history (arrow keys)
|
||||||
|
- Colorful syntax highlighting
|
||||||
|
- Berry VM restart with `BrRestart` command
|
||||||
|
|
||||||
|
### File System and Loading
|
||||||
|
|
||||||
|
Berry files can be source (`.be`) or pre-compiled bytecode (`.bec`):
|
||||||
|
|
||||||
|
```berry
|
||||||
|
load("filename") # Loads .be or .bec file
|
||||||
|
tasmota.compile("file.be") # Compiles .be to .bec
|
||||||
|
```
|
||||||
|
|
||||||
|
**Autostart**: Place `autoexec.be` in filesystem to run Berry code at boot.
|
||||||
|
|
||||||
|
### Tasmota Integration Functions
|
||||||
|
|
||||||
|
#### Core Tasmota Functions
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# System information
|
||||||
|
tasmota.get_free_heap() # Free heap bytes
|
||||||
|
tasmota.memory() # Memory stats map
|
||||||
|
tasmota.arch() # Architecture: "esp32", "esp32s2", etc.
|
||||||
|
tasmota.millis() # Milliseconds since boot
|
||||||
|
tasmota.yield() # Give time to low-level functions
|
||||||
|
tasmota.delay(ms) # Block execution for ms milliseconds
|
||||||
|
|
||||||
|
# Commands and responses
|
||||||
|
tasmota.cmd("command") # Execute Tasmota command
|
||||||
|
tasmota.resp_cmnd_done() # Respond "Done"
|
||||||
|
tasmota.resp_cmnd_error() # Respond "Error"
|
||||||
|
tasmota.resp_cmnd_str(msg) # Custom response string
|
||||||
|
tasmota.resp_cmnd(json) # Custom JSON response
|
||||||
|
|
||||||
|
# Configuration
|
||||||
|
tasmota.get_option(index) # Get SetOption value
|
||||||
|
tasmota.read_sensors() # Get sensor JSON string
|
||||||
|
tasmota.wifi() # WiFi connection info
|
||||||
|
tasmota.eth() # Ethernet connection info
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Rules and Events
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# Add rules (similar to Tasmota Rules but more powerful)
|
||||||
|
tasmota.add_rule("trigger", function)
|
||||||
|
tasmota.add_rule(["trigger1", "trigger2"], function) # AND logic
|
||||||
|
tasmota.remove_rule("trigger")
|
||||||
|
|
||||||
|
# Rule function signature
|
||||||
|
def rule_function(value, trigger, msg)
|
||||||
|
# value: trigger value (%value% equivalent)
|
||||||
|
# trigger: full trigger string
|
||||||
|
# msg: parsed JSON map or original string
|
||||||
|
end
|
||||||
|
|
||||||
|
# Examples
|
||||||
|
tasmota.add_rule("Dimmer>50", def() print("Bright!") end)
|
||||||
|
tasmota.add_rule("ANALOG#A1>300", def(val) print("ADC:", val) end)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Timers and Scheduling
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# Timers (50ms resolution)
|
||||||
|
tasmota.set_timer(delay_ms, function)
|
||||||
|
tasmota.remove_timer(id)
|
||||||
|
tasmota.defer(function) # Run in next millisecond
|
||||||
|
|
||||||
|
# Cron scheduling
|
||||||
|
tasmota.add_cron("*/15 * * * * *", function, "id")
|
||||||
|
tasmota.remove_cron("id")
|
||||||
|
tasmota.next_cron("id") # Next execution timestamp
|
||||||
|
|
||||||
|
# Time functions
|
||||||
|
tasmota.rtc() # Current time info
|
||||||
|
tasmota.time_dump(timestamp) # Decompose timestamp
|
||||||
|
tasmota.time_str(timestamp) # ISO 8601 string
|
||||||
|
tasmota.strftime(format, timestamp)
|
||||||
|
tasmota.strptime(time_str, format)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Device Control
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# Relays and Power
|
||||||
|
tasmota.get_power() # Array of relay states
|
||||||
|
tasmota.set_power(idx, state) # Set relay state
|
||||||
|
|
||||||
|
# Lights (use light module)
|
||||||
|
light.get() # Current light status
|
||||||
|
light.set({"power": true, "bri": 128, "hue": 120})
|
||||||
|
|
||||||
|
# Light attributes: power, bri (0-255), hue (0-360), sat (0-255),
|
||||||
|
# ct (153-500), rgb (hex string), channels (array)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Custom Commands
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# Add custom Tasmota commands
|
||||||
|
def my_command(cmd, idx, payload, payload_json)
|
||||||
|
# cmd: command name, idx: command index
|
||||||
|
# payload: raw string, payload_json: parsed JSON
|
||||||
|
tasmota.resp_cmnd_done()
|
||||||
|
end
|
||||||
|
|
||||||
|
tasmota.add_cmd("MyCmd", my_command)
|
||||||
|
tasmota.remove_cmd("MyCmd")
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tasmota Drivers
|
||||||
|
|
||||||
|
Create complete Tasmota drivers by implementing event methods:
|
||||||
|
|
||||||
|
```berry
|
||||||
|
class MyDriver
|
||||||
|
def every_second() # Called every second
|
||||||
|
end
|
||||||
|
|
||||||
|
def every_50ms() # Called every 50ms
|
||||||
|
end
|
||||||
|
|
||||||
|
def web_sensor() # Add to web UI
|
||||||
|
tasmota.web_send("{s}Sensor{m}Value{e}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def json_append() # Add to JSON teleperiod
|
||||||
|
tasmota.response_append(',"MySensor":{"Value":123}')
|
||||||
|
end
|
||||||
|
|
||||||
|
def web_add_main_button() # Add button to main page
|
||||||
|
import webserver
|
||||||
|
webserver.content_send("<button onclick='la(\"&myaction=1\");'>My Button</button>")
|
||||||
|
end
|
||||||
|
|
||||||
|
def button_pressed() # Handle button press
|
||||||
|
end
|
||||||
|
|
||||||
|
def mqtt_data(topic, idx, data, databytes) # Handle MQTT
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_before_restart() # Before restart
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Register driver
|
||||||
|
driver = MyDriver()
|
||||||
|
tasmota.add_driver(driver)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Fast Loop
|
||||||
|
|
||||||
|
For near real-time events (200Hz, 5ms intervals):
|
||||||
|
|
||||||
|
```berry
|
||||||
|
def fast_function()
|
||||||
|
# High-frequency processing
|
||||||
|
end
|
||||||
|
|
||||||
|
tasmota.add_fast_loop(fast_function)
|
||||||
|
tasmota.remove_fast_loop(fast_function)
|
||||||
|
```
|
||||||
|
|
||||||
|
### GPIO Control
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import gpio
|
||||||
|
|
||||||
|
# GPIO detection and control
|
||||||
|
gpio.pin_used(gpio.REL1) # Check if GPIO is used
|
||||||
|
gpio.pin(gpio.REL1) # Get physical GPIO number
|
||||||
|
gpio.digital_write(pin, gpio.HIGH) # Set GPIO state
|
||||||
|
gpio.digital_read(pin) # Read GPIO state
|
||||||
|
gpio.pin_mode(pin, gpio.OUTPUT) # Set GPIO mode
|
||||||
|
|
||||||
|
# PWM control
|
||||||
|
gpio.set_pwm(pin, duty, phase) # Set PWM value
|
||||||
|
gpio.set_pwm_freq(pin, freq) # Set PWM frequency
|
||||||
|
|
||||||
|
# DAC (ESP32 GPIO 25-26, ESP32-S2 GPIO 17-18)
|
||||||
|
gpio.dac_voltage(pin, voltage_mv) # Set DAC voltage
|
||||||
|
|
||||||
|
# Counters
|
||||||
|
gpio.counter_read(counter) # Read counter value
|
||||||
|
gpio.counter_set(counter, value) # Set counter value
|
||||||
|
```
|
||||||
|
|
||||||
|
### I²C Communication
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# Wire objects: wire1, wire2 for I²C buses
|
||||||
|
wire1.bus -> int # Bus number (read-only)
|
||||||
|
wire1.enabled() -> bool # Check if bus initialized
|
||||||
|
wire1.scan() -> list(int) # Scan for device addresses (decimal)
|
||||||
|
wire1.detect(addr:int) -> bool # Check if device present
|
||||||
|
|
||||||
|
# High-level I/O
|
||||||
|
wire1.read(addr:int, reg:int, size:int) -> int|nil # Read 1-4 bytes
|
||||||
|
wire1.write(addr:int, reg:int, val:int, size:int) -> bool # Write 1-4 bytes
|
||||||
|
wire1.read_bytes(addr:int, reg:int, size:int) -> bytes # Read byte sequence
|
||||||
|
wire1.write_bytes(addr:int, reg:int, val:bytes) -> nil # Write byte sequence
|
||||||
|
|
||||||
|
# Low-level control
|
||||||
|
wire1._begin_transmission(addr:int) -> nil
|
||||||
|
wire1._end_transmission([stop:bool]) -> nil
|
||||||
|
wire1._request_from(addr:int, size:int, [stop:bool]) -> nil
|
||||||
|
wire1._available() -> bool
|
||||||
|
wire1._read() -> int # Read single byte
|
||||||
|
wire1._write(val:int|string) -> nil # Write single byte or string
|
||||||
|
|
||||||
|
# Device discovery
|
||||||
|
wire = tasmota.wire_scan(addr:int, i2c_index:int) -> wire_instance|nil
|
||||||
|
```
|
||||||
|
|
||||||
|
### MQTT Integration
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import mqtt
|
||||||
|
|
||||||
|
# MQTT operations
|
||||||
|
mqtt.publish(topic:string, payload:string|bytes, [retain:bool, start:int, len:int]) -> nil
|
||||||
|
mqtt.subscribe(topic:string, [function:closure]) -> nil # Pattern matching, add wildcards manually
|
||||||
|
mqtt.unsubscribe(topic:string) -> nil
|
||||||
|
mqtt.connected() -> bool
|
||||||
|
|
||||||
|
# Callback function signature (topic, idx, payload_s, payload_b) -> bool
|
||||||
|
def mqtt_callback(topic, idx, payload_s, payload_b)
|
||||||
|
# topic: full topic, idx: unused, payload_s: string, payload_b: bytes
|
||||||
|
return true # Return true if handled (prevents Tasmota command)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Web Server Extensions
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import webserver
|
||||||
|
|
||||||
|
# In driver's web_add_handler() method
|
||||||
|
webserver.on("/my_page", def()
|
||||||
|
webserver.content_send("<html>My Page</html>")
|
||||||
|
end)
|
||||||
|
|
||||||
|
# Request handling
|
||||||
|
webserver.has_arg("param") # Check parameter exists
|
||||||
|
webserver.arg("param") # Get parameter value
|
||||||
|
webserver.arg_size() # Number of parameters
|
||||||
|
|
||||||
|
# Response functions
|
||||||
|
webserver.content_send(html) # Send HTML content
|
||||||
|
webserver.content_button() # Standard button
|
||||||
|
webserver.html_escape(str) # Escape HTML
|
||||||
|
```
|
||||||
|
|
||||||
|
### Persistence
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import persist
|
||||||
|
|
||||||
|
# Automatic persistence to _persist.json
|
||||||
|
persist.my_value = 123
|
||||||
|
persist.save() # Force save to flash
|
||||||
|
persist.has("key") # Check if key exists
|
||||||
|
persist.remove("key") # Remove key
|
||||||
|
persist.find("key", default) # Get with default
|
||||||
|
```
|
||||||
|
|
||||||
|
### Network Clients
|
||||||
|
|
||||||
|
#### HTTP/HTTPS Client
|
||||||
|
|
||||||
|
```berry
|
||||||
|
cl = webclient()
|
||||||
|
cl.begin("https://example.com/api")
|
||||||
|
cl.set_auth("user", "pass")
|
||||||
|
cl.add_header("Content-Type", "application/json")
|
||||||
|
|
||||||
|
result = cl.GET() # or POST(payload)
|
||||||
|
if result == 200
|
||||||
|
response = cl.get_string()
|
||||||
|
# or cl.write_file("filename") for binary
|
||||||
|
end
|
||||||
|
cl.close()
|
||||||
|
```
|
||||||
|
|
||||||
|
#### TCP Client
|
||||||
|
|
||||||
|
```berry
|
||||||
|
tcp = tcpclient()
|
||||||
|
tcp.connect("192.168.1.100", 80)
|
||||||
|
tcp.write("GET / HTTP/1.0\r\n\r\n")
|
||||||
|
response = tcp.read()
|
||||||
|
tcp.close()
|
||||||
|
```
|
||||||
|
|
||||||
|
#### UDP Communication
|
||||||
|
|
||||||
|
```berry
|
||||||
|
u = udp()
|
||||||
|
u.begin("", 2000) # Listen on port 2000
|
||||||
|
u.send("192.168.1.10", 2000, bytes("Hello"))
|
||||||
|
|
||||||
|
# Receive (polling)
|
||||||
|
packet = u.read() # Returns bytes or nil
|
||||||
|
if packet
|
||||||
|
print("From:", u.remote_ip, u.remote_port)
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Serial Communication
|
||||||
|
|
||||||
|
```berry
|
||||||
|
ser = serial(rx_gpio, tx_gpio, baud, serial.SERIAL_8N1)
|
||||||
|
ser.write(bytes("Hello")) # Send data
|
||||||
|
data = ser.read() # Read available data
|
||||||
|
ser.available() # Check bytes available
|
||||||
|
ser.flush() # Flush buffers
|
||||||
|
ser.close() # Close port
|
||||||
|
```
|
||||||
|
|
||||||
|
### Cryptography
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import crypto
|
||||||
|
|
||||||
|
# AES Encryption Classes
|
||||||
|
crypto.AES_CTR(key:bytes(32)).encrypt(data:bytes, iv:bytes(12), cc:int) -> bytes
|
||||||
|
crypto.AES_CTR(key:bytes(32)).decrypt(data:bytes, iv:bytes(12), cc:int) -> bytes
|
||||||
|
|
||||||
|
crypto.AES_GCM(key:bytes(32), iv:bytes(12)).encrypt(data:bytes) -> bytes
|
||||||
|
crypto.AES_GCM(key:bytes(32), iv:bytes(12)).decrypt(data:bytes) -> bytes
|
||||||
|
crypto.AES_GCM(key:bytes(32), iv:bytes(12)).tag() -> bytes(16)
|
||||||
|
|
||||||
|
crypto.AES_CCM(key:bytes(16|32), iv:bytes(7..13), aad:bytes, data_len:int, tag_len:int)
|
||||||
|
crypto.AES_CCM.encrypt1/decrypt1(...) -> bool # Single-call variants
|
||||||
|
|
||||||
|
crypto.AES_CBC.encrypt1(key:bytes(16), iv:bytes(16), data:bytes) -> bool
|
||||||
|
crypto.AES_CBC.decrypt1(key:bytes(16), iv:bytes(16), data:bytes) -> bool
|
||||||
|
|
||||||
|
# Elliptic Curve (requires defines)
|
||||||
|
crypto.EC_C25519().public_key(priv:bytes(32)) -> bytes(32)
|
||||||
|
crypto.EC_C25519().shared_key(our_priv:bytes(32), their_pub:bytes(32)) -> bytes(32)
|
||||||
|
|
||||||
|
crypto.EC_P256().public_key(priv:bytes(32)) -> bytes(65)
|
||||||
|
crypto.EC_P256().shared_key(our_priv:bytes(32), their_pub:bytes(65)) -> bytes(32)
|
||||||
|
crypto.EC_P256().mod/neg/mul/muladd(...) -> bytes # Math operations
|
||||||
|
|
||||||
|
# Key Derivation
|
||||||
|
crypto.HKDF_SHA256().derive(ikm:bytes, salt:bytes, info:bytes, out_len:int) -> bytes
|
||||||
|
crypto.PBKDF2_HMAC_SHA256().derive(pwd:bytes, salt:bytes, iter:int, out_len:int) -> bytes
|
||||||
|
|
||||||
|
# Hashing
|
||||||
|
crypto.SHA256().update(data:bytes).out() -> bytes(32)
|
||||||
|
crypto.MD5().update(data:bytes).finish() -> bytes(16)
|
||||||
|
crypto.HMAC_SHA256(key:bytes).update(data:bytes).out() -> bytes(32)
|
||||||
|
|
||||||
|
# RSA (requires define)
|
||||||
|
crypto.RSA.rs256(private_key_der:bytes, payload:bytes) -> bytes # JWT signing
|
||||||
|
```
|
||||||
|
|
||||||
|
### File System Operations
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import path
|
||||||
|
|
||||||
|
# File/directory operations (SD card: /sd/ subdirectory)
|
||||||
|
path.exists(file:string) -> bool # Check file exists
|
||||||
|
path.isdir(name:string) -> bool # Check if directory
|
||||||
|
path.listdir(dir:string) -> list # List directory contents
|
||||||
|
path.mkdir(dir:string) -> bool # Create directory
|
||||||
|
path.rmdir(dir:string) -> bool # Remove empty directory
|
||||||
|
path.remove(file:string) -> bool # Delete file
|
||||||
|
path.rename(old:string, new:string) -> bool # Rename file/folder
|
||||||
|
path.last_modified(file:string) -> int # File timestamp (nil if not exists)
|
||||||
|
path.format(true) -> bool # Format LittleFS (erases all!)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Regular Expressions
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import re
|
||||||
|
|
||||||
|
# Pattern matching
|
||||||
|
matches = re.search("a.*?b(z+)", "aaaabbbzzz") # Returns matches array
|
||||||
|
all_matches = re.searchall('<([a-zA-Z]+)>', html) # All matches
|
||||||
|
parts = re.split('/', "path/to/file") # Split string
|
||||||
|
|
||||||
|
# Compiled patterns (faster for reuse)
|
||||||
|
pattern = re.compilebytes("\\d+")
|
||||||
|
matches = re.search(pattern, "abc123def")
|
||||||
|
```
|
||||||
|
|
||||||
|
### Energy Monitoring
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# Read energy values
|
||||||
|
energy.voltage # Main phase voltage
|
||||||
|
energy.current # Main phase current
|
||||||
|
energy.active_power # Active power (W)
|
||||||
|
energy.total # Total energy (kWh)
|
||||||
|
|
||||||
|
# Multi-phase access
|
||||||
|
energy.voltage_phases[0] # Phase 0 voltage
|
||||||
|
energy.current_phases[1] # Phase 1 current
|
||||||
|
|
||||||
|
# Berry energy driver (with OPTION_A 9 GPIO)
|
||||||
|
if energy.driver_enabled()
|
||||||
|
energy.voltage = 240
|
||||||
|
energy.current = 1.5
|
||||||
|
energy.active_power = 360 # This drives energy calculation
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Display Integration
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import display
|
||||||
|
|
||||||
|
# Initialize display driver
|
||||||
|
display.start(display_ini_string)
|
||||||
|
display.started() # Check if initialized
|
||||||
|
display.dimmer(50) # Set brightness 0-100
|
||||||
|
display.driver_name() # Get driver name
|
||||||
|
|
||||||
|
# Touch screen updates
|
||||||
|
display.touch_update(touches, x, y, gesture)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Advanced Features
|
||||||
|
|
||||||
|
#### ULP (Ultra Low Power) Coprocessor
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import ULP
|
||||||
|
|
||||||
|
ULP.wake_period(0, 500000) # Configure wake timer
|
||||||
|
ULP.load(bytecode) # Load ULP program
|
||||||
|
ULP.run() # Execute ULP program
|
||||||
|
ULP.set_mem(addr, value) # Set RTC memory
|
||||||
|
ULP.get_mem(addr) # Get RTC memory
|
||||||
|
```
|
||||||
|
|
||||||
|
#### mDNS Support
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import mdns
|
||||||
|
|
||||||
|
mdns.start("hostname") # Start mDNS
|
||||||
|
mdns.add_service("_http", "_tcp", 80, {"path": "/"})
|
||||||
|
mdns.stop() # Stop mDNS
|
||||||
|
```
|
||||||
|
|
||||||
|
### Error Handling Patterns
|
||||||
|
|
||||||
|
Many Tasmota functions return `nil` for errors rather than raising exceptions:
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# Check return values
|
||||||
|
data = json.load(json_string)
|
||||||
|
if data == nil
|
||||||
|
print("Invalid JSON")
|
||||||
|
end
|
||||||
|
|
||||||
|
# Wire operations
|
||||||
|
result = wire1.read(addr, reg, 1)
|
||||||
|
if result == nil
|
||||||
|
print("I2C read failed")
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
### Best Practices for Tasmota
|
||||||
|
|
||||||
|
1. **Memory Management**: Use `tasmota.gc()` to monitor memory usage
|
||||||
|
2. **Non-blocking**: Use timers instead of `delay()` for long waits
|
||||||
|
3. **Error Handling**: Always check return values for `nil`
|
||||||
|
4. **Persistence**: Use `persist` module for settings that survive reboots
|
||||||
|
5. **Performance**: Use fast_loop sparingly, prefer regular driver events
|
||||||
|
6. **Debugging**: Enable `#define USE_BERRY_DEBUG` for development
|
||||||
|
|
||||||
|
## Common Tasmota Berry Patterns
|
||||||
|
|
||||||
|
### Simple Sensor Driver
|
||||||
|
|
||||||
|
```berry
|
||||||
|
class MySensor
|
||||||
|
var wire, addr
|
||||||
|
|
||||||
|
def init()
|
||||||
|
self.addr = 0x48
|
||||||
|
self.wire = tasmota.wire_scan(self.addr, 99) # I2C index 99
|
||||||
|
if self.wire
|
||||||
|
print("MySensor found on bus", self.wire.bus)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def every_second()
|
||||||
|
if !self.wire return end
|
||||||
|
var temp = self.wire.read(self.addr, 0x00, 2) # Read temperature
|
||||||
|
self.temperature = temp / 256.0 # Convert to Celsius
|
||||||
|
end
|
||||||
|
|
||||||
|
def web_sensor()
|
||||||
|
if !self.wire return end
|
||||||
|
import string
|
||||||
|
var msg = string.format("{s}MySensor Temp{m}%.1f °C{e}", self.temperature)
|
||||||
|
tasmota.web_send_decimal(msg)
|
||||||
|
end
|
||||||
|
|
||||||
|
def json_append()
|
||||||
|
if !self.wire return end
|
||||||
|
import string
|
||||||
|
var msg = string.format(',"MySensor":{"Temperature":%.1f}', self.temperature)
|
||||||
|
tasmota.response_append(msg)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
sensor = MySensor()
|
||||||
|
tasmota.add_driver(sensor)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom Command with JSON Response
|
||||||
|
|
||||||
|
```berry
|
||||||
|
def my_status_cmd(cmd, idx, payload, payload_json)
|
||||||
|
import string
|
||||||
|
var response = {
|
||||||
|
"Uptime": tasmota.millis(),
|
||||||
|
"FreeHeap": tasmota.get_free_heap(),
|
||||||
|
"WiFi": tasmota.wifi("rssi")
|
||||||
|
}
|
||||||
|
tasmota.resp_cmnd(json.dump(response))
|
||||||
|
end
|
||||||
|
|
||||||
|
tasmota.add_cmd("MyStatus", my_status_cmd)
|
||||||
|
```
|
||||||
|
|
||||||
|
### MQTT Automation
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import mqtt
|
||||||
|
|
||||||
|
def handle_sensor_data(topic, idx, payload_s, payload_b)
|
||||||
|
var data = json.load(payload_s)
|
||||||
|
if data && data.find("temperature")
|
||||||
|
var temp = data["temperature"]
|
||||||
|
if temp > 25
|
||||||
|
tasmota.cmd("Power1 ON") # Turn on fan
|
||||||
|
elif temp < 20
|
||||||
|
tasmota.cmd("Power1 OFF") # Turn off fan
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
mqtt.subscribe("sensors/+/temperature", handle_sensor_data)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Web UI Button with Action
|
||||||
|
|
||||||
|
```berry
|
||||||
|
class WebButton
|
||||||
|
def web_add_main_button()
|
||||||
|
import webserver
|
||||||
|
webserver.content_send("<p><button onclick='la(\"&toggle_led=1\");'>Toggle LED</button></p>")
|
||||||
|
end
|
||||||
|
|
||||||
|
def web_sensor()
|
||||||
|
import webserver
|
||||||
|
if webserver.has_arg("toggle_led")
|
||||||
|
# Toggle GPIO2 (built-in LED on many ESP32 boards)
|
||||||
|
var pin = 2
|
||||||
|
var current = gpio.digital_read(pin)
|
||||||
|
gpio.digital_write(pin, !current)
|
||||||
|
print("LED toggled to", !current)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
button = WebButton()
|
||||||
|
tasmota.add_driver(button)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Scheduled Task with Persistence
|
||||||
|
|
||||||
|
```berry
|
||||||
|
import persist
|
||||||
|
|
||||||
|
class ScheduledTask
|
||||||
|
def init()
|
||||||
|
if !persist.has("task_count")
|
||||||
|
persist.task_count = 0
|
||||||
|
end
|
||||||
|
# Run every 5 minutes
|
||||||
|
tasmota.add_cron("0 */5 * * * *", /-> self.run_task(), "my_task")
|
||||||
|
end
|
||||||
|
|
||||||
|
def run_task()
|
||||||
|
persist.task_count += 1
|
||||||
|
print("Task executed", persist.task_count, "times")
|
||||||
|
|
||||||
|
# Do something useful
|
||||||
|
var sensors = tasmota.read_sensors()
|
||||||
|
print("Current sensors:", sensors)
|
||||||
|
|
||||||
|
persist.save() # Save counter to flash
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
task = ScheduledTask()
|
||||||
|
```
|
||||||
|
|
||||||
|
### HTTP API Client
|
||||||
|
|
||||||
|
```berry
|
||||||
|
class WeatherAPI
|
||||||
|
var api_key, city
|
||||||
|
|
||||||
|
def init(key, city_name)
|
||||||
|
self.api_key = key
|
||||||
|
self.city = city_name
|
||||||
|
tasmota.add_cron("0 0 * * * *", /-> self.fetch_weather(), "weather")
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_weather()
|
||||||
|
var cl = webclient()
|
||||||
|
var url = f"http://api.openweathermap.org/data/2.5/weather?q={self.city}&appid={self.api_key}"
|
||||||
|
|
||||||
|
cl.begin(url)
|
||||||
|
var result = cl.GET()
|
||||||
|
|
||||||
|
if result == 200
|
||||||
|
var response = cl.get_string()
|
||||||
|
var data = json.load(response)
|
||||||
|
if data
|
||||||
|
var temp = data["main"]["temp"] - 273.15 # Kelvin to Celsius
|
||||||
|
print(f"Weather in {self.city}: {temp:.1f}°C")
|
||||||
|
|
||||||
|
# Store in global for other scripts to use
|
||||||
|
import global
|
||||||
|
global.weather_temp = temp
|
||||||
|
end
|
||||||
|
end
|
||||||
|
cl.close()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# weather = WeatherAPI("your_api_key", "London")
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rule-based Automation
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# Advanced rule that combines multiple conditions
|
||||||
|
tasmota.add_rule(["ANALOG#A0>500", "Switch1#State=1"],
|
||||||
|
def(values, triggers)
|
||||||
|
print("Both conditions met:")
|
||||||
|
print("ADC value:", values[0])
|
||||||
|
print("Switch state:", values[1])
|
||||||
|
tasmota.cmd("Power2 ON") # Activate something
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
# Time-based rule
|
||||||
|
tasmota.add_rule("Time#Minute=30",
|
||||||
|
def()
|
||||||
|
if tasmota.rtc()["hour"] == 18 # 6:30 PM
|
||||||
|
tasmota.cmd("Dimmer 20") # Dim lights for evening
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Best Practices and Tips
|
||||||
|
|
||||||
|
1. **Always check for nil returns** from Tasmota functions
|
||||||
|
2. **Use timers instead of delay()** to avoid blocking Tasmota
|
||||||
|
3. **Implement proper error handling** in I²C and network operations
|
||||||
|
4. **Use persist module** for settings that should survive reboots
|
||||||
|
5. **Test memory usage** with `tasmota.gc()` during development
|
||||||
|
6. **Use fast_loop sparingly** - it runs 200 times per second
|
||||||
|
7. **Prefer driver events** over polling when possible
|
||||||
|
8. **Use f-strings** for readable string formatting
|
||||||
|
9. **Import modules only when needed** to save memory
|
||||||
|
10. **Use `tasmota.wire_scan()`** instead of manual I²C bus detection
|
||||||
175
.doc_for_ai/DOC_DEEP_ANALYSIS.md
Normal file
175
.doc_for_ai/DOC_DEEP_ANALYSIS.md
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
# Deep Analysis of Tasmota Documentation Repository
|
||||||
|
|
||||||
|
This file is a summary of the Tasmota Documentation for the "docs" repository. It is provided here for convenience for GenAI to read it easily.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Tasmota is a comprehensive open-source firmware for ESP8266/ESP8285 and ESP32-based IoT devices that provides local control, MQTT integration, and extensive customization capabilities. The documentation repository contains over 250 markdown files covering every aspect of the firmware, from basic installation to advanced development topics.
|
||||||
|
|
||||||
|
## Repository Structure
|
||||||
|
|
||||||
|
The documentation is organized into several key categories:
|
||||||
|
|
||||||
|
### Core Documentation
|
||||||
|
- **Getting Started**: Complete setup guide from hardware preparation to initial configuration
|
||||||
|
- **Commands**: Comprehensive reference of 200+ commands for device control
|
||||||
|
- **MQTT**: Central communication protocol documentation
|
||||||
|
- **Rules**: Flexible automation system documentation
|
||||||
|
- **Templates**: Device configuration system
|
||||||
|
- **Components**: GPIO mapping and peripheral management
|
||||||
|
|
||||||
|
### Hardware Support
|
||||||
|
- **ESP Platforms**: ESP8266, ESP8285, ESP32 (all variants including S2, S3, C3)
|
||||||
|
- **Supported Devices**: 125+ device-specific configuration files
|
||||||
|
- **Peripherals**: 85+ sensor and peripheral drivers documented
|
||||||
|
- **Pinouts**: Detailed GPIO mappings for common modules
|
||||||
|
|
||||||
|
### Advanced Features
|
||||||
|
- **Berry Scripting**: Modern scripting language for ESP32 (163KB documentation)
|
||||||
|
- **Scripting Language**: Legacy scripting for ESP8266 (93KB documentation)
|
||||||
|
- **Matter Protocol**: Thread/Matter support for modern IoT ecosystems
|
||||||
|
- **Zigbee**: Zigbee2Tasmota gateway functionality (100KB documentation)
|
||||||
|
- **Bluetooth**: BLE sensor integration and device control
|
||||||
|
|
||||||
|
### Integration Ecosystem
|
||||||
|
- **Home Assistant**: Native integration with autodiscovery
|
||||||
|
- **OpenHAB**: Configuration examples and best practices
|
||||||
|
- **Domoticz**: Integration guide
|
||||||
|
- **KNX**: Building automation protocol support
|
||||||
|
- **AWS IoT**: Cloud integration with certificates
|
||||||
|
- **Azure IoT**: Microsoft cloud platform integration
|
||||||
|
|
||||||
|
## Key Technical Insights
|
||||||
|
|
||||||
|
### Architecture Philosophy
|
||||||
|
Tasmota follows a modular architecture where:
|
||||||
|
- Core firmware provides basic functionality (WiFi, MQTT, web interface)
|
||||||
|
- Features are conditionally compiled based on `#define` directives
|
||||||
|
- GPIO mapping is completely flexible through templates
|
||||||
|
- All functionality is controllable via commands (MQTT, HTTP, serial, web console)
|
||||||
|
|
||||||
|
### Memory Management
|
||||||
|
- ESP8266: 80KB RAM total, ~25-30KB available for applications
|
||||||
|
- ESP32: Much more generous memory, supports advanced features
|
||||||
|
- Code size optimization is critical for ESP8266 OTA updates
|
||||||
|
- Flash memory partitioned for dual-boot OTA capability
|
||||||
|
|
||||||
|
### Communication Protocols
|
||||||
|
1. **MQTT** (Primary): All device control and telemetry
|
||||||
|
2. **HTTP**: Web interface and REST API
|
||||||
|
3. **Serial**: Direct console access
|
||||||
|
4. **WebSocket**: Real-time web interface updates
|
||||||
|
|
||||||
|
### Extensibility Mechanisms
|
||||||
|
1. **Rules**: Event-driven automation (up to 1536 characters)
|
||||||
|
2. **Berry Scripts**: Full programming language (ESP32 only)
|
||||||
|
3. **Scripting**: Legacy scripting system (ESP8266)
|
||||||
|
4. **Templates**: Device configuration sharing
|
||||||
|
5. **Custom Drivers**: C++ sensor/peripheral drivers
|
||||||
|
|
||||||
|
## Development Ecosystem
|
||||||
|
|
||||||
|
### Build System
|
||||||
|
- PlatformIO-based compilation
|
||||||
|
- Multiple build environments for different ESP variants
|
||||||
|
- Conditional compilation for feature selection
|
||||||
|
- OTA update system with safety mechanisms
|
||||||
|
|
||||||
|
### Driver Development
|
||||||
|
- Standardized sensor API with callback system
|
||||||
|
- I2C/SPI/UART peripheral support
|
||||||
|
- Memory-conscious development practices
|
||||||
|
- Extensive debugging and profiling tools
|
||||||
|
|
||||||
|
### Scripting Capabilities
|
||||||
|
- **Berry**: Modern language with object-oriented features, garbage collection
|
||||||
|
- **Rules**: Simple trigger-action automation
|
||||||
|
- **Legacy Scripting**: Procedural language for complex automation
|
||||||
|
|
||||||
|
### Integration APIs
|
||||||
|
- **JSON Status Responses**: Standardized telemetry format
|
||||||
|
- **Command Interface**: Unified control mechanism
|
||||||
|
- **Sensor API**: Standardized peripheral integration
|
||||||
|
- **Web Interface Extensions**: Custom UI components
|
||||||
|
|
||||||
|
## Notable Features
|
||||||
|
|
||||||
|
### Advanced Networking
|
||||||
|
- IPv6 support
|
||||||
|
- Wireguard VPN client
|
||||||
|
- Range extender functionality (NAPT)
|
||||||
|
- Multiple WiFi network support
|
||||||
|
- Ethernet support (ESP32)
|
||||||
|
|
||||||
|
### Security Features
|
||||||
|
- TLS/SSL support (ESP32)
|
||||||
|
- Certificate-based authentication
|
||||||
|
- Secure boot options
|
||||||
|
- Network isolation capabilities
|
||||||
|
|
||||||
|
### Display and UI
|
||||||
|
- Universal Display Driver supporting 50+ display types
|
||||||
|
- LVGL graphics library integration
|
||||||
|
- HASPmota: Advanced touch interface system
|
||||||
|
- Web interface customization
|
||||||
|
|
||||||
|
### Industrial Features
|
||||||
|
- Modbus bridge functionality
|
||||||
|
- KNX building automation
|
||||||
|
- Smart meter interfaces (P1, Teleinfo)
|
||||||
|
- Industrial sensor support (4-20mA, etc.)
|
||||||
|
|
||||||
|
## Documentation Quality Assessment
|
||||||
|
|
||||||
|
### Strengths
|
||||||
|
- **Comprehensive Coverage**: Every feature documented with examples
|
||||||
|
- **Practical Focus**: Heavy emphasis on real-world usage scenarios
|
||||||
|
- **Community-Driven**: Active contribution from users and developers
|
||||||
|
- **Multi-Level**: From beginner tutorials to advanced development guides
|
||||||
|
- **Well-Structured**: Logical organization with cross-references
|
||||||
|
|
||||||
|
### Areas for Improvement
|
||||||
|
- **Fragmentation**: Some information scattered across multiple files
|
||||||
|
- **Version Consistency**: Some docs may lag behind rapid development
|
||||||
|
- **Advanced Topics**: Some complex features could use more examples
|
||||||
|
|
||||||
|
## Community and Ecosystem
|
||||||
|
|
||||||
|
### Support Channels
|
||||||
|
- Discord server for real-time help
|
||||||
|
- GitHub discussions for feature requests
|
||||||
|
- Telegram and Matrix communities
|
||||||
|
- Reddit community
|
||||||
|
|
||||||
|
### Device Database
|
||||||
|
- Templates repository with 1000+ device configurations
|
||||||
|
- Community-contributed device support
|
||||||
|
- Standardized template sharing format
|
||||||
|
|
||||||
|
### Integration Ecosystem
|
||||||
|
- Native Home Assistant integration
|
||||||
|
- Multiple home automation platform support
|
||||||
|
- Cloud service integrations (AWS, Azure)
|
||||||
|
- Third-party tool ecosystem
|
||||||
|
|
||||||
|
## Development Trends
|
||||||
|
|
||||||
|
### Modern Features
|
||||||
|
- Matter protocol support for interoperability
|
||||||
|
- Berry scripting for advanced automation
|
||||||
|
- LVGL for rich user interfaces
|
||||||
|
- Machine learning integration (TensorFlow Lite)
|
||||||
|
|
||||||
|
### Hardware Evolution
|
||||||
|
- ESP32 as primary platform for new features
|
||||||
|
- ESP8266 maintained for compatibility
|
||||||
|
- Support for latest ESP32 variants (S2, S3, C3)
|
||||||
|
- Increasing focus on low-power applications
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
The Tasmota documentation represents one of the most comprehensive firmware documentation projects in the IoT space. It successfully bridges the gap between simple device control and advanced IoT development, providing pathways for users to grow from basic usage to sophisticated automation and custom development.
|
||||||
|
|
||||||
|
The documentation's strength lies in its practical approach, extensive hardware support coverage, and community-driven nature. It serves as both a user manual and a development reference, making Tasmota accessible to a wide range of users while providing the depth needed for serious IoT development.
|
||||||
|
|
||||||
|
The modular architecture, extensive command system, and multiple scripting options make Tasmota a powerful platform for IoT development, with documentation that adequately supports this complexity while remaining approachable for newcomers.
|
||||||
977
.doc_for_ai/FOR_DEVELOPERS.md
Normal file
977
.doc_for_ai/FOR_DEVELOPERS.md
Normal file
@ -0,0 +1,977 @@
|
|||||||
|
# Tasmota Developer Guide
|
||||||
|
|
||||||
|
This file is a summary of the Tasmota Documentation for the "docs" repository. It is provided here for convenience for GenAI to read it easily.
|
||||||
|
|
||||||
|
## How Tasmota Works
|
||||||
|
|
||||||
|
### Core Architecture
|
||||||
|
|
||||||
|
Tasmota is a modular firmware that transforms ESP8266/ESP8285 and ESP32 microcontrollers into intelligent IoT devices. The architecture follows these key principles:
|
||||||
|
|
||||||
|
#### 1. Event-Driven System
|
||||||
|
- Main loop processes events and callbacks
|
||||||
|
- Non-blocking operations to maintain responsiveness
|
||||||
|
- Callback system for sensors, drivers, and features
|
||||||
|
- Timer-based scheduling for periodic tasks
|
||||||
|
|
||||||
|
#### 2. Modular Design
|
||||||
|
- Core functionality always present (WiFi, MQTT, web interface)
|
||||||
|
- Optional features compiled conditionally using `#define` directives
|
||||||
|
- Plugin architecture for sensors and peripherals
|
||||||
|
- Template system for device configuration
|
||||||
|
|
||||||
|
#### 3. Communication Hub
|
||||||
|
- **MQTT**: Primary communication protocol for automation systems
|
||||||
|
- **HTTP**: Web interface and REST API
|
||||||
|
- **Serial**: Direct console access for debugging and configuration
|
||||||
|
- **WebSocket**: Real-time web interface updates
|
||||||
|
|
||||||
|
### Firmware Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
tasmota/
|
||||||
|
├── tasmota.ino # Main firmware file
|
||||||
|
├── tasmota_xdrv_driver/ # Driver files directory (187 files)
|
||||||
|
│ ├── xdrv_01_9_webserver.ino # Web server driver
|
||||||
|
│ ├── xdrv_02_9_mqtt.ino # MQTT driver
|
||||||
|
│ ├── xdrv_04_light.ino # Light driver
|
||||||
|
│ └── xdrv_##_name.ino # Other drivers
|
||||||
|
├── tasmota_xsns_sensor/ # Sensor files directory (143 files)
|
||||||
|
│ ├── xsns_01_counter.ino # Counter sensor
|
||||||
|
│ ├── xsns_02_analog.ino # Analog sensor
|
||||||
|
│ └── xsns_##_name.ino # Other sensors
|
||||||
|
├── tasmota_xlgt_light/ # Light driver files directory
|
||||||
|
├── tasmota_xnrg_energy/ # Energy monitoring files directory
|
||||||
|
├── tasmota_support/ # Support functions directory (29 files)
|
||||||
|
│ ├── support.ino # Core support functions
|
||||||
|
│ ├── settings.ino # Settings management
|
||||||
|
│ └── support_*.ino # Other support modules
|
||||||
|
├── include/ # Header files directory (18 files)
|
||||||
|
│ ├── tasmota.h # Main header
|
||||||
|
│ ├── tasmota_types.h # Type definitions
|
||||||
|
│ ├── tasmota_globals.h # Global variables
|
||||||
|
│ └── *.h # Other headers
|
||||||
|
└── my_user_config.h # User configuration overrides
|
||||||
|
```
|
||||||
|
|
||||||
|
### Command System
|
||||||
|
|
||||||
|
All Tasmota functionality is accessible through a unified command system:
|
||||||
|
|
||||||
|
- Commands can be sent via MQTT, HTTP, serial, or web console
|
||||||
|
- Format: `Command [parameter]`
|
||||||
|
- Response format: JSON for structured data
|
||||||
|
- Backlog support for multiple commands: `Backlog cmd1; cmd2; cmd3`
|
||||||
|
|
||||||
|
### GPIO Management
|
||||||
|
|
||||||
|
Tasmota uses a flexible GPIO assignment system:
|
||||||
|
|
||||||
|
1. **Templates**: Pre-defined GPIO configurations for specific devices
|
||||||
|
2. **Components**: Logical functions assigned to physical pins
|
||||||
|
3. **Modules**: Base hardware configurations
|
||||||
|
4. **Runtime Configuration**: GPIO can be reassigned without recompilation
|
||||||
|
|
||||||
|
## Development Environment Setup
|
||||||
|
|
||||||
|
### Prerequisites
|
||||||
|
|
||||||
|
1. **PlatformIO**: Primary build system
|
||||||
|
2. **Git**: Version control
|
||||||
|
3. **Python**: For build scripts and tools
|
||||||
|
4. **Serial Programmer**: For initial flashing
|
||||||
|
|
||||||
|
### Build Configuration
|
||||||
|
|
||||||
|
Create `platformio_tasmota_cenv.ini` for custom environments:
|
||||||
|
|
||||||
|
```ini
|
||||||
|
[env:tasmota32-custom]
|
||||||
|
extends = env:tasmota32
|
||||||
|
build_flags = ${env:tasmota32.build_flags}
|
||||||
|
-DUSE_MY_CUSTOM_FEATURE
|
||||||
|
```
|
||||||
|
|
||||||
|
### User Configuration
|
||||||
|
|
||||||
|
Create `tasmota/user_config_override.h`:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#ifndef _USER_CONFIG_OVERRIDE_H_
|
||||||
|
#define _USER_CONFIG_OVERRIDE_H_
|
||||||
|
|
||||||
|
// Enable custom features
|
||||||
|
#define USE_CUSTOM_SENSOR
|
||||||
|
#define USE_BERRY_DEBUG
|
||||||
|
|
||||||
|
// Disable unused features to save space
|
||||||
|
#undef USE_DOMOTICZ
|
||||||
|
#undef USE_KNX
|
||||||
|
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
|
## Driver Development
|
||||||
|
|
||||||
|
### Sensor Driver Structure
|
||||||
|
|
||||||
|
All sensor drivers follow a standardized pattern:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#ifdef USE_MY_SENSOR
|
||||||
|
#define XSNS_XX XX // Unique sensor ID
|
||||||
|
|
||||||
|
bool MySensorDetected = false;
|
||||||
|
|
||||||
|
void MySensorInit(void) {
|
||||||
|
// Initialize sensor
|
||||||
|
if (sensor_detected) {
|
||||||
|
MySensorDetected = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySensorEverySecond(void) {
|
||||||
|
// Read sensor data
|
||||||
|
}
|
||||||
|
|
||||||
|
void MySensorShow(bool json) {
|
||||||
|
if (json) {
|
||||||
|
ResponseAppend_P(PSTR(",\"MySensor\":{\"Temperature\":%d}"), temperature);
|
||||||
|
}
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
else {
|
||||||
|
WSContentSend_PD(HTTP_SNS_TEMP, "MySensor", temperature);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Xsns_XX(byte function) {
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
if (i2c_flg) { // Only for I2C sensors
|
||||||
|
switch (function) {
|
||||||
|
case FUNC_INIT:
|
||||||
|
MySensorInit();
|
||||||
|
break;
|
||||||
|
case FUNC_EVERY_SECOND:
|
||||||
|
MySensorEverySecond();
|
||||||
|
break;
|
||||||
|
case FUNC_JSON_APPEND:
|
||||||
|
MySensorShow(1);
|
||||||
|
break;
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
case FUNC_WEB_SENSOR:
|
||||||
|
MySensorShow(0);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif // USE_MY_SENSOR
|
||||||
|
```
|
||||||
|
|
||||||
|
### Complete Driver Callback Functions Reference
|
||||||
|
|
||||||
|
**VERIFIED FROM SOURCE CODE**: `tasmota/include/tasmota.h` lines 433-454
|
||||||
|
|
||||||
|
#### Core System Callbacks (Functions WITHOUT return results)
|
||||||
|
|
||||||
|
| Function | Purpose | When Called | Parameters |
|
||||||
|
|----------|---------|-------------|-----------|
|
||||||
|
| `FUNC_SETTINGS_OVERRIDE` | Override default settings | Before settings load | None |
|
||||||
|
| `FUNC_SETUP_RING1` | Early setup phase 1 | System initialization | None |
|
||||||
|
| `FUNC_SETUP_RING2` | Early setup phase 2 | System initialization | None |
|
||||||
|
| `FUNC_PRE_INIT` | Pre-initialization | Before main init | None |
|
||||||
|
| `FUNC_INIT` | Initialize driver/sensor | Once at startup | None |
|
||||||
|
| `FUNC_ACTIVE` | Check if driver is active | Status queries | None |
|
||||||
|
| `FUNC_ABOUT_TO_RESTART` | Prepare for restart | Before system restart | None |
|
||||||
|
|
||||||
|
#### Loop and Timing Callbacks
|
||||||
|
|
||||||
|
| Function | Purpose | Frequency | Parameters |
|
||||||
|
|----------|---------|-----------|-----------|
|
||||||
|
| `FUNC_LOOP` | Main loop processing | Every loop cycle (~1ms) | None |
|
||||||
|
| `FUNC_SLEEP_LOOP` | Sleep mode processing | During sleep cycles | None |
|
||||||
|
| `FUNC_EVERY_50_MSECOND` | Fast polling operations | Every 50ms | None |
|
||||||
|
| `FUNC_EVERY_100_MSECOND` | Medium polling | Every 100ms | None |
|
||||||
|
| `FUNC_EVERY_200_MSECOND` | Slower polling | Every 200ms | None |
|
||||||
|
| `FUNC_EVERY_250_MSECOND` | Quarter second tasks | Every 250ms | None |
|
||||||
|
| `FUNC_EVERY_SECOND` | Regular updates | Every second | None |
|
||||||
|
|
||||||
|
#### Settings and Configuration Callbacks
|
||||||
|
|
||||||
|
| Function | Purpose | When Called | Parameters |
|
||||||
|
|----------|---------|-------------|-----------|
|
||||||
|
| `FUNC_RESET_SETTINGS` | Reset to defaults | Settings reset | None |
|
||||||
|
| `FUNC_RESTORE_SETTINGS` | Restore from backup | Settings restore | None |
|
||||||
|
| `FUNC_SAVE_SETTINGS` | Save current settings | Settings save | None |
|
||||||
|
| `FUNC_SAVE_AT_MIDNIGHT` | Midnight save operations | Daily at 00:00 | None |
|
||||||
|
| `FUNC_SAVE_BEFORE_RESTART` | Save critical data | Before restart | None |
|
||||||
|
|
||||||
|
#### Interrupt and System Control
|
||||||
|
|
||||||
|
| Function | Purpose | When Called | Parameters |
|
||||||
|
|----------|---------|-------------|-----------|
|
||||||
|
| `FUNC_INTERRUPT_STOP` | Stop interrupts | Before critical section | None |
|
||||||
|
| `FUNC_INTERRUPT_START` | Resume interrupts | After critical section | None |
|
||||||
|
| `FUNC_FREE_MEM` | Memory cleanup | Low memory conditions | None |
|
||||||
|
|
||||||
|
#### Telemetry and JSON Callbacks
|
||||||
|
|
||||||
|
| Function | Purpose | When Called | Parameters |
|
||||||
|
|----------|---------|-------------|-----------|
|
||||||
|
| `FUNC_AFTER_TELEPERIOD` | Post-telemetry cleanup | After TelePeriod | None |
|
||||||
|
| `FUNC_JSON_APPEND` | Add JSON telemetry | Every TelePeriod | None |
|
||||||
|
| `FUNC_TELEPERIOD_RULES_PROCESS` | Rules after telemetry | Post-TelePeriod | None |
|
||||||
|
|
||||||
|
#### Web Interface Callbacks
|
||||||
|
|
||||||
|
| Function | Purpose | When Called | Parameters |
|
||||||
|
|----------|---------|-------------|-----------|
|
||||||
|
| `FUNC_WEB_SENSOR` | Show sensor on web | Sensor page load | None |
|
||||||
|
| `FUNC_WEB_COL_SENSOR` | Column sensor display | Web page layout | None |
|
||||||
|
| `FUNC_WEB_ADD_BUTTON` | Add web buttons | Main page load | None |
|
||||||
|
| `FUNC_WEB_ADD_CONSOLE_BUTTON` | Add console button | Console page | None |
|
||||||
|
| `FUNC_WEB_ADD_MANAGEMENT_BUTTON` | Add config button | Config page | None |
|
||||||
|
| `FUNC_WEB_ADD_MAIN_BUTTON` | Add main menu button | Main page | None |
|
||||||
|
| `FUNC_WEB_GET_ARG` | Process web arguments | Form submission | None |
|
||||||
|
| `FUNC_WEB_ADD_HANDLER` | Add URL handlers | Web server init | None |
|
||||||
|
| `FUNC_WEB_STATUS_LEFT` | Left status column | Status page | None |
|
||||||
|
| `FUNC_WEB_STATUS_RIGHT` | Right status column | Status page | None |
|
||||||
|
|
||||||
|
#### MQTT and Communication Callbacks
|
||||||
|
|
||||||
|
| Function | Purpose | When Called | Parameters |
|
||||||
|
|----------|---------|-------------|-----------|
|
||||||
|
| `FUNC_MQTT_SUBSCRIBE` | Subscribe to MQTT topics | MQTT connect | None |
|
||||||
|
| `FUNC_MQTT_INIT` | Initialize MQTT | MQTT setup | None |
|
||||||
|
|
||||||
|
#### Power and Hardware Control
|
||||||
|
|
||||||
|
| Function | Purpose | When Called | Parameters |
|
||||||
|
|----------|---------|-------------|-----------|
|
||||||
|
| `FUNC_SET_POWER` | Handle power changes | Power state change | None |
|
||||||
|
| `FUNC_SHOW_SENSOR` | Display sensor data | Status request | None |
|
||||||
|
| `FUNC_ANY_KEY` | Handle any key press | Key event | None |
|
||||||
|
| `FUNC_LED_LINK` | Control link LED | Network state change | None |
|
||||||
|
| `FUNC_ENERGY_EVERY_SECOND` | Energy monitoring | Every second | None |
|
||||||
|
| `FUNC_ENERGY_RESET` | Reset energy counters | Reset command | None |
|
||||||
|
|
||||||
|
#### Advanced System Callbacks
|
||||||
|
|
||||||
|
| Function | Purpose | When Called | Parameters |
|
||||||
|
|----------|---------|-------------|-----------|
|
||||||
|
| `FUNC_SET_SCHEME` | Set color scheme | Theme change | None |
|
||||||
|
| `FUNC_HOTPLUG_SCAN` | Scan for hotplug devices | Device detection | None |
|
||||||
|
| `FUNC_TIME_SYNCED` | Time synchronization | NTP sync complete | None |
|
||||||
|
| `FUNC_DEVICE_GROUP_ITEM` | Device group processing | Group operations | None |
|
||||||
|
| `FUNC_NETWORK_UP` | Network connected | WiFi/Ethernet up | None |
|
||||||
|
| `FUNC_NETWORK_DOWN` | Network disconnected | WiFi/Ethernet down | None |
|
||||||
|
|
||||||
|
#### Callback Functions WITH Return Results (ID >= 200)
|
||||||
|
|
||||||
|
These functions are expected to return boolean results:
|
||||||
|
|
||||||
|
| Function | Purpose | When Called | Return Value |
|
||||||
|
|----------|---------|-------------|--------------|
|
||||||
|
| `FUNC_PIN_STATE` | GPIO state query | Pin state check | true if handled |
|
||||||
|
| `FUNC_MODULE_INIT` | Module initialization | Module setup | true if success |
|
||||||
|
| `FUNC_ADD_BUTTON` | Add button handler | Button config | true if added |
|
||||||
|
| `FUNC_ADD_SWITCH` | Add switch handler | Switch config | true if added |
|
||||||
|
| `FUNC_BUTTON_PRESSED` | Handle button press | Button event | true if handled |
|
||||||
|
| `FUNC_BUTTON_MULTI_PRESSED` | Multi-button press | Button combo | true if handled |
|
||||||
|
| `FUNC_SET_DEVICE_POWER` | Device power control | Power command | true if handled |
|
||||||
|
| `FUNC_MQTT_DATA` | Process MQTT data | MQTT message | true if handled |
|
||||||
|
| `FUNC_SERIAL` | Serial data processing | Serial input | true if handled |
|
||||||
|
| `FUNC_COMMAND` | Process commands | Command received | true if handled |
|
||||||
|
| `FUNC_COMMAND_SENSOR` | Sensor commands | Sensor command | true if handled |
|
||||||
|
| `FUNC_COMMAND_DRIVER` | Driver commands | Driver command | true if handled |
|
||||||
|
| `FUNC_RULES_PROCESS` | Process rules | Rule evaluation | true if handled |
|
||||||
|
| `FUNC_SET_CHANNELS` | Set PWM channels | Channel update | true if handled |
|
||||||
|
|
||||||
|
#### Callback Implementation Pattern
|
||||||
|
|
||||||
|
```c
|
||||||
|
bool Xdrv_XX(uint8_t function) {
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
switch (function) {
|
||||||
|
case FUNC_INIT:
|
||||||
|
MyDriverInit();
|
||||||
|
break;
|
||||||
|
case FUNC_EVERY_SECOND:
|
||||||
|
MyDriverEverySecond();
|
||||||
|
break;
|
||||||
|
case FUNC_COMMAND:
|
||||||
|
result = MyDriverCommand();
|
||||||
|
break;
|
||||||
|
case FUNC_JSON_APPEND:
|
||||||
|
MyDriverJsonAppend();
|
||||||
|
break;
|
||||||
|
case FUNC_WEB_SENSOR:
|
||||||
|
MyDriverWebSensor();
|
||||||
|
break;
|
||||||
|
case FUNC_SAVE_BEFORE_RESTART:
|
||||||
|
MyDriverSaveSettings();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
### I2C Development
|
||||||
|
|
||||||
|
```c
|
||||||
|
// I2C Helper Functions
|
||||||
|
bool I2cValidRead8(uint8_t *data, uint8_t addr, uint8_t reg);
|
||||||
|
bool I2cValidRead16(uint16_t *data, uint8_t addr, uint8_t reg);
|
||||||
|
uint8_t I2cRead8(uint8_t addr, uint8_t reg);
|
||||||
|
uint16_t I2cRead16(uint8_t addr, uint8_t reg);
|
||||||
|
bool I2cWrite8(uint8_t addr, uint8_t reg, uint8_t val);
|
||||||
|
|
||||||
|
// Device Detection Pattern
|
||||||
|
void MySensorDetect(void) {
|
||||||
|
if (MySensorDetected) return;
|
||||||
|
|
||||||
|
for (uint8_t i = 0; i < SENSOR_MAX_ADDR; i++) {
|
||||||
|
uint8_t addr = SENSOR_BASE_ADDR + i;
|
||||||
|
if (I2cValidRead8(&sensor_id, addr, SENSOR_ID_REG)) {
|
||||||
|
if (sensor_id == EXPECTED_ID) {
|
||||||
|
MySensorDetected = true;
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("MySensor found at 0x%02X"), addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Scripting and Automation
|
||||||
|
|
||||||
|
### Rules System
|
||||||
|
|
||||||
|
Rules provide event-driven automation:
|
||||||
|
|
||||||
|
```
|
||||||
|
Rule1 ON Switch1#State DO Power1 %value% ENDON
|
||||||
|
ON Time#Minute=30 DO Publish stat/topic/alert {"time":"30min"} ENDON
|
||||||
|
```
|
||||||
|
|
||||||
|
### Berry Scripting (ESP32)
|
||||||
|
|
||||||
|
Berry is a modern scripting language for advanced automation:
|
||||||
|
|
||||||
|
```berry
|
||||||
|
# Simple sensor reading
|
||||||
|
import json
|
||||||
|
|
||||||
|
def read_sensor()
|
||||||
|
var temp = tasmota.read_sensors()
|
||||||
|
if temp.contains("Temperature")
|
||||||
|
print("Current temperature:", temp["Temperature"])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Set up timer
|
||||||
|
tasmota.set_timer(5000, read_sensor)
|
||||||
|
|
||||||
|
# Web interface extension
|
||||||
|
def web_add_button()
|
||||||
|
webserver.content_send("<button onclick='la(\"&m_toggle=1\");'>Toggle</button>")
|
||||||
|
end
|
||||||
|
|
||||||
|
tasmota.add_driver(web_add_button)
|
||||||
|
```
|
||||||
|
|
||||||
|
### Command Extensions
|
||||||
|
|
||||||
|
Add custom commands through Berry or C++:
|
||||||
|
|
||||||
|
```berry
|
||||||
|
def my_command(cmd, idx, payload)
|
||||||
|
if cmd == "MYCMD"
|
||||||
|
print("Custom command received:", payload)
|
||||||
|
tasmota.resp_cmnd_done()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
tasmota.add_cmd('MYCMD', my_command)
|
||||||
|
```
|
||||||
|
|
||||||
|
## Complete Settings Structure Reference
|
||||||
|
|
||||||
|
### Settings Memory Layout
|
||||||
|
|
||||||
|
Tasmota uses a structured settings system stored in flash memory. The main settings structure is defined in `settings.h`:
|
||||||
|
|
||||||
|
```c
|
||||||
|
typedef struct {
|
||||||
|
unsigned long cfg_holder; // 000 v6.0.0a
|
||||||
|
unsigned long save_flag; // 004
|
||||||
|
unsigned long version; // 008
|
||||||
|
unsigned short flag; // 00C
|
||||||
|
unsigned short save_data; // 00E
|
||||||
|
int8_t timezone; // 010
|
||||||
|
char ota_url[101]; // 011
|
||||||
|
char mqtt_prefix[3][11]; // 076
|
||||||
|
char serial_delimiter; // 09D
|
||||||
|
uint8_t seriallog_level; // 09E
|
||||||
|
uint8_t sta_config; // 09F
|
||||||
|
char sta_ssid[2][33]; // 0A0
|
||||||
|
char sta_pwd[2][65]; // 102
|
||||||
|
char hostname[33]; // 183
|
||||||
|
char syslog_host[33]; // 1A4
|
||||||
|
uint16_t syslog_port; // 1C5
|
||||||
|
uint8_t syslog_level; // 1C7
|
||||||
|
uint8_t webserver; // 1C8
|
||||||
|
uint8_t weblog_level; // 1C9
|
||||||
|
char mqtt_fingerprint[2][60]; // 1CA
|
||||||
|
char mqtt_host[33]; // 236
|
||||||
|
uint16_t mqtt_port; // 257
|
||||||
|
char mqtt_client[33]; // 259
|
||||||
|
char mqtt_user[33]; // 27A
|
||||||
|
char mqtt_pwd[33]; // 29B
|
||||||
|
char mqtt_topic[33]; // 2BC
|
||||||
|
char button_topic[33]; // 2DD
|
||||||
|
char mqtt_grptopic[33]; // 2FE
|
||||||
|
uint8_t display_model; // 31F
|
||||||
|
uint8_t display_mode; // 320
|
||||||
|
uint8_t display_refresh; // 321
|
||||||
|
uint8_t display_rows; // 322
|
||||||
|
uint8_t display_cols[2]; // 323
|
||||||
|
uint8_t display_address[8]; // 325
|
||||||
|
uint8_t display_dimmer; // 32D
|
||||||
|
uint8_t display_size; // 32E
|
||||||
|
uint16_t pwm_frequency; // 32F
|
||||||
|
power_t power; // 331
|
||||||
|
uint16_t pwm_value[MAX_PWMS]; // 335
|
||||||
|
int16_t altitude; // 345
|
||||||
|
uint16_t tele_period; // 347
|
||||||
|
uint8_t ledstate; // 349
|
||||||
|
uint8_t param[PARAM_MAX]; // 34A
|
||||||
|
int16_t toffset[2]; // 35A
|
||||||
|
uint8_t display_font; // 35E
|
||||||
|
} Settings;
|
||||||
|
|
||||||
|
### ESP8266 Constraints
|
||||||
|
|
||||||
|
- **Flash**: 1MB total, ~500KB available for firmware
|
||||||
|
- **RAM**: 80KB total, ~25-30KB available for application
|
||||||
|
- **Stack**: 4KB maximum
|
||||||
|
|
||||||
|
### Optimization Techniques
|
||||||
|
|
||||||
|
1. **Use PROGMEM for constants**:
|
||||||
|
```c
|
||||||
|
const char MyString[] PROGMEM = "Constant string";
|
||||||
|
```
|
||||||
|
|
||||||
|
2. **Minimize dynamic allocation**:
|
||||||
|
```c
|
||||||
|
// Avoid
|
||||||
|
String result = String(value1) + "," + String(value2);
|
||||||
|
|
||||||
|
// Prefer
|
||||||
|
char result[32];
|
||||||
|
snprintf(result, sizeof(result), "%d,%d", value1, value2);
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Use flash-efficient data types**:
|
||||||
|
```c
|
||||||
|
// Use uint32_t instead of uint8_t for local variables
|
||||||
|
// Use uint8_t only in structs to save memory
|
||||||
|
```
|
||||||
|
|
||||||
|
## Communication Protocols
|
||||||
|
|
||||||
|
### Command Context Structure
|
||||||
|
|
||||||
|
All command handlers receive context through the global XdrvMailbox structure:
|
||||||
|
|
||||||
|
```c
|
||||||
|
struct XDRVMAILBOX {
|
||||||
|
bool grpflg; // Group flag
|
||||||
|
bool usridx; // User index flag
|
||||||
|
uint16_t command_code; // Command code
|
||||||
|
uint32_t index; // Command index
|
||||||
|
uint32_t data_len; // Parameter length
|
||||||
|
int32_t payload; // Numeric parameter
|
||||||
|
char *topic; // MQTT topic
|
||||||
|
char *data; // Command parameters
|
||||||
|
char *command; // Command name
|
||||||
|
} XdrvMailbox;
|
||||||
|
```
|
||||||
|
|
||||||
|
**Key Fields:**
|
||||||
|
- `command`: The command name (e.g., "Power", "Status")
|
||||||
|
- `data`: Raw parameter string
|
||||||
|
- `payload`: Numeric value of first parameter
|
||||||
|
- `data_len`: Length of parameter string
|
||||||
|
- `index`: Command index for numbered commands (Power1, Power2, etc.)
|
||||||
|
|
||||||
|
### MQTT Integration
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Publish sensor data
|
||||||
|
void PublishSensorData(void) {
|
||||||
|
Response_P(PSTR("{\"MySensor\":{\"Value\":%d}}"), sensor_value);
|
||||||
|
MqttPublishTeleSensor();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe to commands
|
||||||
|
bool MyCommand(void) {
|
||||||
|
if (XdrvMailbox.data_len > 0) {
|
||||||
|
// Process command
|
||||||
|
ResponseCmndDone();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
ResponseCmndNumber(current_value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Web Interface Extensions
|
||||||
|
|
||||||
|
```c
|
||||||
|
#ifdef USE_WEBSERVER
|
||||||
|
void MySensorWebShow(void) {
|
||||||
|
WSContentSend_PD(PSTR(
|
||||||
|
"{s}MySensor Temperature{m}%d°C{e}"
|
||||||
|
"{s}MySensor Humidity{m}%d%%{e}"),
|
||||||
|
temperature, humidity);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
|
## Advanced Features
|
||||||
|
|
||||||
|
### Template System
|
||||||
|
|
||||||
|
Templates define device GPIO configurations:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"NAME":"Custom Device",
|
||||||
|
"GPIO":[416,0,418,0,417,2720,0,0,2624,32,2656,224,0,0],
|
||||||
|
"FLAG":0,
|
||||||
|
"BASE":45
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Matter Protocol Support
|
||||||
|
|
||||||
|
For ESP32 devices, Matter provides standardized IoT communication:
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Matter endpoint configuration
|
||||||
|
matter.add_endpoint(1, 0x0100); // On/Off Light
|
||||||
|
matter.add_endpoint(2, 0x0106); // Light with dimming
|
||||||
|
```
|
||||||
|
|
||||||
|
### Display Integration
|
||||||
|
|
||||||
|
Universal Display Driver supports 50+ display types:
|
||||||
|
|
||||||
|
```
|
||||||
|
DisplayModel 1 # Select display type
|
||||||
|
DisplayMode 1 # Text mode
|
||||||
|
DisplayText [s1l1]Hello World
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing and Debugging
|
||||||
|
|
||||||
|
### Debug Options
|
||||||
|
|
||||||
|
Enable debugging in `user_config_override.h`:
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define DEBUG_TASMOTA_CORE
|
||||||
|
#define DEBUG_TASMOTA_DRIVER
|
||||||
|
#define USE_DEBUG_DRIVER
|
||||||
|
```
|
||||||
|
|
||||||
|
### Serial Debugging
|
||||||
|
|
||||||
|
```c
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("Debug: value=%d"), value);
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("Detailed info: %s"), info_string);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Memory Monitoring
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Check free heap
|
||||||
|
uint32_t free_heap = ESP.getFreeHeap();
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("Free heap: %d"), free_heap);
|
||||||
|
```
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
|
||||||
|
### Code Organization
|
||||||
|
|
||||||
|
1. **Use consistent naming**: `MySensor` prefix for all functions
|
||||||
|
2. **Follow callback patterns**: Implement standard driver callbacks
|
||||||
|
3. **Handle errors gracefully**: Check return values and sensor presence
|
||||||
|
4. **Document thoroughly**: Include usage examples and pin assignments
|
||||||
|
|
||||||
|
### Performance Considerations
|
||||||
|
|
||||||
|
1. **Minimize blocking operations**: Use state machines for long operations
|
||||||
|
2. **Cache sensor readings**: Don't read sensors more often than necessary
|
||||||
|
3. **Use appropriate data types**: Consider memory usage vs. precision
|
||||||
|
4. **Optimize for common cases**: Fast path for normal operations
|
||||||
|
|
||||||
|
### Security Guidelines
|
||||||
|
|
||||||
|
1. **Validate all inputs**: Check command parameters and sensor data
|
||||||
|
2. **Use secure defaults**: Enable security features by default
|
||||||
|
3. **Minimize attack surface**: Disable unused network services
|
||||||
|
4. **Regular updates**: Keep firmware and dependencies current
|
||||||
|
|
||||||
|
## Integration Examples
|
||||||
|
|
||||||
|
### Home Assistant Discovery
|
||||||
|
|
||||||
|
```c
|
||||||
|
void PublishDiscovery(void) {
|
||||||
|
Response_P(PSTR("{"
|
||||||
|
"\"name\":\"%s MySensor\","
|
||||||
|
"\"stat_t\":\"%s\","
|
||||||
|
"\"unit_of_meas\":\"°C\","
|
||||||
|
"\"dev_cla\":\"temperature\""
|
||||||
|
"}"), SettingsText(SET_DEVICENAME), GetStateTopic());
|
||||||
|
|
||||||
|
MqttPublish(GetDiscoveryTopic("sensor", "temperature"), true);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Custom Web Interface
|
||||||
|
|
||||||
|
```c
|
||||||
|
const char HTTP_MYSENSOR[] PROGMEM =
|
||||||
|
"{s}MySensor{m}"
|
||||||
|
"<input type='range' min='0' max='100' value='%d' "
|
||||||
|
"onchange='la(\"&mysensor_val=\"+this.value);'>"
|
||||||
|
"{e}";
|
||||||
|
|
||||||
|
void MySensorWebShow(void) {
|
||||||
|
WSContentSend_PD(HTTP_MYSENSOR, current_value);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This guide provides the foundation for understanding and extending Tasmota. The modular architecture, standardized APIs, and extensive documentation make it an excellent platform for IoT development, whether you're adding simple sensor support or implementing complex automation systems.
|
||||||
|
|
||||||
|
## Complete Command Reference
|
||||||
|
|
||||||
|
### Core System Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `Status` | 0-11 | System status information | `Status 0` |
|
||||||
|
| `Reset` | 1-6 | Reset device with options | `Reset 1` |
|
||||||
|
| `Restart` | 1 | Restart device | `Restart 1` |
|
||||||
|
| `Upgrade` | 1 | Start OTA upgrade | `Upgrade 1` |
|
||||||
|
| `Upload` | 1 | Start file upload | `Upload 1` |
|
||||||
|
| `Otaurl` | url | Set OTA URL | `Otaurl http://ota.server/firmware.bin` |
|
||||||
|
| `Seriallog` | 0-4 | Set serial log level | `Seriallog 2` |
|
||||||
|
| `Syslog` | 0-4 | Set syslog level | `Syslog 2` |
|
||||||
|
| `Loghost` | hostname | Set syslog host | `Loghost 192.168.1.100` |
|
||||||
|
| `Logport` | port | Set syslog port | `Logport 514` |
|
||||||
|
| `Ipaddress` | x.x.x.x | Set IP address | `Ipaddress 192.168.1.100` |
|
||||||
|
| `Gateway` | x.x.x.x | Set gateway | `Gateway 192.168.1.1` |
|
||||||
|
| `Subnetmask` | x.x.x.x | Set subnet mask | `Subnetmask 255.255.255.0` |
|
||||||
|
| `Dnsserver` | x.x.x.x | Set DNS server | `Dnsserver 8.8.8.8` |
|
||||||
|
| `Mac` | - | Show MAC address | `Mac` |
|
||||||
|
| `Hostname` | name | Set hostname | `Hostname tasmota-device` |
|
||||||
|
|
||||||
|
### WiFi Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `Ssid1` | ssid | Set WiFi SSID 1 | `Ssid1 MyNetwork` |
|
||||||
|
| `Ssid2` | ssid | Set WiFi SSID 2 | `Ssid2 BackupNetwork` |
|
||||||
|
| `Password1` | password | Set WiFi password 1 | `Password1 MyPassword` |
|
||||||
|
| `Password2` | password | Set WiFi password 2 | `Password2 BackupPassword` |
|
||||||
|
| `Ap` | 0-2 | Set AP mode | `Ap 1` |
|
||||||
|
| `WebServer` | 0-2 | Enable web server | `WebServer 1` |
|
||||||
|
| `WebPassword` | password | Set web password | `WebPassword admin` |
|
||||||
|
| `WifiConfig` | 0-7 | WiFi configuration mode | `WifiConfig 4` |
|
||||||
|
|
||||||
|
### MQTT Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `MqttHost` | hostname | Set MQTT broker | `MqttHost 192.168.1.100` |
|
||||||
|
| `MqttPort` | port | Set MQTT port | `MqttPort 1883` |
|
||||||
|
| `MqttUser` | username | Set MQTT username | `MqttUser myuser` |
|
||||||
|
| `MqttPassword` | password | Set MQTT password | `MqttPassword mypass` |
|
||||||
|
| `MqttClient` | clientid | Set MQTT client ID | `MqttClient tasmota-device` |
|
||||||
|
| `Topic` | topic | Set MQTT topic | `Topic tasmota` |
|
||||||
|
| `GroupTopic` | topic | Set group topic | `GroupTopic tasmotas` |
|
||||||
|
| `FullTopic` | template | Set full topic template | `FullTopic %prefix%/%topic%/` |
|
||||||
|
| `Prefix1` | prefix | Set command prefix | `Prefix1 cmnd` |
|
||||||
|
| `Prefix2` | prefix | Set status prefix | `Prefix2 stat` |
|
||||||
|
| `Prefix3` | prefix | Set telemetry prefix | `Prefix3 tele` |
|
||||||
|
| `Publish` | topic payload | Publish MQTT message | `Publish stat/topic/test Hello` |
|
||||||
|
| `MqttRetry` | seconds | Set MQTT retry time | `MqttRetry 10` |
|
||||||
|
| `StateText1` | text | Set OFF state text | `StateText1 OFF` |
|
||||||
|
| `StateText2` | text | Set ON state text | `StateText2 ON` |
|
||||||
|
| `StateText3` | text | Set TOGGLE state text | `StateText3 TOGGLE` |
|
||||||
|
| `StateText4` | text | Set HOLD state text | `StateText4 HOLD` |
|
||||||
|
|
||||||
|
### Power and Relay Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `Power` | 0/1/2 | Control main power | `Power 1` |
|
||||||
|
| `Power1` | 0/1/2 | Control power 1 | `Power1 ON` |
|
||||||
|
| `Power2` | 0/1/2 | Control power 2 | `Power2 OFF` |
|
||||||
|
| `Power3` | 0/1/2 | Control power 3 | `Power3 TOGGLE` |
|
||||||
|
| `Power4` | 0/1/2 | Control power 4 | `Power4 1` |
|
||||||
|
| `PowerOnState` | 0-4 | Set power on state | `PowerOnState 1` |
|
||||||
|
| `PulseTime` | 1-111 | Set pulse time | `PulseTime1 10` |
|
||||||
|
| `BlinkTime` | 2-3600 | Set blink time | `BlinkTime 10` |
|
||||||
|
| `BlinkCount` | 0-32000 | Set blink count | `BlinkCount 5` |
|
||||||
|
| `Interlock` | 0/1 | Enable interlock | `Interlock 1` |
|
||||||
|
| `Ledstate` | 0-8 | Set LED state | `Ledstate 1` |
|
||||||
|
| `LedPower` | 0-2 | Control LED power | `LedPower 1` |
|
||||||
|
| `LedMask` | hex | Set LED mask | `LedMask 0xFF00` |
|
||||||
|
|
||||||
|
### Sensor Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `TelePeriod` | 10-3600 | Set telemetry period | `TelePeriod 300` |
|
||||||
|
| `Resolution` | 0-3 | Set sensor resolution | `Resolution 2` |
|
||||||
|
| `HumRes` | 0-3 | Set humidity resolution | `HumRes 1` |
|
||||||
|
| `TempRes` | 0-3 | Set temperature resolution | `TempRes 2` |
|
||||||
|
| `PressRes` | 0-3 | Set pressure resolution | `PressRes 1` |
|
||||||
|
| `EnergyRes` | 0-5 | Set energy resolution | `EnergyRes 3` |
|
||||||
|
| `SpeedUnit` | 1-4 | Set speed unit | `SpeedUnit 1` |
|
||||||
|
| `WeightRes` | 0-3 | Set weight resolution | `WeightRes 2` |
|
||||||
|
| `FreqRes` | 0-3 | Set frequency resolution | `FreqRes 2` |
|
||||||
|
|
||||||
|
### Timer Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `Timer1` | parameters | Configure timer 1 | `Timer1 {"Enable":1,"Time":"06:00","Days":"1111100","Repeat":1,"Action":1}` |
|
||||||
|
| `Timer2` | parameters | Configure timer 2 | `Timer2 {"Enable":1,"Time":"22:00","Action":0}` |
|
||||||
|
| `Timers` | 0/1 | Enable/disable timers | `Timers 1` |
|
||||||
|
| `Latitude` | degrees | Set latitude | `Latitude 52.520008` |
|
||||||
|
| `Longitude` | degrees | Set longitude | `Longitude 13.404954` |
|
||||||
|
| `Sunrise` | - | Show sunrise time | `Sunrise` |
|
||||||
|
| `Sunset` | - | Show sunset time | `Sunset` |
|
||||||
|
|
||||||
|
### GPIO and Template Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `Gpio` | pin,function | Set GPIO function | `Gpio 14,21` |
|
||||||
|
| `Gpios` | - | Show GPIO configuration | `Gpios` |
|
||||||
|
| `Template` | json | Set device template | `Template {"NAME":"Generic","GPIO":[255,255,255,255,255,255,255,255,255,255,255,255,255],"FLAG":1,"BASE":18}` |
|
||||||
|
| `Module` | 0-255 | Set device module | `Module 1` |
|
||||||
|
| `Modules` | - | Show available modules | `Modules` |
|
||||||
|
| `I2CScan` | - | Scan I2C bus | `I2CScan` |
|
||||||
|
| `I2CDriver` | driver | Enable I2C driver | `I2CDriver10 1` |
|
||||||
|
|
||||||
|
### Display Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `Display` | - | Show display info | `Display` |
|
||||||
|
| `DisplayModel` | 1-16 | Set display model | `DisplayModel 2` |
|
||||||
|
| `DisplayMode` | 0-5 | Set display mode | `DisplayMode 1` |
|
||||||
|
| `DisplayDimmer` | 0-100 | Set display brightness | `DisplayDimmer 50` |
|
||||||
|
| `DisplaySize` | 1-4 | Set display size | `DisplaySize 2` |
|
||||||
|
| `DisplayRotate` | 0-3 | Set display rotation | `DisplayRotate 2` |
|
||||||
|
| `DisplayText` | text | Display text | `DisplayText [s1l1]Hello World` |
|
||||||
|
| `DisplayClear` | - | Clear display | `DisplayClear` |
|
||||||
|
|
||||||
|
### Rule Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `Rule1` | rule | Set rule 1 | `Rule1 ON Switch1#State DO Power1 %value% ENDON` |
|
||||||
|
| `Rule2` | rule | Set rule 2 | `Rule2 ON Time#Minute=30 DO Publish stat/alert 30min ENDON` |
|
||||||
|
| `Rule3` | rule | Set rule 3 | `Rule3 ON Button1#State DO Backlog Power1 TOGGLE; Delay 10; Power2 TOGGLE ENDON` |
|
||||||
|
| `RuleTimer1` | 0-3600 | Set rule timer 1 | `RuleTimer1 60` |
|
||||||
|
| `RuleTimer2` | 0-3600 | Set rule timer 2 | `RuleTimer2 120` |
|
||||||
|
| `Mem1` | value | Set memory 1 | `Mem1 Hello` |
|
||||||
|
| `Mem2` | value | Set memory 2 | `Mem2 World` |
|
||||||
|
| `Var1` | value | Set variable 1 | `Var1 42` |
|
||||||
|
| `Var2` | value | Set variable 2 | `Var2 3.14` |
|
||||||
|
| `CalcRes` | 0-7 | Set calculation resolution | `CalcRes 2` |
|
||||||
|
|
||||||
|
### Berry Script Commands (ESP32)
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `Br` | code | Execute Berry code | `Br print("Hello")` |
|
||||||
|
| `BrLoad` | filename | Load Berry file | `BrLoad autoexec.be` |
|
||||||
|
| `BrRun` | filename | Run Berry file | `BrRun script.be` |
|
||||||
|
| `BrRestart` | - | Restart Berry VM | `BrRestart` |
|
||||||
|
|
||||||
|
### Energy Monitoring Commands
|
||||||
|
|
||||||
|
| Command | Parameters | Description | Example |
|
||||||
|
|---------|------------|-------------|---------|
|
||||||
|
| `PowerCal` | value | Calibrate power | `PowerCal 12530` |
|
||||||
|
| `VoltageCal` | value | Calibrate voltage | `VoltageCal 1950` |
|
||||||
|
| `CurrentCal` | value | Calibrate current | `CurrentCal 3500` |
|
||||||
|
| `PowerSet` | watts | Set power reading | `PowerSet 100` |
|
||||||
|
| `VoltageSet` | volts | Set voltage reading | `VoltageSet 230` |
|
||||||
|
| `CurrentSet` | amps | Set current reading | `CurrentSet 0.43` |
|
||||||
|
| `FrequencySet` | hz | Set frequency reading | `FrequencySet 50` |
|
||||||
|
| `EnergyReset1` | kWh | Reset energy total | `EnergyReset1 0` |
|
||||||
|
| `EnergyReset2` | kWh | Reset energy yesterday | `EnergyReset2 0` |
|
||||||
|
| `EnergyReset3` | kWh | Reset energy today | `EnergyReset3 0` |
|
||||||
|
| `MaxPower` | watts | Set max power | `MaxPower 3500` |
|
||||||
|
| `MaxPowerHold` | seconds | Set max power hold | `MaxPowerHold 10` |
|
||||||
|
| `MaxPowerWindow` | seconds | Set max power window | `MaxPowerWindow 30` |
|
||||||
|
| `SafePower` | watts | Set safe power | `SafePower 3000` |
|
||||||
|
| `SafePowerHold` | seconds | Set safe power hold | `SafePowerHold 10` |
|
||||||
|
| `SafePowerWindow` | seconds | Set safe power window | `SafePowerWindow 30` |
|
||||||
|
|
||||||
|
## Complete Logging and Debug Reference
|
||||||
|
|
||||||
|
### Log Levels
|
||||||
|
|
||||||
|
```c
|
||||||
|
#define LOG_LEVEL_NONE 0 // No logging
|
||||||
|
#define LOG_LEVEL_ERROR 1 // Critical errors only
|
||||||
|
#define LOG_LEVEL_INFO 2 // Errors and info
|
||||||
|
#define LOG_LEVEL_DEBUG 3 // Errors, info and debug
|
||||||
|
#define LOG_LEVEL_DEBUG_MORE 4 // All logging
|
||||||
|
```
|
||||||
|
|
||||||
|
### Logging Functions
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Main logging function
|
||||||
|
void AddLog(uint32_t loglevel, const char* formatP, ...);
|
||||||
|
|
||||||
|
// Convenience macros
|
||||||
|
#define AddLog_P(loglevel, formatP, ...) AddLog(loglevel, PSTR(formatP), ##__VA_ARGS__)
|
||||||
|
#define AddLog_P2(loglevel, formatP, ...) AddLog(loglevel, formatP, ##__VA_ARGS__)
|
||||||
|
|
||||||
|
// Debug logging (only in debug builds)
|
||||||
|
#ifdef DEBUG_TASMOTA_CORE
|
||||||
|
#define DEBUG_CORE_LOG(...) AddLog(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define DEBUG_CORE_LOG(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_TASMOTA_DRIVER
|
||||||
|
#define DEBUG_DRIVER_LOG(...) AddLog(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define DEBUG_DRIVER_LOG(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DEBUG_TASMOTA_SENSOR
|
||||||
|
#define DEBUG_SENSOR_LOG(...) AddLog(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define DEBUG_SENSOR_LOG(...)
|
||||||
|
#endif
|
||||||
|
```
|
||||||
|
|
||||||
|
### Debug Build Options
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Enable in user_config_override.h for debugging
|
||||||
|
#define DEBUG_TASMOTA_CORE // Core system debugging
|
||||||
|
#define DEBUG_TASMOTA_DRIVER // Driver debugging
|
||||||
|
#define DEBUG_TASMOTA_SENSOR // Sensor debugging
|
||||||
|
#define USE_DEBUG_DRIVER // Enable debug driver
|
||||||
|
#define DEBUG_TASMOTA_PORT Serial // Debug output port
|
||||||
|
```
|
||||||
|
|
||||||
|
### Memory Debugging
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Memory monitoring functions
|
||||||
|
uint32_t ESP_getFreeHeap(void);
|
||||||
|
uint32_t ESP_getMaxAllocHeap(void);
|
||||||
|
uint8_t ESP_getHeapFragmentation(void);
|
||||||
|
uint32_t ESP_getFreeContStack(void);
|
||||||
|
|
||||||
|
// Memory debugging macros
|
||||||
|
#define SHOW_FREE_MEM(x) AddLog(LOG_LEVEL_DEBUG, PSTR(x " free mem: %d"), ESP_getFreeHeap())
|
||||||
|
#define CHECK_OOM() if (ESP_getFreeHeap() < 1000) AddLog(LOG_LEVEL_ERROR, PSTR("Low memory: %d"), ESP_getFreeHeap())
|
||||||
|
```
|
||||||
|
|
||||||
|
## Complete I2C Reference
|
||||||
|
|
||||||
|
### I2C Configuration
|
||||||
|
|
||||||
|
```c
|
||||||
|
// I2C pins (can be changed via GPIO configuration)
|
||||||
|
#define I2C_SDA_PIN 4 // Default SDA pin
|
||||||
|
#define I2C_SCL_PIN 5 // Default SCL pin
|
||||||
|
|
||||||
|
// I2C speeds
|
||||||
|
#define I2C_SPEED_SLOW 50000 // 50kHz
|
||||||
|
#define I2C_SPEED_STANDARD 100000 // 100kHz
|
||||||
|
#define I2C_SPEED_FAST 400000 // 400kHz
|
||||||
|
#define I2C_SPEED_FAST_PLUS 1000000 // 1MHz
|
||||||
|
```
|
||||||
|
|
||||||
|
### I2C Helper Functions
|
||||||
|
|
||||||
|
```c
|
||||||
|
// Basic I2C operations
|
||||||
|
bool I2cValidRead(uint8_t addr, uint8_t reg, uint8_t size);
|
||||||
|
bool I2cValidRead8(uint8_t *data, uint8_t addr, uint8_t reg);
|
||||||
|
bool I2cValidRead16(uint16_t *data, uint8_t addr, uint8_t reg);
|
||||||
|
bool I2cValidRead16LE(uint16_t *data, uint8_t addr, uint8_t reg);
|
||||||
|
bool I2cValidRead24(int32_t *data, uint8_t addr, uint8_t reg);
|
||||||
|
bool I2cValidReadS32(int32_t *data, uint8_t addr, uint8_t reg);
|
||||||
|
bool I2cValidReadS32_LE(int32_t *data, uint8_t addr, uint8_t reg);
|
||||||
|
|
||||||
|
uint8_t I2cRead8(uint8_t addr, uint8_t reg);
|
||||||
|
uint16_t I2cRead16(uint8_t addr, uint8_t reg);
|
||||||
|
uint16_t I2cRead16LE(uint8_t addr, uint8_t reg);
|
||||||
|
int32_t I2cRead24(uint8_t addr, uint8_t reg);
|
||||||
|
int32_t I2cReadS32(uint8_t addr, uint8_t reg);
|
||||||
|
int32_t I2cReadS32_LE(uint8_t addr, uint8_t reg);
|
||||||
|
|
||||||
|
bool I2cWrite8(uint8_t addr, uint8_t reg, uint8_t val);
|
||||||
|
bool I2cWrite16(uint8_t addr, uint8_t reg, uint16_t val);
|
||||||
|
bool I2cWrite16LE(uint8_t addr, uint8_t reg, uint16_t val);
|
||||||
|
|
||||||
|
// Buffer operations
|
||||||
|
uint8_t I2cReadBuffer(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len);
|
||||||
|
uint8_t I2cWriteBuffer(uint8_t addr, uint8_t reg, uint8_t *data, uint16_t len);
|
||||||
|
|
||||||
|
// Device detection
|
||||||
|
bool I2cActive(uint8_t addr);
|
||||||
|
void I2cScan(char *devs, unsigned int devs_len);
|
||||||
|
void I2cResetActive(uint8_t addr, uint8_t count = 1);
|
||||||
|
void I2cSetActive(uint8_t addr, uint8_t count = 1);
|
||||||
|
void I2cSetActiveFound(uint8_t addr, const char *types);
|
||||||
|
```
|
||||||
|
|
||||||
|
### I2C Device Detection Pattern
|
||||||
|
|
||||||
|
```c
|
||||||
|
void MySensorDetect(void) {
|
||||||
|
if (MySensorDetected) return;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < SENSOR_MAX_ADDR; i++) {
|
||||||
|
uint8_t addr = SENSOR_BASE_ADDR + i;
|
||||||
|
if (I2cActive(addr)) continue; // Address already in use
|
||||||
|
|
||||||
|
if (I2cValidRead8(&sensor_id, addr, SENSOR_ID_REG)) {
|
||||||
|
if (sensor_id == EXPECTED_SENSOR_ID) {
|
||||||
|
I2cSetActiveFound(addr, "MySensor");
|
||||||
|
MySensorDetected = true;
|
||||||
|
MySensorAddress = addr;
|
||||||
|
AddLog(LOG_LEVEL_INFO, PSTR("MySensor found at address 0x%02X"), addr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This comprehensive developer reference provides all the essential information needed to understand, extend, and debug Tasmota firmware. The detailed callback system, complete command reference, GPIO configuration options, and debugging tools give developers everything needed to create robust IoT solutions.
|
||||||
2124
.doc_for_ai/TASMOTA_SUPPORT_DEEP_ANALYSIS.md
Normal file
2124
.doc_for_ai/TASMOTA_SUPPORT_DEEP_ANALYSIS.md
Normal file
File diff suppressed because it is too large
Load Diff
705
.doc_for_ai/TASMOTA_WEBUI_CODING_GUIDE.md
Normal file
705
.doc_for_ai/TASMOTA_WEBUI_CODING_GUIDE.md
Normal file
@ -0,0 +1,705 @@
|
|||||||
|
# Tasmota WebUI Coding Guide
|
||||||
|
|
||||||
|
This guide provides comprehensive instructions for coding WebUI interfaces for Tasmota, based on analysis of the actual Tasmota web interface source code and screenshots.
|
||||||
|
|
||||||
|
## Overview
|
||||||
|
|
||||||
|
Tasmota's WebUI is a lightweight, embedded web interface designed for ESP8266/ESP32 microcontrollers with severe memory constraints. The interface follows a minimalist design philosophy while providing comprehensive device control and configuration capabilities.
|
||||||
|
|
||||||
|
### Visual Design Analysis
|
||||||
|
|
||||||
|
Based on the actual Tasmota WebUI screenshots, the interface features:
|
||||||
|
|
||||||
|
1. **Main Control Page**:
|
||||||
|
- Large status display showing device state ("OFF")
|
||||||
|
- Color control sliders with visual gradients (hue, saturation, brightness)
|
||||||
|
- Toggle buttons for device control
|
||||||
|
- Clean button layout with consistent spacing
|
||||||
|
|
||||||
|
2. **Configuration Pages**:
|
||||||
|
- Nested fieldsets for logical grouping
|
||||||
|
- Form elements with proper labels and placeholders
|
||||||
|
- Consistent button styling with color coding (blue for navigation, green for save, red for dangerous actions)
|
||||||
|
- Mobile-optimized layout with full-width buttons
|
||||||
|
|
||||||
|
3. **Navigation Structure**:
|
||||||
|
- Hierarchical menu system
|
||||||
|
- Clear visual separation between sections
|
||||||
|
- Consistent header with device name and Tasmota branding
|
||||||
|
|
||||||
|
## Core Design Principles
|
||||||
|
|
||||||
|
### 1. Memory Efficiency
|
||||||
|
- Minimal HTML/CSS/JavaScript footprint
|
||||||
|
- Inline styles and scripts to reduce HTTP requests
|
||||||
|
- Compressed and minified code
|
||||||
|
- CSS variables for theming without duplication
|
||||||
|
|
||||||
|
### 2. Responsive Design
|
||||||
|
- Mobile-first approach with `viewport` meta tag
|
||||||
|
- Flexible layouts that work on small screens
|
||||||
|
- Touch-friendly button sizes and spacing
|
||||||
|
- Minimal external dependencies
|
||||||
|
|
||||||
|
### 3. Dark Theme by Default
|
||||||
|
- Professional dark color scheme
|
||||||
|
- High contrast for readability
|
||||||
|
- Consistent color variables throughout
|
||||||
|
|
||||||
|
### 4. Progressive Enhancement
|
||||||
|
- Core functionality works without JavaScript
|
||||||
|
- JavaScript enhances user experience
|
||||||
|
- Graceful degradation for older browsers
|
||||||
|
|
||||||
|
## HTML Structure Pattern
|
||||||
|
|
||||||
|
### Basic Page Template
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" class="">
|
||||||
|
<head>
|
||||||
|
<meta charset='utf-8'>
|
||||||
|
<meta name="viewport" content="width=device-width,initial-scale=1"/>
|
||||||
|
<link rel="icon" href="data:image/x-icon;base64,AAABAAEAEBACAAEAAQCwAAAAFgAAACgAAAAQAAAAIAAAAAEAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA////AP5/b+H6X2/h8k9v4eZnb+Hud2/h7ndv4e53b+FmZm/hMkxv4ZgZb+HOc2/h5+dv4fPPb+H5n2/h/D9v4f5/b+EAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4EAADuBAAA7gQAAO4E">
|
||||||
|
<title>Tasmota Configuration</title>
|
||||||
|
<script>
|
||||||
|
// Core JavaScript functions
|
||||||
|
</script>
|
||||||
|
<style>
|
||||||
|
/* CSS styles */
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style='background:var(--c_bg);text-align:left;display:inline-block;color:var(--c_txt);min-width:340px;position:relative;'>
|
||||||
|
<!-- Page content -->
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Key HTML Structure Elements
|
||||||
|
|
||||||
|
1. **Container Div**: Main wrapper with consistent styling
|
||||||
|
2. **Header Section**: Device name and page title
|
||||||
|
3. **Content Area**: Forms, buttons, and configuration options
|
||||||
|
4. **Footer**: Version information and links
|
||||||
|
|
||||||
|
## CSS Design System
|
||||||
|
|
||||||
|
### Color Variables
|
||||||
|
|
||||||
|
Tasmota uses CSS custom properties for consistent theming:
|
||||||
|
|
||||||
|
```css
|
||||||
|
:root {
|
||||||
|
--c_bg: #252525; /* Background color */
|
||||||
|
--c_frm: #4f4f4f; /* Form/fieldset background */
|
||||||
|
--c_ttl: #eaeaea; /* Title text color */
|
||||||
|
--c_txt: #eaeaea; /* Regular text color */
|
||||||
|
--c_txtwrn: #ff5661; /* Warning text color */
|
||||||
|
--c_txtscc: #008000; /* Success text color */
|
||||||
|
--c_btn: #1fa3ec; /* Primary button color */
|
||||||
|
--c_btnoff: #08405e; /* Disabled button color */
|
||||||
|
--c_btntxt: #faffff; /* Button text color */
|
||||||
|
--c_btnhvr: #0e70a4; /* Button hover color */
|
||||||
|
--c_btnrst: #d43535; /* Reset/danger button color */
|
||||||
|
--c_btnrsthvr: #931f1f; /* Reset button hover */
|
||||||
|
--c_btnsv: #47c266; /* Save button color */
|
||||||
|
--c_btnsvhvr: #5aaf6f; /* Save button hover */
|
||||||
|
--c_in: #dddddd; /* Input background */
|
||||||
|
--c_intxt: #000000; /* Input text color */
|
||||||
|
--c_csl: #1f1f1f; /* Console background */
|
||||||
|
--c_csltxt: #65c115; /* Console text color */
|
||||||
|
--c_tab: #999999; /* Tab color */
|
||||||
|
--c_tabtxt: #faffff; /* Tab text color */
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Typography and Layout
|
||||||
|
|
||||||
|
```css
|
||||||
|
body {
|
||||||
|
text-align: center;
|
||||||
|
font-family: verdana, sans-serif;
|
||||||
|
background: var(--c_bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
div, fieldset, input, select {
|
||||||
|
padding: 5px;
|
||||||
|
font-size: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
fieldset {
|
||||||
|
background: var(--c_frm);
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
margin: 0.5em 0;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Input Styling
|
||||||
|
|
||||||
|
```css
|
||||||
|
input {
|
||||||
|
width: 100%;
|
||||||
|
box-sizing: border-box;
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
background: var(--c_in);
|
||||||
|
color: var(--c_intxt);
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=checkbox], input[type=radio] {
|
||||||
|
width: 1em;
|
||||||
|
margin-right: 6px;
|
||||||
|
vertical-align: -1px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=range] {
|
||||||
|
width: 99%;
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
width: 100%;
|
||||||
|
background: var(--c_in);
|
||||||
|
color: var(--c_intxt);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Button System
|
||||||
|
|
||||||
|
```css
|
||||||
|
button {
|
||||||
|
border: 0;
|
||||||
|
border-radius: 0.3rem;
|
||||||
|
background: var(--c_btn);
|
||||||
|
color: var(--c_btntxt);
|
||||||
|
line-height: 2.4rem;
|
||||||
|
font-size: 1.2rem;
|
||||||
|
width: 100%;
|
||||||
|
-webkit-transition-duration: 0.4s;
|
||||||
|
transition-duration: 0.4s;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover {
|
||||||
|
background: var(--c_btnhvr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bred {
|
||||||
|
background: var(--c_btnrst);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bred:hover {
|
||||||
|
background: var(--c_btnrsthvr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bgrn {
|
||||||
|
background: var(--c_btnsv);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bgrn:hover {
|
||||||
|
background: var(--c_btnsvhvr);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## JavaScript Patterns
|
||||||
|
|
||||||
|
### Core Utility Functions
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Element selection shortcuts
|
||||||
|
var eb = s => document.getElementById(s);
|
||||||
|
var qs = s => document.querySelector(s);
|
||||||
|
|
||||||
|
// Password visibility toggle
|
||||||
|
var sp = i => eb(i).type = (eb(i).type === 'text' ? 'password' : 'text');
|
||||||
|
|
||||||
|
// Window load event handler
|
||||||
|
var wl = f => window.addEventListener('load', f);
|
||||||
|
|
||||||
|
// Auto-assign names to form elements
|
||||||
|
function jd() {
|
||||||
|
var t = 0, i = document.querySelectorAll('input,button,textarea,select');
|
||||||
|
while (i.length >= t) {
|
||||||
|
if (i[t]) {
|
||||||
|
i[t]['name'] = (i[t].hasAttribute('id') && (!i[t].hasAttribute('name')))
|
||||||
|
? i[t]['id'] : i[t]['name'];
|
||||||
|
}
|
||||||
|
t++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show/hide elements with class 'hf'
|
||||||
|
function sf(s) {
|
||||||
|
var t = 0, i = document.querySelectorAll('.hf');
|
||||||
|
while (i.length >= t) {
|
||||||
|
if (i[t]) {
|
||||||
|
i[t].style.display = s ? 'block' : 'none';
|
||||||
|
}
|
||||||
|
t++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wl(jd); // Auto-assign names on load
|
||||||
|
```
|
||||||
|
|
||||||
|
### AJAX Communication
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
var x = null, lt, to, tp, pc = '';
|
||||||
|
|
||||||
|
// Load data with AJAX
|
||||||
|
function la(p) {
|
||||||
|
a = p || '';
|
||||||
|
clearTimeout(ft);
|
||||||
|
clearTimeout(lt);
|
||||||
|
if (x != null) { x.abort(); }
|
||||||
|
|
||||||
|
x = new XMLHttpRequest();
|
||||||
|
x.onreadystatechange = () => {
|
||||||
|
if (x.readyState == 4 && x.status == 200) {
|
||||||
|
var s = x.responseText
|
||||||
|
.replace(/{t}/g, "<table style='width:100%'>")
|
||||||
|
.replace(/{s}/g, "<tr><th>")
|
||||||
|
.replace(/{m}/g, "</th><td style='width:20px;white-space:nowrap'>")
|
||||||
|
.replace(/{e}/g, "</td></tr>");
|
||||||
|
eb('l1').innerHTML = s;
|
||||||
|
clearTimeout(ft);
|
||||||
|
clearTimeout(lt);
|
||||||
|
lt = setTimeout(la, 400); // Auto-refresh every 400ms
|
||||||
|
}
|
||||||
|
};
|
||||||
|
x.open('GET', '.?m=1' + a, true);
|
||||||
|
x.send();
|
||||||
|
ft = setTimeout(la, 2e4); // Fallback timeout 20 seconds
|
||||||
|
}
|
||||||
|
|
||||||
|
// Control function for sliders and buttons
|
||||||
|
function lc(v, i, p) {
|
||||||
|
if (eb('s')) {
|
||||||
|
if (v == 'h' || v == 'd') {
|
||||||
|
var sl = eb('sl4').value;
|
||||||
|
eb('s').style.background = 'linear-gradient(to right,rgb(' + sl + '%,' + sl + '%,' + sl + '%),hsl(' + eb('sl2').value + ',100%,50%))';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
la('&' + v + i + '=' + p);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Form Handling
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
// Submit form with UI feedback
|
||||||
|
function su(t) {
|
||||||
|
eb('f3').style.display = 'none';
|
||||||
|
eb('f2').style.display = 'block';
|
||||||
|
t.form.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// File upload with validation
|
||||||
|
function upl(t) {
|
||||||
|
var sl = t.form['u2'].files[0].slice(0, 1);
|
||||||
|
var rd = new FileReader();
|
||||||
|
rd.onload = () => {
|
||||||
|
var bb = new Uint8Array(rd.result);
|
||||||
|
if (bb.length == 1 && bb[0] == 0xE9) {
|
||||||
|
fct(t); // Factory reset check
|
||||||
|
} else {
|
||||||
|
t.form.submit();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
rd.readAsArrayBuffer(sl);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Factory reset confirmation
|
||||||
|
function fct(t) {
|
||||||
|
var x = new XMLHttpRequest();
|
||||||
|
x.open('GET', '/u4?u4=fct&api=', true);
|
||||||
|
x.onreadystatechange = () => {
|
||||||
|
if (x.readyState == 4 && x.status == 200) {
|
||||||
|
var s = x.responseText;
|
||||||
|
if (s == 'false') setTimeout(() => { fct(t); }, 6000);
|
||||||
|
if (s == 'true') setTimeout(() => { su(t); }, 1000);
|
||||||
|
} else if (x.readyState == 4 && x.status == 0) {
|
||||||
|
setTimeout(() => { fct(t); }, 2000);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
x.send();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Page Layout Patterns
|
||||||
|
|
||||||
|
### Configuration Menu Layout
|
||||||
|
|
||||||
|
Based on the Tasmota configuration menu, here's the standard layout pattern:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div style='background:var(--c_bg);text-align:left;display:inline-block;color:var(--c_txt);min-width:340px;position:relative;'>
|
||||||
|
<!-- Header -->
|
||||||
|
<div style='text-align:center;color:var(--c_ttl);'>
|
||||||
|
<noscript>To use Tasmota, please enable JavaScript<br></noscript>
|
||||||
|
<h3>ESP32-DevKit</h3>
|
||||||
|
<h2>Tasmota</h2>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Page Title -->
|
||||||
|
<div style='padding:0px 5px;text-align:center;'>
|
||||||
|
<h3><hr>Configuration<hr></h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Menu Items -->
|
||||||
|
<p></p>
|
||||||
|
<form id="but7" style="display:block;" action='md' method='get'>
|
||||||
|
<button>Module</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<p></p>
|
||||||
|
<form id="but8" style="display:block;" action='wi' method='get'>
|
||||||
|
<button>WiFi</button>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<!-- More menu items... -->
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<div style='text-align:right;font-size:11px;'>
|
||||||
|
<hr>
|
||||||
|
<a href='https://github.com/arendst/Tasmota' target='_blank' style='color:#aaa;'>
|
||||||
|
Tasmota 15.0.1.4 (tasmota) by Theo Arends
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Configuration Form Layout
|
||||||
|
|
||||||
|
For configuration pages with forms:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<fieldset>
|
||||||
|
<legend><b> Other parameters </b></legend>
|
||||||
|
<form method='get' action='co'>
|
||||||
|
|
||||||
|
<!-- Template Section -->
|
||||||
|
<fieldset>
|
||||||
|
<legend><b> Template </b></legend>
|
||||||
|
<p>
|
||||||
|
<input id='t1' placeholder="Template" value='{"NAME":"ESP32-DevKit","GPIO":[1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1376,0,1,224,1,0,1,1,0,0,0,0,0,1,1,0,1,1,0,0,1],"FLAG":0,"BASE":1}'>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<input id='t2' type='checkbox' checked disabled>
|
||||||
|
<b>Activate</b>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<!-- Password Field with Toggle -->
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
<b>Web Admin Password</b>
|
||||||
|
<input type='checkbox' onclick='sp("wp")'>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<input id='wp' type='password' placeholder="Web Admin Password" value="****">
|
||||||
|
|
||||||
|
<!-- Checkboxes -->
|
||||||
|
<br><br>
|
||||||
|
<label>
|
||||||
|
<input id='b3' type='checkbox' checked>
|
||||||
|
<b>HTTP API enable</b>
|
||||||
|
</label>
|
||||||
|
|
||||||
|
<!-- Text Inputs -->
|
||||||
|
<br><br>
|
||||||
|
<label><b>Device Name</b> (Tasmota)</label>
|
||||||
|
<br>
|
||||||
|
<input id='dn' placeholder="" value="Tasmota">
|
||||||
|
|
||||||
|
<!-- Radio Buttons -->
|
||||||
|
<fieldset>
|
||||||
|
<legend><b> Emulation </b></legend>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<input id='r0' name='b2' type='radio' value='0'>
|
||||||
|
<b>None</b>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
<input id='r2' name='b2' type='radio' value='2' checked>
|
||||||
|
<b>Hue Bridge</b> multi device
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<!-- Submit Button -->
|
||||||
|
<br>
|
||||||
|
<button name='save' type='submit' class='button bgrn'>Save</button>
|
||||||
|
</form>
|
||||||
|
</fieldset>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Main Page with Controls
|
||||||
|
|
||||||
|
The main control page features a prominent status display and interactive controls. Based on the screenshot analysis:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- Dynamic Content Area -->
|
||||||
|
<div style='padding:0;' id='l1' name='l1'></div>
|
||||||
|
|
||||||
|
<!-- Control Buttons -->
|
||||||
|
<table style='width:100%'>
|
||||||
|
<tr>
|
||||||
|
<td style='width:100%'>
|
||||||
|
<button id='o1' onclick='la("&o=1");'>Toggle 1</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- Color Controls -->
|
||||||
|
<table style='width:100%'>
|
||||||
|
<!-- Hue Slider -->
|
||||||
|
<tr>
|
||||||
|
<td colspan='2' style='width:100%'>
|
||||||
|
<div id='b' class='r' style='background-image:linear-gradient(to right,#800,#f00 5%,#ff0 20%,#0f0 35%,#0ff 50%,#00f 65%,#f0f 80%,#f00 95%,#800);'>
|
||||||
|
<input id='sl2' type='range' min='0' max='359' value='95' onchange='lc("h",0,value)'>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Saturation Slider -->
|
||||||
|
<tr>
|
||||||
|
<td colspan='2' style='width:100%'>
|
||||||
|
<div id='s' class='r' style='background-image:linear-gradient(to right,#CCCCCC,#6AFF00);'>
|
||||||
|
<input id='sl3' type='range' min='0' max='100' value='94' onchange='lc("n",0,value)'>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Brightness Control -->
|
||||||
|
<tr>
|
||||||
|
<td style='width:15%'>
|
||||||
|
<button id='o2' onclick='la("&o=2");'>T2</button>
|
||||||
|
</td>
|
||||||
|
<td colspan='1' style='width:85%'>
|
||||||
|
<div id='c' class='r' style='background-image:linear-gradient(to right,#000,#fff);'>
|
||||||
|
<input id='sl4' type='range' min='0' max='100' value='80' onchange='lc("d",0,value)'>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- Button State Script -->
|
||||||
|
<script>
|
||||||
|
eb('o1').style.background = 'var(--c_btnoff)';
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
## Advanced UI Components
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Advanced UI Components
|
||||||
|
|
||||||
|
### Range Sliders with Visual Feedback
|
||||||
|
|
||||||
|
```css
|
||||||
|
.r {
|
||||||
|
border-radius: 0.3em;
|
||||||
|
padding: 2px;
|
||||||
|
margin: 4px 2px;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Textarea for Console/Logs
|
||||||
|
|
||||||
|
```css
|
||||||
|
textarea {
|
||||||
|
resize: vertical;
|
||||||
|
width: 98%;
|
||||||
|
height: 318px;
|
||||||
|
padding: 5px;
|
||||||
|
overflow: auto;
|
||||||
|
background: var(--c_bg);
|
||||||
|
color: var(--c_csltxt);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Hidden Elements
|
||||||
|
|
||||||
|
```css
|
||||||
|
.hf {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Utility Classes
|
||||||
|
|
||||||
|
```css
|
||||||
|
.p {
|
||||||
|
float: left;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.q {
|
||||||
|
float: right;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: var(--c_btn);
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
padding: 0px;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Best Practices
|
||||||
|
|
||||||
|
### 1. Memory Optimization
|
||||||
|
- Use inline styles for unique elements
|
||||||
|
- Minimize JavaScript object creation
|
||||||
|
- Reuse DOM elements where possible
|
||||||
|
- Use CSS variables for consistent theming
|
||||||
|
|
||||||
|
### 2. User Experience
|
||||||
|
- Provide immediate visual feedback for actions
|
||||||
|
- Use consistent button sizing and spacing
|
||||||
|
- Implement proper form validation
|
||||||
|
- Show loading states during operations
|
||||||
|
|
||||||
|
### 3. Accessibility
|
||||||
|
- Use semantic HTML elements
|
||||||
|
- Provide proper labels for form controls
|
||||||
|
- Ensure sufficient color contrast
|
||||||
|
- Support keyboard navigation
|
||||||
|
|
||||||
|
### 4. Performance
|
||||||
|
- Minimize HTTP requests
|
||||||
|
- Use efficient DOM manipulation
|
||||||
|
- Implement proper error handling
|
||||||
|
- Cache frequently accessed elements
|
||||||
|
|
||||||
|
### 5. Responsive Design
|
||||||
|
- Use flexible layouts
|
||||||
|
- Test on various screen sizes
|
||||||
|
- Ensure touch-friendly interface
|
||||||
|
- Provide appropriate viewport settings
|
||||||
|
|
||||||
|
## Integration with Tasmota Backend
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Common UI Patterns
|
||||||
|
|
||||||
|
### 1. Toggle Buttons (from original source)
|
||||||
|
```html
|
||||||
|
<button id='o1' onclick='la("&o=1");'>Toggle 1</button>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Configuration Sections
|
||||||
|
```html
|
||||||
|
<fieldset>
|
||||||
|
<legend><b> Section Title </b></legend>
|
||||||
|
<!-- Configuration options -->
|
||||||
|
</fieldset>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3. Input with Label
|
||||||
|
```html
|
||||||
|
<label><b>Setting Name</b> (default)</label>
|
||||||
|
<br>
|
||||||
|
<input id='setting' placeholder="Enter value" value="current_value">
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4. Checkbox with Label
|
||||||
|
```html
|
||||||
|
<label>
|
||||||
|
<input id='option' type='checkbox' checked>
|
||||||
|
<b>Option Description</b>
|
||||||
|
</label>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 5. Radio Button Group
|
||||||
|
```html
|
||||||
|
<fieldset>
|
||||||
|
<legend><b> Emulation </b></legend>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<input name='emulation' type='radio' value='0'>
|
||||||
|
<b>None</b>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<label>
|
||||||
|
<input name='emulation' type='radio' value='2' checked>
|
||||||
|
<b>Hue Bridge</b> multi device
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 6. Password Field with Toggle
|
||||||
|
```html
|
||||||
|
<label>
|
||||||
|
<b>Web Admin Password</b>
|
||||||
|
<input type='checkbox' onclick='sp("wp")' style='width:auto;margin-left:10px;'>
|
||||||
|
</label>
|
||||||
|
<br>
|
||||||
|
<input id='wp' type='password' placeholder="Web Admin Password" value="****">
|
||||||
|
```
|
||||||
|
|
||||||
|
### 7. Template Configuration (from original source)
|
||||||
|
```html
|
||||||
|
<fieldset>
|
||||||
|
<legend><b> Template </b></legend>
|
||||||
|
<p>
|
||||||
|
<input id='t1' placeholder="Template" value='{"NAME":"ESP32-DevKit","GPIO":[1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1376,0,1,224,1,0,1,1,0,0,0,0,0,1,1,0,1,1,0,0,1],"FLAG":0,"BASE":1}'>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<input id='t2' type='checkbox' checked disabled>
|
||||||
|
<b>Activate</b>
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
```
|
||||||
|
|
||||||
|
### 8. Color Control Sliders (from original source)
|
||||||
|
```html
|
||||||
|
<table style='width:100%'>
|
||||||
|
<tr>
|
||||||
|
<td colspan='2' style='width:100%'>
|
||||||
|
<div id='b' class='r' style='background-image:linear-gradient(to right,#800,#f00 5%,#ff0 20%,#0f0 35%,#0ff 50%,#00f 65%,#f0f 80%,#f00 95%,#800);'>
|
||||||
|
<input id='sl2' type='range' min='0' max='359' value='95' onchange='lc("h",0,value)'>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan='2' style='width:100%'>
|
||||||
|
<div id='s' class='r' style='background-image:linear-gradient(to right,#CCCCCC,#6AFF00);'>
|
||||||
|
<input id='sl3' type='range' min='0' max='100' value='94' onchange='lc("n",0,value)'>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style='width:15%'>
|
||||||
|
<button id='o2' onclick='la("&o=2");'>T2</button>
|
||||||
|
</td>
|
||||||
|
<td colspan='1' style='width:85%'>
|
||||||
|
<div id='c' class='r' style='background-image:linear-gradient(to right,#000,#fff);'>
|
||||||
|
<input id='sl4' type='range' min='0' max='100' value='80' onchange='lc("d",0,value)'>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
```
|
||||||
|
|
||||||
|
This guide provides the foundation for creating Tasmota-compatible WebUI interfaces that are efficient, user-friendly, and consistent with the existing design system. The visual specifications are based on actual Tasmota WebUI screenshots showing the main control page, configuration forms, and navigation menus.
|
||||||
BIN
.doc_for_ai/Tasmota configuration menu.png
Normal file
BIN
.doc_for_ai/Tasmota configuration menu.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 74 KiB |
BIN
.doc_for_ai/Tasmota configuration other.png
Normal file
BIN
.doc_for_ai/Tasmota configuration other.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 107 KiB |
BIN
.doc_for_ai/Tasmota main page.png
Normal file
BIN
.doc_for_ai/Tasmota main page.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
2
.github/PULL_REQUEST_TEMPLATE.md
vendored
@ -7,7 +7,7 @@
|
|||||||
- [ ] Only relevant files were touched
|
- [ ] Only relevant files were touched
|
||||||
- [ ] Only one feature/fix was added per PR and the code change compiles without warnings
|
- [ ] Only one feature/fix was added per PR and the code change compiles without warnings
|
||||||
- [ ] The code change is tested and works with Tasmota core ESP8266 V.2.7.8
|
- [ ] The code change is tested and works with Tasmota core ESP8266 V.2.7.8
|
||||||
- [ ] The code change is tested and works with Tasmota core ESP32 V.3.1.3.250504
|
- [ ] The code change is tested and works with Tasmota core ESP32 V.3.1.4
|
||||||
- [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla).
|
- [ ] I accept the [CLA](https://github.com/arendst/Tasmota/blob/development/CONTRIBUTING.md#contributor-license-agreement-cla).
|
||||||
|
|
||||||
_NOTE: The code change must pass CI tests. **Your PR cannot be merged unless tests pass**_
|
_NOTE: The code change must pass CI tests. **Your PR cannot be merged unless tests pass**_
|
||||||
|
|||||||
45
.github/workflows/Tasmota_build_devel.yml
vendored
45
.github/workflows/Tasmota_build_devel.yml
vendored
@ -8,6 +8,7 @@ on:
|
|||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '.github/**' # Ignore changes towards the .github directory
|
- '.github/**' # Ignore changes towards the .github directory
|
||||||
- '**.md' # Do no build if *.md files changes
|
- '**.md' # Do no build if *.md files changes
|
||||||
|
- 'tasmota/berry/**' # Ignore Berry examples
|
||||||
|
|
||||||
# Ensures that only one deploy task per branch/environment will run at a time.
|
# Ensures that only one deploy task per branch/environment will run at a time.
|
||||||
concurrency:
|
concurrency:
|
||||||
@ -89,15 +90,19 @@ jobs:
|
|||||||
variant:
|
variant:
|
||||||
- tasmota32-safeboot
|
- tasmota32-safeboot
|
||||||
- tasmota32solo1-safeboot
|
- tasmota32solo1-safeboot
|
||||||
- tasmota32c2-safeboot
|
|
||||||
- tasmota32c3-safeboot
|
|
||||||
- tasmota32c3ser-safeboot
|
|
||||||
- tasmota32s2-safeboot
|
- tasmota32s2-safeboot
|
||||||
- tasmota32s2cdc-safeboot
|
- tasmota32s2cdc-safeboot
|
||||||
- tasmota32s3-safeboot
|
- tasmota32s3-safeboot
|
||||||
- tasmota32s3ser-safeboot
|
- tasmota32s3ser-safeboot
|
||||||
|
- tasmota32c2-safeboot
|
||||||
|
- tasmota32c3-safeboot
|
||||||
|
- tasmota32c3ser-safeboot
|
||||||
|
- tasmota32c5-safeboot
|
||||||
|
- tasmota32c5ser-safeboot
|
||||||
- tasmota32c6-safeboot
|
- tasmota32c6-safeboot
|
||||||
- tasmota32c6ser-safeboot
|
- tasmota32c6ser-safeboot
|
||||||
|
- tasmota32p4-safeboot
|
||||||
|
- tasmota32p4ser-safeboot
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@ -106,10 +111,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
cp ./platformio_override_sample.ini ./platformio_override.ini
|
cp ./platformio_override_sample.ini ./platformio_override.ini
|
||||||
- name: Add SHA to footer
|
- name: Add SHA to footer
|
||||||
run: |
|
run: |
|
||||||
@ -156,10 +165,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
- name: Add SHA to footer
|
- name: Add SHA to footer
|
||||||
run: |
|
run: |
|
||||||
COMMIT_SHA_LONG=$(git rev-parse --short HEAD || echo "")
|
COMMIT_SHA_LONG=$(git rev-parse --short HEAD || echo "")
|
||||||
@ -194,7 +207,9 @@ jobs:
|
|||||||
- tasmota32-lvgl
|
- tasmota32-lvgl
|
||||||
- tasmota32c2
|
- tasmota32c2
|
||||||
- tasmota32c3
|
- tasmota32c3
|
||||||
|
- tasmota32c5
|
||||||
- tasmota32c6
|
- tasmota32c6
|
||||||
|
- tasmota32p4
|
||||||
- tasmota32s2
|
- tasmota32s2
|
||||||
- tasmota32s2cdc
|
- tasmota32s2cdc
|
||||||
- tasmota32s3
|
- tasmota32s3
|
||||||
@ -207,10 +222,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
cp ./platformio_override_sample.ini ./platformio_override.ini
|
cp ./platformio_override_sample.ini ./platformio_override.ini
|
||||||
- name: Download safeboot firmwares
|
- name: Download safeboot firmwares
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
@ -254,10 +273,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
cp ./platformio_override_sample.ini ./platformio_override.ini
|
cp ./platformio_override_sample.ini ./platformio_override.ini
|
||||||
- name: Download safeboot firmwares
|
- name: Download safeboot firmwares
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
|
|||||||
45
.github/workflows/Tasmota_build_master.yml
vendored
45
.github/workflows/Tasmota_build_master.yml
vendored
@ -7,6 +7,7 @@ on:
|
|||||||
paths-ignore:
|
paths-ignore:
|
||||||
- '.github/**' # Ignore changes towards the .github directory
|
- '.github/**' # Ignore changes towards the .github directory
|
||||||
- '**.md' # Do no build if *.md files changes
|
- '**.md' # Do no build if *.md files changes
|
||||||
|
- 'tasmota/berry/**' # Ignore Berry examples
|
||||||
|
|
||||||
# Ensures that only one deploy task per branch/environment will run at a time.
|
# Ensures that only one deploy task per branch/environment will run at a time.
|
||||||
concurrency:
|
concurrency:
|
||||||
@ -23,15 +24,19 @@ jobs:
|
|||||||
variant:
|
variant:
|
||||||
- tasmota32-safeboot
|
- tasmota32-safeboot
|
||||||
- tasmota32solo1-safeboot
|
- tasmota32solo1-safeboot
|
||||||
- tasmota32c2-safeboot
|
|
||||||
- tasmota32c3-safeboot
|
|
||||||
- tasmota32c3ser-safeboot
|
|
||||||
- tasmota32s2-safeboot
|
- tasmota32s2-safeboot
|
||||||
- tasmota32s2cdc-safeboot
|
- tasmota32s2cdc-safeboot
|
||||||
- tasmota32s3-safeboot
|
- tasmota32s3-safeboot
|
||||||
- tasmota32s3ser-safeboot
|
- tasmota32s3ser-safeboot
|
||||||
|
- tasmota32c2-safeboot
|
||||||
|
- tasmota32c3-safeboot
|
||||||
|
- tasmota32c3ser-safeboot
|
||||||
|
- tasmota32c5-safeboot
|
||||||
|
- tasmota32c5ser-safeboot
|
||||||
- tasmota32c6-safeboot
|
- tasmota32c6-safeboot
|
||||||
- tasmota32c6ser-safeboot
|
- tasmota32c6ser-safeboot
|
||||||
|
- tasmota32p4-safeboot
|
||||||
|
- tasmota32p4ser-safeboot
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
@ -40,10 +45,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
cp ./platformio_override_sample.ini ./platformio_override.ini
|
cp ./platformio_override_sample.ini ./platformio_override.ini
|
||||||
- name: Add "release" to footer
|
- name: Add "release" to footer
|
||||||
run: |
|
run: |
|
||||||
@ -84,10 +93,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
cp ./platformio_override_sample.ini ./platformio_override.ini
|
cp ./platformio_override_sample.ini ./platformio_override.ini
|
||||||
- name: Add "release" to footer
|
- name: Add "release" to footer
|
||||||
run: |
|
run: |
|
||||||
@ -121,7 +134,9 @@ jobs:
|
|||||||
- tasmota32-lvgl
|
- tasmota32-lvgl
|
||||||
- tasmota32c2
|
- tasmota32c2
|
||||||
- tasmota32c3
|
- tasmota32c3
|
||||||
|
- tasmota32c5
|
||||||
- tasmota32c6
|
- tasmota32c6
|
||||||
|
- tasmota32p4
|
||||||
- tasmota32s2
|
- tasmota32s2
|
||||||
- tasmota32s2cdc
|
- tasmota32s2cdc
|
||||||
- tasmota32s3
|
- tasmota32s3
|
||||||
@ -134,10 +149,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
cp ./platformio_override_sample.ini ./platformio_override.ini
|
cp ./platformio_override_sample.ini ./platformio_override.ini
|
||||||
- name: Download safeboot firmwares
|
- name: Download safeboot firmwares
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
@ -179,10 +198,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
cp ./platformio_override_sample.ini ./platformio_override.ini
|
cp ./platformio_override_sample.ini ./platformio_override.ini
|
||||||
- name: Download safeboot firmwares
|
- name: Download safeboot firmwares
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
|
|||||||
38
.github/workflows/build_all_the_things.yml
vendored
38
.github/workflows/build_all_the_things.yml
vendored
@ -19,7 +19,7 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
os-check-win:
|
os-check-win:
|
||||||
runs-on: windows-2019
|
runs-on: windows-latest
|
||||||
if: github.repository == 'arendst/Tasmota'
|
if: github.repository == 'arendst/Tasmota'
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
@ -32,10 +32,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
- name: Run PlatformIO
|
- name: Run PlatformIO
|
||||||
env:
|
env:
|
||||||
PYTHONIOENCODING: utf-8
|
PYTHONIOENCODING: utf-8
|
||||||
@ -60,10 +64,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
- name: Run PlatformIO
|
- name: Run PlatformIO
|
||||||
env:
|
env:
|
||||||
PYTHONIOENCODING: utf-8
|
PYTHONIOENCODING: utf-8
|
||||||
@ -94,7 +102,9 @@ jobs:
|
|||||||
- tasmota32solo1
|
- tasmota32solo1
|
||||||
- tasmota32c2
|
- tasmota32c2
|
||||||
- tasmota32c3
|
- tasmota32c3
|
||||||
|
- tasmota32c5
|
||||||
- tasmota32c6
|
- tasmota32c6
|
||||||
|
- tasmota32p4
|
||||||
- tasmota32s2
|
- tasmota32s2
|
||||||
- tasmota32s2cdc
|
- tasmota32s2cdc
|
||||||
- tasmota32s3
|
- tasmota32s3
|
||||||
@ -111,17 +121,23 @@ jobs:
|
|||||||
- tasmota32s3-safeboot
|
- tasmota32s3-safeboot
|
||||||
- tasmota32c2-safeboot
|
- tasmota32c2-safeboot
|
||||||
- tasmota32c3-safeboot
|
- tasmota32c3-safeboot
|
||||||
|
- tasmota32c5-safeboot
|
||||||
- tasmota32c6-safeboot
|
- tasmota32c6-safeboot
|
||||||
|
- tasmota32p4-safeboot
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Set up Python
|
- name: Set up Python
|
||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
cp ./platformio_override_sample.ini ./platformio_override.ini
|
cp ./platformio_override_sample.ini ./platformio_override.ini
|
||||||
- name: Run PlatformIO
|
- name: Run PlatformIO
|
||||||
env:
|
env:
|
||||||
@ -147,10 +163,14 @@ jobs:
|
|||||||
uses: actions/setup-python@v5
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.13'
|
python-version: '3.13'
|
||||||
|
- name: Install uv
|
||||||
|
uses: astral-sh/setup-uv@v6
|
||||||
|
with:
|
||||||
|
version: "latest"
|
||||||
|
enable-cache: false
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
pip install wheel
|
uv pip install --system platformio
|
||||||
pip install -U platformio
|
|
||||||
- name: Run PlatformIO
|
- name: Run PlatformIO
|
||||||
env:
|
env:
|
||||||
PYTHONIOENCODING: utf-8
|
PYTHONIOENCODING: utf-8
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -24,6 +24,7 @@ CMakeLists.txt
|
|||||||
data
|
data
|
||||||
unpacked_fs
|
unpacked_fs
|
||||||
unpacked_boards
|
unpacked_boards
|
||||||
|
tasmota/user/*
|
||||||
tasmota/user_config_override.h
|
tasmota/user_config_override.h
|
||||||
tasmota/include/local_ca_data.h
|
tasmota/include/local_ca_data.h
|
||||||
tasmota/include/local_ca_descriptor.h
|
tasmota/include/local_ca_descriptor.h
|
||||||
|
|||||||
4
.gitpod.Dockerfile
vendored
4
.gitpod.Dockerfile
vendored
@ -1,3 +1,5 @@
|
|||||||
FROM gitpod/workspace-python-3.11
|
FROM gitpod/workspace-python-3.13
|
||||||
|
|
||||||
|
RUN python -m pip install --break-system-packages uv
|
||||||
|
|
||||||
USER gitpod
|
USER gitpod
|
||||||
|
|||||||
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -70,5 +70,6 @@
|
|||||||
"tooltip": "PlatformIO: Rebuild IntelliSense Index",
|
"tooltip": "PlatformIO: Rebuild IntelliSense Index",
|
||||||
"commands": "platformio-ide.rebuildProjectIndex"
|
"commands": "platformio-ide.rebuildProjectIndex"
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"C_Cpp.dimInactiveRegions": false
|
||||||
}
|
}
|
||||||
|
|||||||
@ -36,6 +36,7 @@ Note: the `minimal` variant is not listed as it shouldn't be used outside of the
|
|||||||
| USE_EXPRESSION | - | x / x | - | - | - | - |
|
| USE_EXPRESSION | - | x / x | - | - | - | - |
|
||||||
| SUPPORT_IF_STATEMENT | - | x / x | - | - | - | - |
|
| SUPPORT_IF_STATEMENT | - | x / x | - | - | - | - |
|
||||||
| USE_HOTPLUG | - | - / - | - | - | - | - |
|
| USE_HOTPLUG | - | - / - | - | - | - | - |
|
||||||
|
| USE_INFLUXDB | - | - / x | - | - | - | - |
|
||||||
| USE_PROMETHEUS | - | - / - | - | - | - | - |
|
| USE_PROMETHEUS | - | - / - | - | - | - | - |
|
||||||
| USE_PING | - | - / - | - | - | - | - |
|
| USE_PING | - | - / - | - | - | - | - |
|
||||||
| USE_HDMI_CEC | - | - / - | - | - | - | - |
|
| USE_HDMI_CEC | - | - / - | - | - | - | - |
|
||||||
@ -113,6 +114,7 @@ Note: the `minimal` variant is not listed as it shouldn't be used outside of the
|
|||||||
| -USE_PCF85063 | - | - / - | - | - | - | - |
|
| -USE_PCF85063 | - | - / - | - | - | - | - |
|
||||||
| -USE_PCF85363 | - | - / - | - | - | - | - |
|
| -USE_PCF85363 | - | - / - | - | - | - | - |
|
||||||
| -USE_RX8010 | - | - / - | - | - | - | - |
|
| -USE_RX8010 | - | - / - | - | - | - | - |
|
||||||
|
| -USE_RX8030 | - | - / - | - | - | - | - |
|
||||||
| USE_SHT | - | - / x | - | x | - | - |
|
| USE_SHT | - | - / x | - | x | - | - |
|
||||||
| USE_HTU | - | - / x | - | x | - | - |
|
| USE_HTU | - | - / x | - | x | - | - |
|
||||||
| USE_BMP | - | - / x | - | x | - | - |
|
| USE_BMP | - | - / x | - | x | - | - |
|
||||||
|
|||||||
96
CHANGELOG.md
96
CHANGELOG.md
@ -3,6 +3,102 @@ All notable changes to this project will be documented in this file.
|
|||||||
|
|
||||||
## [Released]
|
## [Released]
|
||||||
|
|
||||||
|
## [15.1.0]
|
||||||
|
- Release Stella
|
||||||
|
|
||||||
|
## [15.0.1.5] 20251011
|
||||||
|
### Changed
|
||||||
|
- ESP8266 platform update from 2025.09.00 to 2025.10.00 (#23971)
|
||||||
|
- ESP32 Platform from 2025.09.30 to 2025.10.30, Framework (Arduino Core) from v3.1.3.250808 to v3.1.4 and IDF from v5.3.3.250801 to v5.3.4.250826 (#23971)
|
||||||
|
- Extension Manager show current version in UI (#23995)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Berry fixed 'be_top is non zero' warning when calling C mapped functions (#23989)
|
||||||
|
- Berry fixed 'be_top is non zero' when `Br` command fails (#23990)
|
||||||
|
|
||||||
|
## [15.0.1.4] 20251002
|
||||||
|
### Added
|
||||||
|
- ESP32 Extension Manager, replacing loading of Partition Wizard (#23955)
|
||||||
|
- Berry animation framework web ui to compile DSL (#23962)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- ESP32 Platform from 2025.08.30 to 2025.09.30, Framework (Arduino Core) from v3.1.3.250808 to v3.1.4 and IDF from v5.3.3.250801 to v5.3.4.250826 (#23888)
|
||||||
|
- Use HAL instead of ROM for SHA HW acceleration as used by TLS (#23902)
|
||||||
|
- Berry add argument to `werbserver.content_send_style` (#23953)
|
||||||
|
- Make GUI Timer parameters mobile phone friendly (#23959)
|
||||||
|
|
||||||
|
## [15.0.1.3] 20250908
|
||||||
|
### Added
|
||||||
|
- ESP32 ROM SHA Hardware Acceleration to BearSSL (#23819)
|
||||||
|
- Extend state JSON message with functional hostname and ipaddress which could be WiFi or Ethernet
|
||||||
|
- Berry multiplication between string and int (#23850)
|
||||||
|
- Support for RX8030 RTC (#23855)
|
||||||
|
|
||||||
|
### Breaking Changed
|
||||||
|
- Berry `animate` framework is DEPRECATED, will be replace by `animation` framework (#23854)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- ESP32 Platform from 2025.07.31 to 2025.08.30, Framework (Arduino Core) from v3.1.3.250712 to v3.1.3.250808 and IDF from v5.3.3.250707 to v5.3.3.250801 (#23778)
|
||||||
|
- Epdiy library from v1.0.0 to v2.0.0
|
||||||
|
- ESP8266 platform update from 2025.07.00 to 2025.08.00 (#23801)
|
||||||
|
- Support for ESP32-C5 (#23804)
|
||||||
|
- Berry update of preview of animation framework (#23816)
|
||||||
|
- ESP8266 platform update from 2025.08.00 to 2025.09.00 (#23801)
|
||||||
|
- JPEGDEC library from v1.5.0 to v1.8.3 (#23883)
|
||||||
|
- Web UI styles and HTML syntax (#23847)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Syslog RFC5424 compliance (#23509)
|
||||||
|
- Berry calling `setmember` with a function (#23825)
|
||||||
|
- Unable to use default serial GPIOs by TasmotaSerial regression from v14.5.0 with IDF 5.3.2.250120 (#23775)
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- `user-scalable=no` from HTTP HEADER (#23798)
|
||||||
|
|
||||||
|
## [15.0.1.2] 20250803
|
||||||
|
### Added
|
||||||
|
- Command `I2sPause` (#23646)
|
||||||
|
- Basic support for ESP32-P4 (#23663)
|
||||||
|
- ESP32-P4 command `HostedOta` (#23675)
|
||||||
|
- Support for RV3028 RTC (#23672)
|
||||||
|
- Berry preview of animation framework (#23740)
|
||||||
|
- Berry `call()` now works for classes (#23744)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- ESP32 Platform from 2025.05.30 to 2025.07.30, Framework (Arduino Core) from v3.1.3.250504 to v3.1.3.250707 and IDF from v5.3.3.250501 to v5.3.3.250707 (#23642)
|
||||||
|
- Domoticz supports persistent settings for all relays, keys and switches when filesystem `#define USE_UFILESYS` is enabled
|
||||||
|
- ESP32 Platform from 2025.07.30 to 2025.07.31, Framework (Arduino Core) from v3.1.3.250707 to v3.1.3.250712 and IDF from v5.3.3.250707 to v5.3.3.250707 (#23685)
|
||||||
|
- ESP8266 platform update from 2025.05.00 to 2025.07.00 (#23700)
|
||||||
|
- OpenTherm library from v0.9.0 to v1.1.5 (#23704)
|
||||||
|
- Berry raise webserver hooks from 16 to 32 (#23748)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- NeoPool reset to default settings (#23734)
|
||||||
|
|
||||||
|
## [15.0.1.1] 20250708
|
||||||
|
### Added
|
||||||
|
- I2S additions (#23543)
|
||||||
|
- NeoPool add Redox tank alarm (#19811)
|
||||||
|
- Berry f-strings now support ':' in expression (#23618)
|
||||||
|
- Universal display driver for ZJY169S0800TG01 ST7789 280x240 (#23638)
|
||||||
|
- Commands `LoRaWanDecoder "` and `LoRaWanName "` to clear name (#23394)
|
||||||
|
- Internal function 'WSContentSendRaw_P' (#23641)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- BLE updates for esp-nimble-cpp v2.x (#23553)
|
||||||
|
- Library names (#23560)
|
||||||
|
- ESP32 LoRaWan decoding won't duplicate non-decoded message if `SO147 0`
|
||||||
|
- VEML6070 and AHT2x device detection (#23581)
|
||||||
|
- CSS uses named colors variables (#23597)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- LVGL restore `lv_chart.set_range` removed in LVGL 9.3.0 in favor of `lv_chart.set_axis_range` (#23567)
|
||||||
|
- Berry vulnerability in JSON parsing for unicode (#23603)
|
||||||
|
- Berry security issues in `int64` and improve documentation (#23605)
|
||||||
|
- Berry security issues in `berry_mapping` and improve documentation (#23606)
|
||||||
|
- Berry Hue regression from #23429 (#23623)
|
||||||
|
- AHT30 sensor start with null values after deep sleep (#23624)
|
||||||
|
|
||||||
## [15.0.1] 20250614
|
## [15.0.1] 20250614
|
||||||
- Release Sharon
|
- Release Sharon
|
||||||
|
|
||||||
|
|||||||
@ -128,8 +128,10 @@ Index | Define | Driver | Device | Address(es) | Bus2 | Descrip
|
|||||||
88 | USE_QMP6988 | xsns_28 | QMP6988 | 0x56, 0x70 | Yes | Pressure and temperature sensor
|
88 | USE_QMP6988 | xsns_28 | QMP6988 | 0x56, 0x70 | Yes | Pressure and temperature sensor
|
||||||
89 | USE_HX711_M5SCALES | xsns_34 | M5SCALES | 0x26 | Yes | M5Unit (Mini)Scales(HX711 STM32) U177
|
89 | USE_HX711_M5SCALES | xsns_34 | M5SCALES | 0x26 | Yes | M5Unit (Mini)Scales(HX711 STM32) U177
|
||||||
90 | USE_RX8010 | xdrv_56 | RX8010 | 0x32 | Yes | RX8010 RTC from IOTTIMER
|
90 | USE_RX8010 | xdrv_56 | RX8010 | 0x32 | Yes | RX8010 RTC from IOTTIMER
|
||||||
|
90 | USE_RX8030 | xdrv_56 | RX8030 | 0x32 | Yes | RX8030 RTC from #23855
|
||||||
91 | USE_MS5837 | xsns_116 | MS5837 | 0x76 | | Pressure and temperature sensor
|
91 | USE_MS5837 | xsns_116 | MS5837 | 0x76 | | Pressure and temperature sensor
|
||||||
92 | USE_PCF85063 | xdrv_56 | PCF85063 | 0x51 | | PCF85063 Real time clock
|
92 | USE_PCF85063 | xdrv_56 | PCF85063 | 0x51 | | PCF85063 Real time clock
|
||||||
93 | USE_AS33772S | xdrv_119 | AS33772S | 0x52 | Yes | AS33772S USB PD Sink Controller
|
93 | USE_AS33772S | xdrv_119 | AS33772S | 0x52 | Yes | AS33772S USB PD Sink Controller
|
||||||
|
94 | USE_RV3028 | xdrv_56 | RV3028 | 0x52 | Yes | RV-3028-C7 RTC Controller
|
||||||
|
|
||||||
NOTE: Bus2 supported on ESP32 only.
|
NOTE: Bus2 supported on ESP32 only.
|
||||||
|
|||||||
121
RELEASENOTES.md
121
RELEASENOTES.md
@ -36,13 +36,9 @@ While fallback or downgrading is common practice it was never supported due to S
|
|||||||
|
|
||||||
This release will be supported from ESP8266/Arduino library Core version **2.7.8** due to reported security and stability issues on previous Core version. This will also support gzipped binaries.
|
This release will be supported from ESP8266/Arduino library Core version **2.7.8** due to reported security and stability issues on previous Core version. This will also support gzipped binaries.
|
||||||
|
|
||||||
This release will be supported from ESP32/Arduino library Core version **v3.1.3.250504**.
|
This release will be supported from ESP32/Arduino library Core version **v3.1.4**.
|
||||||
|
|
||||||
Support of ESP8266 Core versions before 2.7.8 and ESP32 Core versions before v3.1.3.250504 have been removed.
|
Support of ESP8266 Core versions before 2.7.8 and ESP32 Core versions before v3.1.4 have been removed.
|
||||||
|
|
||||||
## Support of TLS
|
|
||||||
|
|
||||||
In addition to TLS using fingerprints now also user supplied CA certs, AWS IoT and Azure IoT is supported. Read [full documentation](https://tasmota.github.io/docs/AWS-IoT)
|
|
||||||
|
|
||||||
## Initial configuration tools
|
## Initial configuration tools
|
||||||
|
|
||||||
@ -75,12 +71,12 @@ Latest released binaries can be downloaded from
|
|||||||
- http://ota.tasmota.com/tasmota/release
|
- http://ota.tasmota.com/tasmota/release
|
||||||
|
|
||||||
Historical binaries can be downloaded from
|
Historical binaries can be downloaded from
|
||||||
- http://ota.tasmota.com/tasmota/release-15.0.1
|
- http://ota.tasmota.com/tasmota/release-15.1.0
|
||||||
|
|
||||||
The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmota.com/tasmota/release/tasmota.bin.gz``
|
The latter links can be used for OTA upgrades too like ``OtaUrl http://ota.tasmota.com/tasmota/release/tasmota.bin.gz``
|
||||||
|
|
||||||
### ESP32, ESP32-C2, ESP32-C3, ESP32-C6, ESP32-S2 and ESP32-S3 based
|
### ESP32, ESP32-C2, ESP32-C3, ESP32-C6, ESP32-S2, ESP32-S3 and ESP32-P4 based
|
||||||
The following binary downloads have been compiled with ESP32/Arduino library core version **v3.1.3.250504**.
|
The following binary downloads have been compiled with ESP32/Arduino library core version **v3.1.4**.
|
||||||
|
|
||||||
- **tasmota32.bin** = The Tasmota version with most drivers including additional sensors and KNX for 4M+ flash. **RECOMMENDED RELEASE BINARY**
|
- **tasmota32.bin** = The Tasmota version with most drivers including additional sensors and KNX for 4M+ flash. **RECOMMENDED RELEASE BINARY**
|
||||||
- **tasmota32solo1.bin** = The Tasmota version with most drivers including additional sensors and KNX for single core ESP32 and 4M+ flash.
|
- **tasmota32solo1.bin** = The Tasmota version with most drivers including additional sensors and KNX for single core ESP32 and 4M+ flash.
|
||||||
@ -89,7 +85,9 @@ The following binary downloads have been compiled with ESP32/Arduino library cor
|
|||||||
- **tasmota32s3.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-S3 with USB HWCDC and fallback to serial and 4M+ flash.
|
- **tasmota32s3.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-S3 with USB HWCDC and fallback to serial and 4M+ flash.
|
||||||
- **tasmota32c2.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C2 with serial and 4M+ flash.
|
- **tasmota32c2.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C2 with serial and 4M+ flash.
|
||||||
- **tasmota32c3.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C3 with USB HWCDC and fallback to serial and 4M+ flash.
|
- **tasmota32c3.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C3 with USB HWCDC and fallback to serial and 4M+ flash.
|
||||||
|
- **tasmota32c5.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C5 with USB HWCDC and fallback to serial and 4M+ flash.
|
||||||
- **tasmota32c6.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C6 with USB HWCDC and fallback to serial and 4M+ flash.
|
- **tasmota32c6.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-C6 with USB HWCDC and fallback to serial and 4M+ flash.
|
||||||
|
- **tasmota32p4.bin** = The Tasmota version with most drivers including additional sensors and KNX for ESP32-P4 with USB HWCDC and fallback to serial and 4M+ flash.
|
||||||
- **tasmota32-AD.bin** to **tasmota32-VN.bin** = The Tasmota version in different languages for 4M+ flash.
|
- **tasmota32-AD.bin** to **tasmota32-VN.bin** = The Tasmota version in different languages for 4M+ flash.
|
||||||
- **tasmota32-bluetooth.bin** = The Bluetooth version adds BLE support for 4M+ flash.
|
- **tasmota32-bluetooth.bin** = The Bluetooth version adds BLE support for 4M+ flash.
|
||||||
- **tasmota32-display.bin** = The Display version without Energy Monitoring but adds display support for 4M+ flash.
|
- **tasmota32-display.bin** = The Display version without Energy Monitoring but adds display support for 4M+ flash.
|
||||||
@ -104,7 +102,7 @@ Latest released binaries can be downloaded from
|
|||||||
- https://ota.tasmota.com/tasmota32/release
|
- https://ota.tasmota.com/tasmota32/release
|
||||||
|
|
||||||
Historical binaries can be downloaded from
|
Historical binaries can be downloaded from
|
||||||
- https://ota.tasmota.com/tasmota32/release-15.0.1
|
- https://ota.tasmota.com/tasmota32/release-15.1.0
|
||||||
|
|
||||||
The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasmota.com/tasmota32/release/tasmota32.bin``
|
The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasmota.com/tasmota32/release/tasmota32.bin``
|
||||||
|
|
||||||
@ -114,57 +112,62 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm
|
|||||||
|
|
||||||
[Complete list](BUILDS.md) of available feature and sensors.
|
[Complete list](BUILDS.md) of available feature and sensors.
|
||||||
|
|
||||||
## Changelog v15.0.1 Sharon
|
## Changelog v15.1.0 Stella
|
||||||
### Fixed
|
|
||||||
- Berry fix `realline` [#23546](https://github.com/arendst/Tasmota/issues/23546)
|
|
||||||
- LVGL regression missing `lv.ANIM_OFF` and `lv.ANIM_ON` [#23544](https://github.com/arendst/Tasmota/issues/23544)
|
|
||||||
- LVGL HASPmota fix regression introduced with LVGL 9.3.0 [#23547](https://github.com/arendst/Tasmota/issues/23547)
|
|
||||||
|
|
||||||
## Changelog v15.0.0 Sharon
|
|
||||||
### Added
|
### Added
|
||||||
- Provide serial upload port from VSC to PIO [#23436](https://github.com/arendst/Tasmota/issues/23436)
|
- Commands `LoRaWanDecoder "` and `LoRaWanName "` to clear name [#23394](https://github.com/arendst/Tasmota/issues/23394)
|
||||||
- Command `JsonPP 0..7` to enable (>0) JSON Pretty Print on user interfaces and set number of indents
|
- Command `I2sPause` [#23646](https://github.com/arendst/Tasmota/issues/23646)
|
||||||
- Command `JsonPP <command>|backlog <command>;...` to enable JSON PP only once
|
- Support for RV3028 RTC [#23672](https://github.com/arendst/Tasmota/issues/23672)
|
||||||
- Support for multi channel AU915-928 LoRaWanBridge by Rob Clark [#23372](https://github.com/arendst/Tasmota/issues/23372)
|
- Support for RX8030 RTC [#23855](https://github.com/arendst/Tasmota/issues/23855)
|
||||||
- Support for LoRaWan Rx1 and Rx2 profiles [#23394](https://github.com/arendst/Tasmota/issues/23394)
|
- Extend state JSON message with functional hostname and ipaddress which could be WiFi or Ethernet
|
||||||
- Support for AP33772S USB PD Sink Controller as used in CentyLab RotoPD
|
- Internal function 'WSContentSendRaw_P' [#23641](https://github.com/arendst/Tasmota/issues/23641)
|
||||||
- Allow temporary change of DisplayDimmer [#23406](https://github.com/arendst/Tasmota/issues/23406)
|
- Universal display driver for ZJY169S0800TG01 ST7789 280x240 [#23638](https://github.com/arendst/Tasmota/issues/23638)
|
||||||
- WebUI status line for MQTT and TLS, added `FUNC_WEB_STATUS_LEFT` and `FUNC_WEB_STATUS_RIGHT` event [#23354](https://github.com/arendst/Tasmota/issues/23354)
|
- NeoPool add Redox tank alarm [#19811](https://github.com/arendst/Tasmota/issues/19811)
|
||||||
- WebUI heap status [#23356](https://github.com/arendst/Tasmota/issues/23356)
|
- I2S additions [#23543](https://github.com/arendst/Tasmota/issues/23543)
|
||||||
- Optional Wifi strength indicator in WebUI status line [#23352](https://github.com/arendst/Tasmota/issues/23352)
|
- ESP32 ROM SHA Hardware Acceleration to BearSSL [#23819](https://github.com/arendst/Tasmota/issues/23819)
|
||||||
- Wireguard VPN [#23347](https://github.com/arendst/Tasmota/issues/23347)
|
- ESP32 Extension Manager, replacing loading of Partition Wizard [#23955](https://github.com/arendst/Tasmota/issues/23955)
|
||||||
- Berry mqtt publish rule processing
|
- Support for ESP32-P4 [#23663](https://github.com/arendst/Tasmota/issues/23663)
|
||||||
- Berry support for `sortedmap` [#23441](https://github.com/arendst/Tasmota/issues/23441)
|
- Support for ESP32-C5 [#23804](https://github.com/arendst/Tasmota/issues/23804)
|
||||||
- Berry `introspect.module` option to not cache module entry [#23451](https://github.com/arendst/Tasmota/issues/23451)
|
- ESP32-P4 command `HostedOta` [#23675](https://github.com/arendst/Tasmota/issues/23675)
|
||||||
- Berry `webserver.remove_route` to revert `webserver.on` [#23452](https://github.com/arendst/Tasmota/issues/23452)
|
- Berry f-strings now support ':' in expression [#23618](https://github.com/arendst/Tasmota/issues/23618)
|
||||||
- Berry `compile` and `tasmota.compile` option to compile in local context [#23457](https://github.com/arendst/Tasmota/issues/23457)
|
- Berry preview of animation framework [#23816](https://github.com/arendst/Tasmota/issues/23816)
|
||||||
- Berry `tasmota.is_network_up()` [#23532](https://github.com/arendst/Tasmota/issues/23532)
|
- Berry `call()` now works for classes [#23744](https://github.com/arendst/Tasmota/issues/23744)
|
||||||
- HASPmota `antiburn()` [#23400](https://github.com/arendst/Tasmota/issues/23400)
|
- Berry multiplication between string and int [#23850](https://github.com/arendst/Tasmota/issues/23850)
|
||||||
- HASPmota auto-dimming when no touch [#23425](https://github.com/arendst/Tasmota/issues/23425)
|
- Berry animation framework web ui to compile DSL [#23962](https://github.com/arendst/Tasmota/issues/23962)
|
||||||
|
|
||||||
|
### Breaking Changed
|
||||||
|
- Berry `animate` framework is DEPRECATED, will be replace by `animation` framework [#23854](https://github.com/arendst/Tasmota/issues/23854)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- ESP8266 platform update from 2024.09.00 to 2025.05.00 [#23448](https://github.com/arendst/Tasmota/issues/23448)
|
- ESP8266 platform update from 2025.05.00 to 2025.10.00 [#23971](https://github.com/arendst/Tasmota/issues/23971)
|
||||||
- ESP32 Platform from 2025.04.30 to 2025.05.30, Framework (Arduino Core) from v3.1.3.250411 to v3.1.3.250504 and IDF from v5.3.2.250403 to v5.3.3.250501 [#23404](https://github.com/arendst/Tasmota/issues/23404)
|
- ESP32 Platform from 2025.05.30 to 2025.10.30, Framework (Arduino Core) from v3.1.3.250504 to v3.1.4 and IDF from v5.3.3.250501 to v5.3.4.250826 [#23971](https://github.com/arendst/Tasmota/issues/23971)
|
||||||
- ESP32 LVGL library from v9.2.2 to v9.3.0 [#23518](https://github.com/arendst/Tasmota/issues/23518)
|
- Epdiy library from v1.0.0 to v2.0.0
|
||||||
- GPIOViewer from v1.6.2 to v1.6.3 (No functional change)
|
- OpenTherm library from v0.9.0 to v1.1.5 [#23704](https://github.com/arendst/Tasmota/issues/23704)
|
||||||
- Allow command `WebRefresh` minimum from 1000 to 400 mSec
|
- JPEGDEC library from v1.5.0 to v1.8.3 [#23883](https://github.com/arendst/Tasmota/issues/23883)
|
||||||
- Increase number of supported LoRaWan nodes from 4 to 16
|
- Library names [#23560](https://github.com/arendst/Tasmota/issues/23560)
|
||||||
- Format syslog messages according to RFC5424 adding local log time [#23509](https://github.com/arendst/Tasmota/issues/23509)
|
- Web UI styles and HTML syntax [#23847](https://github.com/arendst/Tasmota/issues/23847)
|
||||||
- Zigbee improved message when coordinator failed to start [#23525](https://github.com/arendst/Tasmota/issues/23525)
|
- Make GUI Timer parameters mobile phone friendly [#23959](https://github.com/arendst/Tasmota/issues/23959)
|
||||||
- Berry change number parser for json to reuse same parser as lexer [#23505](https://github.com/arendst/Tasmota/issues/23505)
|
- CSS uses named colors variables [#23597](https://github.com/arendst/Tasmota/issues/23597)
|
||||||
- Berry increase web hooks from 16 to 32 [#23507](https://github.com/arendst/Tasmota/issues/23507)
|
- VEML6070 and AHT2x device detection [#23581](https://github.com/arendst/Tasmota/issues/23581)
|
||||||
|
- Domoticz supports persistent settings for all relays, keys and switches when filesystem `#define USE_UFILESYS` is enabled
|
||||||
|
- ESP32 LoRaWan decoding won't duplicate non-decoded message if `SO147 0`
|
||||||
|
- Use HAL instead of ROM for SHA HW acceleration as used by TLS [#23902](https://github.com/arendst/Tasmota/issues/23902)
|
||||||
|
- BLE updates for esp-nimble-cpp v2.x [#23553](https://github.com/arendst/Tasmota/issues/23553)
|
||||||
|
- Berry raise webserver hooks from 16 to 32 [#23748](https://github.com/arendst/Tasmota/issues/23748)
|
||||||
|
- Berry add argument to `werbserver.content_send_style` [#23953](https://github.com/arendst/Tasmota/issues/23953)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- DNS setting with `IPAddress4/5` not persisted [#23426](https://github.com/arendst/Tasmota/issues/23426)
|
- Syslog RFC5424 compliance [#23509](https://github.com/arendst/Tasmota/issues/23509)
|
||||||
- Autoconf failing when last line has no trailing LF [#23537](https://github.com/arendst/Tasmota/issues/23537)
|
- Unable to use default serial GPIOs by TasmotaSerial regression from v14.5.0 with IDF 5.3.2.250120 [#23775](https://github.com/arendst/Tasmota/issues/23775)
|
||||||
- NimBLE log_level definition conflict [#23366](https://github.com/arendst/Tasmota/issues/23366)
|
- AHT30 sensor start with null values after deep sleep [#23624](https://github.com/arendst/Tasmota/issues/23624)
|
||||||
- Berry `bytes().asstring()` now truncates a string if buffer contains NULL [#23311](https://github.com/arendst/Tasmota/issues/23311)
|
- NeoPool reset to default settings [#23734](https://github.com/arendst/Tasmota/issues/23734)
|
||||||
- Berry string literals containing NULL are truncated [#23312](https://github.com/arendst/Tasmota/issues/23312)
|
- Berry vulnerability in JSON parsing for unicode [#23603](https://github.com/arendst/Tasmota/issues/23603)
|
||||||
- Berry `display.touch_update` wrongly applies resistive calibration [#23363](https://github.com/arendst/Tasmota/issues/23363)
|
- Berry security issues in `int64` and improve documentation [#23605](https://github.com/arendst/Tasmota/issues/23605)
|
||||||
- Berry `introspect.module()` failed to load modules in files [#23376](https://github.com/arendst/Tasmota/issues/23376)
|
- Berry security issues in `berry_mapping` and improve documentation [#23606](https://github.com/arendst/Tasmota/issues/23606)
|
||||||
- Berry avoid json parsing for unmatched commands [#23494](https://github.com/arendst/Tasmota/issues/23494)
|
- Berry Hue regression from #23429 [#23623](https://github.com/arendst/Tasmota/issues/23623)
|
||||||
- Berry integer and real parser to handle overflows [#23495](https://github.com/arendst/Tasmota/issues/23495)
|
- Berry calling `setmember` with a function [#23825](https://github.com/arendst/Tasmota/issues/23825)
|
||||||
- Berry potential pointer underflow with `string.endswith` [#23496](https://github.com/arendst/Tasmota/issues/23496)
|
- Berry fixed 'be_top is non zero' warning when calling C mapped functions [#23989](https://github.com/arendst/Tasmota/issues/23989)
|
||||||
- LVGL Tasmota logo splash screen [#23538](https://github.com/arendst/Tasmota/issues/23538)
|
- Berry fixed 'be_top is non zero' when `Br` command fails [#23990](https://github.com/arendst/Tasmota/issues/23990)
|
||||||
- Matter and mDNS can be enabled at the same time [#23373](https://github.com/arendst/Tasmota/issues/23373)
|
- LVGL restore `lv_chart.set_range` removed in LVGL 9.3.0 in favor of `lv_chart.set_axis_range` [#23567](https://github.com/arendst/Tasmota/issues/23567)
|
||||||
- Haspmota `haspmota.parse()` page parsing [#23403](https://github.com/arendst/Tasmota/issues/23403)
|
|
||||||
|
### Removed
|
||||||
|
- `user-scalable=no` from HTTP HEADER [#23798](https://github.com/arendst/Tasmota/issues/23798)
|
||||||
|
|||||||
14
TEMPLATES.md
14
TEMPLATES.md
@ -5,7 +5,11 @@
|
|||||||
|
|
||||||
# Templates
|
# Templates
|
||||||
|
|
||||||
Find below the available templates as of June 2025. More template information can be found in the [Tasmota Device Templates Repository](http://blakadder.github.io/templates)
|
Find below the available templates as of October 2025. More template information can be found in the [Tasmota Device Templates Repository](http://blakadder.github.io/templates)
|
||||||
|
|
||||||
|
##
|
||||||
|
```
|
||||||
|
```
|
||||||
|
|
||||||
## Adapter Board
|
## Adapter Board
|
||||||
```
|
```
|
||||||
@ -26,6 +30,7 @@ Kogan 5-Stage 3S {"NAME":"Kogan Air Purifier 3S","GPIO":[0,2272,0,23
|
|||||||
## Air Quality Sensor
|
## Air Quality Sensor
|
||||||
```
|
```
|
||||||
AirGradient Pro Version DIY {"NAME":"AirGradient Pro","GPIO":[1600,1,1632,0,640,608,1,1,1664,1,1696,1,1,1],"FLAG":0,"BASE":18}
|
AirGradient Pro Version DIY {"NAME":"AirGradient Pro","GPIO":[1600,1,1632,0,640,608,1,1,1664,1,1696,1,1,1],"FLAG":0,"BASE":18}
|
||||||
|
IoTorero CO2 Sensor {"NAME":"IoTorero SCD40 Sensor","GPIO":[0,0,0,0,0,0,0,0,608,32,640,0,0,0,0,0,0,0,0,0,0,1376],"FLAG":0,"BASE":1}
|
||||||
Tuya PM Box {"NAME":"PM Box","GPIO":[1,1,1,1,1,1,0,0,1,1,1,1,1,0],"FLAG":0,"BASE":54,"CMND":"TuyaMCU 99,91 | TuyaMCU 71,2 | TuyaMCU 73,3 | HumRes 1 | TempRes 1 "}
|
Tuya PM Box {"NAME":"PM Box","GPIO":[1,1,1,1,1,1,0,0,1,1,1,1,1,0],"FLAG":0,"BASE":54,"CMND":"TuyaMCU 99,91 | TuyaMCU 71,2 | TuyaMCU 73,3 | HumRes 1 | TempRes 1 "}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -696,6 +701,7 @@ Electrodragon ESP LED Strip Board, Mosfet Drive {"NAME":"LEDBoard RGBW","GPIO":
|
|||||||
H801 {"NAME":"H801","GPIO":[1,288,1,1,420,321,0,0,418,417,419,416,0,0],"FLAG":0,"BASE":20}
|
H801 {"NAME":"H801","GPIO":[1,288,1,1,420,321,0,0,418,417,419,416,0,0],"FLAG":0,"BASE":20}
|
||||||
Hama Adapter and RGB {"NAME":"HAMA LED-Strip WLAN-Controller","GPIO":[0,0,0,0,417,419,0,0,0,416,418,0,0,0],"FLAG":0,"BASE":18}
|
Hama Adapter and RGB {"NAME":"HAMA LED-Strip WLAN-Controller","GPIO":[0,0,0,0,417,419,0,0,0,416,418,0,0,0],"FLAG":0,"BASE":18}
|
||||||
Holman Garden Light RGB {"NAME":"Holman RGB","GPIO":[0,0,0,0,0,0,0,0,417,416,418,0,0,0],"FLAG":0,"BASE":18}
|
Holman Garden Light RGB {"NAME":"Holman RGB","GPIO":[0,0,0,0,0,0,0,0,417,416,418,0,0,0],"FLAG":0,"BASE":18}
|
||||||
|
IoTorero PWM RGBCCT & Addressable Dul Mode Strip Controller {"NAME":"IoTorero RGBCW Controller","GPIO":[0,0,0,418,419,416,417,420,576,32,1088,0,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
|
||||||
Jinvoo SM-WA104 RGB {"NAME":"Jinvoo LED Controller","GPIO":[0,0,0,0,256,418,0,0,416,32,417,0,257,0],"FLAG":0,"BASE":18}
|
Jinvoo SM-WA104 RGB {"NAME":"Jinvoo LED Controller","GPIO":[0,0,0,0,256,418,0,0,416,32,417,0,257,0],"FLAG":0,"BASE":18}
|
||||||
Konesky 12V RGB {"NAME":"RGBwifi","GPIO":[0,0,0,0,416,0,0,0,417,320,418,0,0,0],"FLAG":0,"BASE":18}
|
Konesky 12V RGB {"NAME":"RGBwifi","GPIO":[0,0,0,0,416,0,0,0,417,320,418,0,0,0],"FLAG":0,"BASE":18}
|
||||||
LEDEnet {"NAME":"LEDEnet","GPIO":[0,1,320,1,3136,420,0,0,417,418,416,419,0,0],"FLAG":0,"BASE":34}
|
LEDEnet {"NAME":"LEDEnet","GPIO":[0,1,320,1,3136,420,0,0,417,418,416,419,0,0],"FLAG":0,"BASE":34}
|
||||||
@ -1019,7 +1025,7 @@ Ucomen {"NAME":"PA-GEH-01SW2","GPIO":[0,0,0,32,2688,2656,0
|
|||||||
WiOn Yard Stake {"NAME":"WiOn 50053","GPIO":[0,0,320,0,0,0,0,0,0,32,0,224,0,0],"FLAG":0,"BASE":18}
|
WiOn Yard Stake {"NAME":"WiOn 50053","GPIO":[0,0,320,0,0,0,0,0,0,32,0,224,0,0],"FLAG":0,"BASE":18}
|
||||||
WOOX R4051 {"NAME":"WOOX R4051","GPIO":[32,0,0,0,0,0,0,0,224,320,0,0,0,0],"FLAG":0,"BASE":18}
|
WOOX R4051 {"NAME":"WOOX R4051","GPIO":[32,0,0,0,0,0,0,0,224,320,0,0,0,0],"FLAG":0,"BASE":18}
|
||||||
WOOX R4052 {"NAME":"WOOX R4052","GPIO":[32,0,0,0,0,0,0,0,224,320,0,0,0,0],"FLAG":0,"BASE":18}
|
WOOX R4052 {"NAME":"WOOX R4052","GPIO":[32,0,0,0,0,0,0,0,224,320,0,0,0,0],"FLAG":0,"BASE":18}
|
||||||
Wyze {"NAME":"Wyze Plug Outdoor","GPIO":[0,0,0,0,0,576,0,0,0,0,0,224,321,7713,7712,320,0,0,0,0,0,2624,2656,2720,0,0,0,0,225,0,4704,0,0,0,0,0],"FLAG":0,"BASE":1}
|
Wyze / Roku {"NAME":"Wyze Plug Outdoor","GPIO":[0,0,0,0,0,576,0,0,0,0,0,224,321,7713,7712,320,0,0,0,0,0,2624,2656,2720,0,0,0,0,225,0,4704,0,0,0,0,0],"FLAG":0,"BASE":1}
|
||||||
XtendLan IP66 Double {"NAME":"XtendLan_ZAS4","GPIO":[32,0,0,0,0,225,33,0,224,0,0,0,0,0],"FLAG":0,"BASE":18}
|
XtendLan IP66 Double {"NAME":"XtendLan_ZAS4","GPIO":[32,0,0,0,0,225,33,0,224,0,0,0,0,0],"FLAG":0,"BASE":18}
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -2242,7 +2248,7 @@ TH3D EZBulb V1 {"NAME":"EZBulb V1","GPIO":[0,0,0,0,416,419,0,0,417
|
|||||||
TikLOk TL530 A19 7.5W 800lm {"NAME":"TikLOk WW-CW-L","GPIO":[0,0,0,0,0,416,0,0,417,0,0,0,0,0],"FLAG":0,"BASE":18}
|
TikLOk TL530 A19 7.5W 800lm {"NAME":"TikLOk WW-CW-L","GPIO":[0,0,0,0,0,416,0,0,417,0,0,0,0,0],"FLAG":0,"BASE":18}
|
||||||
TVLive 7.5W 800lm {"NAME":"TVLIVE RGBCW","GPIO":[0,0,0,0,416,419,0,0,417,420,418,0,0,0],"FLAG":0,"BASE":18}
|
TVLive 7.5W 800lm {"NAME":"TVLIVE RGBCW","GPIO":[0,0,0,0,416,419,0,0,417,420,418,0,0,0],"FLAG":0,"BASE":18}
|
||||||
Utorch LE7 600lm {"NAME":"Utorch LE7","GPIO":[0,0,0,0,0,417,0,0,418,0,419,416,0,0],"FLAG":0,"BASE":18}
|
Utorch LE7 600lm {"NAME":"Utorch LE7","GPIO":[0,0,0,0,0,417,0,0,418,0,419,416,0,0],"FLAG":0,"BASE":18}
|
||||||
V-Tac A60 11W 1055lm {"NAME":"V-TAC LED A60 ","GPIO":[0,0,0,0,4032,0,0,0,0,0,4064,0,0,0],"FLAG":0,"BASE":18}
|
V-Tac A60 11W 1055lm {"NAME":"V-TAC A60 RGBW","GPIO":[0,0,0,0,4032,0,0,0,0,0,4064,0,0,0],"FLAG":0,"BASE":18,"CMND":"SetOption37 30"}
|
||||||
V-Tac A66 15W 1300lm {"NAME":"V-TAC VT-5117","GPIO":[0,0,0,0,4032,0,0,0,0,0,4064,0,0,0],"FLAG":0,"BASE":18}
|
V-Tac A66 15W 1300lm {"NAME":"V-TAC VT-5117","GPIO":[0,0,0,0,4032,0,0,0,0,0,4064,0,0,0],"FLAG":0,"BASE":18}
|
||||||
V-TAC A95 18W 1350lm {"NAME":"V-TAC VT-5021","GPIO":[0,0,0,0,416,420,0,0,417,419,418,0,0,0],"FLAG":0,"BASE":18}
|
V-TAC A95 18W 1350lm {"NAME":"V-TAC VT-5021","GPIO":[0,0,0,0,416,420,0,0,417,419,418,0,0,0],"FLAG":0,"BASE":18}
|
||||||
V-TAC G45 4.5W 300lm {"NAME":"V-TAC VT-5124","GPIO":[0,0,0,0,0,0,0,0,4065,0,4032,0,0,0],"FLAG":0,"BASE":18}
|
V-TAC G45 4.5W 300lm {"NAME":"V-TAC VT-5124","GPIO":[0,0,0,0,0,0,0,0,4065,0,4032,0,0,0],"FLAG":0,"BASE":18}
|
||||||
@ -2372,7 +2378,6 @@ Tuya Air Detector 6 in 1 {"NAME":"DCR-KQG","GPIO":[1,2272,544,2304,1,1,1,1,1
|
|||||||
## Siren
|
## Siren
|
||||||
```
|
```
|
||||||
Connex Smart Indoor {"NAME":"Connex Siren","GPIO":[0,2272,0,2304,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":54}
|
Connex Smart Indoor {"NAME":"Connex Siren","GPIO":[0,2272,0,2304,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":54}
|
||||||
NEO Coolcam Temperature and Humidity 3in1 Alarm {"NAME":"Neo Siren 3in1","GPIO":[0,2272,0,2304,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":54}
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Smart Meter
|
## Smart Meter
|
||||||
@ -2872,6 +2877,7 @@ Coiaca Humidity and {"NAME":"Coiaca AWR01THERMt","GPIO":[576,1216,0,32,
|
|||||||
DS18B20 ESP01 DIY {"NAME":"ESP-01-01S-DS18B20-v1.0","GPIO":[1,1,1312,1,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
|
DS18B20 ESP01 DIY {"NAME":"ESP-01-01S-DS18B20-v1.0","GPIO":[1,1,1312,1,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
|
||||||
ESP01 DHT11 DIY {"NAME":"ESP01S DHT11","GPIO":[1,1,1184,1,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
|
ESP01 DHT11 DIY {"NAME":"ESP01S DHT11","GPIO":[1,1,1184,1,0,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
|
||||||
IOT4SH01DS {"NAME":"IOT4SH01DS","GPIO":[1,1,1,1,1,1,0,0,1,1312,1,1,1,1],"FLAG":0,"BASE":18}
|
IOT4SH01DS {"NAME":"IOT4SH01DS","GPIO":[1,1,1,1,1,1,0,0,1,1312,1,1,1,1],"FLAG":0,"BASE":18}
|
||||||
|
IoTorero Temperature and Humidity Sensor {"NAME":"IoTorero SHT40 Sensor","GPIO":[0,0,0,0,0,0,0,0,608,32,640,0,0,0,0,0,0,0,0,0,0,1376],"FLAG":0,"BASE":1}
|
||||||
Shelly Add-on {"NAME":"Shelly 1 Temp ","GPIO":[1344,0,0,1312,224,192,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":46}
|
Shelly Add-on {"NAME":"Shelly 1 Temp ","GPIO":[1344,0,0,1312,224,192,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":46}
|
||||||
Shelly Plus Add-On {"NAME":"Shelly Plus 1","GPIO":[1344,1312,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,224,0,0,0,0,0,4736,4705,0,0,0,0,0,0],"FLAG":0,"BASE":1}
|
Shelly Plus Add-On {"NAME":"Shelly Plus 1","GPIO":[1344,1312,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,224,0,0,0,0,0,4736,4705,0,0,0,0,0,0],"FLAG":0,"BASE":1}
|
||||||
```
|
```
|
||||||
|
|||||||
44
boards/esp32c5.json
Normal file
44
boards/esp32c5.json
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"core": "esp32",
|
||||||
|
"extra_flags": "-DARDUINO_TASMOTA -DARDUINO_USB_MODE=1 -DESP32_4M -DESP32C5 -DUSE_USB_CDC_CONSOLE",
|
||||||
|
"f_cpu": "240000000L",
|
||||||
|
"f_flash": "80000000L",
|
||||||
|
"flash_mode": "qio",
|
||||||
|
"mcu": "esp32c5",
|
||||||
|
"variant": "esp32c5",
|
||||||
|
"partitions": "partitions/esp32_partition_app2880k_fs320k.csv"
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"wifi",
|
||||||
|
"bluetooth"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32c5.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
|
"espidf"
|
||||||
|
],
|
||||||
|
"name": "Espressif Generic ESP32-C5 >= 4M Flash, Tasmota 2880k Code/OTA, 320k FS",
|
||||||
|
"upload": {
|
||||||
|
"arduino": {
|
||||||
|
"flash_extra_images": [
|
||||||
|
[
|
||||||
|
"0x10000",
|
||||||
|
"tasmota32c5-safeboot.bin"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flash_size": "4MB",
|
||||||
|
"maximum_ram_size": 327680,
|
||||||
|
"maximum_size": 4194304,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 2000000
|
||||||
|
},
|
||||||
|
"download": {
|
||||||
|
"speed": 2000000
|
||||||
|
},
|
||||||
|
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32c5/esp32-c5-devkitc-1/index.html",
|
||||||
|
"vendor": "Espressif"
|
||||||
|
}
|
||||||
44
boards/esp32c5ser.json
Normal file
44
boards/esp32c5ser.json
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"core": "esp32",
|
||||||
|
"extra_flags": "-DARDUINO_TASMOTA -DESP32_4M -DESP32C5",
|
||||||
|
"f_cpu": "240000000L",
|
||||||
|
"f_flash": "80000000L",
|
||||||
|
"flash_mode": "qio",
|
||||||
|
"mcu": "esp32c5",
|
||||||
|
"variant": "esp32c5",
|
||||||
|
"partitions": "partitions/esp32_partition_app2880k_fs320k.csv"
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"wifi",
|
||||||
|
"bluetooth"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32c5.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
|
"espidf"
|
||||||
|
],
|
||||||
|
"name": "Espressif Generic ESP32-C5 >= 4M Flash, Tasmota 2880k Code/OTA, 320k FS",
|
||||||
|
"upload": {
|
||||||
|
"arduino": {
|
||||||
|
"flash_extra_images": [
|
||||||
|
[
|
||||||
|
"0x10000",
|
||||||
|
"tasmota32c5ser-safeboot.bin"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flash_size": "4MB",
|
||||||
|
"maximum_ram_size": 327680,
|
||||||
|
"maximum_size": 4194304,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 460800
|
||||||
|
},
|
||||||
|
"download": {
|
||||||
|
"speed": 230400
|
||||||
|
},
|
||||||
|
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32c5/esp32-c5-devkitc-1/index.html",
|
||||||
|
"vendor": "Espressif"
|
||||||
|
}
|
||||||
45
boards/esp32p4.json
Normal file
45
boards/esp32p4.json
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"core": "esp32",
|
||||||
|
"extra_flags": [
|
||||||
|
"-DARDUINO_TASMOTA -DESP32P4 -DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=1 -DUSE_USB_CDC_CONSOLE"
|
||||||
|
],
|
||||||
|
"f_cpu": "360000000L",
|
||||||
|
"f_flash": "80000000L",
|
||||||
|
"flash_mode": "qio",
|
||||||
|
"mcu": "esp32p4",
|
||||||
|
"variant": "esp32p4",
|
||||||
|
"partitions": "partitions/esp32_partition_app2880k_fs320k.csv"
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"wifi",
|
||||||
|
"bluetooth",
|
||||||
|
"openthread",
|
||||||
|
"ethernet"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32p4.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
|
"espidf"
|
||||||
|
],
|
||||||
|
"name": "Espressif Generic ESP32-P4 >= 4M Flash, Tasmota 2880k Code/OTA, >= 320k FS",
|
||||||
|
"upload": {
|
||||||
|
"arduino": {
|
||||||
|
"flash_extra_images": [
|
||||||
|
[
|
||||||
|
"0x10000",
|
||||||
|
"tasmota32p4-safeboot.bin"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flash_size": "4MB",
|
||||||
|
"maximum_ram_size": 768000,
|
||||||
|
"maximum_size": 4194304,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 1500000
|
||||||
|
},
|
||||||
|
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html",
|
||||||
|
"vendor": "Espressif"
|
||||||
|
}
|
||||||
46
boards/esp32p4_ev.json
Normal file
46
boards/esp32p4_ev.json
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"core": "esp32",
|
||||||
|
"extra_flags": [
|
||||||
|
"-DARDUINO_TASMOTA -DESP32P4 -DBOARD_HAS_PSRAM -DARDUINO_USB_MODE=1 -DUSE_USB_CDC_CONSOLE"
|
||||||
|
],
|
||||||
|
"f_cpu": "360000000L",
|
||||||
|
"f_flash": "80000000L",
|
||||||
|
"flash_mode": "qio",
|
||||||
|
"mcu": "esp32p4",
|
||||||
|
"variant": "esp32p4",
|
||||||
|
"partitions": "partitions/esp32_partition_app3904k_fs3392k.csv"
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"wifi",
|
||||||
|
"bluetooth",
|
||||||
|
"openthread",
|
||||||
|
"ethernet"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32p4.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
|
"espidf"
|
||||||
|
],
|
||||||
|
"name": "Espressif ESP32-P4 Function EV Board",
|
||||||
|
"upload": {
|
||||||
|
"arduino": {
|
||||||
|
"flash_extra_images": [
|
||||||
|
[
|
||||||
|
"0x10000",
|
||||||
|
"tasmota32p4-safeboot.bin"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flash_size": "16MB",
|
||||||
|
"maximum_ram_size": 768000,
|
||||||
|
"maximum_size": 16777216,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 1500000
|
||||||
|
},
|
||||||
|
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html",
|
||||||
|
"vendor": "Espressif"
|
||||||
|
}
|
||||||
|
|
||||||
45
boards/esp32p4ser.json
Normal file
45
boards/esp32p4ser.json
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"build": {
|
||||||
|
"core": "esp32",
|
||||||
|
"extra_flags": [
|
||||||
|
"-DARDUINO_TASMOTA -DESP32P4 -DBOARD_HAS_PSRAM"
|
||||||
|
],
|
||||||
|
"f_cpu": "360000000L",
|
||||||
|
"f_flash": "80000000L",
|
||||||
|
"flash_mode": "qio",
|
||||||
|
"mcu": "esp32p4",
|
||||||
|
"variant": "esp32p4",
|
||||||
|
"partitions": "partitions/esp32_partition_app2880k_fs320k.csv"
|
||||||
|
},
|
||||||
|
"connectivity": [
|
||||||
|
"wifi",
|
||||||
|
"bluetooth",
|
||||||
|
"openthread",
|
||||||
|
"ethernet"
|
||||||
|
],
|
||||||
|
"debug": {
|
||||||
|
"openocd_target": "esp32p4.cfg"
|
||||||
|
},
|
||||||
|
"frameworks": [
|
||||||
|
"arduino",
|
||||||
|
"espidf"
|
||||||
|
],
|
||||||
|
"name": "Espressif Generic ESP32-P4 >= 4M Flash, Tasmota 2880k Code/OTA, >= 320k FS",
|
||||||
|
"upload": {
|
||||||
|
"arduino": {
|
||||||
|
"flash_extra_images": [
|
||||||
|
[
|
||||||
|
"0x10000",
|
||||||
|
"tasmota32p4-safeboot.bin"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"flash_size": "4MB",
|
||||||
|
"maximum_ram_size": 768000,
|
||||||
|
"maximum_size": 4194304,
|
||||||
|
"require_upload_port": true,
|
||||||
|
"speed": 1500000
|
||||||
|
},
|
||||||
|
"url": "https://docs.espressif.com/projects/esp-dev-kits/en/latest/esp32p4/esp32-p4-function-ev-board/index.html",
|
||||||
|
"vendor": "Espressif"
|
||||||
|
}
|
||||||
@ -61,7 +61,7 @@
|
|||||||
// SPI_MOSI_DLEN_REG is not defined anymore in esp32s3
|
// SPI_MOSI_DLEN_REG is not defined anymore in esp32s3
|
||||||
#define SPI_MOSI_DLEN_REG(x) SPI_MS_DLEN_REG(x)
|
#define SPI_MOSI_DLEN_REG(x) SPI_MS_DLEN_REG(x)
|
||||||
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
|
#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C5 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
#define SPI_HOST SPI1_HOST
|
#define SPI_HOST SPI1_HOST
|
||||||
#define HSPI_HOST SPI2_HOST
|
#define HSPI_HOST SPI2_HOST
|
||||||
#define VSPI_HOST SPI2_HOST /* No SPI3_host on C2/C6 */
|
#define VSPI_HOST SPI2_HOST /* No SPI3_host on C2/C6 */
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "TasmotaSerial",
|
"name": "TasmotaSerial",
|
||||||
"version": "3.6.0",
|
"version": "3.7.0",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"serial", "io", "TasmotaSerial"
|
"serial", "io", "TasmotaSerial"
|
||||||
],
|
],
|
||||||
@ -1,5 +1,5 @@
|
|||||||
name=TasmotaSerial
|
name=TasmotaSerial
|
||||||
version=3.6.0
|
version=3.7.0
|
||||||
author=Theo Arends
|
author=Theo Arends
|
||||||
maintainer=Theo Arends <theo@arends.com>
|
maintainer=Theo Arends <theo@arends.com>
|
||||||
sentence=Implementation of software serial with hardware serial fallback for ESP8266 and ESP32.
|
sentence=Implementation of software serial with hardware serial fallback for ESP8266 and ESP32.
|
||||||
@ -27,6 +27,9 @@ extern "C" {
|
|||||||
|
|
||||||
#include <TasmotaSerial.h>
|
#include <TasmotaSerial.h>
|
||||||
|
|
||||||
|
extern void AddLog(uint32_t loglevel, PGM_P formatP, ...);
|
||||||
|
enum LoggingLevels {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE};
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
|
||||||
void IRAM_ATTR callRxRead(void *self) { ((TasmotaSerial*)self)->rxRead(); };
|
void IRAM_ATTR callRxRead(void *self) { ((TasmotaSerial*)self)->rxRead(); };
|
||||||
@ -152,6 +155,17 @@ void TasmotaSerial::setTransmitEnablePin(int tx_enable_pin) {
|
|||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
bool TasmotaSerial::freeUart(void) {
|
bool TasmotaSerial::freeUart(void) {
|
||||||
|
// If users selects default serial interface keep using UART0
|
||||||
|
// From cores\esp32\HardwareSerial.cpp: There is always Seria0 for UART0
|
||||||
|
int pin_soc_rx0 = gpioNumberToDigitalPin(SOC_RX0);
|
||||||
|
int pin_soc_tx0 = gpioNumberToDigitalPin(SOC_TX0);
|
||||||
|
if (((pin_soc_rx0 == m_rx_pin) && (pin_soc_tx0 == m_tx_pin)) ||
|
||||||
|
((pin_soc_rx0 == m_tx_pin) && (pin_soc_tx0 == m_rx_pin))) {
|
||||||
|
m_uart = uart_port_t(0);
|
||||||
|
bitSet(tasmota_serial_uart_bitmap, m_uart);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
// Find a free UART which may end up as UART0
|
||||||
for (uint32_t i = SOC_UART_HP_NUM -1; i >= 0; i--) {
|
for (uint32_t i = SOC_UART_HP_NUM -1; i >= 0; i--) {
|
||||||
if (0 == bitRead(tasmota_serial_uart_bitmap, i)) {
|
if (0 == bitRead(tasmota_serial_uart_bitmap, i)) {
|
||||||
m_uart = uart_port_t(i);
|
m_uart = uart_port_t(i);
|
||||||
@ -159,10 +173,15 @@ bool TasmotaSerial::freeUart(void) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TasmotaSerial::Esp32Begin(void) {
|
void TasmotaSerial::Esp32Begin(void) {
|
||||||
|
// Workaround IDF #14787 introduced in Tasmota v14.5.0, Core 3.1.1, IDF 5.3.2.250120
|
||||||
|
// which kept new Rx low instead of float
|
||||||
|
pinMode(m_rx_pin, INPUT_PULLUP);
|
||||||
|
pinMode(m_tx_pin, INPUT_PULLUP);
|
||||||
TSerial->begin(m_speed, m_config, m_rx_pin, m_tx_pin, m_invert);
|
TSerial->begin(m_speed, m_config, m_rx_pin, m_tx_pin, m_invert);
|
||||||
// For low bit rate, below 9600, set the Full RX threshold at 10 bytes instead of the default 120
|
// For low bit rate, below 9600, set the Full RX threshold at 10 bytes instead of the default 120
|
||||||
if (m_speed <= 9600) {
|
if (m_speed <= 9600) {
|
||||||
@ -251,10 +270,13 @@ bool TasmotaSerial::begin(uint32_t speed, uint32_t config) {
|
|||||||
#if ARDUINO_USB_MODE
|
#if ARDUINO_USB_MODE
|
||||||
TSerial = new HardwareSerial(m_uart);
|
TSerial = new HardwareSerial(m_uart);
|
||||||
#else
|
#else
|
||||||
if (0 == m_uart) {
|
if (0 == m_uart) { // From cores\esp32\HardwareSerial.cpp: There is always Seria0 for UART0
|
||||||
|
/*
|
||||||
|
// Not needed anymore since Core 3.1.0
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
Serial.end();
|
Serial.end();
|
||||||
delay(10); // Allow time to cleanup queues - if not used hangs ESP32
|
delay(10); // Allow time to cleanup queues - if not used hangs ESP32
|
||||||
|
*/
|
||||||
TSerial = &Serial;
|
TSerial = &Serial;
|
||||||
} else {
|
} else {
|
||||||
TSerial = new HardwareSerial(m_uart);
|
TSerial = new HardwareSerial(m_uart);
|
||||||
@ -1,8 +1,8 @@
|
|||||||
name=Unishox Compressor Decompressor highly customized and optimized for ESP8266 and Tasmota
|
name=Unishox (De)Compressor
|
||||||
version=1.0
|
version=1.0
|
||||||
author=Arundale Ramanathan, Stephan Hadinger
|
author=Arundale Ramanathan, Stephan Hadinger
|
||||||
maintainer=Arun <arun@siara.cc>, Stephan <stephan.hadinger@gmail.com>
|
maintainer=Arun <arun@siara.cc>, Stephan <stephan.hadinger@gmail.com>
|
||||||
sentence=Unishox compression for Tasmota Rules
|
sentence=Unishox compression for Tasmota Rules
|
||||||
paragraph=It is based on Unishox hybrid encoding technique. This version has specific Unicode code removed for size.
|
paragraph=It is based on Unishox hybrid encoding technique. This Tasmota version has specific Unicode code removed for size.
|
||||||
url=https://github.com/siara-cc/Unishox
|
url=https://github.com/siara-cc/Unishox
|
||||||
architectures=esp8266,esp32
|
architectures=esp8266,esp32
|
||||||
@ -166,6 +166,10 @@ int WiFiHelper::getPhyMode() {
|
|||||||
WIFI_PHY_MODE_HE20, // PHY mode for Bandwidth HE20 (11ax)
|
WIFI_PHY_MODE_HE20, // PHY mode for Bandwidth HE20 (11ax)
|
||||||
} wifi_phy_mode_t;
|
} wifi_phy_mode_t;
|
||||||
*/
|
*/
|
||||||
|
#ifndef SOC_WIFI_SUPPORTED
|
||||||
|
// ESP32-P4 does not support PHY modes, return 0
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
int phy_mode = 0; // "low rate|11b|11g|HT20|HT40|HE20"
|
int phy_mode = 0; // "low rate|11b|11g|HT20|HT40|HE20"
|
||||||
wifi_phy_mode_t WiFiMode;
|
wifi_phy_mode_t WiFiMode;
|
||||||
if (esp_wifi_sta_get_negotiated_phymode(&WiFiMode) == ESP_OK) {
|
if (esp_wifi_sta_get_negotiated_phymode(&WiFiMode) == ESP_OK) {
|
||||||
@ -175,9 +179,13 @@ int WiFiHelper::getPhyMode() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return phy_mode;
|
return phy_mode;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WiFiHelper::setPhyMode(WiFiPhyMode_t mode) {
|
bool WiFiHelper::setPhyMode(WiFiPhyMode_t mode) {
|
||||||
|
# ifndef SOC_WIFI_SUPPORTED
|
||||||
|
return false; // ESP32-P4 does not support PHY modes
|
||||||
|
# else
|
||||||
uint8_t protocol_bitmap = WIFI_PROTOCOL_11B; // 1
|
uint8_t protocol_bitmap = WIFI_PROTOCOL_11B; // 1
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
#if ESP_IDF_VERSION_MAJOR >= 5
|
||||||
@ -187,6 +195,7 @@ bool WiFiHelper::setPhyMode(WiFiPhyMode_t mode) {
|
|||||||
case 2: protocol_bitmap |= WIFI_PROTOCOL_11G; // 2
|
case 2: protocol_bitmap |= WIFI_PROTOCOL_11G; // 2
|
||||||
}
|
}
|
||||||
return (ESP_OK == esp_wifi_set_protocol(WIFI_IF_STA, protocol_bitmap));
|
return (ESP_OK == esp_wifi_set_protocol(WIFI_IF_STA, protocol_bitmap));
|
||||||
|
#endif // CONFIG_IDF_TARGET_ESP32P4
|
||||||
}
|
}
|
||||||
|
|
||||||
void WiFiHelper::setOutputPower(int n) {
|
void WiFiHelper::setOutputPower(int n) {
|
||||||
@ -370,8 +379,11 @@ String WiFiHelper::macAddress(void) {
|
|||||||
#else
|
#else
|
||||||
uint8_t mac[6] = {0,0,0,0,0,0};
|
uint8_t mac[6] = {0,0,0,0,0,0};
|
||||||
char macStr[18] = { 0 };
|
char macStr[18] = { 0 };
|
||||||
|
#ifdef CONFIG_SOC_HAS_WIFI
|
||||||
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
esp_read_mac(mac, ESP_MAC_WIFI_STA);
|
||||||
|
#else
|
||||||
|
esp_read_mac(mac, ESP_MAC_BASE);
|
||||||
|
#endif // CONFIG_SOC_HAS_WIFI
|
||||||
snprintf(macStr, sizeof(macStr), "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
snprintf(macStr, sizeof(macStr), "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
||||||
return String(macStr);
|
return String(macStr);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -29,12 +29,12 @@ License along with NeoPixel. If not, see
|
|||||||
|
|
||||||
#include "driver/spi_master.h"
|
#include "driver/spi_master.h"
|
||||||
|
|
||||||
#if (defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C6)) && !defined(HSPI_HOST)
|
#if (defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C5) || defined(CONFIG_IDF_TARGET_ESP32C6)) && !defined(HSPI_HOST)
|
||||||
// HSPI_HOST depreciated in C3
|
// HSPI_HOST depreciated in C3
|
||||||
#define HSPI_HOST SPI2_HOST
|
#define HSPI_HOST SPI2_HOST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
class Esp32VspiBus
|
class Esp32VspiBus
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -52,7 +52,7 @@ public:
|
|||||||
const static int ParallelBits = 1;
|
const static int ParallelBits = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
class Esp32Vspi2BitBus
|
class Esp32Vspi2BitBus
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
const static int ParallelBits = 2;
|
const static int ParallelBits = 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
class Esp32Vspi4BitBus
|
class Esp32Vspi4BitBus
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -174,7 +174,7 @@ public:
|
|||||||
// If pins aren't specified, initialize bus with just the default SCK and MOSI pins for the SPI peripheral (no SS, no >1-bit pins)
|
// If pins aren't specified, initialize bus with just the default SCK and MOSI pins for the SPI peripheral (no SS, no >1-bit pins)
|
||||||
void Initialize()
|
void Initialize()
|
||||||
{
|
{
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
if (T_SPIBUS::SpiHostDevice == VSPI_HOST)
|
if (T_SPIBUS::SpiHostDevice == VSPI_HOST)
|
||||||
{
|
{
|
||||||
Initialize(SCK, -1, MOSI, -1, -1, -1);
|
Initialize(SCK, -1, MOSI, -1, -1, -1);
|
||||||
@ -277,7 +277,7 @@ private:
|
|||||||
int8_t _ssPin;
|
int8_t _ssPin;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
// Clock Speed and Default Definitions for DotStarEsp32DmaVspi
|
// Clock Speed and Default Definitions for DotStarEsp32DmaVspi
|
||||||
typedef DotStarEsp32DmaSpiMethod<SpiSpeed40Mhz, Esp32VspiBus> DotStarEsp32DmaVspi40MhzMethod;
|
typedef DotStarEsp32DmaSpiMethod<SpiSpeed40Mhz, Esp32VspiBus> DotStarEsp32DmaVspi40MhzMethod;
|
||||||
typedef DotStarEsp32DmaSpiMethod<SpiSpeed20Mhz, Esp32VspiBus> DotStarEsp32DmaVspi20MhzMethod;
|
typedef DotStarEsp32DmaSpiMethod<SpiSpeed20Mhz, Esp32VspiBus> DotStarEsp32DmaVspi20MhzMethod;
|
||||||
@ -303,7 +303,7 @@ typedef DotStarEsp32DmaSpiMethod<SpiSpeedHz, Esp32HspiBus> DotStarEsp32DmaHspiHz
|
|||||||
|
|
||||||
typedef DotStarEsp32DmaHspi10MhzMethod DotStarEsp32DmaHspiMethod;
|
typedef DotStarEsp32DmaHspi10MhzMethod DotStarEsp32DmaHspiMethod;
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
// Clock Speed and Default Definitions for DotStarEsp32DmaVspi2Bit
|
// Clock Speed and Default Definitions for DotStarEsp32DmaVspi2Bit
|
||||||
typedef DotStarEsp32DmaSpiMethod<SpiSpeed40Mhz,Esp32Vspi2BitBus> DotStarEsp32DmaVspi2Bit40MhzMethod;
|
typedef DotStarEsp32DmaSpiMethod<SpiSpeed40Mhz,Esp32Vspi2BitBus> DotStarEsp32DmaVspi2Bit40MhzMethod;
|
||||||
typedef DotStarEsp32DmaSpiMethod<SpiSpeed20Mhz,Esp32Vspi2BitBus> DotStarEsp32DmaVspi2Bit20MhzMethod;
|
typedef DotStarEsp32DmaSpiMethod<SpiSpeed20Mhz,Esp32Vspi2BitBus> DotStarEsp32DmaVspi2Bit20MhzMethod;
|
||||||
@ -329,7 +329,7 @@ typedef DotStarEsp32DmaSpiMethod<SpiSpeedHz,Esp32Hspi2BitBus> DotStarEsp32DmaHsp
|
|||||||
|
|
||||||
typedef DotStarEsp32DmaHspi2Bit10MhzMethod DotStarEsp32DmaHspi2BitMethod;
|
typedef DotStarEsp32DmaHspi2Bit10MhzMethod DotStarEsp32DmaHspi2BitMethod;
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
// Clock Speed and Default Definitions for DotStarEsp32DmaVspi4Bit
|
// Clock Speed and Default Definitions for DotStarEsp32DmaVspi4Bit
|
||||||
typedef DotStarEsp32DmaSpiMethod<SpiSpeed40Mhz,Esp32Vspi4BitBus> DotStarEsp32DmaVspi4Bit40MhzMethod;
|
typedef DotStarEsp32DmaSpiMethod<SpiSpeed40Mhz,Esp32Vspi4BitBus> DotStarEsp32DmaVspi4Bit40MhzMethod;
|
||||||
typedef DotStarEsp32DmaSpiMethod<SpiSpeed20Mhz,Esp32Vspi4BitBus> DotStarEsp32DmaVspi4Bit20MhzMethod;
|
typedef DotStarEsp32DmaSpiMethod<SpiSpeed20Mhz,Esp32Vspi4BitBus> DotStarEsp32DmaVspi4Bit20MhzMethod;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ enum NeoBusChannel
|
|||||||
NeoBusChannel_0,
|
NeoBusChannel_0,
|
||||||
NeoBusChannel_1,
|
NeoBusChannel_1,
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
|
|
||||||
NeoBusChannel_2,
|
NeoBusChannel_2,
|
||||||
|
|
||||||
|
|||||||
@ -32,7 +32,7 @@ License along with NeoPixel. If not, see
|
|||||||
#include "NeoBusChannel.h"
|
#include "NeoBusChannel.h"
|
||||||
#include "NeoEsp32RmtMethod.h"
|
#include "NeoEsp32RmtMethod.h"
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32C2)
|
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5)
|
||||||
|
|
||||||
|
|
||||||
// translate NeoPixelBuffer into RMT buffer
|
// translate NeoPixelBuffer into RMT buffer
|
||||||
|
|||||||
@ -29,7 +29,7 @@ License along with NeoPixel. If not, see
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32C2)
|
#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5)
|
||||||
|
|
||||||
/* General Reference documentation for the APIs used in this implementation
|
/* General Reference documentation for the APIs used in this implementation
|
||||||
LOW LEVEL: (what is actually used)
|
LOW LEVEL: (what is actually used)
|
||||||
@ -454,7 +454,7 @@ public:
|
|||||||
const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_3;
|
const static rmt_channel_t RmtChannelNumber = RMT_CHANNEL_3;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
|
|
||||||
class NeoEsp32RmtChannel4
|
class NeoEsp32RmtChannel4
|
||||||
{
|
{
|
||||||
|
|||||||
@ -399,7 +399,7 @@ public:
|
|||||||
rmt_channel_handle_t RmtChannelNumber = NULL;
|
rmt_channel_handle_t RmtChannelNumber = NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32C6) // C6 only 2 RMT channels ??
|
#if !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6) // C5 & C6 only 2 RMT channels
|
||||||
class NeoEsp32RmtChannel2
|
class NeoEsp32RmtChannel2
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -417,7 +417,7 @@ protected:
|
|||||||
rmt_channel_handle_t RmtChannelNumber = NULL;
|
rmt_channel_handle_t RmtChannelNumber = NULL;
|
||||||
};
|
};
|
||||||
#endif // !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#endif // !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
|
|
||||||
class NeoEsp32RmtChannel4
|
class NeoEsp32RmtChannel4
|
||||||
{
|
{
|
||||||
@ -634,7 +634,7 @@ typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeedTx1812, NeoEsp32RmtChannel1> NeoEs
|
|||||||
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeed800Kbps, NeoEsp32RmtChannel1> NeoEsp32Rmt1800KbpsMethod;
|
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeed800Kbps, NeoEsp32RmtChannel1> NeoEsp32Rmt1800KbpsMethod;
|
||||||
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeed400Kbps, NeoEsp32RmtChannel1> NeoEsp32Rmt1400KbpsMethod;
|
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeed400Kbps, NeoEsp32RmtChannel1> NeoEsp32Rmt1400KbpsMethod;
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
|
|
||||||
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeedWs2811, NeoEsp32RmtChannel2> NeoEsp32Rmt2Ws2811Method;
|
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeedWs2811, NeoEsp32RmtChannel2> NeoEsp32Rmt2Ws2811Method;
|
||||||
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeedWs2812x, NeoEsp32RmtChannel2> NeoEsp32Rmt2Ws2812xMethod;
|
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtSpeedWs2812x, NeoEsp32RmtChannel2> NeoEsp32Rmt2Ws2812xMethod;
|
||||||
@ -741,7 +741,7 @@ typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeedTx1812, NeoEsp32RmtChannel
|
|||||||
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeed800Kbps, NeoEsp32RmtChannel1> NeoEsp32Rmt1800KbpsInvertedMethod;
|
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeed800Kbps, NeoEsp32RmtChannel1> NeoEsp32Rmt1800KbpsInvertedMethod;
|
||||||
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeed400Kbps, NeoEsp32RmtChannel1> NeoEsp32Rmt1400KbpsInvertedMethod;
|
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeed400Kbps, NeoEsp32RmtChannel1> NeoEsp32Rmt1400KbpsInvertedMethod;
|
||||||
|
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
|
|
||||||
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeedWs2811, NeoEsp32RmtChannel2> NeoEsp32Rmt2Ws2811InvertedMethod;
|
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeedWs2811, NeoEsp32RmtChannel2> NeoEsp32Rmt2Ws2811InvertedMethod;
|
||||||
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeedWs2812x, NeoEsp32RmtChannel2> NeoEsp32Rmt2Ws2812xInvertedMethod;
|
typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeedWs2812x, NeoEsp32RmtChannel2> NeoEsp32Rmt2Ws2812xInvertedMethod;
|
||||||
@ -815,13 +815,13 @@ typedef NeoEsp32RmtMethodBase<NeoEsp32RmtInvertedSpeed400Kbps, NeoEsp32RmtChanne
|
|||||||
#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#endif // !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
|
|
||||||
|
|
||||||
#if defined(NEOPIXEL_ESP32_RMT_DEFAULT) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if defined(NEOPIXEL_ESP32_RMT_DEFAULT) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C5) || defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
|
|
||||||
// Normally I2s method is the default, defining NEOPIXEL_ESP32_RMT_DEFAULT
|
// Normally I2s method is the default, defining NEOPIXEL_ESP32_RMT_DEFAULT
|
||||||
// will switch to use RMT as the default method
|
// will switch to use RMT as the default method
|
||||||
// The ESP32S2 & ESP32C3 will always defualt to RMT
|
// The ESP32S2 & ESP32C3 will always defualt to RMT
|
||||||
|
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C5) || defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
|
|
||||||
// RMT channel 1 method is the default method for Esp32S2 & Esp32C3
|
// RMT channel 1 method is the default method for Esp32S2 & Esp32C3
|
||||||
typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2813Method;
|
typedef NeoEsp32Rmt1Ws2812xMethod NeoWs2813Method;
|
||||||
|
|||||||
@ -30,7 +30,7 @@ License along with NeoPixel. If not, see
|
|||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
|
|
||||||
#if (defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C6)) && !defined(HSPI_HOST)
|
#if (defined(CONFIG_IDF_TARGET_ESP32C3) || defined(CONFIG_IDF_TARGET_ESP32C2) || defined(CONFIG_IDF_TARGET_ESP32C5) || defined(CONFIG_IDF_TARGET_ESP32C6)) && !defined(HSPI_HOST)
|
||||||
// HSPI_HOST depreciated in C3
|
// HSPI_HOST depreciated in C3
|
||||||
#define HSPI_HOST SPI2_HOST
|
#define HSPI_HOST SPI2_HOST
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -29,7 +29,7 @@ License along with NeoPixel. If not, see
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
// ESP32C3 I2S is not supported yet
|
// ESP32C3 I2S is not supported yet
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
#if !defined(ARDUINO_ARCH_ESP8266)
|
#if !defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include "soc/gpio_periph.h"
|
#include "soc/gpio_periph.h"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -29,7 +29,7 @@ License along with NeoPixel. If not, see
|
|||||||
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
#if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32)
|
||||||
|
|
||||||
// ESP32C3 I2S is not supported yet
|
// ESP32C3 I2S is not supported yet
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
#if !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C5) && !defined(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
|
|
||||||
#if defined(ARDUINO_ARCH_ESP8266)
|
#if defined(ARDUINO_ARCH_ESP8266)
|
||||||
#include <eagle_soc.h>
|
#include <eagle_soc.h>
|
||||||
|
|||||||
@ -235,7 +235,7 @@ bool directRead(IO_REG_TYPE mask)
|
|||||||
static inline __attribute__((always_inline))
|
static inline __attribute__((always_inline))
|
||||||
IO_REG_TYPE directRead(IO_REG_TYPE pin)
|
IO_REG_TYPE directRead(IO_REG_TYPE pin)
|
||||||
{
|
{
|
||||||
#if SOC_GPIO_PIN_COUNT <= 32
|
#if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
return (GPIO.in.val >> pin) & 0x1;
|
return (GPIO.in.val >> pin) & 0x1;
|
||||||
#else // ESP32 with over 32 gpios
|
#else // ESP32 with over 32 gpios
|
||||||
if ( pin < 32 )
|
if ( pin < 32 )
|
||||||
@ -250,7 +250,7 @@ IO_REG_TYPE directRead(IO_REG_TYPE pin)
|
|||||||
static inline __attribute__((always_inline))
|
static inline __attribute__((always_inline))
|
||||||
void directWriteLow(IO_REG_TYPE pin)
|
void directWriteLow(IO_REG_TYPE pin)
|
||||||
{
|
{
|
||||||
#if SOC_GPIO_PIN_COUNT <= 32
|
#if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
GPIO.out_w1tc.val = ((uint32_t)1 << pin);
|
GPIO.out_w1tc.val = ((uint32_t)1 << pin);
|
||||||
#else // ESP32 with over 32 gpios
|
#else // ESP32 with over 32 gpios
|
||||||
if ( pin < 32 )
|
if ( pin < 32 )
|
||||||
@ -263,7 +263,7 @@ void directWriteLow(IO_REG_TYPE pin)
|
|||||||
static inline __attribute__((always_inline))
|
static inline __attribute__((always_inline))
|
||||||
void directWriteHigh(IO_REG_TYPE pin)
|
void directWriteHigh(IO_REG_TYPE pin)
|
||||||
{
|
{
|
||||||
#if SOC_GPIO_PIN_COUNT <= 32
|
#if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
GPIO.out_w1ts.val = ((uint32_t)1 << pin);
|
GPIO.out_w1ts.val = ((uint32_t)1 << pin);
|
||||||
#else // ESP32 with over 32 gpios
|
#else // ESP32 with over 32 gpios
|
||||||
if ( pin < 32 )
|
if ( pin < 32 )
|
||||||
@ -280,7 +280,7 @@ void directModeInput(IO_REG_TYPE pin)
|
|||||||
if ( digitalPinIsValid(pin) )
|
if ( digitalPinIsValid(pin) )
|
||||||
{
|
{
|
||||||
// Input
|
// Input
|
||||||
#if SOC_GPIO_PIN_COUNT <= 32
|
#if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
GPIO.enable_w1tc.val = ((uint32_t)1 << (pin));
|
GPIO.enable_w1tc.val = ((uint32_t)1 << (pin));
|
||||||
#else // ESP32 with over 32 gpios
|
#else // ESP32 with over 32 gpios
|
||||||
if ( pin < 32 )
|
if ( pin < 32 )
|
||||||
@ -298,7 +298,7 @@ void directModeOutput(IO_REG_TYPE pin)
|
|||||||
if ( digitalPinCanOutput(pin) )
|
if ( digitalPinCanOutput(pin) )
|
||||||
{
|
{
|
||||||
// Output
|
// Output
|
||||||
#if SOC_GPIO_PIN_COUNT <= 32
|
#if SOC_GPIO_PIN_COUNT <= 32 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
GPIO.enable_w1ts.val = ((uint32_t)1 << (pin));
|
GPIO.enable_w1ts.val = ((uint32_t)1 << (pin));
|
||||||
#else // ESP32 with over 32 gpios
|
#else // ESP32 with over 32 gpios
|
||||||
if ( pin < 32 )
|
if ( pin < 32 )
|
||||||
|
|||||||
@ -599,11 +599,8 @@ uDisplay::uDisplay(char *lp) : Renderer(800, 600) {
|
|||||||
case 'B':
|
case 'B':
|
||||||
lvgl_param.flushlines = next_val(&lp1);
|
lvgl_param.flushlines = next_val(&lp1);
|
||||||
lvgl_param.data = next_val(&lp1);
|
lvgl_param.data = next_val(&lp1);
|
||||||
// temporary fix to disable DMA due to a problem in esp-idf 5.3
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 0)
|
lvgl_param.use_dma = false; // temporary fix to disable DMA due to a problem in esp-idf 5.3
|
||||||
lvgl_param.use_dma = false;
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'M':
|
case 'M':
|
||||||
@ -1241,11 +1238,7 @@ Renderer *uDisplay::Init(void) {
|
|||||||
_panel_config->disp_gpio_num = GPIO_NUM_NC;
|
_panel_config->disp_gpio_num = GPIO_NUM_NC;
|
||||||
|
|
||||||
_panel_config->flags.disp_active_low = 0;
|
_panel_config->flags.disp_active_low = 0;
|
||||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
|
||||||
_panel_config->flags.refresh_on_demand = 0;
|
_panel_config->flags.refresh_on_demand = 0;
|
||||||
#else
|
|
||||||
_panel_config->flags.relax_on_idle = 0;
|
|
||||||
#endif // ESP_IDF_VERSION_MAJOR >= 5
|
|
||||||
_panel_config->flags.fb_in_psram = 1; // allocate frame buffer in PSRAM
|
_panel_config->flags.fb_in_psram = 1; // allocate frame buffer in PSRAM
|
||||||
|
|
||||||
ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(_panel_config, &_panel_handle));
|
ESP_ERROR_CHECK(esp_lcd_new_rgb_panel(_panel_config, &_panel_handle));
|
||||||
@ -1255,16 +1248,9 @@ Renderer *uDisplay::Init(void) {
|
|||||||
uint16_t color = random(0xffff);
|
uint16_t color = random(0xffff);
|
||||||
ESP_ERROR_CHECK(_panel_handle->draw_bitmap(_panel_handle, 0, 0, 1, 1, &color));
|
ESP_ERROR_CHECK(_panel_handle->draw_bitmap(_panel_handle, 0, 0, 1, 1, &color));
|
||||||
|
|
||||||
#if ESP_IDF_VERSION_MAJOR < 5
|
|
||||||
_rgb_panel = __containerof(_panel_handle, esp_rgb_panel_t, base);
|
|
||||||
rgb_fb = (uint16_t *)_rgb_panel->fb;
|
|
||||||
#else
|
|
||||||
void * buf = NULL;
|
void * buf = NULL;
|
||||||
esp_lcd_rgb_panel_get_frame_buffer(_panel_handle, 1, &buf);
|
esp_lcd_rgb_panel_get_frame_buffer(_panel_handle, 1, &buf);
|
||||||
rgb_fb = (uint16_t *)buf;
|
rgb_fb = (uint16_t *)buf;
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // USE_ESP32_S3
|
#endif // USE_ESP32_S3
|
||||||
}
|
}
|
||||||
@ -1340,10 +1326,6 @@ Renderer *uDisplay::Init(void) {
|
|||||||
|
|
||||||
esp_lcd_new_i80_bus(&bus_config, &_i80_bus);
|
esp_lcd_new_i80_bus(&bus_config, &_i80_bus);
|
||||||
|
|
||||||
#if ESP_IDF_VERSION_MAJOR < 5
|
|
||||||
_dma_chan = _i80_bus->dma_chan;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
uint32_t div_a, div_b, div_n, clkcnt;
|
uint32_t div_a, div_b, div_n, clkcnt;
|
||||||
calcClockDiv(&div_a, &div_b, &div_n, &clkcnt, 240*1000*1000, spi_speed*1000000);
|
calcClockDiv(&div_a, &div_b, &div_n, &clkcnt, 240*1000*1000, spi_speed*1000000);
|
||||||
lcd_cam_lcd_clock_reg_t lcd_clock;
|
lcd_cam_lcd_clock_reg_t lcd_clock;
|
||||||
|
|||||||
@ -11,10 +11,8 @@
|
|||||||
#define USE_ESP32_S3
|
#define USE_ESP32_S3
|
||||||
#endif
|
#endif
|
||||||
#include "driver/spi_master.h"
|
#include "driver/spi_master.h"
|
||||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
|
||||||
#include "soc/gpio_periph.h"
|
#include "soc/gpio_periph.h"
|
||||||
#include <rom/gpio.h>
|
#include <rom/gpio.h>
|
||||||
#endif // ESP_IDF_VERSION_MAJOR >= 5
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -56,9 +54,7 @@ static inline void gpio_lo(int_fast8_t pin) { if (pin >= 0) *get_gpio_lo_reg(pin
|
|||||||
#include "esp_lcd_panel_ops.h"
|
#include "esp_lcd_panel_ops.h"
|
||||||
#include <hal/dma_types.h>
|
#include <hal/dma_types.h>
|
||||||
#include <rom/cache.h>
|
#include <rom/cache.h>
|
||||||
#if ESP_IDF_VERSION_MAJOR >= 5
|
|
||||||
#include "esp_rom_lldesc.h"
|
#include "esp_rom_lldesc.h"
|
||||||
#endif // ESP_IDF_VERSION_MAJOR >= 5
|
|
||||||
#endif // USE_ESP32_S3
|
#endif // USE_ESP32_S3
|
||||||
|
|
||||||
#define _UDSP_I2C 1
|
#define _UDSP_I2C 1
|
||||||
@ -112,7 +108,7 @@ enum uColorType { uCOLOR_BW, uCOLOR_COLOR };
|
|||||||
#undef GPIO_SET_SLOW
|
#undef GPIO_SET_SLOW
|
||||||
#undef GPIO_CLR_SLOW
|
#undef GPIO_CLR_SLOW
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6
|
#if CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C5 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
#define GPIO_CLR(A) GPIO.out_w1tc.val = (1 << A)
|
#define GPIO_CLR(A) GPIO.out_w1tc.val = (1 << A)
|
||||||
#define GPIO_SET(A) GPIO.out_w1ts.val = (1 << A)
|
#define GPIO_SET(A) GPIO.out_w1ts.val = (1 << A)
|
||||||
#else // plain ESP32
|
#else // plain ESP32
|
||||||
@ -136,57 +132,6 @@ enum uColorType { uCOLOR_BW, uCOLOR_COLOR };
|
|||||||
#define SPI_DC_LOW if (spi_dc >= 0) GPIO_CLR_SLOW(spi_dc);
|
#define SPI_DC_LOW if (spi_dc >= 0) GPIO_CLR_SLOW(spi_dc);
|
||||||
#define SPI_DC_HIGH if (spi_dc >= 0) GPIO_SET_SLOW(spi_dc);
|
#define SPI_DC_HIGH if (spi_dc >= 0) GPIO_SET_SLOW(spi_dc);
|
||||||
|
|
||||||
|
|
||||||
#if defined(USE_ESP32_S3) && ESP_IDF_VERSION_MAJOR < 5
|
|
||||||
struct esp_lcd_i80_bus_t {
|
|
||||||
int bus_id; // Bus ID, index from 0
|
|
||||||
portMUX_TYPE spinlock; // spinlock used to protect i80 bus members(hal, device_list, cur_trans)
|
|
||||||
lcd_hal_context_t hal; // Hal object
|
|
||||||
size_t bus_width; // Number of data lines
|
|
||||||
intr_handle_t intr; // LCD peripheral interrupt handle
|
|
||||||
void* pm_lock; // Power management lock
|
|
||||||
size_t num_dma_nodes; // Number of DMA descriptors
|
|
||||||
uint8_t *format_buffer; // The driver allocates an internal buffer for DMA to do data format transformer
|
|
||||||
size_t resolution_hz; // LCD_CLK resolution, determined by selected clock source
|
|
||||||
gdma_channel_handle_t dma_chan; // DMA channel handle
|
|
||||||
};
|
|
||||||
|
|
||||||
// extract from esp-idf esp_lcd_rgb_panel.c
|
|
||||||
struct esp_rgb_panel_t
|
|
||||||
{
|
|
||||||
esp_lcd_panel_t base; // Base class of generic lcd panel
|
|
||||||
int panel_id; // LCD panel ID
|
|
||||||
lcd_hal_context_t hal; // Hal layer object
|
|
||||||
size_t data_width; // Number of data lines (e.g. for RGB565, the data width is 16)
|
|
||||||
size_t sram_trans_align; // Alignment for framebuffer that allocated in SRAM
|
|
||||||
size_t psram_trans_align; // Alignment for framebuffer that allocated in PSRAM
|
|
||||||
int disp_gpio_num; // Display control GPIO, which is used to perform action like "disp_off"
|
|
||||||
intr_handle_t intr; // LCD peripheral interrupt handle
|
|
||||||
esp_pm_lock_handle_t pm_lock; // Power management lock
|
|
||||||
size_t num_dma_nodes; // Number of DMA descriptors that used to carry the frame buffer
|
|
||||||
uint8_t *fb; // Frame buffer
|
|
||||||
size_t fb_size; // Size of frame buffer
|
|
||||||
int data_gpio_nums[SOC_LCD_RGB_DATA_WIDTH]; // GPIOs used for data lines, we keep these GPIOs for action like "invert_color"
|
|
||||||
size_t resolution_hz; // Peripheral clock resolution
|
|
||||||
esp_lcd_rgb_timing_t timings; // RGB timing parameters (e.g. pclk, sync pulse, porch width)
|
|
||||||
gdma_channel_handle_t dma_chan; // DMA channel handle
|
|
||||||
#if ESP_IDF_VERSION_MAJOR < 5
|
|
||||||
esp_lcd_rgb_panel_frame_trans_done_cb_t on_frame_trans_done; // Callback, invoked after frame trans done
|
|
||||||
#endif // ESP_IDF_VERSION_MAJOR < 5
|
|
||||||
void *user_ctx; // Reserved user's data of callback functions
|
|
||||||
int x_gap; // Extra gap in x coordinate, it's used when calculate the flush window
|
|
||||||
int y_gap; // Extra gap in y coordinate, it's used when calculate the flush window
|
|
||||||
struct
|
|
||||||
{
|
|
||||||
unsigned int disp_en_level : 1; // The level which can turn on the screen by `disp_gpio_num`
|
|
||||||
unsigned int stream_mode : 1; // If set, the LCD transfers data continuously, otherwise, it stops refreshing the LCD when transaction done
|
|
||||||
unsigned int fb_in_psram : 1; // Whether the frame buffer is in PSRAM
|
|
||||||
} flags;
|
|
||||||
dma_descriptor_t dma_nodes[]; // DMA descriptor pool of size `num_dma_nodes`
|
|
||||||
};
|
|
||||||
#endif //USE_ESP32_S3 && ESP_IDF_VERSION_MAJOR < 5
|
|
||||||
|
|
||||||
|
|
||||||
class uDisplay : public Renderer {
|
class uDisplay : public Renderer {
|
||||||
public:
|
public:
|
||||||
uDisplay(char *);
|
uDisplay(char *);
|
||||||
@ -393,11 +338,6 @@ class uDisplay : public Renderer {
|
|||||||
uint16_t pclk_active_neg;
|
uint16_t pclk_active_neg;
|
||||||
|
|
||||||
esp_lcd_panel_handle_t _panel_handle = NULL;
|
esp_lcd_panel_handle_t _panel_handle = NULL;
|
||||||
#if ESP_IDF_VERSION_MAJOR < 5
|
|
||||||
esp_rgb_panel_t *_rgb_panel;
|
|
||||||
#endif //ESP_IDF_VERSION_MAJOR < 5
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
esp_lcd_i80_bus_handle_t _i80_bus = nullptr;
|
esp_lcd_i80_bus_handle_t _i80_bus = nullptr;
|
||||||
gdma_channel_handle_t _dma_chan;
|
gdma_channel_handle_t _dma_chan;
|
||||||
|
|||||||
@ -1,410 +0,0 @@
|
|||||||
/*
|
|
||||||
OpenTherm.cpp - OpenTherm Communication Library For Arduino, ESP8266
|
|
||||||
Copyright 2018, Ihor Melnyk
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "OpenTherm.h"
|
|
||||||
|
|
||||||
OpenTherm::OpenTherm(int inPin, int outPin, bool isSlave):
|
|
||||||
status(OpenThermStatus::OPTH_NOT_INITIALIZED),
|
|
||||||
inPin(inPin),
|
|
||||||
outPin(outPin),
|
|
||||||
isSlave(isSlave),
|
|
||||||
response(0),
|
|
||||||
responseStatus(OpenThermResponseStatus::OPTH_NONE),
|
|
||||||
responseTimestamp(0),
|
|
||||||
handleInterruptCallback(NULL),
|
|
||||||
processResponseCallback(NULL)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenTherm::begin(void(*handleInterruptCallback)(void), void(*processResponseCallback)(unsigned long, int))
|
|
||||||
{
|
|
||||||
pinMode(inPin, INPUT);
|
|
||||||
pinMode(outPin, OUTPUT);
|
|
||||||
if (handleInterruptCallback != NULL) {
|
|
||||||
this->handleInterruptCallback = handleInterruptCallback;
|
|
||||||
attachInterrupt(digitalPinToInterrupt(inPin), handleInterruptCallback, CHANGE);
|
|
||||||
}
|
|
||||||
activateBoiler();
|
|
||||||
status = OpenThermStatus::OPTH_READY;
|
|
||||||
this->processResponseCallback = processResponseCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenTherm::begin(void(*handleInterruptCallback)(void))
|
|
||||||
{
|
|
||||||
begin(handleInterruptCallback, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ICACHE_RAM_ATTR OpenTherm::isReady()
|
|
||||||
{
|
|
||||||
return status == OpenThermStatus::OPTH_READY;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ICACHE_RAM_ATTR OpenTherm::readState() {
|
|
||||||
return digitalRead(inPin);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenTherm::setActiveState() {
|
|
||||||
digitalWrite(outPin, LOW);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenTherm::setIdleState() {
|
|
||||||
digitalWrite(outPin, HIGH);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenTherm::activateBoiler() {
|
|
||||||
setIdleState();
|
|
||||||
delay(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenTherm::sendBit(bool high) {
|
|
||||||
if (high) setActiveState(); else setIdleState();
|
|
||||||
delayMicroseconds(500);
|
|
||||||
if (high) setIdleState(); else setActiveState();
|
|
||||||
delayMicroseconds(500);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::sendRequestAync(unsigned long request)
|
|
||||||
{
|
|
||||||
//Serial.println("Request: " + String(request, HEX));
|
|
||||||
noInterrupts();
|
|
||||||
const bool ready = isReady();
|
|
||||||
interrupts();
|
|
||||||
|
|
||||||
if (!ready)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
status = OpenThermStatus::OPTH_REQUEST_SENDING;
|
|
||||||
response = 0;
|
|
||||||
responseStatus = OpenThermResponseStatus::OPTH_NONE;
|
|
||||||
|
|
||||||
sendBit(HIGH); //start bit
|
|
||||||
for (int i = 31; i >= 0; i--) {
|
|
||||||
sendBit(bitRead(request, i));
|
|
||||||
}
|
|
||||||
sendBit(HIGH); //stop bit
|
|
||||||
setIdleState();
|
|
||||||
|
|
||||||
status = OpenThermStatus::OPTH_RESPONSE_WAITING;
|
|
||||||
responseTimestamp = micros();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long OpenTherm::sendRequest(unsigned long request)
|
|
||||||
{
|
|
||||||
if (!sendRequestAync(request)) return 0;
|
|
||||||
while (!isReady()) {
|
|
||||||
process();
|
|
||||||
yield();
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::sendResponse(unsigned long request)
|
|
||||||
{
|
|
||||||
status = OpenThermStatus::OPTH_REQUEST_SENDING;
|
|
||||||
response = 0;
|
|
||||||
responseStatus = OpenThermResponseStatus::OPTH_NONE;
|
|
||||||
|
|
||||||
sendBit(HIGH); //start bit
|
|
||||||
for (int i = 31; i >= 0; i--) {
|
|
||||||
sendBit(bitRead(request, i));
|
|
||||||
}
|
|
||||||
sendBit(HIGH); //stop bit
|
|
||||||
setIdleState();
|
|
||||||
status = OpenThermStatus::OPTH_READY;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenThermResponseStatus OpenTherm::getLastResponseStatus()
|
|
||||||
{
|
|
||||||
return responseStatus;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ICACHE_RAM_ATTR OpenTherm::handleInterrupt()
|
|
||||||
{
|
|
||||||
if (isReady())
|
|
||||||
{
|
|
||||||
if (isSlave && readState() == HIGH) {
|
|
||||||
status = OpenThermStatus::OPTH_RESPONSE_WAITING;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long newTs = micros();
|
|
||||||
if (status == OpenThermStatus::OPTH_RESPONSE_WAITING) {
|
|
||||||
if (readState() == HIGH) {
|
|
||||||
status = OpenThermStatus::OPTH_RESPONSE_START_BIT;
|
|
||||||
responseTimestamp = newTs;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
status = OpenThermStatus::OPTH_RESPONSE_INVALID;
|
|
||||||
responseTimestamp = newTs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (status == OpenThermStatus::OPTH_RESPONSE_START_BIT) {
|
|
||||||
if ((newTs - responseTimestamp < 750) && readState() == LOW) {
|
|
||||||
status = OpenThermStatus::OPTH_RESPONSE_RECEIVING;
|
|
||||||
responseTimestamp = newTs;
|
|
||||||
responseBitIndex = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
status = OpenThermStatus::OPTH_RESPONSE_INVALID;
|
|
||||||
responseTimestamp = newTs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (status == OpenThermStatus::OPTH_RESPONSE_RECEIVING) {
|
|
||||||
if ((newTs - responseTimestamp) > 750) {
|
|
||||||
if (responseBitIndex < 32) {
|
|
||||||
response = (response << 1) | !readState();
|
|
||||||
responseTimestamp = newTs;
|
|
||||||
responseBitIndex++;
|
|
||||||
}
|
|
||||||
else { //stop bit
|
|
||||||
status = OpenThermStatus::OPTH_RESPONSE_READY;
|
|
||||||
responseTimestamp = newTs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenTherm::process()
|
|
||||||
{
|
|
||||||
noInterrupts();
|
|
||||||
OpenThermStatus st = status;
|
|
||||||
unsigned long ts = responseTimestamp;
|
|
||||||
interrupts();
|
|
||||||
|
|
||||||
if (st == OpenThermStatus::OPTH_READY) return;
|
|
||||||
unsigned long newTs = micros();
|
|
||||||
if (st != OpenThermStatus::OPTH_NOT_INITIALIZED && (newTs - ts) > 1000000) {
|
|
||||||
status = OpenThermStatus::OPTH_READY;
|
|
||||||
responseStatus = OpenThermResponseStatus::OPTH_TIMEOUT;
|
|
||||||
if (processResponseCallback != NULL) {
|
|
||||||
processResponseCallback(response, responseStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (st == OpenThermStatus::OPTH_RESPONSE_INVALID) {
|
|
||||||
status = OpenThermStatus::OPTH_DELAY;
|
|
||||||
responseStatus = OpenThermResponseStatus::OPTH_INVALID;
|
|
||||||
if (processResponseCallback != NULL) {
|
|
||||||
processResponseCallback(response, responseStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (st == OpenThermStatus::OPTH_RESPONSE_READY) {
|
|
||||||
status = OpenThermStatus::OPTH_DELAY;
|
|
||||||
responseStatus = (isSlave ? isValidRequest(response) : isValidResponse(response)) ? OpenThermResponseStatus::OPTH_SUCCESS : OpenThermResponseStatus::OPTH_INVALID;
|
|
||||||
if (processResponseCallback != NULL) {
|
|
||||||
processResponseCallback(response, responseStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (st == OpenThermStatus::OPTH_DELAY) {
|
|
||||||
if ((newTs - ts) > 100000) {
|
|
||||||
status = OpenThermStatus::OPTH_READY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::parity(unsigned long frame) //odd parity
|
|
||||||
{
|
|
||||||
byte p = 0;
|
|
||||||
while (frame > 0)
|
|
||||||
{
|
|
||||||
if (frame & 1) p++;
|
|
||||||
frame = frame >> 1;
|
|
||||||
}
|
|
||||||
return (p & 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenThermMessageType OpenTherm::getMessageType(unsigned long message)
|
|
||||||
{
|
|
||||||
OpenThermMessageType msg_type = static_cast<OpenThermMessageType>((message >> 28) & 7);
|
|
||||||
return msg_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenThermMessageID OpenTherm::getDataID(unsigned long frame)
|
|
||||||
{
|
|
||||||
return (OpenThermMessageID)((frame >> 16) & 0xFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long OpenTherm::buildRequest(OpenThermMessageType type, OpenThermMessageID id, unsigned int data)
|
|
||||||
{
|
|
||||||
unsigned long request = data;
|
|
||||||
if (type == OpenThermMessageType::OPTH_WRITE_DATA) {
|
|
||||||
request |= 1ul << 28;
|
|
||||||
}
|
|
||||||
request |= ((unsigned long)id) << 16;
|
|
||||||
if (OpenTherm::parity(request)) request |= (1ul << 31);
|
|
||||||
return request;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long OpenTherm::buildResponse(OpenThermMessageType type, OpenThermMessageID id, unsigned int data)
|
|
||||||
{
|
|
||||||
unsigned long response = data;
|
|
||||||
response |= type << 28;
|
|
||||||
response |= ((unsigned long)id) << 16;
|
|
||||||
if (OpenTherm::parity(response)) response |= (1ul << 31);
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::isValidResponse(unsigned long response)
|
|
||||||
{
|
|
||||||
if (OpenTherm::parity(response)) return false;
|
|
||||||
byte msgType = (response << 1) >> 29;
|
|
||||||
return msgType == OPTH_READ_ACK || msgType == OPTH_WRITE_ACK;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::isValidRequest(unsigned long request)
|
|
||||||
{
|
|
||||||
if (OpenTherm::parity(request)) return false;
|
|
||||||
byte msgType = (request << 1) >> 29;
|
|
||||||
return msgType == OPTH_READ_DATA || msgType == OPTH_WRITE_DATA;
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenTherm::end() {
|
|
||||||
if (this->handleInterruptCallback != NULL) {
|
|
||||||
detachInterrupt(digitalPinToInterrupt(inPin));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *OpenTherm::statusToString(OpenThermResponseStatus status)
|
|
||||||
{
|
|
||||||
switch (status) {
|
|
||||||
case OPTH_NONE: return "NONE";
|
|
||||||
case OPTH_SUCCESS: return "SUCCESS";
|
|
||||||
case OPTH_INVALID: return "INVALID";
|
|
||||||
case OPTH_TIMEOUT: return "TIMEOUT";
|
|
||||||
default: return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *OpenTherm::messageTypeToString(OpenThermMessageType message_type)
|
|
||||||
{
|
|
||||||
switch (message_type) {
|
|
||||||
case OPTH_READ_DATA: return "READ_DATA";
|
|
||||||
case OPTH_WRITE_DATA: return "WRITE_DATA";
|
|
||||||
case OPTH_INVALID_DATA: return "INVALID_DATA";
|
|
||||||
case OPTH_RESERVED: return "RESERVED";
|
|
||||||
case OPTH_READ_ACK: return "READ_ACK";
|
|
||||||
case OPTH_WRITE_ACK: return "WRITE_ACK";
|
|
||||||
case OPTH_DATA_INVALID: return "DATA_INVALID";
|
|
||||||
case OPTH_UNKNOWN_DATA_ID: return "UNKNOWN_DATA_ID";
|
|
||||||
default: return "UNKNOWN";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//building requests
|
|
||||||
|
|
||||||
unsigned long OpenTherm::buildSetBoilerStatusRequest(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2) {
|
|
||||||
unsigned int data = enableCentralHeating | (enableHotWater << 1) | (enableCooling << 2) | (enableOutsideTemperatureCompensation << 3) | (enableCentralHeating2 << 4);
|
|
||||||
data <<= 8;
|
|
||||||
return buildRequest(OpenThermMessageType::OPTH_READ_DATA, OpenThermMessageID::Status, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long OpenTherm::buildSetBoilerTemperatureRequest(float temperature) {
|
|
||||||
unsigned int data = temperatureToData(temperature);
|
|
||||||
return buildRequest(OpenThermMessageType::OPTH_WRITE_DATA, OpenThermMessageID::TSet, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long OpenTherm::buildSetHotWaterTemperatureRequest(float temperature) {
|
|
||||||
unsigned int data = temperatureToData(temperature);
|
|
||||||
return buildRequest(OpenThermMessageType::OPTH_WRITE_DATA, OpenThermMessageID::TdhwSet, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long OpenTherm::buildGetBoilerTemperatureRequest() {
|
|
||||||
return buildRequest(OpenThermMessageType::OPTH_READ_DATA, OpenThermMessageID::Tboiler, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long OpenTherm::buildSlaveConfigurationRequest() {
|
|
||||||
return buildRequest(OpenThermMessageType::OPTH_READ_DATA, OpenThermMessageID::SConfigSMemberIDcode, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//parsing responses
|
|
||||||
bool OpenTherm::isFault(unsigned long response) {
|
|
||||||
return response & 0x1;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::isCentralHeatingActive(unsigned long response) {
|
|
||||||
return response & 0x2;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::isHotWaterActive(unsigned long response) {
|
|
||||||
return response & 0x4;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::isFlameOn(unsigned long response) {
|
|
||||||
return response & 0x8;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::isCoolingActive(unsigned long response) {
|
|
||||||
return response & 0x10;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::isDiagnostic(unsigned long response) {
|
|
||||||
return response & 0x40;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t OpenTherm::getUInt(const unsigned long response) {
|
|
||||||
const uint16_t u88 = response & 0xffff;
|
|
||||||
return u88;
|
|
||||||
}
|
|
||||||
|
|
||||||
float OpenTherm::getFloat(const unsigned long response) {
|
|
||||||
const uint16_t u88 = getUInt(response);
|
|
||||||
const float f = (u88 & 0x8000) ? -(0x10000L - u88) / 256.0f : u88 / 256.0f;
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int OpenTherm::temperatureToData(float temperature) {
|
|
||||||
if (temperature < 0) temperature = 0;
|
|
||||||
if (temperature > 100) temperature = 100;
|
|
||||||
unsigned int data = (unsigned int)(temperature * 256);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
//basic requests
|
|
||||||
|
|
||||||
unsigned long OpenTherm::setBoilerStatus(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2) {
|
|
||||||
return sendRequest(buildSetBoilerStatusRequest(enableCentralHeating, enableHotWater, enableCooling, enableOutsideTemperatureCompensation, enableCentralHeating2));
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::setBoilerTemperature(float temperature) {
|
|
||||||
unsigned long response = sendRequest(buildSetBoilerTemperatureRequest(temperature));
|
|
||||||
return isValidResponse(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OpenTherm::setHotWaterTemperature(float temperature) {
|
|
||||||
unsigned long response = sendRequest(buildSetHotWaterTemperatureRequest(temperature));
|
|
||||||
return isValidResponse(response);
|
|
||||||
}
|
|
||||||
|
|
||||||
float OpenTherm::getBoilerTemperature() {
|
|
||||||
unsigned long response = sendRequest(buildGetBoilerTemperatureRequest());
|
|
||||||
return isValidResponse(response) ? getFloat(response) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float OpenTherm::getReturnTemperature() {
|
|
||||||
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::OPTH_READ, OpenThermMessageID::Tret, 0));
|
|
||||||
return isValidResponse(response) ? getFloat(response) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float OpenTherm::getModulation() {
|
|
||||||
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::OPTH_READ, OpenThermMessageID::RelModLevel, 0));
|
|
||||||
return isValidResponse(response) ? getFloat(response) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
float OpenTherm::getPressure() {
|
|
||||||
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::OPTH_READ, OpenThermMessageID::CHPressure, 0));
|
|
||||||
return isValidResponse(response) ? getFloat(response) : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char OpenTherm::getFault() {
|
|
||||||
return ((sendRequest(buildRequest(OpenThermRequestType::OPTH_READ, OpenThermMessageID::ASFflags, 0)) >> 8) & 0xff);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned long OpenTherm::getSlaveConfiguration() {
|
|
||||||
return sendRequest(buildSlaveConfigurationRequest());
|
|
||||||
}
|
|
||||||
@ -1,193 +0,0 @@
|
|||||||
/*
|
|
||||||
OpenTherm.h - OpenTherm Library for the ESP8266/Arduino platform
|
|
||||||
https://github.com/ihormelnyk/OpenTherm
|
|
||||||
http://ihormelnyk.com/pages/OpenTherm
|
|
||||||
Licensed under MIT license
|
|
||||||
Copyright 2018, Ihor Melnyk
|
|
||||||
|
|
||||||
Frame Structure:
|
|
||||||
P MGS-TYPE SPARE DATA-ID DATA-VALUE
|
|
||||||
0 000 0000 00000000 00000000 00000000
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef OpenTherm_h
|
|
||||||
#define OpenTherm_h
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <Arduino.h>
|
|
||||||
|
|
||||||
enum OpenThermResponseStatus {
|
|
||||||
OPTH_NONE,
|
|
||||||
OPTH_SUCCESS,
|
|
||||||
OPTH_INVALID,
|
|
||||||
OPTH_TIMEOUT
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
enum OpenThermMessageType {
|
|
||||||
/* Master to Slave */
|
|
||||||
OPTH_READ_DATA = B000,
|
|
||||||
OPTH_READ = OPTH_READ_DATA, // for backwared compatibility
|
|
||||||
OPTH_WRITE_DATA = B001,
|
|
||||||
OPTH_WRITE = OPTH_WRITE_DATA, // for backwared compatibility
|
|
||||||
OPTH_INVALID_DATA = B010,
|
|
||||||
OPTH_RESERVED = B011,
|
|
||||||
/* Slave to Master */
|
|
||||||
OPTH_READ_ACK = B100,
|
|
||||||
OPTH_WRITE_ACK = B101,
|
|
||||||
OPTH_DATA_INVALID = B110,
|
|
||||||
OPTH_UNKNOWN_DATA_ID = B111
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef OpenThermMessageType OpenThermRequestType; // for backwared compatibility
|
|
||||||
|
|
||||||
enum OpenThermMessageID {
|
|
||||||
Status, // flag8 / flag8 Master and Slave Status flags.
|
|
||||||
TSet, // f8.8 Control setpoint ie CH water temperature setpoint (°C)
|
|
||||||
MConfigMMemberIDcode, // flag8 / u8 Master Configuration Flags / Master MemberID Code
|
|
||||||
SConfigSMemberIDcode, // flag8 / u8 Slave Configuration Flags / Slave MemberID Code
|
|
||||||
Command, // u8 / u8 Remote Command
|
|
||||||
ASFflags, // / OEM-fault-code flag8 / u8 Application-specific fault flags and OEM fault code
|
|
||||||
RBPflags, // flag8 / flag8 Remote boiler parameter transfer-enable & read/write flags
|
|
||||||
CoolingControl, // f8.8 Cooling control signal (%)
|
|
||||||
TsetCH2, // f8.8 Control setpoint for 2e CH circuit (°C)
|
|
||||||
TrOverride, // f8.8 Remote override room setpoint
|
|
||||||
TSP, // u8 / u8 Number of Transparent-Slave-Parameters supported by slave
|
|
||||||
TSPindexTSPvalue, // u8 / u8 Index number / Value of referred-to transparent slave parameter.
|
|
||||||
FHBsize, // u8 / u8 Size of Fault-History-Buffer supported by slave
|
|
||||||
FHBindexFHBvalue, // u8 / u8 Index number / Value of referred-to fault-history buffer entry.
|
|
||||||
MaxRelModLevelSetting, // f8.8 Maximum relative modulation level setting (%)
|
|
||||||
MaxCapacityMinModLevel, // u8 / u8 Maximum boiler capacity (kW) / Minimum boiler modulation level(%)
|
|
||||||
TrSet, // f8.8 Room Setpoint (°C)
|
|
||||||
RelModLevel, // f8.8 Relative Modulation Level (%)
|
|
||||||
CHPressure, // f8.8 Water pressure in CH circuit (bar)
|
|
||||||
DHWFlowRate, // f8.8 Water flow rate in DHW circuit. (litres/minute)
|
|
||||||
DayTime, // special / u8 Day of Week and Time of Day
|
|
||||||
Date, // u8 / u8 Calendar date
|
|
||||||
Year, // u16 Calendar year
|
|
||||||
TrSetCH2, // f8.8 Room Setpoint for 2nd CH circuit (°C)
|
|
||||||
Tr, // f8.8 Room temperature (°C)
|
|
||||||
Tboiler, // f8.8 Boiler flow water temperature (°C)
|
|
||||||
Tdhw, // f8.8 DHW temperature (°C)
|
|
||||||
Toutside, // f8.8 Outside temperature (°C)
|
|
||||||
Tret, // f8.8 Return water temperature (°C)
|
|
||||||
Tstorage, // f8.8 Solar storage temperature (°C)
|
|
||||||
Tcollector, // f8.8 Solar collector temperature (°C)
|
|
||||||
TflowCH2, // f8.8 Flow water temperature CH2 circuit (°C)
|
|
||||||
Tdhw2, // f8.8 Domestic hot water temperature 2 (°C)
|
|
||||||
Texhaust, // s16 Boiler exhaust temperature (°C)
|
|
||||||
TdhwSetUBTdhwSetLB = 48, // s8 / s8 DHW setpoint upper & lower bounds for adjustment (°C)
|
|
||||||
MaxTSetUBMaxTSetLB, // s8 / s8 Max CH water setpoint upper & lower bounds for adjustment (°C)
|
|
||||||
HcratioUBHcratioLB, // s8 / s8 OTC heat curve ratio upper & lower bounds for adjustment
|
|
||||||
TdhwSet = 56, // f8.8 DHW setpoint (°C) (Remote parameter 1)
|
|
||||||
MaxTSet, // f8.8 Max CH water setpoint (°C) (Remote parameters 2)
|
|
||||||
Hcratio, // f8.8 OTC heat curve ratio (°C) (Remote parameter 3)
|
|
||||||
RemoteOverrideFunction = 100, // flag8 / - Function of manual and program changes in master and remote room setpoint.
|
|
||||||
OEMDiagnosticCode = 115, // u16 OEM-specific diagnostic/service code
|
|
||||||
BurnerStarts, // u16 Number of starts burner
|
|
||||||
CHPumpStarts, // u16 Number of starts CH pump
|
|
||||||
DHWPumpValveStarts, // u16 Number of starts DHW pump/valve
|
|
||||||
DHWBurnerStarts, // u16 Number of starts burner during DHW mode
|
|
||||||
BurnerOperationHours, // u16 Number of hours that burner is in operation (i.e. flame on)
|
|
||||||
CHPumpOperationHours, // u16 Number of hours that CH pump has been running
|
|
||||||
DHWPumpValveOperationHours, // u16 Number of hours that DHW pump has been running or DHW valve has been opened
|
|
||||||
DHWBurnerOperationHours, // u16 Number of hours that burner is in operation during DHW mode
|
|
||||||
OpenThermVersionMaster, // f8.8 The implemented version of the OpenTherm Protocol Specification in the master.
|
|
||||||
OpenThermVersionSlave, // f8.8 The implemented version of the OpenTherm Protocol Specification in the slave.
|
|
||||||
MasterVersion, // u8 / u8 Master product version number and type
|
|
||||||
SlaveVersion, // u8 / u8 Slave product version number and type
|
|
||||||
};
|
|
||||||
|
|
||||||
enum OpenThermStatus {
|
|
||||||
OPTH_NOT_INITIALIZED,
|
|
||||||
OPTH_READY,
|
|
||||||
OPTH_DELAY,
|
|
||||||
OPTH_REQUEST_SENDING,
|
|
||||||
OPTH_RESPONSE_WAITING,
|
|
||||||
OPTH_RESPONSE_START_BIT,
|
|
||||||
OPTH_RESPONSE_RECEIVING,
|
|
||||||
OPTH_RESPONSE_READY,
|
|
||||||
OPTH_RESPONSE_INVALID
|
|
||||||
};
|
|
||||||
|
|
||||||
class OpenTherm
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
OpenTherm(int inPin = 4, int outPin = 5, bool isSlave = false);
|
|
||||||
volatile OpenThermStatus status;
|
|
||||||
void begin(void(*handleInterruptCallback)(void));
|
|
||||||
void begin(void(*handleInterruptCallback)(void), void(*processResponseCallback)(unsigned long, int));
|
|
||||||
bool isReady();
|
|
||||||
unsigned long sendRequest(unsigned long request);
|
|
||||||
bool sendResponse(unsigned long request);
|
|
||||||
bool sendRequestAync(unsigned long request);
|
|
||||||
static unsigned long buildRequest(OpenThermMessageType type, OpenThermMessageID id, unsigned int data);
|
|
||||||
static unsigned long buildResponse(OpenThermMessageType type, OpenThermMessageID id, unsigned int data);
|
|
||||||
OpenThermResponseStatus getLastResponseStatus();
|
|
||||||
const char *statusToString(OpenThermResponseStatus status);
|
|
||||||
void handleInterrupt();
|
|
||||||
void process();
|
|
||||||
void end();
|
|
||||||
|
|
||||||
static bool parity(unsigned long frame);
|
|
||||||
OpenThermMessageType getMessageType(unsigned long message);
|
|
||||||
OpenThermMessageID getDataID(unsigned long frame);
|
|
||||||
const char *messageTypeToString(OpenThermMessageType message_type);
|
|
||||||
bool isValidRequest(unsigned long request);
|
|
||||||
bool isValidResponse(unsigned long response);
|
|
||||||
|
|
||||||
//requests
|
|
||||||
unsigned long buildSetBoilerStatusRequest(bool enableCentralHeating, bool enableHotWater = false, bool enableCooling = false, bool enableOutsideTemperatureCompensation = false, bool enableCentralHeating2 = false);
|
|
||||||
unsigned long buildSetBoilerTemperatureRequest(float temperature);
|
|
||||||
unsigned long buildGetBoilerTemperatureRequest();
|
|
||||||
unsigned long buildSetHotWaterTemperatureRequest(float temperature);
|
|
||||||
unsigned long buildSlaveConfigurationRequest();
|
|
||||||
|
|
||||||
|
|
||||||
//responses
|
|
||||||
static bool isFault(unsigned long response);
|
|
||||||
static bool isCentralHeatingActive(unsigned long response);
|
|
||||||
static bool isHotWaterActive(unsigned long response);
|
|
||||||
static bool isFlameOn(unsigned long response);
|
|
||||||
static bool isCoolingActive(unsigned long response);
|
|
||||||
static bool isDiagnostic(unsigned long response);
|
|
||||||
static uint16_t getUInt(const unsigned long response);
|
|
||||||
static float getFloat(const unsigned long response);
|
|
||||||
static unsigned int temperatureToData(float temperature);
|
|
||||||
|
|
||||||
//basic requests
|
|
||||||
unsigned long setBoilerStatus(bool enableCentralHeating, bool enableHotWater = false, bool enableCooling = false, bool enableOutsideTemperatureCompensation = false, bool enableCentralHeating2 = false);
|
|
||||||
bool setBoilerTemperature(float temperature);
|
|
||||||
bool setHotWaterTemperature(float temperature);
|
|
||||||
float getBoilerTemperature();
|
|
||||||
float getReturnTemperature();
|
|
||||||
float getModulation();
|
|
||||||
float getPressure();
|
|
||||||
unsigned char getFault();
|
|
||||||
unsigned long getSlaveConfiguration();
|
|
||||||
|
|
||||||
private:
|
|
||||||
const int inPin;
|
|
||||||
const int outPin;
|
|
||||||
const bool isSlave;
|
|
||||||
|
|
||||||
volatile unsigned long response;
|
|
||||||
volatile OpenThermResponseStatus responseStatus;
|
|
||||||
volatile unsigned long responseTimestamp;
|
|
||||||
volatile byte responseBitIndex;
|
|
||||||
|
|
||||||
int readState();
|
|
||||||
void setActiveState();
|
|
||||||
void setIdleState();
|
|
||||||
void activateBoiler();
|
|
||||||
|
|
||||||
void sendBit(bool high);
|
|
||||||
void(*handleInterruptCallback)();
|
|
||||||
void(*processResponseCallback)(unsigned long, int);
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifndef ICACHE_RAM_ATTR
|
|
||||||
#define ICACHE_RAM_ATTR
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // OpenTherm_h
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
Attention when updating library. Changes in lib needed!!
|
|
||||||
All OpenTherm constants shall be prepended with `OPTH_` to avoid conflicts with other libs.
|
|
||||||
|
|
||||||
See commit https://github.com/arendst/Tasmota/commit/960291729ccc7cb4da50108e5299d44a79cb06de
|
|
||||||
|
|
||||||
As of OpenTherm-0.9.0, hte list is:
|
|
||||||
OPTH_NONE
|
|
||||||
OPTH_SUCCESS
|
|
||||||
OPTH_INVALID
|
|
||||||
OPTH_TIMEOUT
|
|
||||||
OPTH_READ_DATA
|
|
||||||
OPTH_READ
|
|
||||||
OPTH_WRITE_DATA
|
|
||||||
OPTH_WRITE
|
|
||||||
OPTH_INVALID_DATA
|
|
||||||
OPTH_RESERVED
|
|
||||||
OPTH_READ_ACK
|
|
||||||
OPTH_WRITE_ACK
|
|
||||||
OPTH_DATA_INVALID
|
|
||||||
OPTH_UNKNOWN_DATA_ID
|
|
||||||
OPTH_NOT_INITIALIZED
|
|
||||||
OPTH_READY
|
|
||||||
OPTH_DELAY
|
|
||||||
OPTH_REQUEST_SENDING
|
|
||||||
OPTH_RESPONSE_WAITING
|
|
||||||
OPTH_RESPONSE_START_BIT
|
|
||||||
OPTH_RESPONSE_RECEIVING
|
|
||||||
OPTH_RESPONSE_READY
|
|
||||||
OPTH_RESPONSE_INVALID
|
|
||||||
@ -1,8 +1,8 @@
|
|||||||
# OpenTherm Arduino/ESP8266 Library
|
# OpenTherm Arduino/ESP8266/ESP32 Library
|
||||||
|
|
||||||
This library provides implementation of OpenTherm protocol.
|
This library provides implementation of OpenTherm protocol.
|
||||||
|
|
||||||
OpenTherm Library is based on OpenTherm protocol specification v2.2 and works with all OpenTherm compatible boilers. Library can be easily installed into Arduino IDE and compiled for Arduino, ESP8266 and other similar controllers.
|
OpenTherm Library is based on OpenTherm protocol specification v2.2 and works with all OpenTherm compatible boilers. Library can be easily installed into Arduino IDE and compiled for Arduino, ESP8266/ESP32 and other similar controllers.
|
||||||
|
|
||||||
OpenTherm protocol requires simple low voltage twowire connection to boiler, but voltage levels (7..15V) still much higher than Arduino/ESP8266 levels, which requires [OpenTherm Adapter](http://ihormelnyk.com/opentherm_adapter).
|
OpenTherm protocol requires simple low voltage twowire connection to boiler, but voltage levels (7..15V) still much higher than Arduino/ESP8266 levels, which requires [OpenTherm Adapter](http://ihormelnyk.com/opentherm_adapter).
|
||||||
|
|
||||||
@ -30,6 +30,8 @@ doSomething KEYWORD2
|
|||||||
setBoilerStatus KEYWORD2
|
setBoilerStatus KEYWORD2
|
||||||
setBoilerTemperature KEYWORD2
|
setBoilerTemperature KEYWORD2
|
||||||
getBoilerTemperature KEYWORD2
|
getBoilerTemperature KEYWORD2
|
||||||
|
setDHWSetpoint KEYWORD2
|
||||||
|
getDHWTemperature KEYWORD2
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Instances (KEYWORD2)
|
# Instances (KEYWORD2)
|
||||||
@ -1,8 +1,8 @@
|
|||||||
name=OpenTherm Library
|
name=OpenTherm Library
|
||||||
version=0.9.0
|
version=1.1.5
|
||||||
author=Ihor Melnyk <ihor.melnyk@gmail.com>
|
author=Ihor Melnyk <ihor.melnyk@gmail.com>
|
||||||
maintainer=Ihor Melnyk <ihor.melnyk@gmail.com>
|
maintainer=Ihor Melnyk <ihor.melnyk@gmail.com>
|
||||||
sentence=OpenTherm Library for HVAC system control communication using Arduino and ESP8266 hardware.
|
sentence=OpenTherm Library for HVAC system control communication using Arduino and ESP8266/ESP32 hardware.
|
||||||
paragraph=OpenTherm Library is based on OpenTherm protocol specification v2.2 and works with all OpenTherm compatible boilers.
|
paragraph=OpenTherm Library is based on OpenTherm protocol specification v2.2 and works with all OpenTherm compatible boilers.
|
||||||
category=Communication
|
category=Communication
|
||||||
url=https://github.com/ihormelnyk/opentherm_library
|
url=https://github.com/ihormelnyk/opentherm_library
|
||||||
578
lib/lib_div/OpenTherm/src/OpenTherm.cpp
Normal file
578
lib/lib_div/OpenTherm/src/OpenTherm.cpp
Normal file
@ -0,0 +1,578 @@
|
|||||||
|
/*
|
||||||
|
OpenTherm.cpp - OpenTherm Communication Library For Arduino, ESP8266, ESP32
|
||||||
|
Copyright 2023, Ihor Melnyk
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "OpenTherm.h"
|
||||||
|
#if !defined(__AVR__)
|
||||||
|
#include "FunctionalInterrupt.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
OpenTherm::OpenTherm(int inPin, int outPin, bool isSlave) :
|
||||||
|
status(OpenThermStatus::NOT_INITIALIZED),
|
||||||
|
inPin(inPin),
|
||||||
|
outPin(outPin),
|
||||||
|
isSlave(isSlave),
|
||||||
|
response(0),
|
||||||
|
responseStatus(OpenThermResponseStatus::NONE),
|
||||||
|
responseTimestamp(0),
|
||||||
|
processResponseCallback(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenTherm::begin(void (*handleInterruptCallback)(void))
|
||||||
|
{
|
||||||
|
pinMode(inPin, INPUT);
|
||||||
|
pinMode(outPin, OUTPUT);
|
||||||
|
if (handleInterruptCallback != NULL)
|
||||||
|
{
|
||||||
|
attachInterrupt(digitalPinToInterrupt(inPin), handleInterruptCallback, CHANGE);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
#if !defined(__AVR__)
|
||||||
|
attachInterruptArg(
|
||||||
|
digitalPinToInterrupt(inPin),
|
||||||
|
OpenTherm::handleInterruptHelper,
|
||||||
|
this,
|
||||||
|
CHANGE
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
activateBoiler();
|
||||||
|
status = OpenThermStatus::READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenTherm::begin(void (*handleInterruptCallback)(void), void (*processResponseCallback)(unsigned long, int))
|
||||||
|
{
|
||||||
|
begin(handleInterruptCallback);
|
||||||
|
this->processResponseCallback = processResponseCallback;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(__AVR__)
|
||||||
|
void OpenTherm::begin()
|
||||||
|
{
|
||||||
|
begin(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenTherm::begin(std::function<void(unsigned long, OpenThermResponseStatus)> processResponseFunction)
|
||||||
|
{
|
||||||
|
begin();
|
||||||
|
this->processResponseFunction = processResponseFunction;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool IRAM_ATTR OpenTherm::isReady()
|
||||||
|
{
|
||||||
|
return status == OpenThermStatus::READY;
|
||||||
|
}
|
||||||
|
|
||||||
|
int IRAM_ATTR OpenTherm::readState()
|
||||||
|
{
|
||||||
|
return digitalRead(inPin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenTherm::setActiveState()
|
||||||
|
{
|
||||||
|
digitalWrite(outPin, LOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenTherm::setIdleState()
|
||||||
|
{
|
||||||
|
digitalWrite(outPin, HIGH);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenTherm::activateBoiler()
|
||||||
|
{
|
||||||
|
setIdleState();
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenTherm::sendBit(bool high)
|
||||||
|
{
|
||||||
|
if (high)
|
||||||
|
setActiveState();
|
||||||
|
else
|
||||||
|
setIdleState();
|
||||||
|
delayMicroseconds(500);
|
||||||
|
if (high)
|
||||||
|
setIdleState();
|
||||||
|
else
|
||||||
|
setActiveState();
|
||||||
|
delayMicroseconds(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::sendRequestAsync(unsigned long request)
|
||||||
|
{
|
||||||
|
noInterrupts();
|
||||||
|
const bool ready = isReady();
|
||||||
|
|
||||||
|
if (!ready)
|
||||||
|
{
|
||||||
|
interrupts();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = OpenThermStatus::REQUEST_SENDING;
|
||||||
|
response = 0;
|
||||||
|
responseStatus = OpenThermResponseStatus::NONE;
|
||||||
|
|
||||||
|
#ifdef INC_FREERTOS_H
|
||||||
|
BaseType_t schedulerState = xTaskGetSchedulerState();
|
||||||
|
if (schedulerState == taskSCHEDULER_RUNNING)
|
||||||
|
{
|
||||||
|
vTaskSuspendAll();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
interrupts();
|
||||||
|
|
||||||
|
sendBit(HIGH); // start bit
|
||||||
|
for (int i = 31; i >= 0; i--)
|
||||||
|
{
|
||||||
|
sendBit(bitRead(request, i));
|
||||||
|
}
|
||||||
|
sendBit(HIGH); // stop bit
|
||||||
|
setIdleState();
|
||||||
|
|
||||||
|
responseTimestamp = micros();
|
||||||
|
status = OpenThermStatus::RESPONSE_WAITING;
|
||||||
|
|
||||||
|
#ifdef INC_FREERTOS_H
|
||||||
|
if (schedulerState == taskSCHEDULER_RUNNING) {
|
||||||
|
xTaskResumeAll();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long OpenTherm::sendRequest(unsigned long request)
|
||||||
|
{
|
||||||
|
if (!sendRequestAsync(request))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!isReady())
|
||||||
|
{
|
||||||
|
process();
|
||||||
|
yield();
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::sendResponse(unsigned long request)
|
||||||
|
{
|
||||||
|
noInterrupts();
|
||||||
|
const bool ready = isReady();
|
||||||
|
|
||||||
|
if (!ready)
|
||||||
|
{
|
||||||
|
interrupts();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
status = OpenThermStatus::REQUEST_SENDING;
|
||||||
|
response = 0;
|
||||||
|
responseStatus = OpenThermResponseStatus::NONE;
|
||||||
|
|
||||||
|
#ifdef INC_FREERTOS_H
|
||||||
|
BaseType_t schedulerState = xTaskGetSchedulerState();
|
||||||
|
if (schedulerState == taskSCHEDULER_RUNNING)
|
||||||
|
{
|
||||||
|
vTaskSuspendAll();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
interrupts();
|
||||||
|
|
||||||
|
sendBit(HIGH); // start bit
|
||||||
|
for (int i = 31; i >= 0; i--)
|
||||||
|
{
|
||||||
|
sendBit(bitRead(request, i));
|
||||||
|
}
|
||||||
|
sendBit(HIGH); // stop bit
|
||||||
|
setIdleState();
|
||||||
|
status = OpenThermStatus::READY;
|
||||||
|
|
||||||
|
#ifdef INC_FREERTOS_H
|
||||||
|
if (schedulerState == taskSCHEDULER_RUNNING) {
|
||||||
|
xTaskResumeAll();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long OpenTherm::getLastResponse()
|
||||||
|
{
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenThermResponseStatus OpenTherm::getLastResponseStatus()
|
||||||
|
{
|
||||||
|
return responseStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
void IRAM_ATTR OpenTherm::handleInterrupt()
|
||||||
|
{
|
||||||
|
if (isReady())
|
||||||
|
{
|
||||||
|
if (isSlave && readState() == HIGH)
|
||||||
|
{
|
||||||
|
status = OpenThermStatus::RESPONSE_WAITING;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long newTs = micros();
|
||||||
|
if (status == OpenThermStatus::RESPONSE_WAITING)
|
||||||
|
{
|
||||||
|
if (readState() == HIGH)
|
||||||
|
{
|
||||||
|
status = OpenThermStatus::RESPONSE_START_BIT;
|
||||||
|
responseTimestamp = newTs;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = OpenThermStatus::RESPONSE_INVALID;
|
||||||
|
responseTimestamp = newTs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (status == OpenThermStatus::RESPONSE_START_BIT)
|
||||||
|
{
|
||||||
|
if ((newTs - responseTimestamp < 750) && readState() == LOW)
|
||||||
|
{
|
||||||
|
status = OpenThermStatus::RESPONSE_RECEIVING;
|
||||||
|
responseTimestamp = newTs;
|
||||||
|
responseBitIndex = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = OpenThermStatus::RESPONSE_INVALID;
|
||||||
|
responseTimestamp = newTs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (status == OpenThermStatus::RESPONSE_RECEIVING)
|
||||||
|
{
|
||||||
|
if ((newTs - responseTimestamp) > 750)
|
||||||
|
{
|
||||||
|
if (responseBitIndex < 32)
|
||||||
|
{
|
||||||
|
response = (response << 1) | !readState();
|
||||||
|
responseTimestamp = newTs;
|
||||||
|
responseBitIndex = responseBitIndex + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // stop bit
|
||||||
|
status = OpenThermStatus::RESPONSE_READY;
|
||||||
|
responseTimestamp = newTs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if !defined(__AVR__)
|
||||||
|
void IRAM_ATTR OpenTherm::handleInterruptHelper(void* ptr)
|
||||||
|
{
|
||||||
|
static_cast<OpenTherm*>(ptr)->handleInterrupt();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void OpenTherm::processResponse()
|
||||||
|
{
|
||||||
|
if (processResponseCallback != NULL)
|
||||||
|
{
|
||||||
|
processResponseCallback(response, (int)responseStatus);
|
||||||
|
}
|
||||||
|
#if !defined(__AVR__)
|
||||||
|
if (this->processResponseFunction != NULL)
|
||||||
|
{
|
||||||
|
processResponseFunction(response, responseStatus);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenTherm::process()
|
||||||
|
{
|
||||||
|
noInterrupts();
|
||||||
|
OpenThermStatus st = status;
|
||||||
|
unsigned long ts = responseTimestamp;
|
||||||
|
interrupts();
|
||||||
|
|
||||||
|
if (st == OpenThermStatus::READY)
|
||||||
|
return;
|
||||||
|
unsigned long newTs = micros();
|
||||||
|
if (st != OpenThermStatus::NOT_INITIALIZED && st != OpenThermStatus::DELAY && (newTs - ts) > 1000000)
|
||||||
|
{
|
||||||
|
status = OpenThermStatus::READY;
|
||||||
|
responseStatus = OpenThermResponseStatus::TIMEOUT;
|
||||||
|
processResponse();
|
||||||
|
}
|
||||||
|
else if (st == OpenThermStatus::RESPONSE_INVALID)
|
||||||
|
{
|
||||||
|
status = OpenThermStatus::DELAY;
|
||||||
|
responseStatus = OpenThermResponseStatus::INVALID;
|
||||||
|
processResponse();
|
||||||
|
}
|
||||||
|
else if (st == OpenThermStatus::RESPONSE_READY)
|
||||||
|
{
|
||||||
|
status = OpenThermStatus::DELAY;
|
||||||
|
responseStatus = (isSlave ? isValidRequest(response) : isValidResponse(response)) ? OpenThermResponseStatus::SUCCESS : OpenThermResponseStatus::INVALID;
|
||||||
|
processResponse();
|
||||||
|
}
|
||||||
|
else if (st == OpenThermStatus::DELAY)
|
||||||
|
{
|
||||||
|
if ((newTs - ts) > (isSlave ? 20000 : 100000))
|
||||||
|
{
|
||||||
|
status = OpenThermStatus::READY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::parity(unsigned long frame) // odd parity
|
||||||
|
{
|
||||||
|
byte p = 0;
|
||||||
|
while (frame > 0)
|
||||||
|
{
|
||||||
|
if (frame & 1)
|
||||||
|
p++;
|
||||||
|
frame = frame >> 1;
|
||||||
|
}
|
||||||
|
return (p & 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenThermMessageType OpenTherm::getMessageType(unsigned long message)
|
||||||
|
{
|
||||||
|
OpenThermMessageType msg_type = static_cast<OpenThermMessageType>((message >> 28) & 7);
|
||||||
|
return msg_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenThermMessageID OpenTherm::getDataID(unsigned long frame)
|
||||||
|
{
|
||||||
|
return (OpenThermMessageID)((frame >> 16) & 0xFF);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long OpenTherm::buildRequest(OpenThermMessageType type, OpenThermMessageID id, unsigned int data)
|
||||||
|
{
|
||||||
|
unsigned long request = data;
|
||||||
|
if (type == OpenThermMessageType::WRITE_DATA)
|
||||||
|
{
|
||||||
|
request |= 1ul << 28;
|
||||||
|
}
|
||||||
|
request |= ((unsigned long)id) << 16;
|
||||||
|
if (parity(request))
|
||||||
|
request |= (1ul << 31);
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long OpenTherm::buildResponse(OpenThermMessageType type, OpenThermMessageID id, unsigned int data)
|
||||||
|
{
|
||||||
|
unsigned long response = data;
|
||||||
|
response |= ((unsigned long)type) << 28;
|
||||||
|
response |= ((unsigned long)id) << 16;
|
||||||
|
if (parity(response))
|
||||||
|
response |= (1ul << 31);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::isValidResponse(unsigned long response)
|
||||||
|
{
|
||||||
|
if (parity(response))
|
||||||
|
return false;
|
||||||
|
byte msgType = (response << 1) >> 29;
|
||||||
|
return msgType == (byte)OpenThermMessageType::READ_ACK || msgType == (byte)OpenThermMessageType::WRITE_ACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::isValidRequest(unsigned long request)
|
||||||
|
{
|
||||||
|
if (parity(request))
|
||||||
|
return false;
|
||||||
|
byte msgType = (request << 1) >> 29;
|
||||||
|
return msgType == (byte)OpenThermMessageType::READ_DATA || msgType == (byte)OpenThermMessageType::WRITE_DATA;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenTherm::end()
|
||||||
|
{
|
||||||
|
detachInterrupt(digitalPinToInterrupt(inPin));
|
||||||
|
}
|
||||||
|
|
||||||
|
OpenTherm::~OpenTherm()
|
||||||
|
{
|
||||||
|
end();
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *OpenTherm::statusToString(OpenThermResponseStatus status)
|
||||||
|
{
|
||||||
|
switch (status)
|
||||||
|
{
|
||||||
|
case OpenThermResponseStatus::NONE:
|
||||||
|
return "NONE";
|
||||||
|
case OpenThermResponseStatus::SUCCESS:
|
||||||
|
return "SUCCESS";
|
||||||
|
case OpenThermResponseStatus::INVALID:
|
||||||
|
return "INVALID";
|
||||||
|
case OpenThermResponseStatus::TIMEOUT:
|
||||||
|
return "TIMEOUT";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *OpenTherm::messageTypeToString(OpenThermMessageType message_type)
|
||||||
|
{
|
||||||
|
switch (message_type)
|
||||||
|
{
|
||||||
|
case OpenThermMessageType::READ_DATA:
|
||||||
|
return "READ_DATA";
|
||||||
|
case OpenThermMessageType::WRITE_DATA:
|
||||||
|
return "WRITE_DATA";
|
||||||
|
case OpenThermMessageType::INVALID_DATA:
|
||||||
|
return "INVALID_DATA";
|
||||||
|
case OpenThermMessageType::RESERVED:
|
||||||
|
return "RESERVED";
|
||||||
|
case OpenThermMessageType::READ_ACK:
|
||||||
|
return "READ_ACK";
|
||||||
|
case OpenThermMessageType::WRITE_ACK:
|
||||||
|
return "WRITE_ACK";
|
||||||
|
case OpenThermMessageType::DATA_INVALID:
|
||||||
|
return "DATA_INVALID";
|
||||||
|
case OpenThermMessageType::UNKNOWN_DATA_ID:
|
||||||
|
return "UNKNOWN_DATA_ID";
|
||||||
|
default:
|
||||||
|
return "UNKNOWN";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// building requests
|
||||||
|
|
||||||
|
unsigned long OpenTherm::buildSetBoilerStatusRequest(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2)
|
||||||
|
{
|
||||||
|
unsigned int data = enableCentralHeating | (enableHotWater << 1) | (enableCooling << 2) | (enableOutsideTemperatureCompensation << 3) | (enableCentralHeating2 << 4);
|
||||||
|
data <<= 8;
|
||||||
|
return buildRequest(OpenThermMessageType::READ_DATA, OpenThermMessageID::Status, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long OpenTherm::buildSetBoilerTemperatureRequest(float temperature)
|
||||||
|
{
|
||||||
|
unsigned int data = temperatureToData(temperature);
|
||||||
|
return buildRequest(OpenThermMessageType::WRITE_DATA, OpenThermMessageID::TSet, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long OpenTherm::buildGetBoilerTemperatureRequest()
|
||||||
|
{
|
||||||
|
return buildRequest(OpenThermMessageType::READ_DATA, OpenThermMessageID::Tboiler, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// parsing responses
|
||||||
|
bool OpenTherm::isFault(unsigned long response)
|
||||||
|
{
|
||||||
|
return response & 0x1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::isCentralHeatingActive(unsigned long response)
|
||||||
|
{
|
||||||
|
return response & 0x2;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::isHotWaterActive(unsigned long response)
|
||||||
|
{
|
||||||
|
return response & 0x4;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::isFlameOn(unsigned long response)
|
||||||
|
{
|
||||||
|
return response & 0x8;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::isCoolingActive(unsigned long response)
|
||||||
|
{
|
||||||
|
return response & 0x10;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::isDiagnostic(unsigned long response)
|
||||||
|
{
|
||||||
|
return response & 0x40;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t OpenTherm::getUInt(const unsigned long response)
|
||||||
|
{
|
||||||
|
const uint16_t u88 = response & 0xffff;
|
||||||
|
return u88;
|
||||||
|
}
|
||||||
|
|
||||||
|
float OpenTherm::getFloat(const unsigned long response)
|
||||||
|
{
|
||||||
|
const uint16_t u88 = getUInt(response);
|
||||||
|
const float f = (u88 & 0x8000) ? -(0x10000L - u88) / 256.0f : u88 / 256.0f;
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int OpenTherm::temperatureToData(float temperature)
|
||||||
|
{
|
||||||
|
if (temperature < 0)
|
||||||
|
temperature = 0;
|
||||||
|
if (temperature > 100)
|
||||||
|
temperature = 100;
|
||||||
|
unsigned int data = (unsigned int)(temperature * 256);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
// basic requests
|
||||||
|
|
||||||
|
unsigned long OpenTherm::setBoilerStatus(bool enableCentralHeating, bool enableHotWater, bool enableCooling, bool enableOutsideTemperatureCompensation, bool enableCentralHeating2)
|
||||||
|
{
|
||||||
|
return sendRequest(buildSetBoilerStatusRequest(enableCentralHeating, enableHotWater, enableCooling, enableOutsideTemperatureCompensation, enableCentralHeating2));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::setBoilerTemperature(float temperature)
|
||||||
|
{
|
||||||
|
unsigned long response = sendRequest(buildSetBoilerTemperatureRequest(temperature));
|
||||||
|
return isValidResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
float OpenTherm::getBoilerTemperature()
|
||||||
|
{
|
||||||
|
unsigned long response = sendRequest(buildGetBoilerTemperatureRequest());
|
||||||
|
return isValidResponse(response) ? getFloat(response) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float OpenTherm::getReturnTemperature()
|
||||||
|
{
|
||||||
|
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::READ, OpenThermMessageID::Tret, 0));
|
||||||
|
return isValidResponse(response) ? getFloat(response) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OpenTherm::setDHWSetpoint(float temperature)
|
||||||
|
{
|
||||||
|
unsigned int data = temperatureToData(temperature);
|
||||||
|
unsigned long response = sendRequest(buildRequest(OpenThermMessageType::WRITE_DATA, OpenThermMessageID::TdhwSet, data));
|
||||||
|
return isValidResponse(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
float OpenTherm::getDHWTemperature()
|
||||||
|
{
|
||||||
|
unsigned long response = sendRequest(buildRequest(OpenThermMessageType::READ_DATA, OpenThermMessageID::Tdhw, 0));
|
||||||
|
return isValidResponse(response) ? getFloat(response) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float OpenTherm::getModulation()
|
||||||
|
{
|
||||||
|
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::READ, OpenThermMessageID::RelModLevel, 0));
|
||||||
|
return isValidResponse(response) ? getFloat(response) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
float OpenTherm::getPressure()
|
||||||
|
{
|
||||||
|
unsigned long response = sendRequest(buildRequest(OpenThermRequestType::READ, OpenThermMessageID::CHPressure, 0));
|
||||||
|
return isValidResponse(response) ? getFloat(response) : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char OpenTherm::getFault()
|
||||||
|
{
|
||||||
|
return ((sendRequest(buildRequest(OpenThermRequestType::READ, OpenThermMessageID::ASFflags, 0)) >> 8) & 0xff);
|
||||||
|
}
|
||||||
256
lib/lib_div/OpenTherm/src/OpenTherm.h
Normal file
256
lib/lib_div/OpenTherm/src/OpenTherm.h
Normal file
@ -0,0 +1,256 @@
|
|||||||
|
/*
|
||||||
|
OpenTherm.h - OpenTherm Library for the ESP8266/ESP32/Arduino platform
|
||||||
|
https://github.com/ihormelnyk/OpenTherm
|
||||||
|
http://ihormelnyk.com/pages/OpenTherm
|
||||||
|
Licensed under MIT license
|
||||||
|
Copyright 2023, Ihor Melnyk
|
||||||
|
|
||||||
|
Frame Structure:
|
||||||
|
P MGS-TYPE SPARE DATA-ID DATA-VALUE
|
||||||
|
0 000 0000 00000000 00000000 00000000
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef OpenTherm_h
|
||||||
|
#define OpenTherm_h
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
enum class OpenThermResponseStatus : byte
|
||||||
|
{
|
||||||
|
NONE,
|
||||||
|
SUCCESS,
|
||||||
|
INVALID,
|
||||||
|
TIMEOUT
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class OpenThermMessageType : byte
|
||||||
|
{
|
||||||
|
/* Master to Slave */
|
||||||
|
READ_DATA = 0b000,
|
||||||
|
READ = READ_DATA, // for backwared compatibility
|
||||||
|
WRITE_DATA = 0b001,
|
||||||
|
WRITE = WRITE_DATA, // for backwared compatibility
|
||||||
|
INVALID_DATA = 0b010,
|
||||||
|
RESERVED = 0b011,
|
||||||
|
/* Slave to Master */
|
||||||
|
READ_ACK = 0b100,
|
||||||
|
WRITE_ACK = 0b101,
|
||||||
|
DATA_INVALID = 0b110,
|
||||||
|
UNKNOWN_DATA_ID = 0b111
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef OpenThermMessageType OpenThermRequestType; // for backwared compatibility
|
||||||
|
|
||||||
|
enum class OpenThermMessageID : byte
|
||||||
|
{
|
||||||
|
Status = 0, // flag8/flag8 Master and Slave Status flags.
|
||||||
|
TSet = 1, // f8.8 Control Setpoint i.e.CH water temperature Setpoint(°C)
|
||||||
|
MConfigMMemberIDcode = 2, // flag8/u8 Master Configuration Flags / Master MemberID Code
|
||||||
|
SConfigSMemberIDcode = 3, // flag8/u8 Slave Configuration Flags / Slave MemberID Code
|
||||||
|
RemoteRequest = 4, // u8/u8 Remote Request
|
||||||
|
ASFflags = 5, // flag8/u8 Application - specific fault flags and OEM fault code
|
||||||
|
RBPflags = 6, // flag8/flag8 Remote boiler parameter transfer - enable & read / write flags
|
||||||
|
CoolingControl = 7, // f8.8 Cooling control signal(%)
|
||||||
|
TsetCH2 = 8, // f8.8 Control Setpoint for 2e CH circuit(°C)
|
||||||
|
TrOverride = 9, // f8.8 Remote override room Setpoint
|
||||||
|
TSP = 10, // u8/u8 Number of Transparent - Slave - Parameters supported by slave
|
||||||
|
TSPindexTSPvalue = 11, // u8/u8 Index number / Value of referred - to transparent slave parameter.
|
||||||
|
FHBsize = 12, // u8/u8 Size of Fault - History - Buffer supported by slave
|
||||||
|
FHBindexFHBvalue = 13, // u8/u8 Index number / Value of referred - to fault - history buffer entry.
|
||||||
|
MaxRelModLevelSetting = 14, // f8.8 Maximum relative modulation level setting(%)
|
||||||
|
MaxCapacityMinModLevel = 15, // u8/u8 Maximum boiler capacity(kW) / Minimum boiler modulation level(%)
|
||||||
|
TrSet = 16, // f8.8 Room Setpoint(°C)
|
||||||
|
RelModLevel = 17, // f8.8 Relative Modulation Level(%)
|
||||||
|
CHPressure = 18, // f8.8 Water pressure in CH circuit(bar)
|
||||||
|
DHWFlowRate = 19, // f8.8 Water flow rate in DHW circuit. (litres / minute)
|
||||||
|
DayTime = 20, // special/u8 Day of Week and Time of Day
|
||||||
|
Date = 21, // u8/u8 Calendar date
|
||||||
|
Year = 22, // u16 Calendar year
|
||||||
|
TrSetCH2 = 23, // f8.8 Room Setpoint for 2nd CH circuit(°C)
|
||||||
|
Tr = 24, // f8.8 Room temperature(°C)
|
||||||
|
Tboiler = 25, // f8.8 Boiler flow water temperature(°C)
|
||||||
|
Tdhw = 26, // f8.8 DHW temperature(°C)
|
||||||
|
Toutside = 27, // f8.8 Outside temperature(°C)
|
||||||
|
Tret = 28, // f8.8 Return water temperature(°C)
|
||||||
|
Tstorage = 29, // f8.8 Solar storage temperature(°C)
|
||||||
|
Tcollector = 30, // f8.8 Solar collector temperature(°C)
|
||||||
|
TflowCH2 = 31, // f8.8 Flow water temperature CH2 circuit(°C)
|
||||||
|
Tdhw2 = 32, // f8.8 Domestic hot water temperature 2 (°C)
|
||||||
|
Texhaust = 33, // s16 Boiler exhaust temperature(°C)
|
||||||
|
TboilerHeatExchanger = 34, // f8.8 Boiler heat exchanger temperature(°C)
|
||||||
|
BoilerFanSpeedSetpointAndActual = 35, // u8/u8 Boiler fan speed Setpoint and actual value
|
||||||
|
FlameCurrent = 36, // f8.8 Electrical current through burner flame[μA]
|
||||||
|
TrCH2 = 37, // f8.8 Room temperature for 2nd CH circuit(°C)
|
||||||
|
RelativeHumidity = 38, // f8.8 Actual relative humidity as a percentage
|
||||||
|
TrOverride2 = 39, // f8.8 Remote Override Room Setpoint 2
|
||||||
|
TdhwSetUBTdhwSetLB = 48, // s8/s8 DHW Setpoint upper & lower bounds for adjustment(°C)
|
||||||
|
MaxTSetUBMaxTSetLB = 49, // s8/s8 Max CH water Setpoint upper & lower bounds for adjustment(°C)
|
||||||
|
TdhwSet = 56, // f8.8 DHW Setpoint(°C) (Remote parameter 1)
|
||||||
|
MaxTSet = 57, // f8.8 Max CH water Setpoint(°C) (Remote parameters 2)
|
||||||
|
StatusVentilationHeatRecovery = 70, // flag8/flag8 Master and Slave Status flags ventilation / heat - recovery
|
||||||
|
Vset = 71, // -/u8 Relative ventilation position (0-100%). 0% is the minimum set ventilation and 100% is the maximum set ventilation.
|
||||||
|
ASFflagsOEMfaultCodeVentilationHeatRecovery = 72, // flag8/u8 Application-specific fault flags and OEM fault code ventilation / heat-recovery
|
||||||
|
OEMDiagnosticCodeVentilationHeatRecovery = 73, // u16 An OEM-specific diagnostic/service code for ventilation / heat-recovery system
|
||||||
|
SConfigSMemberIDCodeVentilationHeatRecovery = 74, // flag8/u8 Slave Configuration Flags / Slave MemberID Code ventilation / heat-recovery
|
||||||
|
OpenThermVersionVentilationHeatRecovery = 75, // f8.8 The implemented version of the OpenTherm Protocol Specification in the ventilation / heat-recovery system.
|
||||||
|
VentilationHeatRecoveryVersion = 76, // u8/u8 Ventilation / heat-recovery product version number and type
|
||||||
|
RelVentLevel = 77, // -/u8 Relative ventilation (0-100%)
|
||||||
|
RHexhaust = 78, // -/u8 Relative humidity exhaust air (0-100%)
|
||||||
|
CO2exhaust = 79, // u16 CO2 level exhaust air (0-2000 ppm)
|
||||||
|
Tsi = 80, // f8.8 Supply inlet temperature (°C)
|
||||||
|
Tso = 81, // f8.8 Supply outlet temperature (°C)
|
||||||
|
Tei = 82, // f8.8 Exhaust inlet temperature (°C)
|
||||||
|
Teo = 83, // f8.8 Exhaust outlet temperature (°C)
|
||||||
|
RPMexhaust = 84, // u16 Exhaust fan speed in rpm
|
||||||
|
RPMsupply = 85, // u16 Supply fan speed in rpm
|
||||||
|
RBPflagsVentilationHeatRecovery = 86, // flag8/flag8 Remote ventilation / heat-recovery parameter transfer-enable & read/write flags
|
||||||
|
NominalVentilationValue = 87, // u8/- Nominal relative value for ventilation (0-100 %)
|
||||||
|
TSPventilationHeatRecovery = 88, // u8/u8 Number of Transparent-Slave-Parameters supported by TSP’s ventilation / heat-recovery
|
||||||
|
TSPindexTSPvalueVentilationHeatRecovery = 89, // u8/u8 Index number / Value of referred-to transparent TSP’s ventilation / heat-recovery parameter.
|
||||||
|
FHBsizeVentilationHeatRecovery = 90, // u8/u8 Size of Fault-History-Buffer supported by ventilation / heat-recovery
|
||||||
|
FHBindexFHBvalueVentilationHeatRecovery = 91, // u8/u8 Index number / Value of referred-to fault-history buffer entry ventilation / heat-recovery
|
||||||
|
Brand = 93, // u8/u8 Index number of the character in the text string ASCII character referenced by the above index number
|
||||||
|
BrandVersion = 94, // u8/u8 Index number of the character in the text string ASCII character referenced by the above index number
|
||||||
|
BrandSerialNumber = 95, // u8/u8 Index number of the character in the text string ASCII character referenced by the above index number
|
||||||
|
CoolingOperationHours = 96, // u16 Number of hours that the slave is in Cooling Mode. Reset by zero is optional for slave
|
||||||
|
PowerCycles = 97, // u16 Number of Power Cycles of a slave (wake-up after Reset), Reset by zero is optional for slave
|
||||||
|
RFsensorStatusInformation = 98, // special/special For a specific RF sensor the RF strength and battery level is written
|
||||||
|
RemoteOverrideOperatingModeHeatingDHW = 99, // special/special Operating Mode HC1, HC2/ Operating Mode DHW
|
||||||
|
RemoteOverrideFunction = 100, // flag8/- Function of manual and program changes in master and remote room Setpoint
|
||||||
|
StatusSolarStorage = 101, // flag8/flag8 Master and Slave Status flags Solar Storage
|
||||||
|
ASFflagsOEMfaultCodeSolarStorage = 102, // flag8/u8 Application-specific fault flags and OEM fault code Solar Storage
|
||||||
|
SConfigSMemberIDcodeSolarStorage = 103, // flag8/u8 Slave Configuration Flags / Slave MemberID Code Solar Storage
|
||||||
|
SolarStorageVersion = 104, // u8/u8 Solar Storage product version number and type
|
||||||
|
TSPSolarStorage = 105, // u8/u8 Number of Transparent - Slave - Parameters supported by TSP’s Solar Storage
|
||||||
|
TSPindexTSPvalueSolarStorage = 106, // u8/u8 Index number / Value of referred - to transparent TSP’s Solar Storage parameter.
|
||||||
|
FHBsizeSolarStorage = 107, // u8/u8 Size of Fault - History - Buffer supported by Solar Storage
|
||||||
|
FHBindexFHBvalueSolarStorage = 108, // u8/u8 Index number / Value of referred - to fault - history buffer entry Solar Storage
|
||||||
|
ElectricityProducerStarts = 109, // U16 Number of start of the electricity producer.
|
||||||
|
ElectricityProducerHours = 110, // U16 Number of hours the electricity produces is in operation
|
||||||
|
ElectricityProduction = 111, // U16 Current electricity production in Watt.
|
||||||
|
CumulativElectricityProduction = 112, // U16 Cumulative electricity production in KWh.
|
||||||
|
UnsuccessfulBurnerStarts = 113, // u16 Number of un - successful burner starts
|
||||||
|
FlameSignalTooLowNumber = 114, // u16 Number of times flame signal was too low
|
||||||
|
OEMDiagnosticCode = 115, // u16 OEM - specific diagnostic / service code
|
||||||
|
SuccessfulBurnerStarts = 116, // u16 Number of succesful starts burner
|
||||||
|
CHPumpStarts = 117, // u16 Number of starts CH pump
|
||||||
|
DHWPumpValveStarts = 118, // u16 Number of starts DHW pump / valve
|
||||||
|
DHWBurnerStarts = 119, // u16 Number of starts burner during DHW mode
|
||||||
|
BurnerOperationHours = 120, // u16 Number of hours that burner is in operation(i.e.flame on)
|
||||||
|
CHPumpOperationHours = 121, // u16 Number of hours that CH pump has been running
|
||||||
|
DHWPumpValveOperationHours = 122, // u16 Number of hours that DHW pump has been running or DHW valve has been opened
|
||||||
|
DHWBurnerOperationHours = 123, // u16 Number of hours that burner is in operation during DHW mode
|
||||||
|
OpenThermVersionMaster = 124, // f8.8 The implemented version of the OpenTherm Protocol Specification in the master.
|
||||||
|
OpenThermVersionSlave = 125, // f8.8 The implemented version of the OpenTherm Protocol Specification in the slave.
|
||||||
|
MasterVersion = 126, // u8/u8 Master product version number and type
|
||||||
|
SlaveVersion = 127, // u8/u8 Slave product version number and type
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class OpenThermStatus : byte
|
||||||
|
{
|
||||||
|
NOT_INITIALIZED,
|
||||||
|
READY,
|
||||||
|
DELAY,
|
||||||
|
REQUEST_SENDING,
|
||||||
|
RESPONSE_WAITING,
|
||||||
|
RESPONSE_START_BIT,
|
||||||
|
RESPONSE_RECEIVING,
|
||||||
|
RESPONSE_READY,
|
||||||
|
RESPONSE_INVALID
|
||||||
|
};
|
||||||
|
|
||||||
|
class OpenTherm
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
OpenTherm(int inPin = 4, int outPin = 5, bool isSlave = false);
|
||||||
|
~OpenTherm();
|
||||||
|
volatile OpenThermStatus status;
|
||||||
|
void begin(void (*handleInterruptCallback)(void));
|
||||||
|
void begin(void (*handleInterruptCallback)(void), void (*processResponseCallback)(unsigned long, int));
|
||||||
|
#if !defined(__AVR__)
|
||||||
|
void begin();
|
||||||
|
void begin(std::function<void(unsigned long, OpenThermResponseStatus)> processResponseFunction);
|
||||||
|
#endif
|
||||||
|
bool isReady();
|
||||||
|
unsigned long sendRequest(unsigned long request);
|
||||||
|
bool sendResponse(unsigned long request);
|
||||||
|
bool sendRequestAsync(unsigned long request);
|
||||||
|
static unsigned long buildRequest(OpenThermMessageType type, OpenThermMessageID id, unsigned int data);
|
||||||
|
static unsigned long buildResponse(OpenThermMessageType type, OpenThermMessageID id, unsigned int data);
|
||||||
|
unsigned long getLastResponse();
|
||||||
|
OpenThermResponseStatus getLastResponseStatus();
|
||||||
|
static const char *statusToString(OpenThermResponseStatus status);
|
||||||
|
void handleInterrupt();
|
||||||
|
#if !defined(__AVR__)
|
||||||
|
static void handleInterruptHelper(void* ptr);
|
||||||
|
#endif
|
||||||
|
void process();
|
||||||
|
void end();
|
||||||
|
|
||||||
|
static bool parity(unsigned long frame);
|
||||||
|
static OpenThermMessageType getMessageType(unsigned long message);
|
||||||
|
static OpenThermMessageID getDataID(unsigned long frame);
|
||||||
|
static const char *messageTypeToString(OpenThermMessageType message_type);
|
||||||
|
static bool isValidRequest(unsigned long request);
|
||||||
|
static bool isValidResponse(unsigned long response);
|
||||||
|
|
||||||
|
// requests
|
||||||
|
static unsigned long buildSetBoilerStatusRequest(bool enableCentralHeating, bool enableHotWater = false, bool enableCooling = false, bool enableOutsideTemperatureCompensation = false, bool enableCentralHeating2 = false);
|
||||||
|
static unsigned long buildSetBoilerTemperatureRequest(float temperature);
|
||||||
|
static unsigned long buildGetBoilerTemperatureRequest();
|
||||||
|
|
||||||
|
// responses
|
||||||
|
static bool isFault(unsigned long response);
|
||||||
|
static bool isCentralHeatingActive(unsigned long response);
|
||||||
|
static bool isHotWaterActive(unsigned long response);
|
||||||
|
static bool isFlameOn(unsigned long response);
|
||||||
|
static bool isCoolingActive(unsigned long response);
|
||||||
|
static bool isDiagnostic(unsigned long response);
|
||||||
|
static uint16_t getUInt(const unsigned long response);
|
||||||
|
static float getFloat(const unsigned long response);
|
||||||
|
static unsigned int temperatureToData(float temperature);
|
||||||
|
|
||||||
|
// basic requests
|
||||||
|
unsigned long setBoilerStatus(bool enableCentralHeating, bool enableHotWater = false, bool enableCooling = false, bool enableOutsideTemperatureCompensation = false, bool enableCentralHeating2 = false);
|
||||||
|
bool setBoilerTemperature(float temperature);
|
||||||
|
float getBoilerTemperature();
|
||||||
|
float getReturnTemperature();
|
||||||
|
bool setDHWSetpoint(float temperature);
|
||||||
|
float getDHWTemperature();
|
||||||
|
float getModulation();
|
||||||
|
float getPressure();
|
||||||
|
unsigned char getFault();
|
||||||
|
|
||||||
|
private:
|
||||||
|
const int inPin;
|
||||||
|
const int outPin;
|
||||||
|
const bool isSlave;
|
||||||
|
|
||||||
|
volatile unsigned long response;
|
||||||
|
volatile OpenThermResponseStatus responseStatus;
|
||||||
|
volatile unsigned long responseTimestamp;
|
||||||
|
volatile byte responseBitIndex;
|
||||||
|
|
||||||
|
int readState();
|
||||||
|
void setActiveState();
|
||||||
|
void setIdleState();
|
||||||
|
void activateBoiler();
|
||||||
|
|
||||||
|
void sendBit(bool high);
|
||||||
|
void processResponse();
|
||||||
|
void (*processResponseCallback)(unsigned long, int);
|
||||||
|
#if !defined(__AVR__)
|
||||||
|
std::function<void(unsigned long, OpenThermResponseStatus)> processResponseFunction;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifndef ICACHE_RAM_ATTR
|
||||||
|
#define ICACHE_RAM_ATTR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef IRAM_ATTR
|
||||||
|
#define IRAM_ATTR ICACHE_RAM_ATTR
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // OpenTherm_h
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user