mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-04-10 21:03:01 +00:00
Screen tuning
Adjust buggy screen rotation
This commit is contained in:
36
README.md
36
README.md
@@ -76,6 +76,42 @@ For sensitive settings like API keys:
|
|||||||
1. Copy the template: `cp config/config_secrets.template.json config/config_secrets.json`
|
1. Copy the template: `cp config/config_secrets.template.json config/config_secrets.json`
|
||||||
2. Edit `config/config_secrets.json` with your API keys
|
2. Edit `config/config_secrets.json` with your API keys
|
||||||
|
|
||||||
|
## Important: Sound Module Configuration
|
||||||
|
|
||||||
|
The LED matrix library is known to conflict with the Raspberry Pi's built-in sound module. To prevent issues:
|
||||||
|
|
||||||
|
1. Remove unnecessary services that might interfere with the LED matrix:
|
||||||
|
```bash
|
||||||
|
sudo apt-get remove bluez bluez-firmware pi-bluetooth triggerhappy pigpio
|
||||||
|
```
|
||||||
|
|
||||||
|
2. Blacklist the sound module:
|
||||||
|
```bash
|
||||||
|
cat <<EOF | sudo tee /etc/modprobe.d/blacklist-rgb-matrix.conf
|
||||||
|
blacklist snd_bcm2835
|
||||||
|
EOF
|
||||||
|
|
||||||
|
sudo update-initramfs -u
|
||||||
|
```
|
||||||
|
|
||||||
|
3. Reboot:
|
||||||
|
```bash
|
||||||
|
sudo reboot
|
||||||
|
```
|
||||||
|
|
||||||
|
Note: If you still experience issues, you can additionally disable the audio hardware by editing `/boot/firmware/config.txt`:
|
||||||
|
```bash
|
||||||
|
sudo nano /boot/firmware/config.txt
|
||||||
|
```
|
||||||
|
And adding:
|
||||||
|
```
|
||||||
|
dtparam=audio=off
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, you can:
|
||||||
|
- Use external USB sound adapters if you need audio
|
||||||
|
- Run the program with `--led-no-hardware-pulse` flag (may cause more flicker)
|
||||||
|
|
||||||
## Running the Clock
|
## Running the Clock
|
||||||
|
|
||||||
The program must be run with root privileges to access the LED matrix hardware:
|
The program must be run with root privileges to access the LED matrix hardware:
|
||||||
|
|||||||
@@ -22,13 +22,14 @@
|
|||||||
"panel_type": "",
|
"panel_type": "",
|
||||||
"row_addr_type": 0,
|
"row_addr_type": 0,
|
||||||
"multiplexing": 0,
|
"multiplexing": 0,
|
||||||
"disable_hardware_pulsing": false,
|
"disable_hardware_pulsing": true,
|
||||||
"inverse_colors": false,
|
"inverse_colors": false,
|
||||||
"show_refresh_rate": false,
|
"show_refresh_rate": false,
|
||||||
"limit_refresh_rate_hz": 100
|
"limit_refresh_rate_hz": 100,
|
||||||
|
"rotation": 180
|
||||||
},
|
},
|
||||||
"runtime": {
|
"runtime": {
|
||||||
"gpio_slowdown": 3
|
"gpio_slowdown": 2
|
||||||
},
|
},
|
||||||
"rotation_interval": 10
|
"rotation_interval": 10
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -22,39 +22,52 @@ class DisplayManager:
|
|||||||
self.draw = ImageDraw.Draw(self.image)
|
self.draw = ImageDraw.Draw(self.image)
|
||||||
DisplayManager._initialized = True
|
DisplayManager._initialized = True
|
||||||
|
|
||||||
def _setup_matrix(self) -> RGBMatrix:
|
def _setup_matrix(self):
|
||||||
"""Setup the RGB matrix with the provided configuration."""
|
"""Initialize the RGB matrix with configuration settings."""
|
||||||
options = RGBMatrixOptions()
|
options = RGBMatrixOptions()
|
||||||
|
|
||||||
# Get hardware and runtime configs
|
# Hardware configuration
|
||||||
hw_config = self.config.get('hardware', {})
|
hardware_config = self.config.get('hardware', {})
|
||||||
|
options.rows = hardware_config.get('rows', 32)
|
||||||
|
options.cols = hardware_config.get('cols', 64)
|
||||||
|
options.chain_length = hardware_config.get('chain_length', 2)
|
||||||
|
options.parallel = hardware_config.get('parallel', 1)
|
||||||
|
options.hardware_mapping = hardware_config.get('hardware_mapping', 'adafruit-hat-pwm')
|
||||||
|
options.brightness = hardware_config.get('brightness', 50)
|
||||||
|
options.pwm_bits = hardware_config.get('pwm_bits', 11)
|
||||||
|
options.pwm_lsb_nanoseconds = hardware_config.get('pwm_lsb_nanoseconds', 130)
|
||||||
|
options.led_rgb_sequence = hardware_config.get('led_rgb_sequence', 'RGB')
|
||||||
|
options.pixel_mapper_config = hardware_config.get('pixel_mapper_config', '')
|
||||||
|
options.row_address_type = hardware_config.get('row_addr_type', 0)
|
||||||
|
options.multiplexing = hardware_config.get('multiplexing', 0)
|
||||||
|
options.disable_hardware_pulsing = hardware_config.get('disable_hardware_pulsing', True)
|
||||||
|
options.show_refresh_rate = hardware_config.get('show_refresh_rate', False)
|
||||||
|
options.limit_refresh_rate_hz = hardware_config.get('limit_refresh_rate_hz', 100)
|
||||||
|
|
||||||
|
# Runtime configuration
|
||||||
runtime_config = self.config.get('runtime', {})
|
runtime_config = self.config.get('runtime', {})
|
||||||
|
options.gpio_slowdown = runtime_config.get('gpio_slowdown', 3)
|
||||||
|
|
||||||
# Hardware specific settings
|
# Initialize the matrix
|
||||||
options.rows = hw_config.get('rows', 32)
|
self.matrix = RGBMatrix(options=options)
|
||||||
options.cols = hw_config.get('cols', 64)
|
self.canvas = self.matrix.CreateFrameCanvas()
|
||||||
options.chain_length = hw_config.get('chain_length', 2)
|
|
||||||
options.parallel = hw_config.get('parallel', 1)
|
|
||||||
options.brightness = hw_config.get('brightness', 50)
|
|
||||||
options.hardware_mapping = hw_config.get('hardware_mapping', 'adafruit-hat')
|
|
||||||
options.pwm_bits = hw_config.get('pwm_bits', 11)
|
|
||||||
options.pwm_lsb_nanoseconds = hw_config.get('pwm_lsb_nanoseconds', 130)
|
|
||||||
options.led_rgb_sequence = hw_config.get('led_rgb_sequence', 'RGB')
|
|
||||||
options.pixel_mapper_config = hw_config.get('pixel_mapper_config', '')
|
|
||||||
options.multiplexing = hw_config.get('multiplexing', 0)
|
|
||||||
options.row_address_type = hw_config.get('row_addr_type', 0)
|
|
||||||
options.panel_type = hw_config.get('panel_type', '')
|
|
||||||
|
|
||||||
# Display options
|
# Apply rotation if specified
|
||||||
options.show_refresh_rate = hw_config.get('show_refresh_rate', False)
|
self.rotation = hardware_config.get('rotation', 0)
|
||||||
options.limit_refresh_rate_hz = hw_config.get('limit_refresh_rate_hz', 100)
|
|
||||||
options.inverse_colors = hw_config.get('inverse_colors', False)
|
|
||||||
options.disable_hardware_pulsing = hw_config.get('disable_hardware_pulsing', False)
|
|
||||||
|
|
||||||
# Runtime options
|
def _draw_text(self, text, x, y, font, color=(255, 255, 255)):
|
||||||
options.gpio_slowdown = runtime_config.get('gpio_slowdown', 4)
|
"""Draw text on the canvas with optional rotation."""
|
||||||
|
if self.rotation == 180:
|
||||||
|
# For 180 degree rotation, flip coordinates
|
||||||
|
width = self.matrix.width
|
||||||
|
height = self.matrix.height
|
||||||
|
# Get text size for proper positioning
|
||||||
|
text_width, text_height = font.getsize(text)
|
||||||
|
# Adjust coordinates for rotation
|
||||||
|
x = width - x - text_width
|
||||||
|
y = height - y - text_height
|
||||||
|
|
||||||
return RGBMatrix(options=options)
|
graphics.DrawText(self.canvas, font, x, y, graphics.Color(*color), text)
|
||||||
|
|
||||||
def clear(self):
|
def clear(self):
|
||||||
"""Clear the display."""
|
"""Clear the display."""
|
||||||
|
|||||||
Reference in New Issue
Block a user