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;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
// use freedv mode text instead if it is active
|
||||
|
|
|
@ -8,11 +8,19 @@ import com.radio.codec2talkie.settings.SettingsWrapper;
|
|||
|
||||
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) {
|
||||
return (int)(sf * (4.0 / cr) / (Math.pow(2.0, sf) / bw));
|
||||
}
|
||||
|
||||
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 maxSpeedBps = 128000;
|
||||
try {
|
||||
|
@ -26,6 +34,10 @@ public class RadioTools {
|
|||
e.printStackTrace();
|
||||
}
|
||||
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) {
|
||||
|
|
Ładowanie…
Reference in New Issue