public void Run(IBackgroundTaskInstance taskInstance) { // // TODO: Insert code to perform background work // // If you start any asynchronous methods here, prevent the task // from closing prematurely by using BackgroundTaskDeferral as // described in http://aka.ms/backgroundtaskdeferral // _deferral = taskInstance.GetDeferral(); Init().Wait(); CanvasTextFormat txtFmt1 = new CanvasTextFormat { FontSize = 28, FontFamily = "Old English Five", LineSpacingMode = CanvasLineSpacingMode.Proportional, LineSpacingBaseline = 0.8f }; CanvasTextFormat txtFmt2 = new CanvasTextFormat { FontSize = 18, FontFamily = "Segoe UI Emoji", LineSpacingMode = CanvasLineSpacingMode.Proportional, LineSpacingBaseline = 0.8f }; //display on spi if (_displaySpi.State == SSD1603.States.Ready) { //draw using (CanvasDrawingSession ds = _displaySpi.Render.CreateDrawingSession()) { ds.Clear(SSD1603.BackgroundColor); ds.DrawText("Hello", 0, 0, SSD1603.ForeColor, txtFmt1); } _displaySpi.Display(); } //display on i2c if (_displayI2c.State == SSD1603.States.Ready) { //draw using (CanvasDrawingSession ds = _displayI2c.Render.CreateDrawingSession()) { ds.Antialiasing = CanvasAntialiasing.Aliased; ds.TextAntialiasing = CanvasTextAntialiasing.Aliased; //REG ADD "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts" /v "Astronaut III" /t REG_SZ /d "astronautiii.ttf" ds.Clear(SSD1603.BackgroundColor); ds.DrawText("\U0001F600\U00002603\U0001F341\U0001F50D", 0, 0, SSD1603.ForeColor, txtFmt2); } _displayI2c.Display(); } }
private void ShowEmoji(int idx, string emoji) { SSD1603 display = idx == 0 ? _displaySpi : _displayI2c; CanvasTextFormat fmt = idx == 0 ? _fmtBg : _fmtSm; if (display != null && display.State == SSD1603.States.Ready) { //draw using (CanvasDrawingSession ds = display.Render.CreateDrawingSession()) { ds.Antialiasing = CanvasAntialiasing.Aliased; ds.TextAntialiasing = CanvasTextAntialiasing.Aliased; ds.Clear(SSD1603.BackgroundColor); ds.DrawText(emoji, 0, 0, SSD1603.ForeColor, fmt); } Debug.WriteLine("display " + emoji); display.Display(); } }