forked from flipperdevices/flipperzero-firmware
-
-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add happiness management (#10)
* small refactoring of time functions * Add deed on pomodoro complete * Event queue refactoring
- Loading branch information
Showing
5 changed files
with
121 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
/** | ||
* Index of dependencies for the main app | ||
*/ | ||
|
||
#include <furi.h> | ||
#include <furi_hal.h> | ||
#include "helpers/time.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include <furi.h> | ||
#include <furi_hal.h> | ||
#include "time.h" | ||
|
||
const int TIME_SECONDS_IN_MINUTE = 60; | ||
const int TIME_MINUTES_IN_HOUR = 60; | ||
|
||
uint32_t time_now() { | ||
return furi_hal_rtc_get_timestamp(); | ||
}; | ||
|
||
TimeDifference time_difference_seconds(uint32_t begin, uint32_t end) { | ||
const uint32_t duration_seconds = end - begin; | ||
|
||
uint32_t minutes = (duration_seconds / TIME_MINUTES_IN_HOUR) % TIME_MINUTES_IN_HOUR; | ||
uint32_t seconds = duration_seconds % TIME_SECONDS_IN_MINUTE; | ||
|
||
return (TimeDifference){.total_seconds=duration_seconds, .minutes=minutes, .seconds=seconds}; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#pragma once | ||
|
||
#include <furi.h> | ||
#include <furi_hal.h> | ||
|
||
extern const int TIME_SECONDS_IN_MINUTE; | ||
extern const int TIME_MINUTES_IN_HOUR; | ||
|
||
/// @brief Container for a time period | ||
typedef struct { | ||
uint8_t seconds; | ||
uint8_t minutes; | ||
uint32_t total_seconds; | ||
} TimeDifference; | ||
|
||
/// @brief Time by the moment of calling | ||
/// @return A timestamp(seconds percision) | ||
uint32_t time_now(); | ||
|
||
/// @brief Calculates difference between two provided timestamps | ||
/// @param begin - start timestamp of the period | ||
/// @param end - end timestamp of the period to measure | ||
/// @return TimeDifference struct | ||
TimeDifference time_difference_seconds(uint32_t begin, uint32_t end); | ||
|