~aleteoryx/muditaos

fdd68635fbbadc43e6f6b9333cc2db10bc60c52d — Mateusz Grzywacz 5 years ago 3b08e4c
[EGD-5089] linux battery bsp charging done added
1 files changed, 14 insertions(+), 4 deletions(-)

M module-bsp/board/linux/battery-charger/battery_charger.cpp
M module-bsp/board/linux/battery-charger/battery_charger.cpp => module-bsp/board/linux/battery-charger/battery_charger.cpp +14 -4
@@ 54,7 54,7 @@ namespace bsp
    }
    void battery_getBatteryLevel(uint8_t &levelPercent)
    {
        levelPercent = battLevel;
        levelPercent                   = battLevel;
        Store::Battery::modify().level = battLevel;
    }



@@ 98,18 98,28 @@ namespace bsp
                uint8_t notification = 0;
                switch (buff[0]) {
                case 'p':
                    notification = 0x02;
                    notification = static_cast<uint8_t>(bsp::batteryIRQSource::INOKB);
                    plugged      = 1 - plugged;
                    break;
                case ']':
                    notification = 0x01;
                    notification = static_cast<uint8_t>(bsp::batteryIRQSource::INTB);
                    if (battLevel < 100)
                        battLevel++;
                    else {
                        // second 100% in a row
                        if (plugged && Store::Battery::get().level == 100) {
                            Store::Battery::modify().state = Store::Battery::State::PluggedNotCharging;
                        }
                    }
                    break;
                case '[':
                    notification = 0x01;
                    notification = static_cast<uint8_t>(bsp::batteryIRQSource::INTB);
                    if (battLevel >= 1)
                        battLevel--;
                    if (plugged && Store::Battery::get().level == 100) {
                        // charging but not 100% anymore
                        Store::Battery::modify().state = Store::Battery::State::Charging;
                    }
                    break;
                }
                xQueueSend(qHandleIrq, &notification, 100);