The Despia Adaptive Brightness SDK enables your application to dynamically adjust screen brightness to improve QR code scanning and ticket display. This feature optimizes the readability of QR codes and other scannable content while intelligently managing battery life through automatic brightness control.
Quick Start
1. Select a Brightness Mode
Choose between automatic, manual on, or manual off modes to control screen brightness.
const mode = "auto" // auto, off, or on
window.despia = `scanningmode://${mode}`
2. Enable Automatic Brightness Adjustment
Let the system intelligently adjust brightness based on environmental conditions.
window.despia = "scanningmode://auto"
3. Return to Normal Brightness
Restore default brightness settings when scanning is complete.
window.despia = "scanningmode://off"
How It Works
The Adaptive Brightness SDK provides seamless control over device screen brightness to optimize the scanning experience. When enabled, the feature can:
-
Boost screen brightness to improve QR code visibility and scan speed
-
Automatically adjust brightness based on ambient light conditions
-
Return to normal brightness settings to conserve battery when scanning is complete
The SDK offers three distinct operation modes to suit different use cases:
-
Auto Mode: Intelligently adjusts brightness based on environmental conditions
-
Manual On: Forces maximum brightness for guaranteed scan visibility
-
Manual Off: Returns device to standard brightness settings
Implementation Examples
Here's how to implement the Adaptive Brightness SDK in common ticket and scanning scenarios:
// Ticket Display Example
function showTicket() {
// Increase brightness for scanning
window.despia = "scanningmode://on"
// Show ticket QR code
displayTicketQR()
}
// Smart Scanning Example
function startScanning() {
// Let system decide brightness
window.despia = "scanningmode://auto"
// Show scannable content
showScanContent()
}
// Cleanup Example
function exitScanning() {
// Return to normal
window.despia = "scanningmode://off"
// Hide scan content
hideScanContent()
}
Data Structure
The SDK uses a simple string-based command structure:
window.despia = "scanningmode://[mode]"
Where [mode]
can be:
-
auto
: System determines optimal brightness based on conditions -
on
: Forces maximum brightness for scanning -
off
: Returns to normal device brightness settings
Best Practices
Performance Optimization
-
Use auto mode when possible to balance scanning performance and battery life
-
Turn off enhanced brightness immediately after scanning is complete
-
Consider battery impact when using the "on" mode for extended periods
User Experience
-
Test scanning in different lighting conditions to validate effectiveness
-
Provide user feedback when brightness modes change
-
Consider implementing a timeout to revert to normal brightness
Troubleshooting
Common Issues
Brightness Not Changing
-
Verify the correct syntax for the scanningmode URL
-
Check if the device supports brightness control
-
Ensure the application has proper permissions
Battery Drain
-
Limit the use of "on" mode to essential scanning operations
-
Implement timeouts to automatically revert to normal brightness
-
Use "auto" mode instead of "on" when possible
For additional support or questions, please contact our support team at support@despia.com