-
Dependencies: CommandHandler HygroClip2 InterruptBasedEncoder SPI_TFT_ILI9341 mbed-src-no-hal
Diff: GraphScale.cpp
- Revision:
- 3:3ef8c2d7b1bf
- Parent:
- 2:81fc8f80fdb4
- Child:
- 4:47fd4584df95
diff -r 81fc8f80fdb4 -r 3ef8c2d7b1bf GraphScale.cpp --- a/GraphScale.cpp Wed Feb 17 07:30:14 2016 +0000 +++ b/GraphScale.cpp Tue Mar 15 07:46:06 2016 +0000 @@ -2,7 +2,7 @@ GraphScale::GraphScale(SPI_TFT_ILI9341 * tft, int x, int y, int width, int height, int min, int max, int scaleSteps) : tft_(tft), x_(x), y_(y), width_(width), height_(height), min_(min), max_(max), scaleSteps_(scaleSteps) -{ +{ } void GraphScale::draw(int color) @@ -11,12 +11,12 @@ int x2 = x_+width_+1; int y1 = y_-1; int y2 = y_+height_+1; - + tft_->rect(x1, y1, x2, y2, color); - + int stepsize = height_ / ((max_-min_) / scaleSteps_); int stepposition = min_; - + while (stepposition <= max_) { float yPos = scaleY(stepposition); @@ -31,13 +31,13 @@ { static float valueRange = static_cast<float>(max_-min_); static float buttomOfGraph = static_cast<float>(y_+height_); - + if (ypos < min_) ypos = min_; if (ypos > max_) ypos = max_; - + float scaled = buttomOfGraph - (height_ * ((ypos-min_) / valueRange)); - + return scaled; } \ No newline at end of file