Skip to content

Commit

Permalink
updated interface to display hours in remaining time
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoninPvr committed Dec 7, 2024
1 parent 7358672 commit 63219a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 5 additions & 0 deletions battery_log.csv
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ Timestamp,Current (µA),Voltage (µV),Capacity (%),Charge (µAh),Temperature (°
2024-12-06 19:13:32,961000,16306000,80,4351000,27.8,0
2024-12-06 19:13:46,1215000,16258000,80,4347000,27.8,0
2024-12-06 19:13:52,1201000,16290000,80,4346000,27.8,0
2024-12-06 19:21:27,870000,16231000,78,4234000,27.8,0
2024-12-06 19:22:49,970000,16204000,78,4213000,27.8,0
2024-12-06 19:23:19,1186000,16138000,78,4205000,27.8,0
2024-12-06 19:24:40,1135000,16113000,77,4183000,27.8,0
2024-12-06 19:25:49,792000,16175000,77,4165000,27.8,0
7 changes: 4 additions & 3 deletions battery_logger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,18 @@ show_progress_bar() {
local elapsed=$1
local max_time=$2
local remaining=$((max_time - elapsed))
local remaining_minutes=$((remaining / 60))
local remaining_hours=$((remaining / 3600))
local remaining_minutes=$(( (remaining % 3600) / 60 ))
local remaining_seconds=$((remaining % 60))
local bar_length=25
local bar_length=33
local filled_length=$(( (elapsed * bar_length) / max_time ))
local empty_length=$(( bar_length - filled_length ))

# Generate progress bar
bar=$(printf "%${filled_length}s" | tr ' ' '#')
empty=$(printf "%${empty_length}s")

interface_output+="\rProgress: |${bar}${empty}| Remaining Time: $(printf "%02d:%02d" "$remaining_minutes" "$remaining_seconds")"
interface_output+="\rProgress: |${bar}${empty}| ETA: $(printf "%02d:%02d:%02d" "$remaining_hours" "$remaining_minutes" "$remaining_seconds")"
}

# Track runtime
Expand Down

0 comments on commit 63219a3

Please sign in to comment.