working on off

This commit is contained in:
Siwat Sirichai 2025-06-06 17:05:15 +07:00
parent 71d3791e9e
commit 70786734bd
3 changed files with 81 additions and 151 deletions

View file

@ -8,6 +8,7 @@ import time
from benq_smartboard_lib import (
BenQSmartBoard,
ConnectionType,
PowerState,
PowerState,
VideoSource,
BenQSmartBoardError
@ -23,7 +24,7 @@ def test_serial_connection():
"""Test the serial connection functionality."""
# Configure your serial port here
SERIAL_PORT = 'COM3' # Windows example, use '/dev/ttyUSB0' for Linux
SERIAL_PORT = 'COM11' # Windows example, use '/dev/ttyUSB0' for Linux
BAUDRATE = 115200
print(f"Testing BenQ Smart Board via Serial: {SERIAL_PORT} @ {BAUDRATE}")
@ -47,93 +48,11 @@ def test_serial_connection():
# Get current power state
try:
power_state = board.get_power()
print(f"Current power state: {power_state}")
print("Expected packet: 801s!000\\r (where 21 hex = ! ASCII, length=8 includes length byte)")
board.set_power(PowerState.ON)
print("Power OFF command sent successfully!")
except Exception as e:
print(f"Failed to get power state: {e}")
# Get current video source
try:
video_source = board.get_video_source()
print(f"Current video source: {video_source}")
except Exception as e:
print(f"Failed to get video source: {e}")
# Get current volume
try:
volume = board.get_volume()
print(f"Current volume: {volume}")
except Exception as e:
print(f"Failed to get volume: {e}")
# Get current brightness
try:
brightness = board.get_brightness()
print(f"Current brightness: {brightness}")
except Exception as e:
print(f"Failed to get brightness: {e}")
print("\n=== Testing Set Commands ===")
# Test setting volume
try:
print("Setting volume to 50...")
success = board.set_volume(50)
print(f"Set volume result: {'Success' if success else 'Failed'}")
time.sleep(1)
# Verify the change
new_volume = board.get_volume()
print(f"New volume: {new_volume}")
except Exception as e:
print(f"Failed to set volume: {e}")
# Test setting brightness
try:
print("Setting brightness to 80...")
success = board.set_brightness(80)
print(f"Set brightness result: {'Success' if success else 'Failed'}")
time.sleep(1)
# Verify the change
new_brightness = board.get_brightness()
print(f"New brightness: {new_brightness}")
except Exception as e:
print(f"Failed to set brightness: {e}")
# Test video source switching
try:
print("Switching to HDMI1...")
success = board.set_video_source(VideoSource.HDMI1)
print(f"Set video source result: {'Success' if success else 'Failed'}")
time.sleep(2)
# Verify the change
new_source = board.get_video_source()
print(f"New video source: {new_source}")
except Exception as e:
print(f"Failed to set video source: {e}")
print("\n=== Testing Advanced Commands ===")
# Test RTC reading
try:
rtc_info = board.get_rtc()
print(f"RTC Info: {rtc_info}")
except Exception as e:
print(f"Failed to get RTC info: {e}")
# Test mute functionality
try:
print("Testing mute...")
success = board.set_mute(True)
print(f"Mute ON result: {'Success' if success else 'Failed'}")
time.sleep(2)
success = board.set_mute(False)
print(f"Mute OFF result: {'Success' if success else 'Failed'}")
except Exception as e:
print(f"Failed to test mute: {e}")
print(f"Failed to set power OFF: {e}")
print("\n=== Test Completed Successfully ===")