44
44
import butterknife .ButterKnife ;
45
45
import io .pslab .R ;
46
46
import io .pslab .activity .guide .GuideActivity ;
47
- import io .pslab .communication .CommunicationHandler ;
48
47
import io .pslab .communication .ScienceLab ;
49
48
import io .pslab .items .SquareImageButton ;
50
49
import io .pslab .models .PowerSourceData ;
@@ -88,7 +87,7 @@ public class PowerSourceActivity extends GuideActivity {
88
87
private static final Range <Float > PV3_VOLTAGE_RANGE = Range .create (0.0f , 3.30f );
89
88
private static final Range <Float > PCS_CURRENT_RANGE = Range .create (0.0f , 3.30f );
90
89
91
- private final NumberFormat numberFormat = NumberFormat .getNumberInstance (Locale .getDefault () );
90
+ private final NumberFormat numberFormat = NumberFormat .getNumberInstance (Locale .ROOT );
92
91
93
92
/**
94
93
* Step of one tap on an up or down button.
@@ -214,7 +213,8 @@ public void onClick(View v) {
214
213
public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
215
214
if (actionId == EditorInfo .IME_ACTION_DONE ) {
216
215
final String voltageValue = remove (displayPV1 .getText (), "V" , "\\ +" ).trim ();
217
- final float voltage = PV1_VOLTAGE_RANGE .clamp (parseFloat (voltageValue , PV1_VOLTAGE_RANGE .getLower ()));
216
+ final String decimalVoltageValue = voltageValue .replace ("," , "." );
217
+ final float voltage = PV1_VOLTAGE_RANGE .clamp (parseFloat (decimalVoltageValue , PV1_VOLTAGE_RANGE .getLower ()));
218
218
setText (displayPV1 , VOLTAGE_FORMAT , voltage );
219
219
controllerPV1 .setProgress (mapPowerToProgress (voltage , PV1_CONTROLLER_MAX ,
220
220
PV1_VOLTAGE_RANGE .getUpper (), PV1_VOLTAGE_RANGE .getLower ()));
@@ -228,7 +228,8 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
228
228
public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
229
229
if (actionId == EditorInfo .IME_ACTION_DONE ) {
230
230
final String voltageValue = remove (displayPV2 .getText (), "V" , "\\ +" ).trim ();
231
- final float voltage = PV2_VOLTAGE_RANGE .clamp (parseFloat (voltageValue , PV2_VOLTAGE_RANGE .getLower ()));
231
+ final String decimalVoltageValue = voltageValue .replace ("," , "." );
232
+ final float voltage = PV2_VOLTAGE_RANGE .clamp (parseFloat (decimalVoltageValue , PV2_VOLTAGE_RANGE .getLower ()));
232
233
setText (displayPV2 , VOLTAGE_FORMAT , voltage );
233
234
controllerPV2 .setProgress (mapPowerToProgress (voltage , PV2_CONTROLLER_MAX ,
234
235
PV2_VOLTAGE_RANGE .getUpper (), PV2_VOLTAGE_RANGE .getLower ()));
@@ -242,7 +243,8 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
242
243
public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
243
244
if (actionId == EditorInfo .IME_ACTION_DONE ) {
244
245
final String voltageValue = remove (displayPV3 .getText (), "V" , "\\ +" ).trim ();
245
- final float voltage = PV3_VOLTAGE_RANGE .clamp (parseFloat (voltageValue , PV3_VOLTAGE_RANGE .getLower ()));
246
+ final String decimalVoltageValue = voltageValue .replace ("," , "." );
247
+ final float voltage = PV3_VOLTAGE_RANGE .clamp (parseFloat (decimalVoltageValue , PV3_VOLTAGE_RANGE .getLower ()));
246
248
setText (displayPV3 , VOLTAGE_FORMAT , voltage );
247
249
controllerPV3 .setProgress (mapPowerToProgress (voltage , PV3_CONTROLLER_MAX ,
248
250
PV3_VOLTAGE_RANGE .getUpper (), PV3_VOLTAGE_RANGE .getLower ()));
@@ -256,7 +258,8 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
256
258
public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
257
259
if (actionId == EditorInfo .IME_ACTION_DONE ) {
258
260
final String currentValue = remove (displayPCS .getText (), "mA" , "\\ +" ).trim ();
259
- final float current = PCS_CURRENT_RANGE .clamp (parseFloat (currentValue , PCS_CURRENT_RANGE .getLower ()));
261
+ final String decimalCurrentValue = currentValue .replace ("," , "." );
262
+ final float current = PCS_CURRENT_RANGE .clamp (parseFloat (decimalCurrentValue , PCS_CURRENT_RANGE .getLower ()));
260
263
setText (displayPV3 , CURRENT_FORMAT , current );
261
264
controllerPCS .setProgress (mapPowerToProgress (current , PCS_CONTROLLER_MAX ,
262
265
PCS_CURRENT_RANGE .getUpper (), PCS_CURRENT_RANGE .getLower ()));
0 commit comments