Complete

Unexpected Type Error for solar intensity

I have a problem how to check that the device has solar display. For example the MARQ has support for SDK 3.2 but does not work code:

if(Sys.getSystemStats() has :solarIntensity){
    solar = Sys.getSystemStats().solarIntensity.toNumber();
}

Devices without SDK 3.2 support works with this code well.
Any ideas how to fix?

  • This code is functionally the same as that posted by , but avoids making multiple calls to getSystemStats() which is more efficient, and it handles cases where the device is not charging.

    var systemStats = Sys.getSystemStats();
    
    // device family has solar charging support
    if (systemStats has :solarIntensity) {
    
        var solarIntensity = systemStats.solarIntensity;
        if (solarIntensity == null) {
            // not supported on current device. this can happen if
            // one or more devices in a family have solar charging
            // support, but not all of them do. e.g., Fenix 6X Pro
            // would return null, but Fenix 6X Pro Solar would not.
        } else if (solarIntensity < 0) {
            // not charging
        } else {
            // charging (value is a Number from 0 to 100
        }
    }

  • if(Sys.getSystemStats() has :solarIntensity && Sys.getSystemStats().solarIntensity != null){
    			solar = Sys.getSystemStats().solarIntensity.toNumber();
    }

    Solved..