-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathprogress_tracker.h
More file actions
100 lines (88 loc) · 2.66 KB
/
Copy pathprogress_tracker.h
File metadata and controls
100 lines (88 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/**
* @file progress_tracker.h
* @brief Progress tracking utility for long operations
*
* This module provides a reusable progress tracker that can be used
* across different scenes to show detailed progress information with
* percentage, progress bar, and estimated time remaining.
*/
#pragma once
#include <furi.h>
#include <gui/modules/popup.h>
/**
* @brief Progress tracker structure
*/
typedef struct ProgressTracker ProgressTracker;
/**
* @brief Create a new progress tracker
*
* @param total_items Total number of items to process
* @param operation_name Name of the operation (e.g., "Writing")
* @return Allocated ProgressTracker instance
*/
ProgressTracker* progress_tracker_alloc(uint32_t total_items, const char* operation_name);
/**
* @brief Free progress tracker
*
* @param tracker Progress tracker instance
*/
void progress_tracker_free(ProgressTracker* tracker);
/**
* @brief Update progress
*
* @param tracker Progress tracker instance
* @param completed_items Number of completed items
*/
void progress_tracker_update(ProgressTracker* tracker, uint32_t completed_items);
/**
* @brief Increment progress by one item
*
* @param tracker Progress tracker instance
*/
void progress_tracker_increment(ProgressTracker* tracker);
/**
* @brief Get current progress percentage
*
* @param tracker Progress tracker instance
* @return Progress percentage (0-100)
*/
uint8_t progress_tracker_get_percentage(const ProgressTracker* tracker);
/**
* @brief Get formatted progress string
*
* Generates a string like: "Writing: 45/64 blocks (70%)"
*
* @param tracker Progress tracker instance
* @return Allocated FuriString with progress text
*/
FuriString* progress_tracker_get_text(const ProgressTracker* tracker);
/**
* @brief Get progress bar string
*
* Generates ASCII progress bar like: "[=======> ]"
*
* @param tracker Progress tracker instance
* @param width Width of progress bar in characters
* @return Allocated FuriString with progress bar
*/
FuriString* progress_tracker_get_bar(const ProgressTracker* tracker, uint8_t width);
/**
* @brief Get estimated time remaining
*
* @param tracker Progress tracker instance
* @return Estimated seconds remaining, or 0 if unknown
*/
uint32_t progress_tracker_get_eta_seconds(const ProgressTracker* tracker);
/**
* @brief Update popup with progress information
*
* Convenience function to update a popup view with complete progress info.
*
* @param tracker Progress tracker instance
* @param popup Popup view to update
* @param header Optional header text (NULL to keep current)
*/
void progress_tracker_update_popup(
ProgressTracker* tracker,
Popup* popup,
const char* header);