Pseudo-Medical Monitor Code TFT STUFF
Jump to navigation
Jump to search
// Generic graphic wrappers to make a change in display type easier
// to implement for obscure display type
#define TFT_CS_PIN 10 //
#define TFT_AO_PIN 11 //
#define TFT_RST_PIN 9 //
#define SD_CS_PIN 8 // SD Card
uint16_t COMMON_BLACK = ST7735_BLACK;
uint16_t COMMON_WHITE = ST7735_WHITE;
uint16_t COMMON_RED = ST7735_RED;
uint16_t COMMON_ORANGE = ST7735_ORANGE;
uint16_t COMMON_YELLOW = ST7735_YELLOW;
uint16_t COMMON_GREEN = ST7735_GREEN;
uint16_t COMMON_BLUE = ST7735_BLUE;
uint16_t COMMON_MAGENTA = ST7735_MAGENTA;
uint16_t COMMON_CYAN = ST7735_CYAN;
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS_PIN, TFT_AO_PIN, TFT_RST_PIN); // Display-Bibliothek Setup
bool setup_TFT()
{
tft.initR(INITR_BLACKTAB); // ST7735-Chip initialisieren
tft.fillScreen(COMMON_BLACK);
tft.setTextColor(COMMON_WHITE, COMMON_BLACK);
return(true);
}
void DrawScreenCompartment(int x_POS,int y_POS,int x_WIDTH,int y_HEIGHT,uint16_t base_COLOR,uint16_t frame_COLOR)
{
tft.fillRect(x_POS,y_POS,x_WIDTH,y_HEIGHT,base_COLOR);
tft.drawRect(x_POS,y_POS,x_WIDTH,y_HEIGHT,frame_COLOR);
}
void DrawScreenBlock(int x_POS, int y_POS, int x_WIDTH, int y_HEIGHT, uint16_t block_COLOR)
{
tft.fillRect(x_POS,y_POS,x_WIDTH,y_HEIGHT,block_COLOR);
}
void DrawScreenBitmap(int image_left, int image_top, const unsigned char *image_matrix, int image_width, int image_height, uint16_t base_COLOR, uint16_t image_COLOR)
{
tft.fillRect(image_left, image_top, image_width, image_height, base_COLOR);
tft.drawBitmap(image_left, image_top, image_matrix, image_width, image_height, image_COLOR); //Draw the second picture (bigger heart)
}
void DrawScreenText(int x_offset,int y_offset,String message_string,uint16_t fore_COLOR = COMMON_WHITE,uint16_t back_COLOR = COMMON_BLACK)
{
tft.setTextColor(fore_COLOR, back_COLOR);
tft.setCursor(x_offset, y_offset);
tft.print(message_string);
}
void DrawScreenRotation(int orientation)
{
tft.setRotation(orientation);
}
void DrawScreenLine(int x_0,int y_0, int x_1, int y_1,uint16_t line_color)
{
tft.drawLine(x_0,y_0,x_1,y_1,line_color);
}
void DrawScreenFill(uint16_t fill_color)
{
tft.fillScreen(fill_color);
}
void DrawScreenReset()
{
DrawScreenRotation(0);
DrawScreenFill(COMMON_BLACK);
}