Skip to content

Commit

Permalink
Fixing incorrect label for state of charge percentage bar
Browse files Browse the repository at this point in the history
  • Loading branch information
svartalf committed Mar 13, 2019
1 parent ce749b9 commit 9ff2265
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.2.1] - 2019-03-13
### Fixed

- Incorrect label for state of charge bar

## [0.2.0] - 2019-03-13
### Added
- CLI arguments handling (see `battop --help`) [#1](https://github.com/svartalf/rust-battop/issues/1)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[![Latest Version](https://img.shields.io/crates/v/battop.svg)](https://crates.io/crates/battop)
[![Build Status](https://travis-ci.org/svartalf/rust-battop.svg?branch=master)](https://travis-ci.org/svartalf/rust-battop)
[![dependency status](https://deps.rs/crate/battop/0.2.0/status.svg)](https://deps.rs/crate/battop/0.2.0)
[![dependency status](https://deps.rs/crate/battop/0.2.1/status.svg)](https://deps.rs/crate/battop/0.2.1)
![Apache 2.0 OR MIT licensed](https://img.shields.io/badge/license-Apache2.0%2FMIT-blue.svg)

`battop` is an interactive viewer, similar to `top`, `htop` and other *top utilities,
Expand Down
9 changes: 5 additions & 4 deletions src/app/ui/painter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,17 +143,18 @@ impl<'i> Painter<'i> {

pub fn draw_state_of_charge_bar<B: Backend>(&self, frame: &mut Frame<B>, area: Rect) {
let value = f64::from(self.view.battery().state_of_charge().get::<ratio>());
let value_label = f64::from(self.view.battery().state_of_charge().get::<percent>());
let block = Block::default().title("State of charge").borders(Borders::ALL);
let color = match () {
_ if value > 30.0 => Color::Green,
_ if value > 15.0 => Color::Yellow,
_ if value > 0.3 => Color::Green,
_ if value > 0.15 => Color::Yellow,
_ => Color::Red,
};
Gauge::default()
.block(block)
.ratio(value / 100.0)
.ratio(value)
.style(Style::default().fg(color))
.label(&format!("{:.2} %", value))
.label(&format!("{:.2} %", value_label))
.render(frame, area);
}

Expand Down

0 comments on commit 9ff2265

Please sign in to comment.