@@ -3,22 +3,15 @@ package org.koreader.launcher.device.lights
3
3
import android.app.Activity
4
4
import android.util.Log
5
5
import org.koreader.launcher.device.LightsInterface
6
- import org.koreader.launcher.extensions.read
7
- import org.koreader.launcher.extensions.write
8
- import java.io.File
9
6
10
- class OnyxBlController : LightsInterface {
7
+ class OnyxSdk2LightsController : LightsInterface {
11
8
companion object {
12
9
private const val TAG = " Lights"
13
- private const val MIN = 0
14
- private const val WHITE_FILE = " /sys/class/backlight/onyx_bl_br/brightness"
15
- private const val WARMTH_FILE = " /sys/class/backlight/onyx_bl_ct/brightness"
16
- private const val MAX_WHITE_FILE = " /sys/class/backlight/onyx_bl_br/max_brightness"
17
- private const val MAX_WARMTH_FILE = " /sys/class/backlight/onyx_bl_ct/max_brightness"
10
+ private const val MIN_LIGHT_VALUE = 0
18
11
}
19
12
20
13
override fun getPlatform (): String {
21
- return " onyx-bl "
14
+ return " onyx-sdk-2-lights "
22
15
}
23
16
24
17
override fun hasFallback (): Boolean {
@@ -34,53 +27,52 @@ class OnyxBlController : LightsInterface {
34
27
}
35
28
36
29
override fun getBrightness (activity : Activity ): Int {
37
- return File ( WHITE_FILE ).read( )
30
+ return OnyxSdkDeviceController .getLightValue( OnyxSdkDeviceController . Light . COLD )
38
31
}
39
32
40
33
override fun getWarmth (activity : Activity ): Int {
41
- return File ( WARMTH_FILE ).read( )
34
+ return OnyxSdkDeviceController .getLightValue( OnyxSdkDeviceController . Light . WARM )
42
35
}
43
36
44
37
override fun setBrightness (activity : Activity , brightness : Int ) {
45
- if (brightness < MIN || brightness > getMaxBrightness()) {
38
+ if (brightness < getMinBrightness() || brightness > getMaxBrightness()) {
46
39
Log .w(TAG , " brightness value of of range: $brightness " )
47
40
return
48
41
}
49
42
Log .v(TAG , " Setting brightness to $brightness " )
50
- File ( WHITE_FILE ).write( brightness)
43
+ OnyxSdkDeviceController .setLightValue( OnyxSdkDeviceController . Light . COLD , brightness)
51
44
}
52
45
53
46
override fun setWarmth (activity : Activity , warmth : Int ) {
54
- if (warmth < MIN || warmth > getMaxWarmth()) {
47
+ if (warmth < getMinWarmth() || warmth > getMaxWarmth()) {
55
48
Log .w(TAG , " warmth value of of range: $warmth " )
56
49
return
57
50
}
58
-
59
51
Log .v(TAG , " Setting warmth to $warmth " )
60
- File ( WARMTH_FILE ).write( warmth)
52
+ OnyxSdkDeviceController .setLightValue( OnyxSdkDeviceController . Light . WARM , warmth)
61
53
}
62
54
63
55
override fun getMinWarmth (): Int {
64
- return MIN
56
+ return MIN_LIGHT_VALUE
65
57
}
66
58
67
59
override fun getMaxWarmth (): Int {
68
- return File ( MAX_WARMTH_FILE ).read( )
60
+ return OnyxSdkDeviceController .getMaxLightValue( OnyxSdkDeviceController . Light . WARM )
69
61
}
70
62
71
63
override fun getMinBrightness (): Int {
72
- return MIN
64
+ return MIN_LIGHT_VALUE
73
65
}
74
66
75
67
override fun getMaxBrightness (): Int {
76
- return File ( MAX_WHITE_FILE ).read( )
68
+ return OnyxSdkDeviceController .getMaxLightValue( OnyxSdkDeviceController . Light . COLD )
77
69
}
78
70
79
71
override fun enableFrontlightSwitch (activity : Activity ): Int {
80
72
return 1
81
73
}
82
74
83
75
override fun hasStandaloneWarmth (): Boolean {
84
- return true
76
+ return false
85
77
}
86
78
}
0 commit comments