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");
        }
Exemple #3
0
        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();
            }
        }