Example #1
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _tSource = new CancellationTokenSource();

            var deferral = taskInstance.GetDeferral();

            //BODY GOES HERE
            _display = InitLcd();

            var bus = new BusManager();

            _commMgr = new SmartSensorManager();
            //_api = new SmartWaterApi("http://192.168.25.181:15151");
            _api = new SmartWaterApi("https://smartwater.azurewebsites.net");

            _commMgr.StatusUpdate += CommMgrOnStatusUpdate;

            bus.SetRequest  += BusOnSetRequest;
            bus.ZeroRequest += BusOnZeroRequest;

            //END BODY
            while (!_tSource.Token.IsCancellationRequested)
            {
                await _commMgr.GetStatus();

                await Task.Delay(TimeSpan.FromMinutes(1), _tSource.Token);
            }

            //CLOSING DOWN

            deferral.Complete();
        }
Example #2
0
        private static DisplayI2C InitLcd()
        {
            // Here is I2C bus and Display itself initialized.
            //
            //  I2C bus is initialized by library constructor. There is also defined PCF8574 pins
            //  Default `DEVICE_I2C_ADDRESS` is `0x27` (you can change it by A0-2 pins on PCF8574 - for more info please read datasheet)
            //  `I2C_CONTROLLER_NAME` for Raspberry Pi 2 is `"I2C1"`
            //  For Arduino it should be `"I2C5"`, but I did't test it.
            //  Other arguments should be: RS = 0, RW = 1, EN = 2, D4 = 4, D5 = 5, D6 = 6, D7 = 7, BL = 3
            //  But it depends on your PCF8574.
            var lcd = new DisplayI2C(DEVICE_I2C_ADDRESS, I2C_CONTROLLER_NAME, RS, RW, EN, D4, D5, D6, D7, BL);

            //Initialization of HD44780 display do by init method.
            //By arguments you can turnOnDisplay, turnOnCursor, blinkCursor, cursorDirection and textShift (in thius order)
            lcd.init();
            //lcd.createSymbol(new byte[] { 0x00, 0x00, 0x0A, 0x00, 0x11, 0x0E, 0x00, 0x00 }, 0x00);

            // Here is printed string
            lcd.prints("Good morning,");

            // Navigation to second line
            lcd.gotoxy(0, 1);

            // Here is printed string
            lcd.prints("gentlemen");

            // Here is printed our new symbol (emoticon)
            //lcd.printSymbol(0x00);

            return(lcd);
        }