private Task printOnLcd() { while (!_cts.IsCancellationRequested) { List <string> line1 = prepairLine1(); foreach (var content in line1) { SymbolConfig.initilizeSymbols(); LCD.prints(content); LCD.gotoSecondLine(); printLine2(); try { Task.Delay(3500).Wait(_cts.Token); } catch (Exception e) { Debug.WriteLine("cancel LCD-Writing Task"); return(Task.CompletedTask); } LCD.clrscr(); } } return(Task.CompletedTask); }
private void printLine2() { LCD.prints(" "); this.LCD.printSymbol(SymbolConfig.busySymbolAddress); LCD.prints(" "); this.LCD.printSymbol(SymbolConfig.batterySymbolAddress); LCD.prints(" "); this.LCD.printSymbol(SymbolConfig.initSymbolAddress); LCD.prints(" "); this.LCD.printSymbol(SymbolConfig.volumeSymbolAddress); LCD.prints(" "); }
/// <summary> /// Method to wrap updating the LCD with fixed information. /// </summary> public void updateLCD() { if (RasPi.isTestMode()) { return; } LCD.initiateLCD(); cancelWritingWait(); CheckTurnOnBacklight(); _writingOnLcd = Task.Run(async() => await printOnLcd(), _cts.Token); }
/// <summary> /// Executes the Command SendToLCD in dependency of the parsed parameter /// </summary> /// <param name="parameter">Either a text:string which is to be printed on lcd /// or a #command:string e.g #reset to clear the display /// and terminate all tasks related to a previous call /// </param> /// <returns>The provided text or a status information.</returns> public string SendToLCD(string text) { const int charsMaxInLine = 16; if (text == "#reset") { LCD.resetLCD(); return("Reset display"); } if (text.Length <= charsMaxInLine) { LCD.writeToLCD(text); } else if (text.Length <= 2 * charsMaxInLine) { LCD.printInTwoLines(text); } else { throw new Exception("Text too long to print on LCD"); } return(text); }