static void DemoScreen2(SSD1306Driver oledScreen) { Random rnd = new Random(); oledScreen.DrawProgressBar(5, 5, 118, 10, rnd.Next(100)); oledScreen.DrawXbm(64, 22, wifiLogo.Width, wifiLogo.Height, wifiLogo.Datas); // legacy lib signature oledScreen.DrawXbm(20, 22, nanofLogo); // modern dotnet signature }
static void DemoScreen4(SSD1306Driver oledScreen) { oledScreen.Clear(); oledScreen.CurrentFont = FontArialMTPlain10.GetFont(); oledScreen.DrawHorizontalLine(0, 32, 128); oledScreen.DrawVerticalLine(64, 0, 64); oledScreen.CurrentTextAlignement = TextAlignment.Left; oledScreen.DrawString(0, 0, "DrawString()\rLine 1\nLine 2\r\nLine 3"); oledScreen.CurrentTextAlignement = TextAlignment.Right; oledScreen.DrawString(128, 0, "DrawString()\rLine 1\nLine 2\r\nLine 3"); oledScreen.CurrentTextAlignement = TextAlignment.Center; oledScreen.DrawString(64, 0, "< >\r-< >-\roO0[]0Oo\r/ \\\r\\_ _/"); }
static void DemoScreen3(SSD1306Driver oledScreen) { oledScreen.Clear(); oledScreen.CurrentTextAlignement = TextAlignment.Left; oledScreen.CurrentFont = FontArialMTPlain10.GetFont(); oledScreen.DrawString(1, 0, "NiCo"); oledScreen.CurrentFont = FontArialMTPlain16.GetFont(); oledScreen.DrawString(1, 11, "nIc0"); oledScreen.CurrentFont = FontArialMTPlain24.GetFont(); oledScreen.DrawString(1, 30, "N1co"); }
static void initRadio(SSD1306Driver oledScreen) { //Set LoRa Pins byte MessageCount = System.Byte.MaxValue; int chipSelectPinNumber = Gpio.IO18; int interruptPinNumber = Gpio.IO26; int resetPinNumber = Gpio.IO14; Configuration.SetPinFunction(Gpio.IO19, DeviceFunction.SPI1_MISO); Configuration.SetPinFunction(Gpio.IO27, DeviceFunction.SPI1_MOSI); Configuration.SetPinFunction(Gpio.IO05, DeviceFunction.SPI1_CLOCK); //Initialize Modem - BEEEEEEEEEEEEEEEEEEEEEEP.......BUUUUUUUUUUUUUUUUUUUUUR....................WEEEEDOOOOWEEEEEDOOO.................SKRRRRRRRRRRRRRRRRRR Rfm9XDevice rfm9XDevice = new Rfm9XDevice(SpiBusId, chipSelectPinNumber, resetPinNumber, interruptPinNumber); oledScreen.DrawString(0, 20, "Success......."); oledScreen.RefreshDisplay(); rfm9XDevice.Initialise(Frequency, paBoost: true); oledScreen.DrawString(0, 30, "Powering Radio On......."); oledScreen.RefreshDisplay(); rfm9XDevice.OnReceive += Rfm9XDevice_OnReceive; rfm9XDevice.Receive(); rfm9XDevice.OnTransmit += Rfm9XDevice_OnTransmit; //LED INIT - Not required, just gave me something to see in my peripheral so I did not have to read the OLED all the time GpioController gpioc = new GpioController(); GpioPin led = gpioc.OpenPin(OnBoardDevicePortNumber.Led, PinMode.Output); led.Write(PinValue.High); Thread.Sleep(5000); //Too fast and we reset int count = 0; while (true) //Send a message and update the OLED { string messageText = $"Hello from {DeviceName} ! {MessageCount}"; MessageCount -= 1; count++; oledScreen.Clear(); oledScreen.DrawString(0, 0, "Transmitting...."); oledScreen.DrawString(0, 10, "Messages Sent: " + count.ToString()); oledScreen.RefreshDisplay(); byte[] messageBytes = UTF8Encoding.UTF8.GetBytes(messageText); Debug.WriteLine($"{DateTime.UtcNow:hh:mm:ss}-TX {messageBytes.Length} byte message {messageText}"); rfm9XDevice.Send(messageBytes); Thread.Sleep(1000); led.Toggle(); } }
public void Begin() { this.PowerON(); this.Reset(); // Configuration of I2C1 bus for onboard LED Configuration.SetPinFunction(OnBoardOled.Data, DeviceFunction.I2C1_DATA); Configuration.SetPinFunction(OnBoardOled.Clock, DeviceFunction.I2C1_CLOCK); i2cBusSSD1306 = I2cDevice.Create(new I2cConnectionSettings(1, OnBoardOled.I2CAddress, I2cBusSpeed.FastMode)); ssd1306 = new SSD1306Driver(i2cBusSSD1306, oledReset, 50 /* Heltec onboard oled support 0ms */); ssd1306.Init(); //ssd1306.FlipScreenVertically(); ssd1306.RefreshDisplay(); }
static void DemoGeometry(SSD1306Driver oledScreen) { oledScreen.DrawLine(0, 0, oledScreen.DisplayWidth - 1, oledScreen.DisplayHeight - 1); oledScreen.DrawLine(0, oledScreen.DisplayHeight - 1, oledScreen.DisplayWidth - 1, 0); oledScreen.DrawHorizontalLine(20, 32, 88); oledScreen.DrawVerticalLine(64, 10, 44); oledScreen.DrawRect(30, 15, 68, 34); oledScreen.CurrentColor = OledColor.Inverse; oledScreen.FillRect(2, 15, 20, 34); oledScreen.FillRect(106, 15, 20, 34); oledScreen.DrawCircleQuads(30, 0, 30, 0b0100); oledScreen.DrawCircleQuads(98, 0, 30, 0b1000); oledScreen.DrawCircleQuads(30, 64, 30, 0b0010); oledScreen.DrawCircleQuads(98, 64, 30, 0b0001); oledScreen.FillCircle(64, 31, 12); oledScreen.CurrentColor = OledColor.White; oledScreen.DrawCircle(64, 31, 30); }