void NeoBattery::updateSysStatus() { charging = isCharging(); qLog(PowerManagement) << __PRETTY_FUNCTION__ << charging; int capacity = getCapacity(); battery->setCharging(charging); battery->setCharge(capacity); battery->setTimeRemaining(getTimeRemaining()); // stop the charging animation when fully charged and plugged in // otherwise it looks like it never gets full if (capacity > 98 && charging) battery->setCharging(false); }
int BatteryBusinessLogic::remainingIdleTime () { int ret = -1; /* * When device is charging we're return -1 from here... */ if (isCharging ()) return ret; #ifdef HAVE_QMSYSTEM MeeGo::QmBattery::RemainingTimeMode mode = PSMValue () ? MeeGo::QmBattery::PowersaveMode : MeeGo::QmBattery::NormalMode; ret = m_battery->getRemainingIdleTime (mode); #endif return ret; }
void ChargeMonitor::update() { if (isCharging()) { current_samples.push(ammeter.sample()); const uint32_t now = system::Timer::millis(); if ((now - last_sample) > 1000) { // Update charge energy watt_seconds += current_samples.get() * VOLTAGE / 1000; last_sample = now; // Check charge limit const uint32_t charge_limit = getChargeLimit(); if (charge_limit) { State &state = State::get(); if (state.ready == State::READY && wattHours() > charge_limit) setKwhLimited(true); } } } }
void AppleACPIBatteryDevice::rebuildLegacyIOBatteryInfo(void) { OSDictionary *legacyDict = OSDictionary::withCapacity(5); uint32_t flags = 0; OSNumber *flags_num = NULL; if (externalConnected()) flags |= kIOPMACInstalled; if (batteryInstalled()) flags |= kIOPMBatteryInstalled; if (isCharging()) flags |= kIOPMBatteryCharging; flags_num = OSNumber::withNumber((unsigned long long)flags, NUM_BITS); legacyDict->setObject(kIOBatteryFlagsKey, flags_num); flags_num->release(); legacyDict->setObject(kIOBatteryCurrentChargeKey, properties->getObject(kIOPMPSCurrentCapacityKey)); legacyDict->setObject(kIOBatteryCapacityKey, properties->getObject(kIOPMPSMaxCapacityKey)); legacyDict->setObject(kIOBatteryVoltageKey, properties->getObject(kIOPMPSVoltageKey)); legacyDict->setObject(kIOBatteryAmperageKey, properties->getObject(kIOPMPSAmperageKey)); legacyDict->setObject(kIOBatteryCycleCountKey, properties->getObject(kIOPMPSCycleCountKey)); setLegacyIOBatteryInfo(legacyDict); legacyDict->release(); }
uint32_t ChargeMonitor::chargeCurrent() const { return isCharging() ? current_samples.get() : 0; }