Пример #1
0
    public IEnumerator coGetBatteryCharge(string auth)
    {
        UnityWebRequest req =
            UnityWebRequest.Get("http://" + IP + "/api/power/battery");

        return(coGetResponse(req, auth, (res) =>
        {
            BatteryResponse parsed =
                BatteryResponse.CreateFromJSON(res.downloadHandler.text);
            setBatteryLevel(parsed);
        }));
    }
Пример #2
0
    private void setBatteryLevel(BatteryResponse data)
    {
        BatterySlider.value = data.GetRemainingCharge();
        BatteryText.text    = ((int)(data.GetRemainingCharge() * 100)) + "%";
        //show charge on overview screen
        tab.SetCharge(data.GetRemainingCharge());
        bool isPluggedIn = data.Charging > 0;

        tab.SetPlugged(isPluggedIn);
        BatteryPlugged.enabled = isPluggedIn;
        if (data.GetRemainingCharge() <= tab.lowLevel && data.Charging == 0)
        {
            warnings.addWarning(Warning.Battery, "plug in device");
        }
        else
        {
            warnings.removeWarning(Warning.Battery);
        }
    }