Skip to content

Commit

Permalink
Merge pull request #1 from Bartixxx32/detached
Browse files Browse the repository at this point in the history
never allow to value be lower than 0 and switch_2 seems to be enough
  • Loading branch information
Bartixxx32 authored Dec 10, 2024
2 parents dee086b + c5c0212 commit 49e33d0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "com.bartixxx.opflashcontrol"
minSdk = 29
targetSdk = 35
versionCode = 7
versionName = "1.0.6"
versionCode = 8
versionName = "1.0.7"

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
24 changes: 14 additions & 10 deletions app/src/main/java/com/bartixxx/opflashcontrol/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class MainActivity : AppCompatActivity() {
const val FLASH_WHITE_LED_PATH = "/sys/class/leds/led:flash_0/brightness"
const val FLASH_YELLOW_LED_PATH = "/sys/class/leds/led:flash_1/brightness"
val TOGGLE_PATHS = listOf(
"/sys/class/leds/led:switch_0/brightness",
"/sys/class/leds/led:switch_1/brightness",
//"/sys/class/leds/led:switch_0/brightness",
//"/sys/class/leds/led:switch_1/brightness",
"/sys/class/leds/led:switch_2/brightness"
)
}
Expand All @@ -42,7 +42,7 @@ class MainActivity : AppCompatActivity() {

setupSeekBar(masterSeekBar, masterBrightnessText, "Master Brightness") { progress ->
masterBrightness = progress
if (isLedOn && whiteBrightness == 0 && yellowBrightness == 0) {
if (isLedOn && whiteBrightness <= 1 && yellowBrightness <= 1) {
controlLeds("on", WHITE_LED_PATH, YELLOW_LED_PATH, TOGGLE_PATHS, masterBrightness, masterBrightness)
}
}
Expand Down Expand Up @@ -72,11 +72,11 @@ class MainActivity : AppCompatActivity() {

offButton.setOnClickListener {
isLedOn = false
controlLeds("off", WHITE_LED_PATH, YELLOW_LED_PATH, TOGGLE_PATHS, 0, 0)
controlLeds("off", WHITE_LED_PATH, YELLOW_LED_PATH, TOGGLE_PATHS, 1, 1)
}

extraButton.setOnClickListener {
controlLeds("off", FLASH_WHITE_LED_PATH, FLASH_YELLOW_LED_PATH, TOGGLE_PATHS, 0, 0)
controlLeds("off", FLASH_WHITE_LED_PATH, FLASH_YELLOW_LED_PATH, TOGGLE_PATHS, 1000, 1000)
controlLeds("on", FLASH_WHITE_LED_PATH, FLASH_YELLOW_LED_PATH, TOGGLE_PATHS, 1500, 1500)
isLedOn = true
}
Expand All @@ -95,7 +95,11 @@ class MainActivity : AppCompatActivity() {

override fun onStartTrackingTouch(seekBar: SeekBar) {}
override fun onStopTrackingTouch(seekBar: SeekBar) {
onStopTracking(seekBar.progress)
var progress = seekBar.progress
if (progress == 0) {
progress = 1 // Prevent zero brightness
}
onStopTracking(progress)
}
})
}
Expand All @@ -111,16 +115,16 @@ class MainActivity : AppCompatActivity() {
val commands = mutableListOf<String>()

if (action == "on") {
commands.add("echo 0 > $whiteLedPath")
commands.add("echo 0 > $yellowLedPath")
commands.add("echo 80 > $whiteLedPath")
commands.add("echo 80 > $yellowLedPath")
togglePaths.forEach { commands.add("echo 0 > $it") }

commands.add("echo $whiteBrightness > $whiteLedPath")
commands.add("echo $yellowBrightness > $yellowLedPath")
togglePaths.forEach { commands.add("echo 255 > $it") }
} else if (action == "off") {
commands.add("echo 0 > $whiteLedPath")
commands.add("echo 0 > $yellowLedPath")
commands.add("echo 80 > $whiteLedPath")
commands.add("echo 80 > $yellowLedPath")
togglePaths.forEach { commands.add("echo 0 > $it") }
}

Expand Down
9 changes: 6 additions & 3 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
android:layout_height="40dp"
android:layout_x="0dp"
android:layout_y="549dp"
android:max="255" />
android:max="255"
android:min="0" />

<TextView
android:id="@+id/textView2"
Expand All @@ -59,7 +60,8 @@
android:layout_height="40dp"
android:layout_x="0dp"
android:layout_y="491dp"
android:max="255" />
android:max="255"
android:min="0" />

<TextView
android:id="@+id/textView3"
Expand All @@ -76,7 +78,8 @@
android:layout_height="40dp"
android:layout_x="0dp"
android:layout_y="441dp"
android:max="255" />
android:max="255"
android:min="0" />

<TextView
android:id="@+id/yellowTextView"
Expand Down

0 comments on commit 49e33d0

Please sign in to comment.