4444import butterknife .ButterKnife ;
4545import io .pslab .R ;
4646import io .pslab .activity .guide .GuideActivity ;
47- import io .pslab .communication .CommunicationHandler ;
4847import io .pslab .communication .ScienceLab ;
4948import io .pslab .items .SquareImageButton ;
5049import io .pslab .models .PowerSourceData ;
@@ -88,7 +87,7 @@ public class PowerSourceActivity extends GuideActivity {
8887 private static final Range <Float > PV3_VOLTAGE_RANGE = Range .create (0.0f , 3.30f );
8988 private static final Range <Float > PCS_CURRENT_RANGE = Range .create (0.0f , 3.30f );
9089
91- private final NumberFormat numberFormat = NumberFormat .getNumberInstance (Locale .getDefault () );
90+ private final NumberFormat numberFormat = NumberFormat .getNumberInstance (Locale .ROOT );
9291
9392 /**
9493 * Step of one tap on an up or down button.
@@ -214,7 +213,8 @@ public void onClick(View v) {
214213 public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
215214 if (actionId == EditorInfo .IME_ACTION_DONE ) {
216215 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 ()));
218218 setText (displayPV1 , VOLTAGE_FORMAT , voltage );
219219 controllerPV1 .setProgress (mapPowerToProgress (voltage , PV1_CONTROLLER_MAX ,
220220 PV1_VOLTAGE_RANGE .getUpper (), PV1_VOLTAGE_RANGE .getLower ()));
@@ -228,7 +228,8 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
228228 public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
229229 if (actionId == EditorInfo .IME_ACTION_DONE ) {
230230 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 ()));
232233 setText (displayPV2 , VOLTAGE_FORMAT , voltage );
233234 controllerPV2 .setProgress (mapPowerToProgress (voltage , PV2_CONTROLLER_MAX ,
234235 PV2_VOLTAGE_RANGE .getUpper (), PV2_VOLTAGE_RANGE .getLower ()));
@@ -242,7 +243,8 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
242243 public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
243244 if (actionId == EditorInfo .IME_ACTION_DONE ) {
244245 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 ()));
246248 setText (displayPV3 , VOLTAGE_FORMAT , voltage );
247249 controllerPV3 .setProgress (mapPowerToProgress (voltage , PV3_CONTROLLER_MAX ,
248250 PV3_VOLTAGE_RANGE .getUpper (), PV3_VOLTAGE_RANGE .getLower ()));
@@ -256,7 +258,8 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
256258 public boolean onEditorAction (TextView v , int actionId , KeyEvent event ) {
257259 if (actionId == EditorInfo .IME_ACTION_DONE ) {
258260 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 ()));
260263 setText (displayPV3 , CURRENT_FORMAT , current );
261264 controllerPCS .setProgress (mapPowerToProgress (current , PCS_CONTROLLER_MAX ,
262265 PCS_CURRENT_RANGE .getUpper (), PCS_CURRENT_RANGE .getLower ()));
0 commit comments