~aleteoryx/muditaos

24e2607f6b0d5e18d06540bb1877d783c6fbcc40 — Wojtek Rzepecki 5 years ago 6cd6047
[EGD-4727] Change Torch hardware control

Change way of button usage
M changelog.md => changelog.md +3 -0
@@ 14,6 14,9 @@

* Fix missing texts for ApplicationDesktop windows

### Changed

* `[UserInterface]` Torch light control button press time recognition.
## [0.51.1 2020-12-18]

### Added

M module-apps/Application.cpp => module-apps/Application.cpp +3 -9
@@ 540,7 540,7 @@ namespace app
        return AudioServiceAPI::GetSetting(this, audio::Setting::Volume, volume);
    }

    void Application::toggleTorchAndColourTemps()
    void Application::toggleTorch(bsp::torch::ColourTemperature temperature)
    {
        using namespace bsp;



@@ 558,16 558,10 @@ namespace app
            switch (msgGetState->state) {
            case torch::State::off:
                msgSetState->state      = torch::State::on;
                msgSetState->colourTemp = torch::warmest;
                msgSetState->colourTemp = temperature;
                break;
            case torch::State::on:
                if (msgGetState->colourTemp == torch::warmest) { // toggle colour temp
                    msgSetState->state      = torch::State::on;
                    msgSetState->colourTemp = torch::coldest;
                }
                else {
                    msgSetState->state = torch::State::off;
                }
                msgSetState->state = torch::State::off;
                break;
            }
            sys::Bus::SendUnicast(msgSetState, service::name::evt_manager, this);

M module-apps/Application.hpp => module-apps/Application.hpp +1 -1
@@ 280,7 280,7 @@ namespace app
        }
        audio::RetCode getCurrentVolume(audio::Volume &volume);

        void toggleTorchAndColourTemps();
        void toggleTorch(bsp::torch::ColourTemperature temperature);

        /// @defgroup Application Application static functions
        /// All this functions are meant to be used in ApplicationManager only

M module-apps/windows/AppWindow.cpp => module-apps/windows/AppWindow.cpp +27 -21
@@ 127,29 127,35 @@ namespace gui
            LOG_INFO("exit to main menu");
            app::manager::Controller::sendAction(application, app::manager::actions::Home);
        }
        // process only if key is released
        if ((inputEvent.state != InputEvent::State::keyReleasedShort))
            return false;

        switch (inputEvent.keyCode) {
        case KeyCode::KEY_VOLUP: {
            application->increaseCurrentVolume();
            return true;
        }
        case KeyCode::KEY_VOLDN: {
            application->decreaseCurrentVolume();
            return true;
        }
        case KeyCode::KEY_RF: {
            application->returnToPreviousWindow();
            return true;
        if ((inputEvent.isShortPress())) {
            switch (inputEvent.keyCode) {
            case KeyCode::KEY_VOLUP: {
                application->increaseCurrentVolume();
                return true;
            }
            case KeyCode::KEY_VOLDN: {
                application->decreaseCurrentVolume();
                return true;
            }
            case KeyCode::KEY_RF: {
                application->returnToPreviousWindow();
                return true;
            }
            default:
                break;
            }
        }
        case KeyCode::KEY_TORCH: {
            application->toggleTorchAndColourTemps();
            return true;
        }
        default:
            break;

        if (inputEvent.keyCode == KeyCode::KEY_TORCH) {
            if (inputEvent.isLongPress()) {
                application->toggleTorch(bsp::torch::ColourTemperature::warmest);
                return true;
            }
            else if (inputEvent.isShortPress()) {
                application->toggleTorch(bsp::torch::ColourTemperature::coldest);
                return true;
            }
        }

        return false;