-
Dependencies: CommandHandler HygroClip2 InterruptBasedEncoder SPI_TFT_ILI9341 mbed-src-no-hal
Diff: GraphScale.cpp
- Revision:
- 0:9ed7238d49e2
- Child:
- 2:81fc8f80fdb4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/GraphScale.cpp Tue Feb 16 11:35:36 2016 +0000 @@ -0,0 +1,29 @@ +#include "GraphScale.h" + +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) +{ + int x1 = x_-1; + 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_; + + for(uint16_t i = 0; i <= height_; i += stepsize) + { + uint16_t yPos = y2-i-1; + tft_->line(x2, yPos, x2+5, yPos, color); + tft_->locate(x2+10,yPos-6); + tft_->printf("%d",stepposition); + + stepposition += scaleSteps_; + } +} \ No newline at end of file