Example #1
0
        private bool setup_GPIO()
        {
            deviceSetupPage        = this;
            triggered_gpio_already = false;

            if (!useSpill)
            {
                return(true);
            }

            IntPtr gpio0Signal = mbl_mw_gpio_get_pin_monitor_data_signal(getBoard(), GPIO_PIN);

            if (gpio0Signal.ToInt64() != 0)
            {
                //IntPtr gpio0Signal = mbl_mw_gpio_get_digital_input_data_signal(getBoard(), PIN);
                mbl_mw_datasignal_subscribe(gpio0Signal, gpio0DataHandler);
                mbl_mw_gpio_set_pull_mode(getBoard(), GPIO_PIN, Gpio.PullMode.UP);
                mbl_mw_gpio_set_pin_change_type(getBoard(), GPIO_PIN, Gpio.PinChangeType.FALLING);
                mbl_mw_gpio_start_pin_monitoring(getBoard(), GPIO_PIN);

                Debug.WriteLine("gpio-initialized");
                return(true);
            }
            else
            {
                info("failed to setup the GPIO signal");
                return(false);
            }
        }
Example #2
0
        public async Task <bool> update_battery_info(DeviceSetup deviceSetup)
        {
            IntPtr batterySignal = mbl_mw_settings_get_battery_state_data_signal(deviceSetup.getBoard());

            if (batterySignal.ToInt64() != 0)
            {
                mbl_mw_datasignal_subscribe(batterySignal, deviceSetup.batteryDataHandler);
                DeviceSetup.gotSignal = false;
                mbl_mw_datasignal_read(batterySignal);

                while (!DeviceSetup.gotSignal)
                {
                    await Task.Delay(10);
                }

                string msg = "" + DeviceSetup.batteryValue.charge + " %, " + DeviceSetup.batteryValue.voltage + " V";
                await append_file(msg);


                deviceSetup.setBatteryText(msg + "(press for update)");

                mbl_mw_datasignal_unsubscribe(batterySignal);
            }
            else
            {
                deviceSetup.info("failed to initialize battery signal");
            }
            return(true);
        }
Example #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var mwBoard = MetaWearBoard.getMetaWearBoardInstance(e.Parameter as BluetoothLEDevice);

            board = mwBoard.cppBoard;

            deviceSetupPage = this;

            triggered_gpio_already = false;

            this.gyroCheckbox.IsChecked  = useGyro;
            this.accelCheckbox.IsChecked = useAccel;
            this.spillCheckbox.IsChecked = useSpill;
        }
Example #4
0
        internal void start_battery_logging(DeviceSetup deviceSetup)
        {
            TimeSpan period = TimeSpan.FromSeconds(BATTERY_UPDATE_SECONDS);

            ThreadPoolTimer PeriodicTimer = ThreadPoolTimer.CreatePeriodicTimer((source) =>
            {
                //
                // Update the UI thread by using the UI core dispatcher.
                //
                deviceSetup.Dispatcher.RunAsync(CoreDispatcherPriority.High,
                                                () =>
                {
                    Debug.WriteLine("auto-update of battery status!");
                    update_battery_info(deviceSetup);
                });
            }, period);
        }