mirror of
https://github.com/arwidcool/Solder-Plate.git
synced 2024-11-28 08:20:52 +01:00
Work on tft
This commit is contained in:
parent
0784fbddd6
commit
2537e1e8b3
@ -65,7 +65,8 @@ TFT_XY TFT_Display::getRightAlignedTextXY(char *text, uint16_t x, uint16_t y)
|
|||||||
{
|
{
|
||||||
TFT_XY xy;
|
TFT_XY xy;
|
||||||
|
|
||||||
uint8_t textLength = strlen(text);
|
uint8_t textLength = strlen(text) * 6;
|
||||||
|
uint8_t textHeight = 4;
|
||||||
int16_t x1, y1;
|
int16_t x1, y1;
|
||||||
uint16_t w, h;
|
uint16_t w, h;
|
||||||
w = tft.width();
|
w = tft.width();
|
||||||
@ -74,7 +75,7 @@ TFT_XY TFT_Display::getRightAlignedTextXY(char *text, uint16_t x, uint16_t y)
|
|||||||
tft.getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
tft.getTextBounds(text, 0, 0, &x1, &y1, &w, &h);
|
||||||
|
|
||||||
xy.x = x - textLength - 1;
|
xy.x = x - textLength - 1;
|
||||||
xy.y = y;
|
xy.y = y - textHeight;
|
||||||
|
|
||||||
return xy;
|
return xy;
|
||||||
}
|
}
|
||||||
@ -143,15 +144,40 @@ TFT_XY TFT_Display::getXYWithinGraphBounds(uint8_t temp, uint8_t time)
|
|||||||
void TFT_Display::drawGraph()
|
void TFT_Display::drawGraph()
|
||||||
{
|
{
|
||||||
|
|
||||||
tft.drawPixel(graphXY.x, graphXY.y, ST77XX_WHITE);
|
drawGraphAxis();
|
||||||
|
drawGraphAxisLabels();
|
||||||
|
drawGraphAxisTicks();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TFT_Display::drawGraphAxis()
|
||||||
|
{
|
||||||
|
|
||||||
tft.drawFastHLine(graphXY.x, graphXY.y, graphWidth, ST77XX_WHITE);
|
tft.drawFastHLine(graphXY.x, graphXY.y, graphWidth, ST77XX_WHITE);
|
||||||
|
|
||||||
tft.drawFastVLine(graphXY.x, graphXY.y - graphHeight, graphHeight, ST77XX_WHITE);
|
tft.drawFastVLine(graphXY.x, graphXY.y - graphHeight, graphHeight, ST77XX_WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TFT_Display::drawGraphAxisLabels()
|
||||||
|
{
|
||||||
|
|
||||||
tft.setTextColor(ST77XX_WHITE);
|
tft.setTextColor(ST77XX_WHITE);
|
||||||
tft.setTextSize(1);
|
tft.setTextSize(1);
|
||||||
TFT_XY position = getLeftAlignedTopTextXY("20", graphXY.x, graphXY.y);
|
|
||||||
|
tft.setCursor(5, 10);
|
||||||
|
tft.println("Temp");
|
||||||
|
|
||||||
|
TFT_XY position = getCenteredTextXY("Time");
|
||||||
|
tft.setCursor(position.x, position.y +228);
|
||||||
|
tft.println("Time");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TFT_Display::drawGraphAxisTicks()
|
||||||
|
{
|
||||||
|
tft.setTextColor(ST77XX_WHITE);
|
||||||
|
tft.setTextSize(1);
|
||||||
|
TFT_XY position = getRightAlignedTextXY("20", graphXY.x, graphXY.y);
|
||||||
tft.setCursor(position.x, position.y);
|
tft.setCursor(position.x, position.y);
|
||||||
tft.println("20");
|
tft.println("20");
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ private:
|
|||||||
TFT_XY getLeftAlignedTopTextXY(char *text, uint16_t x, uint16_t y);
|
TFT_XY getLeftAlignedTopTextXY(char *text, uint16_t x, uint16_t y);
|
||||||
void getMaxTempFromProfile(ReflowProfile *profile);
|
void getMaxTempFromProfile(ReflowProfile *profile);
|
||||||
|
|
||||||
uint8_t graphHeight = 180;
|
uint16_t graphHeight = 180;
|
||||||
uint16_t graphWidth = 256;
|
uint16_t graphWidth = 256;
|
||||||
TFT_XY graphXY = {32, 220};
|
TFT_XY graphXY = {32, 220};
|
||||||
uint16_t maxTemp = 0;
|
uint16_t maxTemp = 0;
|
||||||
@ -39,6 +39,9 @@ private:
|
|||||||
TFT_XY getXYWithinGraphBounds(uint8_t temp, uint8_t time);
|
TFT_XY getXYWithinGraphBounds(uint8_t temp, uint8_t time);
|
||||||
|
|
||||||
void drawGraph();
|
void drawGraph();
|
||||||
|
void drawGraphAxis();
|
||||||
|
void drawGraphAxisLabels();
|
||||||
|
void drawGraphAxisTicks();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // TFT_H
|
#endif // TFT_H
|
||||||
|
Loading…
Reference in New Issue
Block a user