~aleteoryx/muditaos

39281cb09eed396249e60a7256b289b8d333e82a — Dawid Wojtas 2 years ago 882a6d0
[BH-1241] Fix the frontlight in pre-wake up

Disable the frontlight and chime when the
pre-wake up is off using deep press.
M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 14,6 14,7 @@
* Fixed disabling the alarm on the system shutdown screen
* Fixed "Next alarm will ring in 24h" popup on shutdown screen
* Fixed redundant clock face display while shutting down Harmony
* Fixed problem with disabling the frontlight in pre-wake up

### Added


M products/BellHybrid/services/evtmgr/screen-light-control/ScreenLightControl.cpp => products/BellHybrid/services/evtmgr/screen-light-control/ScreenLightControl.cpp +2 -2
@@ 1,4 1,4 @@
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include "ScreenLightControl.hpp"


@@ 176,7 176,7 @@ namespace bell::screen_light_control
    void ScreenLightController::turnOff()
    {
        lightOn = false;
        ::screen_light_control::functions::setRampTarget(MINIMAL_TARGET);
        setBrightnessInstant(MINIMAL_TARGET);
        cpuSentinelRelease();
        enableTimers();
    }

M products/BellHybrid/services/time/AlarmOperations.cpp => products/BellHybrid/services/time/AlarmOperations.cpp +20 -6
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#include <time/AlarmOperations.hpp>


@@ 224,6 224,17 @@ namespace alarms
        return event;
    }

    void AlarmOperations::turnOffRingingAlarm(const std::uint32_t id, OnTurnOffRingingAlarm callback)
    {
        auto nextEvent = getNextPreWakeUpEvent();
        if (nextEvent.isValid()) {
            if (auto event = std::dynamic_pointer_cast<AlarmEventRecord>(nextEvent.parent); event) {
                disablePreWakeUp(event);
            }
        }
        AlarmOperationsCommon::turnOffRingingAlarm(id, callback);
    }

    void AlarmOperations::handlePreWakeUp(const SingleEventRecord &event, PreWakeUp::Decision decision)
    {
        if (auto alarmEventPtr = std::dynamic_pointer_cast<AlarmEventRecord>(event.parent); alarmEventPtr) {


@@ 236,6 247,12 @@ namespace alarms
        }
    }

    auto AlarmOperations::disablePreWakeUp(const std::shared_ptr<AlarmEventRecord> &event) -> void
    {
        AlarmOperationsCommon::handleAlarmEvent(event, alarms::AlarmType::PreWakeUpChime, false);
        AlarmOperationsCommon::handleAlarmEvent(event, alarms::AlarmType::PreWakeUpFrontlight, false);
    }

    bool AlarmOperations::processSnoozeChime(TimePoint now)
    {
        if (!ongoingSingleEvents.empty()) {


@@ 279,9 296,7 @@ namespace alarms
        if (alarmType != alarms::AlarmType::Clock) {
            return;
        }

        handleAlarmEvent(event, alarms::AlarmType::PreWakeUpChime, false);
        handleAlarmEvent(event, alarms::AlarmType::PreWakeUpFrontlight, false);
        disablePreWakeUp(event);
    }
    bool AlarmOperations::isBedtimeAllowed() const
    {


@@ 293,8 308,7 @@ namespace alarms
                                           bool newStateOn)
    {
        if (newStateOn && alarmType == alarms::AlarmType::Clock) {
            AlarmOperationsCommon::handleAlarmEvent(event, alarms::AlarmType::PreWakeUpChime, false);
            AlarmOperationsCommon::handleAlarmEvent(event, alarms::AlarmType::PreWakeUpFrontlight, false);
            disablePreWakeUp(event);
        }
        AlarmOperationsCommon::handleAlarmEvent(event, alarmType, newStateOn);
    }

M products/BellHybrid/services/time/include/time/AlarmOperations.hpp => products/BellHybrid/services/time/include/time/AlarmOperations.hpp +3 -1
@@ 1,4 1,4 @@
// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once


@@ 105,9 105,11 @@ namespace alarms

        SingleEventRecord getNextPreWakeUpEvent();
        void handlePreWakeUp(const SingleEventRecord &event, PreWakeUp::Decision decision);
        void disablePreWakeUp(const std::shared_ptr<AlarmEventRecord> &event);
        void handleSnoozeChime(const SingleEventRecord &event, bool newStateOn);
        void handleBedtime(const SingleEventRecord &event, bool decision);
        void processBedtime(TimePoint now);
        void turnOffRingingAlarm(const std::uint32_t id, OnTurnOffRingingAlarm callback) override;
        void onAlarmTurnedOff(const std::shared_ptr<AlarmEventRecord> &event, alarms::AlarmType alarmType) override;
        void handleAlarmEvent(const std::shared_ptr<AlarmEventRecord> &event,
                              alarms::AlarmType alarmType,