Skip to content

Commit

Permalink
Fix issue #19
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteCarra committed May 18, 2019
1 parent 5d1df10 commit ae39ad0
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 31 deletions.
12 changes: 6 additions & 6 deletions app/src/main/java/mattecarra/accapp/acc/v201905111/AccHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AccHandler(): AccInterface {
override val defaultConfig: AccConfig = AccConfig(
AccConfig.ConfigCapacity(5, 70, 80),
AccConfig.ConfigVoltage(null, null),
AccConfig.ConfigTemperature(400, 450, 90),
AccConfig.ConfigTemperature(40, 45, 90),
null,
null,
null,
Expand All @@ -45,7 +45,7 @@ class AccHandler(): AccInterface {
val config = readConfigToString()

val (capacityShutdown, capacityCoolDown, capacityResume, capacityPause) = CAPACITY_CONFIG_REGEXP.find(config)!!.destructured
val (coolDownTemp, pauseChargingTemp, waitSeconds) = TEMP_CONFIG_REGEXP.find(config)!!.destructured
val (temperatureCooldown, temperatureMax, waitSeconds) = TEMP_CONFIG_REGEXP.find(config)!!.destructured

val coolDownMatchResult = COOLDOWN_CONFIG_REGEXP.find(config)?.destructured

Expand All @@ -54,8 +54,8 @@ class AccHandler(): AccInterface {
return AccConfig(
AccConfig.ConfigCapacity(capacityShutdown.toIntOrNull() ?: 0, capacityResume.toInt(), capacityPause.toInt()),
AccConfig.ConfigVoltage(cVolt?.component1(), cVolt?.component2()?.toIntOrNull()),
AccConfig.ConfigTemperature(coolDownTemp.toIntOrNull()?.let { it / 10 } ?: 90,
pauseChargingTemp.toIntOrNull()?.let { it / 10 } ?: 95,
AccConfig.ConfigTemperature(temperatureCooldown.toIntOrNull() ?: 90,
temperatureMax.toIntOrNull() ?: 95,
waitSeconds.toIntOrNull() ?: 90),
getOnBoot(config),
getOnPlugged(config),
Expand Down Expand Up @@ -355,8 +355,8 @@ class AccHandler(): AccInterface {
* @param wait seconds to wait until charging is resumed.
* @return the boolean result of the command's execution.
*/
private fun updateAccTemperature(coolDownTemperature: Int, pauseTemperature: Int, wait: Int) : Boolean {
return Shell.su("acc -s temperature ${coolDownTemperature*10}-${pauseTemperature*10}_$wait").exec().isSuccess
private fun updateAccTemperature(coolDownTemperature: Int, temperatureMax: Int, wait: Int) : Boolean {
return Shell.su("acc -s temperature ${coolDownTemperature}-${temperatureMax}_$wait").exec().isSuccess
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.appcompat.widget.Toolbar
import com.afollestad.materialdialogs.MaterialDialog
import com.afollestad.materialdialogs.input.input
import kotlinx.android.synthetic.main.content_acc_config_editor.*
import mattecarra.accapp.acc.v201905111.AccHandler
import mattecarra.accapp.R
import android.app.Activity
import android.content.Intent
Expand Down Expand Up @@ -271,23 +270,23 @@ class AccConfigEditorActivity : AppCompatActivity(), NumberPicker.OnValueChangeL
pause_capacity_picker.setOnValueChangedListener(this)

//temps
if(mAccConfig.configTemperature.coolDownTemperature >= 90 && mAccConfig.configTemperature.pause >= 95) {
if(mAccConfig.configTemperature.coolDownTemperature >= 90 && mAccConfig.configTemperature.maxTemperature >= 95) {
temp_switch.isChecked = false
cooldown_temperature_picker.isEnabled = false
pause_temperature_picker.isEnabled = false
temperature_cooldown_picker.isEnabled = false
temperature_max_picker.isEnabled = false
temperature_max_pause_seconds_picker.isEnabled = false
}
temp_switch.setOnCheckedChangeListener(this)

cooldown_temperature_picker.minValue = 20
cooldown_temperature_picker.maxValue = 90
cooldown_temperature_picker.value = mAccConfig.configTemperature.coolDownTemperature
cooldown_temperature_picker.setOnValueChangedListener(this)
temperature_cooldown_picker.minValue = 20
temperature_cooldown_picker.maxValue = 90
temperature_cooldown_picker.value = mAccConfig.configTemperature.coolDownTemperature
temperature_cooldown_picker.setOnValueChangedListener(this)

pause_temperature_picker.minValue = 20
pause_temperature_picker.maxValue = 95
pause_temperature_picker.value = mAccConfig.configTemperature.pause
pause_temperature_picker.setOnValueChangedListener(this)
temperature_max_picker.minValue = 20
temperature_max_picker.maxValue = 95
temperature_max_picker.value = mAccConfig.configTemperature.maxTemperature
temperature_max_picker.setOnValueChangedListener(this)

temperature_max_pause_seconds_picker.minValue = 10
temperature_max_pause_seconds_picker.maxValue = 120
Expand Down Expand Up @@ -420,20 +419,20 @@ class AccConfigEditorActivity : AppCompatActivity(), NumberPicker.OnValueChangeL
if(buttonView == null) return
when(buttonView.id) {
R.id.temp_switch -> {
cooldown_temperature_picker.isEnabled = isChecked
pause_temperature_picker.isEnabled = isChecked
temperature_cooldown_picker.isEnabled = isChecked
temperature_max_picker.isEnabled = isChecked
temperature_max_pause_seconds_picker.isEnabled = isChecked

if(isChecked) {
cooldown_temperature_picker.value = 40
pause_temperature_picker.value = 45
temperature_cooldown_picker.value = 40
temperature_max_picker.value = 45

mAccConfig.configTemperature.coolDownTemperature = 40
mAccConfig.configTemperature.pause = 45
mAccConfig.configTemperature.maxTemperature = 45
unsavedChanges = true
} else {
mAccConfig.configTemperature.coolDownTemperature= 90
mAccConfig.configTemperature.pause = 95
mAccConfig.configTemperature.maxTemperature = 95
unsavedChanges = true
}
}
Expand Down Expand Up @@ -482,10 +481,10 @@ class AccConfigEditorActivity : AppCompatActivity(), NumberPicker.OnValueChangeL
}

//temp
R.id.cooldown_temperature_picker ->
R.id.temperature_cooldown_picker ->
mAccConfig.configTemperature.coolDownTemperature = newVal

R.id.pause_temperature_picker ->
R.id.temperature_max_picker ->
mAccConfig.configTemperature.maxTemperature = newVal

R.id.temperature_max_pause_seconds_picker ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class AccaRoomDatabase : RoomDatabase() {
AccConfig(
AccConfig.ConfigCapacity(5, 85, 90),
AccConfig.ConfigVoltage(null, null),
AccConfig.ConfigTemperature(400, 450, 90),
AccConfig.ConfigTemperature(40, 45, 90),
null,
"usb/current_max:500000",
null,
Expand All @@ -72,7 +72,7 @@ abstract class AccaRoomDatabase : RoomDatabase() {
AccConfig(
AccConfig.ConfigCapacity(5, 70, 80),
AccConfig.ConfigVoltage(null, null),
AccConfig.ConfigTemperature(400, 450, 90),
AccConfig.ConfigTemperature(40, 45, 90),
null,
" usb/current_max:500000",
null,
Expand All @@ -85,7 +85,7 @@ abstract class AccaRoomDatabase : RoomDatabase() {
AccConfig(
AccConfig.ConfigCapacity(5, 70, 80),
AccConfig.ConfigVoltage(null, null),
AccConfig.ConfigTemperature(400, 450, 90),
AccConfig.ConfigTemperature(40, 45, 90),
null,
null,
AccConfig.ConfigCoolDown(60, 50, 10),
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/content_acc_config_editor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,15 @@
android:layout_below="@+id/temps_labels">

<NumberPicker
android:id="@+id/cooldown_temperature_picker"
android:id="@+id/temperature_cooldown_picker"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
android:layout_marginRight="3dp"/>

<NumberPicker
android:id="@+id/pause_temperature_picker"
android:id="@+id/temperature_max_picker"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
Expand Down

0 comments on commit ae39ad0

Please sign in to comment.