From 8b7c9f850c1ab0d0b2df0c700b7747250e02b105 Mon Sep 17 00:00:00 2001 From: Adrian Stevens Date: Tue, 12 Sep 2023 17:28:03 -0700 Subject: [PATCH] Update readme --- Source/OLED128x32Wing/Driver/Readme.md | 31 ++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/Source/OLED128x32Wing/Driver/Readme.md b/Source/OLED128x32Wing/Driver/Readme.md index 71ee53f..e7ad664 100644 --- a/Source/OLED128x32Wing/Driver/Readme.md +++ b/Source/OLED128x32Wing/Driver/Readme.md @@ -8,3 +8,34 @@ The **Meadow.Foundation** peripherals library is an open-source repository of dr For more information on developing for Meadow, visit [developer.wildernesslabs.co](http://developer.wildernesslabs.co/), to view all Wilderness Labs open-source projects, including samples, visit [github.com/wildernesslabs](https://github.com/wildernesslabs/) +## Usage + +``` +OLED128x32Wing oledWing; +MicroGraphics graphics; + +public override Task Initialize() +{ + Console.WriteLine("Initializing ..."); + var i2cBus = Device.CreateI2cBus(I2cBusSpeed.FastPlus); + + oledWing = new OLED128x32Wing(i2cBus, Device.Pins.D11, Device.Pins.D10, Device.Pins.D09); + + graphics = new MicroGraphics(oledWing.Display); + graphics.CurrentFont = new Font12x16(); + + oledWing.ButtonA.Clicked += (sender, e) => UpdateDisplay("A pressed"); + oledWing.ButtonB.Clicked += (sender, e) => UpdateDisplay("B pressed"); + oledWing.ButtonC.Clicked += (sender, e) => UpdateDisplay("C pressed"); + + return Task.CompletedTask; +} + +void UpdateDisplay(string message) +{ + graphics.Clear(); + graphics.DrawText(0, 8, message); + graphics.Show(); +} + +```