kopia lustrzana https://github.com/sh123/codec2_talkie
Display speed based on modulation
rodzic
3346003d2d
commit
9886bccaf4
|
@ -76,6 +76,11 @@ public class AudioTools {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getModulationAsText(SharedPreferences sharedPreferences) {
|
||||||
|
int modulation = Integer.parseInt(sharedPreferences.getString(PreferenceKeys.KISS_EXTENSIONS_RADIO_MOD, "0"));
|
||||||
|
return modulation == RadioTools.ModulationTypeLora ? "LoRa" : "FSK";
|
||||||
|
}
|
||||||
|
|
||||||
public static String getSpeedStatusText(String codec2ModeName, SharedPreferences sharedPreferences) {
|
public static String getSpeedStatusText(String codec2ModeName, SharedPreferences sharedPreferences) {
|
||||||
|
|
||||||
// use freedv mode text instead if it is active
|
// use freedv mode text instead if it is active
|
||||||
|
|
|
@ -8,11 +8,19 @@ import com.radio.codec2talkie.settings.SettingsWrapper;
|
||||||
|
|
||||||
public class RadioTools {
|
public class RadioTools {
|
||||||
|
|
||||||
|
public static final int ModulationTypeLora = 0;
|
||||||
|
public static final int ModulationTypeFsk = 1;
|
||||||
|
|
||||||
public static int calculateLoraSpeedBps(int bw, int sf, int cr) {
|
public static int calculateLoraSpeedBps(int bw, int sf, int cr) {
|
||||||
return (int)(sf * (4.0 / cr) / (Math.pow(2.0, sf) / bw));
|
return (int)(sf * (4.0 / cr) / (Math.pow(2.0, sf) / bw));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getRadioSpeed(SharedPreferences sharedPreferences) {
|
public static int getRadioSpeed(SharedPreferences sharedPreferences) {
|
||||||
|
int modulation = Integer.parseInt(sharedPreferences.getString(PreferenceKeys.KISS_EXTENSIONS_RADIO_MOD, "0"));
|
||||||
|
if (SettingsWrapper.isSoundModemEnabled(sharedPreferences)) {
|
||||||
|
return SettingsWrapper.getFskSpeed(sharedPreferences);
|
||||||
|
}
|
||||||
|
if (modulation == ModulationTypeLora) {
|
||||||
int resultBps = 0;
|
int resultBps = 0;
|
||||||
int maxSpeedBps = 128000;
|
int maxSpeedBps = 128000;
|
||||||
try {
|
try {
|
||||||
|
@ -22,10 +30,14 @@ public class RadioTools {
|
||||||
int cr = Integer.parseInt(sharedPreferences.getString(PreferenceKeys.KISS_EXTENSIONS_RADIO_CR, "5"));
|
int cr = Integer.parseInt(sharedPreferences.getString(PreferenceKeys.KISS_EXTENSIONS_RADIO_CR, "5"));
|
||||||
resultBps = RadioTools.calculateLoraSpeedBps(bw, sf, cr);
|
resultBps = RadioTools.calculateLoraSpeedBps(bw, sf, cr);
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException|ArithmeticException e) {
|
} catch (NumberFormatException | ArithmeticException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return (resultBps > 0 && resultBps <= maxSpeedBps) ? resultBps : 0;
|
return (resultBps > 0 && resultBps <= maxSpeedBps) ? resultBps : 0;
|
||||||
|
} else if (modulation == ModulationTypeFsk){
|
||||||
|
return Integer.parseInt(sharedPreferences.getString(PreferenceKeys.KISS_EXTENSIONS_RADIO_FSK_BIT_RATE, "4.8"));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double calculateLoraSensitivity(SharedPreferences sharedPreferences) {
|
public static double calculateLoraSensitivity(SharedPreferences sharedPreferences) {
|
||||||
|
|
Ładowanie…
Reference in New Issue