Skip to content

fix: restore brightness on resume#22

Open
ben16w wants to merge 9 commits intomainfrom
brightness-fix
Open

fix: restore brightness on resume#22
ben16w wants to merge 9 commits intomainfrom
brightness-fix

Conversation

@ben16w
Copy link
Owner

@ben16w ben16w commented May 13, 2025

closes #4

@ben16w ben16w changed the title fix: set brightness on resume fix: restore brightness on resume May 13, 2025
Copilot AI review requested due to automatic review settings October 27, 2025 21:32
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a brightness control utility to restore brightness on device resume. The implementation provides platform-specific brightness management for three different handheld gaming devices.

Key changes:

  • Added a new Go program (set-brightness.go) that sets brightness levels for tg5040, miyoomini, and rg35xxplus platforms
  • Updated build system to compile platform-specific binaries with embedded platform identifiers

Reviewed Changes

Copilot reviewed 2 out of 5 changed files in this pull request and generated 5 comments.

File Description
src/set-brightness.go New brightness control utility with platform-specific implementations using ioctl and sysfs interfaces
Makefile Build targets for platform-specific set-brightness binaries with compile-time platform identification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

}

func applybrightnessDevice(val int) error {
const brightnessDevice = "/sys/class/pwm/pwmchip0/pwm0/brightnessDevice"
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sysfs path appears incorrect. The standard PWM sysfs interface uses 'duty_cycle' not 'brightnessDevice'. This path likely doesn't exist and will cause the function to fail.

Suggested change
const brightnessDevice = "/sys/class/pwm/pwmchip0/pwm0/brightnessDevice"
const brightnessDevice = "/sys/class/pwm/pwmchip0/pwm0/duty_cycle"

Copilot uses AI. Check for mistakes.
Comment on lines +69 to +77
fmt.Errorf("Failed to open %s: %w", brightnessDevice, err)
return err
}
defer file.Close()

_, err = fmt.Fprintf(file, "%d", val)
if err != nil {
fmt.Errorf("Failed to set brightness: %w", err)
return err
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Errorf return value is not being used. Should be 'return fmt.Errorf(...)' or use fmt.Printf/fmt.Println to output the error.

Suggested change
fmt.Errorf("Failed to open %s: %w", brightnessDevice, err)
return err
}
defer file.Close()
_, err = fmt.Fprintf(file, "%d", val)
if err != nil {
fmt.Errorf("Failed to set brightness: %w", err)
return err
return fmt.Errorf("Failed to open %s: %w", brightnessDevice, err)
}
defer file.Close()
_, err = fmt.Fprintf(file, "%d", val)
if err != nil {
return fmt.Errorf("Failed to set brightness: %w", err)

Copilot uses AI. Check for mistakes.
Comment on lines +76 to +78
fmt.Errorf("Failed to set brightness: %w", err)
return err
}
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fmt.Errorf return value is not being used. Should be 'return fmt.Errorf(...)' or use fmt.Printf/fmt.Println to output the error.

Suggested change
fmt.Errorf("Failed to set brightness: %w", err)
return err
}
return fmt.Errorf("Failed to set brightness: %w", err)
}

Copilot uses AI. Check for mistakes.
Comment on lines +19 to +20
mapTrimui := [11]int{0, 1, 8, 16, 32, 48, 72, 96, 128, 176, 255}
raw = mapTrimui[value]
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing bounds check before array access. If 'value' is outside 0-10 range, this will panic with index out of range. Add validation or use a bounds check.

Copilot uses AI. Check for mistakes.
Comment on lines +30 to +31
mapRg35xxplus := [11]int{0, 4, 6, 10, 16, 32, 48, 64, 96, 160, 255}
raw = mapRg35xxplus[value]
Copy link

Copilot AI Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing bounds check before array access. If 'value' is outside 0-10 range, this will panic with index out of range. Add validation or use a bounds check.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Screen staying turned off on resume

2 participants