//public static LiquidCrystalI2C Lcd; private static void LCDFinish(Lcd lcd, string message) { lcd.SetCursorPosition(0, 1); lcd.Write(message); Thread.Sleep(600); lcd.Clear(); }
public MenuItemWithCheckBox(Lcd lcd, string text, bool checkedAtStart, Func <bool, bool> enterFunc = null) { this.text = text; this.lcd = lcd; this.Checked = checkedAtStart; this.func = enterFunc; }
static bool ShowUpdatesDialogs(Lcd lcd, Buttons btns, bool showDescriptionDialog) { if (WiFiDevice.IsLinkUp()) { try { InfoDialog dialog = null; if (showDescriptionDialog) { dialog = new InfoDialog(font, lcd, btns, "Checking for updates. Please wait", false); dialog.Show(); } if (UpdateAvailable()) { dialog = new InfoDialog(font, lcd, btns, "Software update available. Visit monobrick.dk", true); } else { dialog = new InfoDialog(font, lcd, btns, "No software updates available", true); } dialog.Show(); } catch { InfoDialog dialog = new InfoDialog(font, lcd, btns, "Failed to check for updates", true); dialog.Show(); } } else { var dialog = new InfoDialog(font, lcd, btns, "WiFi device is not pressent", true); dialog.Show(); } return(false); }
static bool ShowSettings(Lcd lcd, Buttons btns) { //Create the settings items and apply the settings List <IMenuItem> items = new List <IMenuItem> (); var terminateWithEscapeItem = new MenuItemWithCheckBox(lcd, "Debug termination", settings.DebugSettings.TerminateWithEscape); var debugPortItem = new MenuItemWithNumericInput(lcd, "Debug port", settings.DebugSettings.Port, 1, ushort.MaxValue); var checkForUpdate = new MenuItemWithCheckBox(lcd, "Update check", settings.GeneralSettings.CheckForSwUpdatesAtStartUp); var wifiConnect = new MenuItemWithCheckBox(lcd, "WiFi auto connect", settings.WiFiSettings.ConnectAtStartUp); var soundVolume = new MenuItemWithNumericInput(lcd, "Volume", settings.SoundSettings.Volume); var enableSound = new MenuItemWithCheckBox(lcd, "Enable sound", settings.SoundSettings.EnableSound); items.Add(wifiConnect); items.Add(checkForUpdate); items.Add(terminateWithEscapeItem); items.Add(debugPortItem); items.Add(soundVolume); //Show the menu Menu m = new Menu(font, lcd, btns, "Settings", items); m.Show(); new Thread(delegate() { settings.DebugSettings.TerminateWithEscape = terminateWithEscapeItem.Checked; settings.DebugSettings.Port = debugPortItem.Value; settings.GeneralSettings.CheckForSwUpdatesAtStartUp = checkForUpdate.Checked; settings.WiFiSettings.ConnectAtStartUp = wifiConnect.Checked; settings.SoundSettings.Volume = soundVolume.Value; settings.SoundSettings.EnableSound = enableSound.Checked; settings.Save(); }).Start(); return(false); }
static bool Information(Lcd lcd, Buttons btns) { string monoVersion = "Unknown"; Type type = Type.GetType("Mono.Runtime"); if (type != null) { MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); if (displayName != null) { monoVersion = (string)displayName.Invoke(null, null); } } string monoCLR = System.Reflection.Assembly.GetExecutingAssembly().ImageRuntimeVersion; Point offset = new Point(0, (int)font.maxHeight); Point startPos = new Point(0, 0); lcd.Clear(); lcd.WriteText(font, startPos + offset * 0, versionString, true); lcd.WriteText(font, startPos + offset * 1, "Mono version: " + monoVersion.Substring(0, 7), true); lcd.WriteText(font, startPos + offset * 2, "Mono CLR: " + monoCLR, true); lcd.WriteText(font, startPos + offset * 3, "IP: " + WiFiDevice.GetIpAddress(), true); lcd.Update(); btns.GetKeypress(); return(false); }
static void Shutdown(Motor motorR, Motor motorL) { motorR.Off(); //voor de zekerheid dat alle motoren stoppen met draaien na het afsluiten motorL.Off(); Lcd.Clear(); //het lcd scherm vrijmaken van de text en het vrijgemaakte scherm tonen Lcd.Update(); }
public BNOCalibUpdate(SerialBno bno, Lcd lcd, int delay) { _lcd = lcd; _bno = bno; _delay = delay; _workItem = new WorkItem(UpdateCalib, ref _dataArray, loggable: false, persistent: true, pauseable: true); }
private void DisplayInputMessage(DisplayPiInputMessage message, TimeSpan?endDelay = null) { Lcd.Clear(); Lcd.SendMessage($"{message.Author}\n{message.Message}"); Debug.WriteLine(message.ToString()); Task.Delay(endDelay ?? TimeSpan.FromSeconds(3)).Wait(); }
// Script constructor public Program() { logger = new Logger(this, "DEBUG"); logger.level = 5; model = new Model(); model.AddResourceItem("Cobalt", "Co", 1000000, 10000); model.AddResourceItem("Gold", "Au", 1000000, 10000); model.AddResourceItem("Iron", "Fe", 1000000, 10000); model.AddResourceItem("Magnesium", "Ma", 1000000, 10000); model.AddResourceItem("Nickel", "Ni", 1000000, 10000); model.AddResourceItem("Platinum", "Pt", 1000000, 10000); model.AddResourceItem("Scrap", "Scrap", 1000000, 10000); model.AddResourceItem("Silicon", "Si", 1000000, 10000); model.AddResourceItem("Silver", "Ag", 1000000, 10000); model.AddResourceItem("Stone", "Stone", 1000000, 10000); model.AddResourceItem("Uranium", "Ur", 1000000, 10000); lcd_ore = new Lcd(this); lcd_stat = new Lcd(this); controller_refinery = new ControllerRefinery(this, TAG_REFINERY); controller_cargo_ore = new ControllerCargo(this, TAG_CARGO_ORE); controller_cargo_ingot = new ControllerCargo(this, TAG_CARGO_INGOT); // Set the continuous update frequency of this script Runtime.UpdateFrequency = UpdateFrequency.Update100; }
private void AnimationThread() { while (run) { for (int i = 0; i < rects.Count; i++) { Lcd.DrawRectangle(rects [i], i == showIndex, true); } Lcd.Update(); if (leftToRight) { showIndex++; if (showIndex == rects.Count - 1) { leftToRight = false; } } else { showIndex--; if (showIndex == 0) { leftToRight = true; } } resetEvent.WaitOne(updateFrequency); } }
public QuestionDialog(Font f, Lcd lcd, Buttons btns, string question, string title, string positiveText = "Yes", string negativeText = "No", bool isPositiveSelected = true) : base(f, lcd, btns, title) { this.negativeText = negativeText; this.positiveText = positiveText; this.question = question; this.IsPositiveSelected = isPositiveSelected; }
public override void OnDrawContent() { string monoVersion = "Unknown"; Type type = Type.GetType("Mono.Runtime"); if (type != null) { MethodInfo displayName = type.GetMethod("GetDisplayName", BindingFlags.NonPublic | BindingFlags.Static); if (displayName != null) { monoVersion = (string)displayName.Invoke(null, null); } } string monoCLR = System.Reflection.Assembly.GetExecutingAssembly().ImageRuntimeVersion; var currentVersion = UpdateHelper.InstalledVersion(); Point offset = new Point(0, (int)Font.MediumFont.maxHeight); Point startPos = new Point(0, 0); Lcd.Clear(); Lcd.WriteText(Font.MediumFont, startPos + offset * 0, "Firmware: " + currentVersion.Firmware, true); Lcd.WriteText(Font.MediumFont, startPos + offset * 1, "Image: " + currentVersion.Image, true); Lcd.WriteText(Font.MediumFont, startPos + offset * 2, "Mono version: " + monoVersion.Substring(0, 7), true); Lcd.WriteText(Font.MediumFont, startPos + offset * 3, "Mono CLR: " + monoCLR, true); Lcd.WriteText(Font.MediumFont, startPos + offset * 4, "IP: " + WiFiDevice.GetIpAddress(), true); Lcd.Update(); }
public MenuItemWithAction(Lcd lcd, string text, Func <bool> action, MenuItemSymbole symbole = MenuItemSymbole.None) { this.text = text; this.action = action; this.lcd = lcd; this.symbole = symbole; }
protected void ClearContent() { Lcd.LoadScreen(); Lcd.DrawRectangle(outherWindow, true, true); Lcd.DrawRectangle(innerWindow, false, true); Lcd.WriteTextBox(font, titleRect, title, false, Lcd.Alignment.Center); }
public static void Main() { var setup = new BaseShifterLcdTransferProvider.ShifterSetup { BL = ShifterPin.GP7, RS = ShifterPin.GP1, RW = ShifterPin.None, Enable = ShifterPin.GP2, D4 = ShifterPin.GP6, D5 = ShifterPin.GP5, D6 = ShifterPin.GP4, D7 = ShifterPin.GP3 }; var lcdBus = new Shifter74Hc595LcdTransferProvider(SPI.SPI_module.SPI1, Pins.GPIO_PIN_D3, Shifter74Hc595LcdTransferProvider.BitOrder.MSBFirst, setup); var lcd = new Lcd(lcdBus); lcd.Begin(16, 2); lcd.Write("Hello, world!"); while (true) { lcd.SetCursorPosition(0, 1); lcd.Write((Utility.GetMachineTime().Ticks / 10000).ToString()); Microsoft.SPOT.Debug.Print("here"); Thread.Sleep(100); } }
public LCDTest() { // RS,RW,E,D4,D5,D6,D7 RaspPiGPIOMemLcdTransferProvider lcdProvider = new RaspPiGPIOMemLcdTransferProvider( GPIOPins.Pin_P1_07, GPIOPins.Pin_P1_22, GPIOPins.Pin_P1_11, GPIOPins.Pin_P1_12, GPIOPins.Pin_P1_15, GPIOPins.Pin_P1_16, GPIOPins.Pin_P1_18); string meintext = "Hello World, how are you?"; Lcd lcd = new Lcd(lcdProvider); lcd.Begin(16, 2); lcd.Clear(); lcd.Backlight = false; lcd.SetCursorPosition(0, 0); lcd.Write(meintext); //System.Threading.Thread.Sleep (3); //lcd.Clear(); //lcd.Write("Ahoj Bernie?!"); System.Threading.Thread.Sleep(2000); int anzahl = meintext.Length; while (anzahl > 0) { lcd.ScrollDisplayLeft(); System.Threading.Thread.Sleep(200); anzahl--; } }
public MenuItemWithOptions(Lcd lcd, string text, OptionType[] options, int startIdx = 0) { this.text = text; this.lcd = lcd; this.options = options; this.OptionIndex = startIdx; }
private void DrawItemList() { if (!isItemSizeCalculated) { CalculateItemSize(); isItemSizeCalculated = true; } Lcd.Clear(); Rectangle currentPos = new Rectangle(new Point(0, 0), itemSize); Rectangle arrowRect = new Rectangle(new Point(Lcd.Width / 2 - arrowWidth / 2, Lcd.Height - arrowHeight), new Point(Lcd.Width / 2 + arrowWidth / 2, Lcd.Height - 1)); Lcd.WriteTextBox(font, currentPos, title, true, Lcd.Alignment.Center); int i = 0; while (i != itemsOnScreen) { if (i + scrollPos >= items.Count) { break; } items [i + scrollPos].OnDrawTitle(font, currentPos + itemHeight * (i + 1), i != cursorPos); i++; } Lcd.DrawArrow(arrowRect, Lcd.ArrowOrientation.Down, scrollPos + itemsOnScreen < items.Count); Lcd.Update(); }
private void DrawScrollBar() { Lcd.DrawRectangle(scrollBar, false, true); Lcd.DrawRectangle(scrollBar, true, false); Rectangle indexRec = new Rectangle(new Point(scrollBar.P1.X + (scrollBarWidth - scrollIndexWith) / 2, scrollBar.P1.Y + pagePos * indexHeight), new Point(scrollBar.P2.X - (scrollBarWidth - scrollIndexWith) / 2, scrollBar.P1.Y + pagePos * indexHeight + indexHeight)); Lcd.DrawRectangle(indexRec, true, true); }
public void OnDrawTitle(Font font, Rectangle rectangle, bool selected) { Lcd.WriteTextBox(font, rectangle, title, selected); int arrowWidth = (int)font.maxWidth / 3; Rectangle arrowRect = new Rectangle(new Point(rectangle.P2.X - (arrowWidth + arrowOffset), rectangle.P1.Y + arrowEdge), new Point(rectangle.P2.X - arrowOffset, rectangle.P2.Y - arrowEdge)); Lcd.DrawArrow(arrowRect, Lcd.ArrowOrientation.Right, selected); }
public override void Draw() { Lcd.DrawRectangle(outherBox, true, true); Lcd.DrawRectangle(innerBox, Selected, true); Lcd.DrawArrow(arrowRect, Lcd.ArrowOrientation.Left, !Selected); Lcd.DrawLine(new Point(arrowRect.P2.X, outherBox.P1.Y + ((outherBox.P2.Y - outherBox.P1.Y) / 2)), new Point(outherBox.P2.X - 8 * characterEdge, outherBox.P1.Y + ((outherBox.P2.Y - outherBox.P1.Y) / 2)), !Selected); Lcd.DrawLine(new Point(outherBox.P2.X - 8 * characterEdge, outherBox.P1.Y + ((outherBox.P2.Y - outherBox.P1.Y) / 2)), new Point(outherBox.P2.X - 8 * characterEdge, outherBox.P1.Y + 4 * characterEdge), !Selected); }
public MenuItemWithNumericInput(Lcd lcd, string text, int startValue, int min = int.MinValue, int max = int.MaxValue) { this.text = text; this.lcd = lcd; this.Value = startValue; this.min = min; this.max = max; }
public SelectDialog(Font f, Lcd lcd, Buttons btns, SelectionType[] options, string title, bool allowEsc) : base(f, lcd, btns, title, 160, 90 + (int)f.maxHeight / 2, (int)f.maxHeight / 4) { this.options = options; cursorPos = 0; scrollPos = 0; this.allowEsc = allowEsc; EscPressed = false; }
/// <summary> /// Constructor for parallel LCD connection /// </summary> /// <param name="rs"></param> /// <param name="rw"></param> /// <param name="enable"></param> /// <param name="d4"></param> /// <param name="d5"></param> /// <param name="d6"></param> /// <param name="d7"></param> /// <param name="rows"></param> /// <param name="cols"></param> public clsLCD_MLC(Cpu.Pin rs, Cpu.Pin rw, Cpu.Pin enable, Cpu.Pin d4, Cpu.Pin d5, Cpu.Pin d6, Cpu.Pin d7, byte rows, byte cols) { GpioLcdTransferProvider lcdProvider = new GpioLcdTransferProvider(rs, rw, enable, d4, d5, d6, d7); lcd = new Lcd(lcdProvider); lcd_begin(rows, cols); }
static bool ShowWebServerMenu(Lcd lcd, Buttons btns) { List <IMenuItem> items = new List <IMenuItem> (); var portItem = new MenuItemWithNumericInput(lcd, "Port", settings.WebServerSettings.Port, 1, ushort.MaxValue); portItem.OnValueChanged += delegate(int value) { new Thread(delegate() { settings.WebServerSettings.Port = value; settings.Save(); }).Start(); }; var startItem = new MenuItemWithCheckBox(lcd, "Start server", WebServer.IsRunning(), delegate(bool running) { webServer = new WebServer(settings.WebServerSettings.Port); bool isRunning = running; if (running) { var dialog = new InfoDialog(font, lcd, btns, "Shutting down Web-Server", false); dialog.Show(); webServer.Stop(); dialog = new InfoDialog(font, lcd, btns, "Web-server Stopped!", true); dialog.Show(); isRunning = false; } else { var dialog = new InfoDialog(font, lcd, btns, "Starting Web-Server Please Wait", false, "Web-Server"); dialog.Show(); webServer.CompilingServer += delegate() { dialog.UpdateMessage("Compiling..."); }; webServer.LoadingPage += delegate() { dialog.UpdateMessage("Loading page"); }; webServer.StartingServer += delegate() { dialog.UpdateMessage("Starting server"); }; if (webServer.Restart()) { dialog = new InfoDialog(font, lcd, btns, "Started successfully at port" + settings.WebServerSettings.Port, true); dialog.Show(); isRunning = true; } else { dialog = new InfoDialog(font, lcd, btns, "Failed to start Web-Servers", true); dialog.Show(); isRunning = false; } } return(isRunning); } ); items.Add(portItem); items.Add(startItem); //Show the menu Menu m = new Menu(font, lcd, btns, "Web Server", items); m.Show(); return(false); }
private static void ShowMainMenu(Lcd lcd, Buttons btns) { List <IMenuItem> items = new List <IMenuItem>(); items.Add(new MenuItemWithAction(lcd, "Start", () => Start(lcd, btns), MenuItemSymbole.None)); int[] tasks = { taskFind, taskEscape }; int curTask = Array.IndexOf(tasks, taskID); var itemMode = new MenuItemWithOptions <string>(lcd, "Mode", new string[] { "FIND", "ESCAPE" }, curTask); itemMode.OnOptionChanged += delegate(string selection) { if (selection == "FIND") { taskID = taskFind; } if (selection == "ESCAPE") { taskID = taskEscape; } }; String red = Color.Red.ToString().ToUpper(); String green = Color.Green.ToString().ToUpper(); String blue = Color.Blue.ToString().ToUpper(); String white = Color.White.ToString().ToUpper(); String[] colors = { red, green, blue, white }; int curColor = Array.IndexOf(colors, enemyColor.ToString().ToUpper()); var itemEnemyColor = new MenuItemWithOptions <string>(lcd, "Enemy Color", colors, curColor); itemEnemyColor.OnOptionChanged += delegate(string selection) { if (selection == red) { enemyColor = Color.Red; } if (selection == green) { enemyColor = Color.Green; } if (selection == blue) { enemyColor = Color.Blue; } if (selection == white) { enemyColor = Color.White; } }; items.Add(itemMode); items.Add(itemEnemyColor); items.Add(new MenuItemWithAction(lcd, "Exit", () => Exit(lcd, btns), MenuItemSymbole.None)); Menu m = new Menu(font, lcd, btns, "Robot", items); m.Show(); }
public static void Main() { DateTime dt = Ds1307.GetDateTime(); Utility.SetLocalTime(dt); var lcdProvider = new GpioLcdTransferProvider(Stm32F4Discovery.Pins.PD1, Stm32F4Discovery.Pins.PD2, Stm32F4Discovery.Pins.PD9, Stm32F4Discovery.Pins.PD11, Stm32F4Discovery.Pins.PD10, Stm32F4Discovery.Pins.PD8); var lcd = new Lcd(lcdProvider); lcd.Begin(Columns, 2); var userButton = new InterruptPort(Stm32F4Discovery.ButtonPins.User, false, Port.ResistorMode.PullDown, Port.InterruptMode.InterruptEdgeLow); DateTime showUptimeMode = DateTime.MinValue; userButton.OnInterrupt += (d1, d2, t) => showUptimeMode = DateTime.Now.AddSeconds(ShowUptimeInterval); for (;;) { var now = DateTime.Now; string line1, line2; if (showUptimeMode > now) { TimeSpan uptime = GetUptime(); string uptimeStr = uptime.ToString(); int endIndex = uptimeStr.LastIndexOf('.'); if (endIndex > Columns) { endIndex = Columns; } line1 = "Uptime: "; line2 = uptimeStr.Substring(0, endIndex); } else { line1 = now.ToString("yyyy-MM-dd"); line2 = now.ToString("HH:mm:ss "); } lcd.SetCursorPosition(0, 0); lcd.Write(line1); lcd.SetCursorPosition(0, 1); lcd.Write(line2); Thread.Sleep(100); } }
public clsLCD_MLC(Cpu.Pin rs, Cpu.Pin rw, Cpu.Pin enable, Cpu.Pin d4, Cpu.Pin d5, Cpu.Pin d6, Cpu.Pin d7, byte rows, byte cols) { lcdProvider = new GpioLcdTransferProvider(rs, rw, enable, d4, d5, d6, d7); lcd = new Lcd(lcdProvider); SetScreenSize(rows, cols); lcd.Write("hello, world!"); strBlankRow = new string(' ', cols); }
public MenuItemWithCharacterInput(Lcd lcd, UserInput.Buttons btns, string subject, string dialogTitle, string startText, bool hideInput = false) { this.dialogTitle = dialogTitle; this.subject = subject; this.Text = startText; this.lcd = lcd; this.btns = btns; this.hide = hideInput; }
public Core(TextAsset asset, Drawer drawer) { cpu = new CPU(this); memory = new Memory(this, asset.bytes); clock = new Clock(this); screen = new Screen(this, drawer); lcd = new Lcd(this); keyboard = new Keyboard(this); }
static void Main(string[] args) { using (StreamReader reader = File.OpenText(args[0])) while (!reader.EndOfStream) { string[] line = reader.ReadLine().Split(';'); if (line == null) continue; Lcd lcd = new Lcd(line[0]); Console.WriteLine(lcd.CanDisplay(line[1]) ? 1 : 0); } }