zephyr/dts/bindings/input/futaba,sbus.yaml

71 lines
1.9 KiB
YAML
Raw Normal View History

# Copyright (c) 2024 NXP Semiconductors
# SPDX-License-Identifier: Apache-2.0
description: |
SBUS input driver using
This driver implements the SBUS protocol used on RC radio's
to send out analogue joystick and switches output.
SBUS is an single-wire inverted serial protocol so either you need to use
the rx-invert feature of your serial driver or use an external signal inverter.
The driver binds this to the Zephyr input system using INPUT_EV_CODES.
everywhere: replace double words import os import re common_words = set([ 'about', 'after', 'all', 'also', 'an', 'and', 'any', 'are', 'as', 'at', 'be', 'because', 'but', 'by', 'can', 'come', 'could', 'day', 'do', 'even', 'first', 'for', 'get', 'give', 'go', 'has', 'have', 'he', 'her', 'him', 'his', 'how', 'I', 'in', 'into', 'it', 'its', 'just', 'know', 'like', 'look', 'make', 'man', 'many', 'me', 'more', 'my', 'new', 'no', 'not', 'now', 'of', 'one', 'only', 'or', 'other', 'our', 'out', 'over', 'people', 'say', 'see', 'she', 'so', 'some', 'take', 'tell', 'than', 'their', 'them', 'then', 'there', 'these', 'they', 'think', 'this', 'time', 'two', 'up', 'use', 'very', 'want', 'was', 'way', 'we', 'well', 'what', 'when', 'which', 'who', 'will', 'with', 'would', 'year', 'you', 'your' ]) valid_extensions = set([ 'c', 'h', 'yaml', 'cmake', 'conf', 'txt', 'overlay', 'rst', 'dtsi', 'Kconfig', 'dts', 'defconfig', 'yml', 'ld', 'sh', 'py', 'soc', 'cfg' ]) def filter_repeated_words(text): # Split the text into lines lines = text.split('\n') # Combine lines into a single string with unique separator combined_text = '/*sep*/'.join(lines) # Replace repeated words within a line def replace_within_line(match): return match.group(1) # Regex for matching repeated words within a line within_line_pattern = re.compile(r'\b(' + '|'.join(map(re.escape, common_words)) + r')\b\s+\b\1\b') combined_text = within_line_pattern. sub(replace_within_line, combined_text) # Replace repeated words across line boundaries def replace_across_lines(match): return match.group(1) + match.group(2) # Regex for matching repeated words across line boundaries across_lines_pattern = re. compile(r'\b(' + '|'.join( map(re.escape, common_words)) + r')\b(\s*[*\/\n\s]*)\b\1\b') combined_text = across_lines_pattern. sub(replace_across_lines, combined_text) # Split the text back into lines filtered_text = combined_text.split('/*sep*/') return '\n'.join(filtered_text) def process_file(file_path): with open(file_path, 'r', encoding='utf-8') as file: text = file.read() new_text = filter_repeated_words(text) with open(file_path, 'w', encoding='utf-8') as file: file.write(new_text) def process_directory(directory_path): for root, dirs, files in os.walk(directory_path): dirs[:] = [d for d in dirs if not d.startswith('.')] for file in files: # Filter out hidden files if file.startswith('.'): continue file_extension = file.split('.')[-1] if file_extension in valid_extensions: # 只处理指定后缀的文件 file_path = os.path.join(root, file) print(f"Processed file: {file_path}") process_file(file_path) directory_to_process = "/home/mi/works/github/zephyrproject/zephyr" process_directory(directory_to_process) Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
2024-06-22 14:28:05 +08:00
The following examples defines a binding of 2 joysticks and a button using 5 channels.
&lpuart6 {
status = "okay";
sbus {
compatible = "futaba,sbus";
right_stick_x {
channel = <1>;
type = <INPUT_EV_ABS>;
zephyr,code = <INPUT_ABS_RX>;
};
right_stick_y {
channel = <2>;
type = <INPUT_EV_ABS>;
zephyr,code = <INPUT_ABS_RY>;
};
left_stick_x {
channel = <3>;
type = <INPUT_EV_ABS>;
zephyr,code = <INPUT_ABS_X>;
};
left_stick_y {
channel = <4>;
type = <INPUT_EV_ABS>;
zephyr,code = <INPUT_ABS_Y>;
};
kill_switch {
channel = <5>;
type = <INPUT_EV_KEY>;
zephyr,code = <INPUT_KEY_0>;
};
};
};
compatible: "futaba,sbus"
include: [base.yaml, uart-device.yaml]
child-binding:
description: |
SBUS Channel to input-event-code binding
INPUT_EV_ABS & INPUT_EV_MSC gives raw input value
INPUT_EV_KEY emulates a key
properties:
channel:
type: int
required: true
description: |
SBUS input channel
Valid range: 1 - 16
type:
type: int
required: true
description: Input event types see INPUT_EV_CODES
zephyr,code:
type: int
required: true
description: Code to emit.