~aleteoryx/muditaos

3f38b150ecabd0fecb4d735a5ca13cc25ef53b81 — Maciej Gibowicz 1 year, 11 months ago 3ae500d
[BH-1846] Reducing power consumption while the application is running

Replacing double with float in rendering a circular progressbar results
in a significant reduction in the demand for computing power, which in
turn translates into reduced power consumption in all applications using
a circular progressbar.
3 files changed, 17 insertions(+), 16 deletions(-)

M harmony_changelog.md
M module-gui/gui/core/renderers/ArcRenderer.cpp
M module-utils/math/Math.hpp
M harmony_changelog.md => harmony_changelog.md +1 -0
@@ 15,6 15,7 @@
* Removed minus sign in progress countdown timers in Relaxation, Meditation and Power Nap apps
* Extended volume scale from 10 to 15 point scale
* Modified volume control characteristic for better user experience
* Reducing power consumption for meditation and power nap applications

## [2.3.0 2023-12-20]


M module-gui/gui/core/renderers/ArcRenderer.cpp => module-gui/gui/core/renderers/ArcRenderer.cpp +10 -10
@@ 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 "ArcRenderer.hpp"


@@ 43,17 43,17 @@ namespace gui::renderer

        const auto start = trigonometry::toRadians(begin);
        const auto end   = trigonometry::toRadians(begin + sweep);
        double step;
        trigonometry::Radians step;

        if (radius < RadiusPrecisionLimit) {
            step = 0.01;
            step = 0.01f;
        }
        else {
            step = 0.001;
            step = 0.001f;
        }

        double cosine, sine;
        for (double radians = start; radians <= end; radians += step) {
        trigonometry::Radians cosine, sine;
        for (trigonometry::Radians radians = start; radians <= end; radians += step) {
            cosine = std::cos(radians);
            sine   = std::sin(radians);
            for (Length i = 0; i < width; ++i) {


@@ 74,17 74,17 @@ namespace gui::renderer
    {
        const auto start = trigonometry::toRadians(begin);
        const auto end   = trigonometry::toRadians(begin + sweep);
        double step;
        trigonometry::Radians step;

        if (radius < RadiusPrecisionLimit) {
            step = 0.01;
            step = 0.01f;
        }
        else {
            step = 0.001;
            step = 0.001f;
        }

        long int x, y;
        for (double radians = start; radians <= end; radians += step) {
        for (trigonometry::Radians radians = start; radians <= end; radians += step) {
            x = trigonometry::AdjacentSide::fromAngle(radians, radius);
            y = trigonometry::OppositeSide::fromAngle(radians, radius);
            PixelRenderer::draw(ctx, Point(center.x + x, center.y + y), color);

M module-utils/math/Math.hpp => module-utils/math/Math.hpp +6 -6
@@ 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

#pragma once


@@ 10,7 10,7 @@ namespace trigonometry
{
    using SideLength = std::int32_t;
    using Degrees    = std::int32_t;
    using Radians    = double;
    using Radians    = float;

    constexpr Degrees FullAngle  = 360;
    constexpr Degrees HalfAngle  = 180;


@@ 23,12 23,12 @@ namespace trigonometry

    struct AdjacentSide
    {
        static auto fromAngle(Radians angle, SideLength hypotenuse) -> SideLength
        static inline auto fromAngle(Radians angle, SideLength hypotenuse) -> SideLength
        {
            return std::round(std::cos(angle) * hypotenuse);
        }

        static auto fromCosine(double cosine, SideLength hypotenuse) -> SideLength
        static inline auto fromCosine(float cosine, SideLength hypotenuse) -> SideLength
        {
            return std::round(cosine * hypotenuse);
        }


@@ 36,12 36,12 @@ namespace trigonometry

    struct OppositeSide
    {
        static auto fromAngle(Radians angle, SideLength hypotenuse) -> SideLength
        static inline auto fromAngle(Radians angle, SideLength hypotenuse) -> SideLength
        {
            return std::round(std::sin(angle) * hypotenuse);
        }

        static auto fromSine(double sine, SideLength hypotenuse) -> SideLength
        static inline auto fromSine(float sine, SideLength hypotenuse) -> SideLength
        {
            return std::round(sine * hypotenuse);
        }