-
Dependencies: CommandHandler HygroClip2 InterruptBasedEncoder SPI_TFT_ILI9341 mbed-src-no-hal
GraphScale.cpp
- Committer:
- wolfsberger
- Date:
- 2016-02-16
- Revision:
- 0:9ed7238d49e2
- Child:
- 2:81fc8f80fdb4
File content as of revision 0:9ed7238d49e2:
#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_; } }