73 const int maxCurrentFromPanel = 900; // Not currently used (100,150,500,900,1200,2000 - will pick closest) (550mA for 3.5W Panel, 340 for 2W panel)
74 SystemPowerConfiguration conf;
75 System.setPowerConfiguration(SystemPowerConfiguration()); // To restore the default configuration
76
77 conf.powerSourceMaxCurrent(maxCurrentFromPanel) // Set maximum current the power source can provide 3.5W Panel (applies only when powered through VIN)
78 .powerSourceMinVoltage(5080) // Set minimum voltage the power source can provide (applies only when powered through VIN)
79 .batteryChargeCurrent(maxCurrentFromPanel) // Set battery charge current
80 .batteryChargeVoltage(4208) // Set battery termination voltage
81 .feature(SystemPowerFeature::USE_VIN_SETTINGS_WITH_USB_HOST); // For the cases where the device is powered through VIN
82 // but the USB cable is connected to a USB host, this feature flag
83 // enforces the voltage/current limits specified in the configuration
84 // (where by default the device would be thinking that it's powered by the USB Host)
85 int res = System.setPowerConfiguration(conf); // returns SYSTEM_ERROR_NONE (0) in case of success