~aleteoryx/muditaos

bb06380ca132310b26d86aeb80fc3e7722c6bf22 — Lucjan Bryndza 5 years ago 6c4c4e8 + 17a8053
[EGD-5737] Merge with master

Keep experimental up to date with changes from master
M .gdbinit-1051 => .gdbinit-1051 +2 -0
@@ 5,6 5,8 @@ monitor halt
monitor memU32 0x401BC000 = 128;
load
eval "monitor exec SetRTTAddr %p", &_SEGGER_RTT
info threads
thread 2
b main
b HardFault_Handler
b MemManage_Handler

M .vscode/launch.json => .vscode/launch.json +49 -2
@@ 2,12 2,12 @@
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch",
            "name": "Linux Launch",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build-linux-Debug/PurePhone.elf",
            "args": [],
            "stopAtEntry": false,
            "stopAtEntry": true,
            "cwd": "${workspaceFolder}/build-linux-Debug/",
            "environment": [],
            "externalConsole": false,


@@ 25,6 25,25 @@
            ]
        },
        {
            "name": "Linux Attach",
            "type": "cppdbg",
            "request": "attach",
            "program": "${workspaceFolder}/build-linux-Debug/PurePhone.elf",
            "MIMode": "gdb",
            "processId": "${command:pickProcess}",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                },
                {
                    "description": "disable SIGUSR1 logs",
                    "text": "handle SIGUSR1 nostop noprint"
                },
            ]
        },
        {
            "name": "Debug (rt1051)",
            "type": "gdb",
            "gdbpath": "arm-none-eabi-gdb",


@@ 40,6 59,34 @@
                "monitor halt",
                "monitor memU32 0x401BC000 = 128;",
                "load",
                "info threads",
                "thread 2",
                "b ResetISR",
                "b main",
                "b HardFault_Handler",
                "b MemManage_Handler",
                "b BusFault_Handler",
                "b UsageFault_Handler",
            ]
        },
        {
            "name": "RelWithDebug (rt1051)",
            "type": "gdb",
            "gdbpath": "arm-none-eabi-gdb",
            "request": "attach",
            "target": ":2331",
            "remote": true,
            "cwd": "${workspaceRoot}",
            "valuesFormatting": "parseText",
            "executable": "${workspaceFolder}/build-rt1051-RelWithDebInfo/PurePhone.elf",
            "autorun": [
                "eval \"monitor exec SetRTTAddr %p\", &_SEGGER_RTT",
                "monitor reset 0",
                "monitor halt",
                "monitor memU32 0x401BC000 = 128;",
                "load",
                "info threads",
                "thread 2",
                "b ResetISR",
                "b main",
                "b HardFault_Handler",

A art/phone/application_desktop/topbar/battery/battery1_W_M.png => art/phone/application_desktop/topbar/battery/battery1_W_M.png +0 -0
A art/phone/application_desktop/topbar/battery/battery2_W_M.png => art/phone/application_desktop/topbar/battery/battery2_W_M.png +0 -0
A art/phone/application_desktop/topbar/battery/battery3_W_M.png => art/phone/application_desktop/topbar/battery/battery3_W_M.png +0 -0
A art/phone/application_desktop/topbar/battery/battery4_W_M.png => art/phone/application_desktop/topbar/battery/battery4_W_M.png +0 -0
A art/phone/application_desktop/topbar/battery/battery5_W_M.png => art/phone/application_desktop/topbar/battery/battery5_W_M.png +0 -0
A art/phone/application_desktop/topbar/battery/battery_charging_W_M.png => art/phone/application_desktop/topbar/battery/battery_charging_W_M.png +0 -0
A art/phone/application_desktop/topbar/battery/battery_charging_ready_W_M.png => art/phone/application_desktop/topbar/battery/battery_charging_ready_W_M.png +0 -0
A art/phone/application_desktop/topbar/battery/battery_low_W_M.png => art/phone/application_desktop/topbar/battery/battery_low_W_M.png +0 -0
M changelog.md => changelog.md +2 -0
@@ 15,10 15,12 @@
* Fix auto-unlocking screen on idle.
* Fix missing texts in the desktop application.
* Fix occasional cases of no audio during an incoming call.
* Charging state icons in simulator

### Changed

* Torch light control button press time recognition.
* New battery icons

### Other


D image/assets/images/battery0.vpi => image/assets/images/battery0.vpi +0 -0
D image/assets/images/battery1.vpi => image/assets/images/battery1.vpi +0 -0
A image/assets/images/battery1_W_M.vpi => image/assets/images/battery1_W_M.vpi +0 -0
D image/assets/images/battery2.vpi => image/assets/images/battery2.vpi +0 -0
A image/assets/images/battery2_W_M.vpi => image/assets/images/battery2_W_M.vpi +0 -0
D image/assets/images/battery3.vpi => image/assets/images/battery3.vpi +0 -0
A image/assets/images/battery3_W_M.vpi => image/assets/images/battery3_W_M.vpi +0 -0
D image/assets/images/battery4.vpi => image/assets/images/battery4.vpi +0 -0
A image/assets/images/battery4_W_M.vpi => image/assets/images/battery4_W_M.vpi +0 -0
R image/assets/images/battery5.vpi => image/assets/images/battery5_W_M.vpi +0 -0
A image/assets/images/battery_charging_W_M.vpi => image/assets/images/battery_charging_W_M.vpi +0 -0
A image/assets/images/battery_charging_ready_W_M.vpi => image/assets/images/battery_charging_ready_W_M.vpi +0 -0
A image/assets/images/battery_low_W_M.vpi => image/assets/images/battery_low_W_M.vpi +0 -0
M module-apps/Application.cpp => module-apps/Application.cpp +5 -9
@@ 126,7 126,7 @@ namespace app
        if (state == State::ACTIVE_FORGROUND) {
            auto window = getCurrentWindow();
            if (Store::Battery::get().state == Store::Battery::State::Charging) {
                window->batteryCharging(true);
                window->updateBatteryCharger(true);
            }
            else {
                window->updateBatteryLevel(Store::Battery::get().level);


@@ 298,7 298,7 @@ namespace app
    sys::MessagePointer Application::handleBatteryLevel(sys::Message *msgl)
    {
        auto msg = static_cast<sevm::BatteryLevelMessage *>(msgl);
        LOG_INFO("Application battery level: %d", msg->levelPercents);
        LOG_INFO("Battery level: %d", msg->levelPercents);

        if (getCurrentWindow()->updateBatteryLevel(msg->levelPercents)) {
            refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);


@@ 310,16 310,12 @@ namespace app
    {
        auto *msg = static_cast<sevm::BatteryPlugMessage *>(msgl);
        if (msg->plugged == true) {
            LOG_INFO("Application charger connected");
            getCurrentWindow()->batteryCharging(true);
            refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
            LOG_INFO("Charger connected");
        }
        else {
            LOG_INFO("Application charger disconnected");
            getCurrentWindow()->batteryCharging(false);
            refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
            LOG_INFO("Charger disconnected");
        }

        getCurrentWindow()->updateBatteryCharger(msg->plugged);
        refreshWindow(gui::RefreshModes::GUI_REFRESH_FAST);
        return msgHandled();
    }

M module-apps/windows/AppWindow.cpp => module-apps/windows/AppWindow.cpp +5 -5
@@ 55,15 55,15 @@ namespace gui
        topBar->setActive(TopBar::Elements::SIGNAL, false);
    }

    bool AppWindow::batteryCharging(bool charging)
    bool AppWindow::setSIM()
    {
        topBar->setBatteryCharging(charging);
        topBar->simSet();
        return true;
    }

    bool AppWindow::setSIM()
    bool AppWindow::updateBatteryCharger(bool charging)
    {
        topBar->simSet();
        topBar->updateBattery(charging);
        return true;
    }



@@ 73,7 73,7 @@ namespace gui
        // get old value of battery level, calcualte new level and comapre both
        // if they are different make a change and return true, otherwise return false;
        if (topBar != nullptr) {
            return topBar->setBatteryLevel(percentage);
            return topBar->updateBattery(percentage);
        }
        return false;
    }

M module-apps/windows/AppWindow.hpp => module-apps/windows/AppWindow.hpp +1 -1
@@ 60,7 60,7 @@ namespace gui
        };
        virtual bool onDatabaseMessage(sys::Message *msg);

        bool batteryCharging(bool charging);
        bool updateBatteryCharger(bool charging);
        bool setSIM();
        // updates battery level in the window
        bool updateBatteryLevel(uint32_t percentage);

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

    void battery_getChargeStatus(bool &status)
    {
        status = plugged;
        if (status) {
            Store::Battery::modify().state = Store::Battery::State::Charging;
        }
        else {
            Store::Battery::modify().state = Store::Battery::State::Discharging;
        }
    }

    // TODO function unused in linux driver, left for compatibility with target driver


@@ 92,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);

M module-gui/gui/widgets/TopBar.cpp => module-gui/gui/widgets/TopBar.cpp +50 -51
@@ 43,16 43,16 @@ namespace gui

    void TopBar::batteryShowBars(uint32_t val)
    {
        if (val > battery.size()) {
        if (val > batteryBars.size()) {
            LOG_ERROR("Trying to set battery level out of scope");
            val = battery.size();
            val = batteryBars.size();
        }
        for (unsigned int i = 0; i < battery.size(); ++i) {
        for (unsigned int i = 0; i < batteryBars.size(); ++i) {
            if (elements.battery) {
                battery[i]->setVisible(val >= i);
                batteryBars[i]->setVisible(i == val);
            }
            else {
                battery[i]->setVisible(false);
                batteryBars[i]->setVisible(false);
            }
        }
    }


@@ 69,22 69,23 @@ namespace gui
        updateSignalStrength();

        // icons for battery
        battery = {
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery0"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery1"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery2"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery3"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery4"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery5"),
        batteryBars = {
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery_low_W_M"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery1_W_M"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery2_W_M"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery3_W_M"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery4_W_M"),
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery5_W_M"),
        };
        batteryShowBars(0);

        charging = new Label(this, batteryOffset, 15, 30, this->drawArea.h);
        charging->setFilled(false);
        charging->setBorderColor(gui::ColorNoColor);
        charging->setFont(style::header::font::title);
        charging->setText("Z");
        charging->setVisible(false);
        batteryChargings[Store::Battery::State::Charging] =
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery_charging_W_M");
        batteryChargings[Store::Battery::State::PluggedNotCharging] =
            new gui::Image(this, batteryOffset, 15, 0, 0, "battery_charging_ready_W_M");
        for (auto &el : batteryChargings) {
            el.second->setVisible(false);
        }

        const auto design_sim_offset = 376; // this offset is not final, but it is pixel Purefect
        sim                          = new SIM(this, design_sim_offset, 12);


@@ 122,18 123,7 @@ namespace gui
        switch (element) {
        case Elements::BATTERY: {
            elements.battery = active;
            if (Store::Battery::get().state == Store::Battery::State::Discharging) {
                setBatteryLevel(active ? Store::Battery::get().level : 0);
            }
            else {
                if (active) {
                    setBatteryCharging(true);
                }
                else {
                    charging->setVisible(false);
                    setBatteryLevel(0);
                }
            }
            showBattery(elements.battery);
        } break;
        case Elements::LOCK: {
            elements.lock = active;


@@ 162,10 152,10 @@ namespace gui
        };
    }

    uint32_t calculateBatteryLavel(uint32_t percentage)
    uint32_t calculateBatteryBars(uint32_t percentage)
    {
        uint32_t level = 0;
        if (percentage <= 5)
        if (percentage <= 5) // level critical
            level = 0;
        else if (percentage <= 27)
            level = 1;


@@ 178,37 168,46 @@ namespace gui
        else
            level = 5;

        if (level >= batteryLevelCount) {
        if (level >= batteryBarsCount) {
            LOG_ERROR("Battery level calculations are done wrong!");
            return batteryLevelCount - 1;
            return batteryBarsCount - 1;
        }
        return level;
    }

    bool TopBar::setBatteryLevel(uint32_t percent)
    bool TopBar::updateBattery(uint32_t percent)
    {
        if (Store::Battery::get().state != Store::Battery::State::Discharging) {
            return false;
        }
        charging->setVisible(false);
        batteryShowBars(calculateBatteryLavel(percent));
        showBattery(elements.battery);
        return true;
    }

    void TopBar::setBatteryCharging(bool plugged)
    bool TopBar::updateBattery(bool plugged)
    {
        if (plugged) {
            batteryShowBars(0);
        showBattery(elements.battery);
        return true;
    }

    void TopBar::showBattery(bool shown)
    {
        // hide battery bars icons
        for (const auto &bars : batteryBars) {
            bars->setVisible(false);
        }
        if (charging == nullptr)
            return;
        if (plugged) {
            charging->setVisible(true);
            batteryShowBars(0);
        // hide battery charging icons
        for (const auto &charging : batteryChargings) {
            charging.second->setVisible(false);
        }
        else {
            charging->setVisible(false);
            setBatteryLevel(Store::Battery::get().level);

        if (shown) {
            switch (Store::Battery::get().state) {
            case Store::Battery::State::Discharging:
                batteryShowBars(calculateBatteryBars(Store::Battery::get().level));
                break;
            case Store::Battery::State::Charging:
            case Store::Battery::State::PluggedNotCharging:
                batteryChargings[Store::Battery::get().state]->setVisible(true);
                break;
            }
        }
    }


M module-gui/gui/widgets/TopBar.hpp => module-gui/gui/widgets/TopBar.hpp +9 -7
@@ 9,11 9,12 @@
#include "Rect.hpp"
#include "TopBar/SIM.hpp"
#include <common_data/EventStore.hpp>
#include <map>

namespace gui
{

    static const uint32_t batteryLevelCount = 6;
    static const uint32_t batteryBarsCount  = 6;
    static const uint32_t signalImgCount    = 6;

    /// Header of most of design Windows


@@ 55,9 56,10 @@ namespace gui
        Label *networkAccessTechnologyLabel = nullptr;
        Image *signal[static_cast<size_t>(Store::RssiBar::noOfSupprtedBars)];
        Image *lock;
        std::array<Image *, batteryLevelCount> battery = {nullptr};
        Label *charging                                = nullptr;
        gui::SIM *sim                                  = nullptr;
        std::array<Image *, batteryBarsCount> batteryBars               = {nullptr};
        std::map<const Store::Battery::State, Image *> batteryChargings = {
            {Store::Battery::State::Charging, nullptr}, {Store::Battery::State::PluggedNotCharging, nullptr}};
        gui::SIM *sim = nullptr;
        void prepareWidget();
        static TimeMode timeMode;



@@ 89,9 91,9 @@ namespace gui
         * displayed.
         * @return if display should be refreshed or not
         */
        bool setBatteryLevel(uint32_t percent);

        void setBatteryCharging(bool plugged);
        bool updateBattery(uint32_t percent);
        bool updateBattery(bool plugged);
        void showBattery(bool shown);

        /**
         * @brief updates signal strength. This will cause appropriate image to be displayed.

M module-utils/common_data/EventStore.hpp => module-utils/common_data/EventStore.hpp +1 -0
@@ 25,6 25,7 @@ namespace Store
        {
            Discharging,
            Charging,
            PluggedNotCharging,
        } state            = State::Discharging;
        unsigned int level = 0;