private static void DisplayHelp(SerialInputItem inputItem) { _serialUI.Stop(); DisplayHelp(); RefreshMainMenu(null); _serialUI.Go(); }
private static void ShowStatus(SerialInputItem inputItem) { _serialUI.DisplayLine("\r\n\r\nAntenna and Radio Status"); _serialUI.DisplayLine("========================\r\n"); _serialUI.DisplayLine("ANTENNA NAME 160 80 40 20 15 10 "); _serialUI.DisplayLine("======================================"); for (int i = 0; i < _antennas.Length; i++) { _serialUI.Display(i + 1 + ") " + StringExtension.PadRight(_antennas[i].Name, MAX_ANTENNA_NAME_LENGTH) + " "); string mask = _antennas[i].BandMask.ToString(); mask = mask.Replace("0", "- ").Replace("1", "1 ").Replace("2", "2 "); _serialUI.Display(mask + "\r\n"); } _serialUI.DisplayLine("======================================"); _serialUI.DisplayLine("\r\n"); _serialUI.DisplayLine("Radio A: " + Utilities.BandDecodingMethodToString(_radios[0].BandDecodingMethod)); _serialUI.DisplayLine(" BPF A: " + Utilities.BandPassFilterTypeToString(_radios[0].BandPassFilterType) + "\r\n"); _serialUI.DisplayLine("Radio B: " + Utilities.BandDecodingMethodToString(_radios[1].BandDecodingMethod)); _serialUI.DisplayLine(" BPF B: " + Utilities.BandPassFilterTypeToString(_radios[1].BandPassFilterType) + "\r\n"); _serialUI.DisplayLine("\r\n"); RefreshMainMenu(null); }
public static void MainMenu(SerialInputItem item) { _serialUI.Stop(); if (_showWelcomeMessage) { _serialUI.AddDisplayItem("Welcome to the M1DST 2x6 Antenna Switcher\r\n"); _serialUI.AddDisplayItem(Divider); _serialUI.AddDisplayItem("\r\n"); _serialUI.Go(); } _serialUI.Stop(); _serialUI.AddDisplayItem("Main Menu:\r\n"); _serialUI.AddDisplayItem("==========\r\n\r\n"); _serialUI.AddInputItem(new SerialInputItem { Option = "1", Label = ": Configure Antenna 1", Callback = ConfigureAntenna, Context = 1 }); _serialUI.AddInputItem(new SerialInputItem { Option = "2", Label = ": Configure Antenna 2", Callback = ConfigureAntenna, Context = 2 }); _serialUI.AddInputItem(new SerialInputItem { Option = "3", Label = ": Configure Antenna 3", Callback = ConfigureAntenna, Context = 3 }); _serialUI.AddInputItem(new SerialInputItem { Option = "4", Label = ": Configure Antenna 4", Callback = ConfigureAntenna, Context = 4 }); _serialUI.AddInputItem(new SerialInputItem { Option = "5", Label = ": Configure Antenna 5", Callback = ConfigureAntenna, Context = 5 }); _serialUI.AddInputItem(new SerialInputItem { Option = "6", Label = ": Configure Antenna 6", Callback = ConfigureAntenna, Context = 6 }); _serialUI.AddInputItem(new SerialInputItem()); _serialUI.AddInputItem(new SerialInputItem { Option = "A", Label = ": Configure Radio A", Callback = ConfigureRadio, Context = 1 }); _serialUI.AddInputItem(new SerialInputItem { Option = "B", Label = ": Configure Radio B", Callback = ConfigureRadio, Context = 2 }); _serialUI.AddInputItem(new SerialInputItem()); _serialUI.AddInputItem(new SerialInputItem { Option = "S", Label = ": Show Status", Callback = ShowStatus }); _serialUI.AddInputItem(new SerialInputItem { Option = "H", Label = ": Show Help", Callback = DisplayHelp }); _serialUI.AddInputItem(new SerialInputItem { Option = "R", Label = ": Factory Reset", Callback = FactoryReset }); _serialUI.AddInputItem(new SerialInputItem { Callback = RefreshMainMenu }); _serialUI.Go(); _showWelcomeMessage = false; }
private static void ConfigureAntennaName(SerialInputItem inputItem) { _serialUI.Stop(); int antenna = 0; switch (inputItem.Context) { // Prompt user to see if we're gonna change the name. case 1: case 2: case 3: case 4: case 5: case 6: antenna = inputItem.Context; _serialUI.Store.Clear(); _serialUI.DisplayLine("\r\nWe're now going to configure antenna " + antenna + "."); _serialUI.DisplayLine("\r\nThe current name for the antenna is : " + _antennas[antenna - 1].Name); _serialUI.DisplayLine("\r\nPlease enter a new name for the antenna. (Maximum " + MAX_ANTENNA_NAME_LENGTH + " characters)"); _serialUI.DisplayLine("Pressing ENTER leaves the current name configured."); _serialUI.AddInputItem(new SerialInputItem { Label = "", Callback = ConfigureAntennaName, Context = inputItem.Context + 10, StoreKey = "name" }); break; // Check the change name response. case 11: case 12: case 13: case 14: case 15: case 16: antenna = inputItem.Context - 10; if (_serialUI.Store["name"].ToString() != "") { var name = _serialUI.Store["name"].ToString().Trim().ToUpper(); if (name.Length > MAX_ANTENNA_NAME_LENGTH) { name = name.Substring(0, MAX_ANTENNA_NAME_LENGTH); } _antennas[antenna - 1].Name = name; Eeprom.WriteString(antenna * 100, name); _serialUI.DisplayLine("\r\nName changed to : " + _antennas[antenna - 1].Name + "\r\n\r\n"); } else { _serialUI.DisplayLine("\r\nName NOT changed. (" + _antennas[antenna - 1].Name + ")\r\n\r\n"); } _serialUI.Stop(); ConfigureAntenna(new SerialInputItem { Context = antenna }); return; } _serialUI.Go(); }
private static void ConfigureBandDecoder(SerialInputItem inputItem) { _serialUI.Stop(); int radio = 0; switch (inputItem.Context) { // Prompt user to see if we're gonna change the decoder type. case 1: case 2: radio = inputItem.Context; _serialUI.Store.Clear(); _serialUI.DisplayLine("\r\nWe're now going to configure the band decoder for radio " + radio + "."); _serialUI.DisplayLine("\r\nThe current configuration is : " + Utilities.BandDecodingMethodToString(_radios[radio - 1].BandDecodingMethod) + "\r\n"); _serialUI.DisplayLine("Please select a new option : \r\n"); _serialUI.AddInputItem(new SerialInputItem { Option = "0", Label = ": " + Utilities.BandDecodingMethodToString(BandDecodingMethod.YaesuBcd), Callback = ConfigureBandDecoder, Context = inputItem.Context + 10, StoreKey = "band_decoder" }); _serialUI.AddInputItem(new SerialInputItem { Option = "1", Label = ": " + Utilities.BandDecodingMethodToString(BandDecodingMethod.IcomVoltage), Callback = ConfigureBandDecoder, Context = inputItem.Context + 10, StoreKey = "band_decoder" }); _serialUI.AddInputItem(new SerialInputItem { Option = "2", Label = ": " + Utilities.BandDecodingMethodToString(BandDecodingMethod.Civ), Callback = ConfigureBandDecoder, Context = inputItem.Context + 10, StoreKey = "band_decoder" }); _serialUI.AddInputItem(new SerialInputItem { Option = "3", Label = ": " + Utilities.BandDecodingMethodToString(BandDecodingMethod.Kenwood), Callback = ConfigureBandDecoder, Context = inputItem.Context + 10, StoreKey = "band_decoder" }); _serialUI.AddInputItem(new SerialInputItem { Option = "..", Label = ": Back to the Main Menu", Callback = RefreshMainMenu }); _serialUI.AddInputItem(new SerialInputItem { Callback = ConfigureBandDecoder, Context = inputItem.Context }); break; // Check the response. case 11: case 12: radio = inputItem.Context - 10; _radios[radio - 1].BandDecodingMethod = (BandDecodingMethod)Convert.ToInt16(_serialUI.Store["band_decoder"].ToString()); var address = radio * 10; Eeprom.WriteInt16(address, (int)_radios[radio - 1].BandDecodingMethod); _serialUI.DisplayLine("\r\nBand Decoder Type changed to : " + Utilities.BandDecodingMethodToString(_radios[radio - 1].BandDecodingMethod) + "\r\n\r\n"); _serialUI.Stop(); ConfigureRadio(new SerialInputItem { Context = radio }); return; } _serialUI.Go(); }
private static void ConfigureAntennaMask(SerialInputItem inputItem) { _serialUI.Stop(); int antenna; switch (inputItem.Context) { // Prompt user to see if we're gonna change the mask. case 1: case 2: case 3: case 4: case 5: case 6: antenna = inputItem.Context; _serialUI.Store.Clear(); _serialUI.DisplayLine("\r\nWe're now going to configure antenna " + antenna + "."); _serialUI.DisplayLine("\r\nThe current mask for the antenna is : " + _antennas[antenna - 1].BandMask.ToString()); _serialUI.DisplayLine("\r\nPlease enter a new mask for the antenna. (Maximum 6 characters)"); _serialUI.DisplayLine("Pressing ENTER leaves the current mask configured."); _serialUI.AddInputItem(new SerialInputItem { Label = "", Callback = ConfigureAntennaMask, Context = inputItem.Context + 10, StoreKey = "mask" }); break; // Check the change mask response. case 11: case 12: case 13: case 14: case 15: case 16: antenna = inputItem.Context - 10; if (_serialUI.Store["mask"].ToString() != "") { _antennas[antenna - 1].BandMask = new BandMask(_serialUI.Store["mask"].ToString()); Eeprom.WriteString(((antenna * 100) + MAX_ANTENNA_NAME_LENGTH + 1), _antennas[antenna - 1].BandMask.ToString()); _serialUI.DisplayLine("\r\nMask changed to : " + _antennas[antenna - 1].BandMask.ToString() + "\r\n\r\n"); } else { _serialUI.DisplayLine("\r\nMask NOT changed. (" + _antennas[antenna - 1].BandMask + ")\r\n\r\n"); } _serialUI.Stop(); ConfigureAntenna(new SerialInputItem { Context = antenna }); return; } _serialUI.Go(); }
private static void ConfigureBandPassFilter(SerialInputItem inputItem) { _serialUI.Stop(); int radio = 0; switch (inputItem.Context) { // Prompt user to see if we're gonna change the bandpass filter output type. case 1: case 2: radio = inputItem.Context; _serialUI.Store.Clear(); _serialUI.DisplayLine("\r\nWe're now going to configure the BPF for radio " + radio + "."); _serialUI.DisplayLine("\r\nThe current configuration is : " + Utilities.BandPassFilterTypeToString(_radios[radio - 1].BandPassFilterType) + "\r\n"); _serialUI.DisplayLine("Please select a new option : \r\n"); _serialUI.AddInputItem(new SerialInputItem { Option = "0", Label = ": " + Utilities.BandPassFilterTypeToString(BandPassFilterType.None), Callback = ConfigureBandPassFilter, Context = inputItem.Context + 10, StoreKey = "bpf" }); _serialUI.AddInputItem(new SerialInputItem { Option = "1", Label = ": " + Utilities.BandPassFilterTypeToString(BandPassFilterType.YaesuBCD), Callback = ConfigureBandPassFilter, Context = inputItem.Context + 10, StoreKey = "bpf" }); _serialUI.AddInputItem(new SerialInputItem { Option = "2", Label = ": " + Utilities.BandPassFilterTypeToString(BandPassFilterType.SeparateBands), Callback = ConfigureBandPassFilter, Context = inputItem.Context + 10, StoreKey = "bpf" }); _serialUI.AddInputItem(new SerialInputItem { Option = "..", Label = ": Back to the Main Menu", Callback = RefreshMainMenu }); _serialUI.AddInputItem(new SerialInputItem { Callback = ConfigureBandPassFilter, Context = inputItem.Context }); break; // Check the response. case 11: case 12: radio = inputItem.Context - 10; _radios[radio - 1].BandPassFilterType = (BandPassFilterType)Convert.ToInt16(_serialUI.Store["bpf"].ToString()); var address = (radio * 10) + 1; Eeprom.WriteInt16(address, (int)_radios[radio - 1].BandPassFilterType); _serialUI.DisplayLine("\r\nBPF output changed to : " + Utilities.BandPassFilterTypeToString(_radios[radio - 1].BandPassFilterType) + "\r\n\r\n"); _serialUI.Stop(); ConfigureRadio(new SerialInputItem { Context = radio }); return; } _serialUI.Go(); }
private static void FactoryReset(SerialInputItem inputItem) { _serialUI.Stop(); _serialUI.DisplayLine("Resetting..."); FactoryReset(); _serialUI.DisplayLine("Done..."); _serialUI.DisplayLine("\r\n"); RefreshMainMenu(null); _serialUI.Go(); }
private static void ConfigureAntenna(SerialInputItem inputItem) { _serialUI.Stop(); _serialUI.DisplayLine("Configuring Antenna " + inputItem.Context); _serialUI.DisplayLine("=====================\r\n"); _serialUI.AddInputItem(new SerialInputItem { Option = "N", Label = ": Configure Antenna Name", Callback = ConfigureAntennaName, Context = inputItem.Context }); _serialUI.AddInputItem(new SerialInputItem { Option = "M", Label = ": Configure Antenna Mask", Callback = ConfigureAntennaMask, Context = inputItem.Context }); _serialUI.AddInputItem(new SerialInputItem { Option = "..", Label = ": Back to the Main Menu", Callback = RefreshMainMenu }); _serialUI.AddInputItem(new SerialInputItem { Callback = ConfigureAntenna, Context = inputItem.Context }); _serialUI.Go(); }
private static void ConfigureRadio(SerialInputItem inputItem) { _serialUI.Stop(); _serialUI.DisplayLine("Configuring Radio " + inputItem.Context); _serialUI.DisplayLine("=====================\r\n"); _serialUI.AddInputItem(new SerialInputItem { Option = "D", Label = ": Configure Band Decoder", Callback = ConfigureBandDecoder, Context = inputItem.Context }); _serialUI.AddInputItem(new SerialInputItem { Option = "B", Label = ": Configure Band Pass Filter Output", Callback = ConfigureBandPassFilter, Context = inputItem.Context }); _serialUI.AddInputItem(new SerialInputItem { Option = "..", Label = ": Back to the Main Menu", Callback = RefreshMainMenu }); _serialUI.AddInputItem(new SerialInputItem { Callback = ConfigureRadio, Context = inputItem.Context }); _serialUI.Go(); }
// Add an input item to the user interface public void AddInputItem(SerialInputItem item) { _inputItems.Add(item); }
public static void RefreshMainMenu(SerialInputItem item) { _showMainMenu = true; }