void updateLabel(tlabel *lbl, char *str){ TFT_Set_Font(lbl->Fontname, Box1.Color, FO_HORIZONTAL); TFT_Write_Text(lbl->Caption, lbl->Left, lbl->Top); strcpy(lbl->Caption, str); TFT_Set_Font(lbl->Fontname, lbl->Font_Color, FO_HORIZONTAL); DrawLabel(lbl); }
void Calibrate() { TFT_Set_Pen(CL_WHITE, 3); TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL); TFT_Write_Text("Touch selected corners for calibration", 50, 100); TFT_Line(315, 1, 319, 1); TFT_Line(310, 10, 319, 1); TFT_Line(319, 5, 319, 1); TFT_Write_Text("first here", 250, 20); TP_TFT_Calibrate_Min(); // Calibration of bottom left corner Delay_ms(500); TFT_Set_Pen(CL_BLACK, 3); TFT_Set_Font(TFT_defaultFont, CL_BLACK, FO_HORIZONTAL); TFT_Line(315, 1, 319, 1); TFT_Line(310, 10, 319, 1); TFT_Line(319, 5, 319, 1); TFT_Write_Text("first here", 250, 20); TFT_Set_Pen(CL_WHITE, 3); TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL); TFT_Line(0, 239, 0, 235); TFT_Line(0, 239, 5, 239); TFT_Line(0, 239, 10, 229); TFT_Write_Text("now here ", 15, 200); TP_TFT_Calibrate_Max(); // Calibration of bottom left corner Delay_ms(500); }
void DrawLabel(TLabel *ALabel) { if (ALabel->Visible != 0) { if (ALabel->VerticalText != 0) TFT_Set_Font(ALabel->FontName, ALabel->Font_Color, FO_VERTICAL_COLUMN); else TFT_Set_Font(ALabel->FontName, ALabel->Font_Color, FO_HORIZONTAL); TFT_Write_Text(ALabel->Caption, ALabel->Left, ALabel->Top); } }
void Calibrate() { TFT_Set_Pen(CL_WHITE, 3); TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL); TFT_Write_Text("Touch selected corners for calibration", 50, 80); TFT_Write_Text("Touch selected corners for calibration", 50, 75); TFT_Line(315, 1, 319, 1); TFT_Line(310, 10, 319, 1); TFT_Line(319, 5, 319, 1); TFT_Write_Text("first here", 230, 20); TFT_Image(47, 90, logo_bmp, 1); /* DrawImage(&Image2); Image2.OwnerScreen = &Screen1; Image2.Order = 5; Image2.Left = 47; Image2.Top = 90; Image2.Width = 226; Image2.Height = 56; Image2.Picture_Type = 0; Image2.Picture_Ratio = 1; Image2.Picture_Name = logo_bmp; Image2.Visible = 1; Image2.Active = 1; Image2.OnUpPtr = 0; Image2.OnDownPtr = 0; Image2.OnClickPtr = 0; Image2.OnPressPtr = 0; */ TP_TFT_Calibrate_Min(); // Calibration of TP minimum Delay_ms(500); TFT_Set_Pen(CL_BLACK, 3); TFT_Set_Font(TFT_defaultFont, CL_BLACK, FO_HORIZONTAL); TFT_Line(315, 1, 319, 1); TFT_Line(310, 10, 319, 1); TFT_Line(319, 5, 319, 1); TFT_Write_Text("first here", 230, 20); TFT_Set_Pen(CL_WHITE, 3); TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL); TFT_Line(0, 239, 0, 235); TFT_Line(0, 239, 5, 239); TFT_Line(0, 239, 10, 230); TFT_Write_Text("now here ", 15, 200); TP_TFT_Calibrate_Max(); // Calibration of TP maximum Delay_ms(500); }
void main() { int x0, y0; int i = 0, j = 0; int receive_block; int image_to_draw; receive_block = -1; USBIP0_bit = 1; USBIP1_bit = 1; USBIP2_bit = 1; USBIE_bit = 1; EnableInterrupts(); Start_TP(); TFT_Fill_Screen(CL_WHITE); TFT_Set_Font(TFT_defaultFont, CL_BLACK, FO_HORIZONTAL); ClearBuffer(ReadBuffer, USB_LENGTH); ClearBuffer(WriteBuffer, USB_LENGTH); HID_Enable(ReadBuffer, &WriteBuffer); for(i=0; i<2; i++) { for(j=0; j<4; j++) { DrawIcon(j, i); } } while (1) { Check_TP(); if (HID_Read()) { ClearBuffer(WriteBuffer, USB_LENGTH); if (strstr(ReadBuffer, "AT+SEND_IMAGE")) { strcpy(WriteBuffer, "READY"); HID_Write(WriteBuffer,USB_LENGTH); receive_block = 0; } else if ((receive_block>=0)&&(receive_block<2048)) { memcpy((char *)Image_icon+receive_block, ReadBuffer, USB_LENGTH); strcpy(WriteBuffer, "OK"); HID_Write(WriteBuffer,USB_LENGTH); receive_block+=USB_LENGTH; } else if (strstr(&ReadBuffer, "AT+DRAW_IMAGE=")) { image_to_draw = ReadBuffer[strlen("AT+DRAW_IMAGE=")]-'0'; DrawIcon(image_to_draw%4, image_to_draw/4); strcpy(WriteBuffer, "OK"); HID_Write(WriteBuffer,USB_LENGTH); } } ClearBuffer(&ReadBuffer, USB_LENGTH); if(receive_block > 2048-USB_LENGTH) receive_block = -1; } }
/************************************************************************************************** * Function ACCEL_Start() * ------------------------------------------------------------------------------------------------- * Overview: Function Initialize I2C bus and accel module * Input: Nothing * Output: test status: 0 - skiped; 1 - pass; 2 - fail **************************************************************************************************/ void ACCEL_Start(char *test) { // Reset error flag *test = 0; // Initialize I2C communication I2C2_Init(250000); TFT_Set_Font(TFT_defaultFont, CL_WHITE, FO_HORIZONTAL); TFT_Set_Pen(bg_color, 1); TFT_Set_Brush(1, bg_color, 0, 0, 0, 0); TFT_Write_Text("Starting Accel test...", 90, 100); Delay_ms(2000); TFT_Rectangle(70, 70, 250, 130); // Initialize ADXL345 accelerometer if (ADXL345_Init() == 0) { TFT_Write_Text("Accel module initialized.", 90, 100); *test = 1; Delay_ms(2000); } else { TFT_Write_Text("Error during Accel module initialization.", 90, 100); *test = 2; } TFT_Rectangle(70, 70, 250, 130); }
void DrawFrame() { TFT_Fill_Screen(CL_WHITE); TFT_Set_Pen(CL_BLACK, 1); TFT_Line(20, 220, 300, 220); TFT_Line(20, 46, 300, 46); TFT_Set_Font(&TFT_defaultFont, CL_RED, FO_HORIZONTAL); TFT_Write_Text("BLE2 Click Board Demo", 25, 14); TFT_Set_Font(&TFT_defaultFont, CL_BLACK, FO_HORIZONTAL); TFT_Write_Text("EasyMx PRO v7", 19, 223); TFT_Set_Font(&TFT_defaultFont, CL_RED, FO_HORIZONTAL); TFT_Write_Text("www.mikroe.com", 200, 223); TFT_Set_Font(&TFT_defaultFont, CL_BLACK, FO_HORIZONTAL); TFT_Write_Text("BATTERY SERVICE", 40, 60); TFT_Write_Text("BATTERY LEVEL:", 40, 100); TFT_Write_Text("RECEIVE:", 40, 120); }
void UI_UpdateFolderName(void) { TFT_Set_Pen(MainScreen.Color, 0); TFT_Set_Brush(1, MainScreen.Color, 0, LEFT_TO_RIGHT, CL_WHITE, CL_WHITE); TFT_Rectangle(Label2.Left, Label2.Top, 240, 22); TFT_Set_Font(Label2.FontName, Label2.Font_Color, FO_HORIZONTAL); TFT_Write_Text(CurrentFolderName, Label2.Left, Label2.Top); }
void main() { system_init(); display_init(); // Device initialisation // Must be done before usage rf_meter_init(); Delay_ms( 200 ); while( 1 ) { // Signal strength measurement result = rf_meter_get_signal_strength(); // Change the track value only in case of the signal strenght chaged // scope to avoid the display refreshing on every single loop if ( result < -50.0 ) track = 0; else if ( ( result < -35.0 ) && ( result >= -50.0 ) ) track = 1; else if ( ( result < -20.0 ) && ( result >= -35 ) ) track = 2; else track = 3; // If scope changed delete old picture and draw a new one if ( track != last_track ) { TFT_Rectangle( 112, 98, 196, 166 ); switch( track ) { case 0 : TFT_Image( 114, 100, signal_lo_bmp , 2 ); break; case 1 : TFT_Image( 114, 100, signal_lo_m_bmp , 2 ); break; case 2 : TFT_Image( 114, 100, signal_hi_m_bmp , 2 ); break; case 3 : TFT_Image( 114, 100, signal_hi_bmp , 2 ); break; } // Replace old scope value with the new one last_track = track; } // Display signal strength sprintf( tmp_txt, "%5.1f dBm", result ); TFT_Rectangle( 198, 200, 288, 218 ); TFT_Set_Font( &Tahoma15x16_Bold, CL_BLUE, FO_HORIZONTAL ); TFT_Write_Text( tmp_txt, 205, 200 ); Delay_ms( 500 ); } }
void display_init() { TFT_Init_ILI9341_8bit( 320, 240 ); TFT_BLED = 1; TFT_Set_Pen( CL_WHITE, 1 ); TFT_Set_Brush( 1,CL_WHITE,0,0,0,0 ); TFT_Set_Font( TFT_defaultFont, CL_BLACK, FO_HORIZONTAL ); TFT_Fill_Screen( CL_WHITE ); TFT_Set_Pen( CL_BLACK, 1 ); TFT_Line( 20, 46, 300, 46 ); TFT_Line( 20, 70, 300, 70 ); TFT_Line( 20, 196, 300, 196 );; TFT_Line( 20, 220, 300, 220 ); TFT_Set_Pen( CL_WHITE, 1 ); TFT_Set_Font( &HandelGothic_BT21x22_Regular, CL_RED, FO_HORIZONTAL ); TFT_Write_Text( "RF Meter click", 95, 14 ); TFT_Set_Font( &Tahoma15x16_Bold, CL_BLUE, FO_HORIZONTAL ); TFT_Write_Text( "AD8318", 130, 50 ); TFT_Set_Font( &Verdana12x13_Regular, CL_BLACK, FO_HORIZONTAL ); TFT_Write_Text("EasyMx PRO v7 for STM32", 19, 223); TFT_Set_Font( &Verdana12x13_Regular, CL_RED, FO_HORIZONTAL ); TFT_Write_Text( "www.mikroe.com", 200, 223 ); TFT_Set_Font( &Tahoma15x16_Bold, CL_BLACK, FO_HORIZONTAL ); TFT_Write_Text( "Current signal strength", 30, 200 ); TFT_Set_Font( &HandelGothic_BT21x22_Regular, CL_BLACK, FO_HORIZONTAL ); TFT_Image( 114, 100, signal_lo_bmp , 2 ); }
static void tft_initialize() { TFT_Init_ILI9341_8bit( 320, 280 ); TFT_BLED = 1; TFT_Set_Default_Mode(); TFT_Set_Pen( CL_WHITE, 1 ); TFT_Set_Brush( 1, CL_WHITE, 0, 0, 0, 0 ); TFT_Set_Font( TFT_defaultFont, CL_BLACK, FO_HORIZONTAL ); TFT_Fill_Screen( CL_WHITE ); TFT_Set_Pen( CL_BLACK, 1 ); TFT_Line( 20, 222, 300, 222 ); TFT_Set_Font( &Verdana12x13_Regular, CL_BLACK, FO_HORIZONTAL ); TFT_Write_Text( "EasyMx PRO v7 for STM32", 19, 223 ); TFT_Set_Font( &Verdana12x13_Regular, CL_RED, FO_HORIZONTAL ); TFT_Write_Text( "www.mikroe.com", 200, 223 ); TFT_Image( ( 320 - 220 ) / 2, 0, rudderangle_bmp, 1 ); TFT_Set_Font( TFT_defaultFont, CL_BLACK, FO_HORIZONTAL ); }
/******************************************************************************* * Function Scroll_Get_One_Text_Line(char line, char *text) * ------------------------------------------------------------------------------ * Overview: Function Gets desired Pixel Line of text and fills it in a array * Input: desired line number, pointer to text * Output: Nothing *******************************************************************************/ void Scroll_Get_One_Text_Line(char line, char *text){ memset(pix_array, 0, 165); current_text_column = line; TFT_Write_Data_Ptr = Dummy_Write_data; TFT_SSD1963_Set_Address_Ptr = Dummy_Set_address; TFT_Set_Font(MP3_Font, _MP3_FONT_COLOR, FO_HORIZONTAL); TFT_Write_Text(text, _MP3_TEXT_VLINE, 0); TFT_SSD1963_Set_Address_Ptr = TFT_Set_Address_SSD1963II; //TFT_Write_Data_Ptr = TFT_Write_to_16bitPort; }
/******************************************************************************* * Function Scroll_Fill_Area() * ------------------------------------------------------------------------------ * Overview: Function fills Scroll area with text from File_List * Input: Nothing * Output: Nothing *******************************************************************************/ void Scroll_Fill_Area(){ char *ptr, *dptr, i; unsigned int temp, temp1; dptr = Scroll_text; i = 0; ptr = File_List[i].FileName; // write Text while (*ptr != 0xFF){ while(*dptr++ = *ptr++) ; temp = i * (_FONT_HEIGHT + _FONT_VERTICAL_SPACING); ptr = File_List[i+1].FileName; if (temp < _SCROLL_LAST_LINE - _SCROLL_FIRST_LINE - _FONT_HEIGHT){ if (File_List[i].FileType == 1) TFT_Image(_MP3_IMAGE_VLINE, _SCROLL_FIRST_LINE + temp, file_icon.Picture_Name, 1); if (File_List[i].FileType == 2) TFT_Image(_MP3_IMAGE_VLINE, _SCROLL_FIRST_LINE + temp, folder_icon.Picture_Name, 1); TFT_Set_Font(MP3_Font, _MP3_FONT_COLOR, FO_HORIZONTAL); TFT_Write_Text(Scroll_text, _MP3_TEXT_VLINE, _SCROLL_FIRST_LINE + temp); i ++; dptr = Scroll_text; temp1 = _SCROLL_FIRST_LINE + temp; } else{ i ++; dptr = Scroll_text; } } Scroll_total_columns = temp + (_FONT_HEIGHT + _FONT_VERTICAL_SPACING); // if there is uncomplete text, write it too temp1 = temp1 + _FONT_HEIGHT + _FONT_VERTICAL_SPACING - 1; if (temp1 < _SCROLL_LAST_LINE) current_text_column = 1; if (temp1 <= temp){ while (temp1 < _SCROLL_LAST_LINE){ memset(pix_array, 0, 479); i = Scrool_Get_new_text(last_window_column / (_FONT_HEIGHT + _FONT_VERTICAL_SPACING)); Scroll_Get_One_Text_Line(current_text_column, Scroll_text); if (File_List[i].FileType == 1) Scroll_Write_One_Line(temp1, &file_icon); if (File_List[i].FileType == 2) Scroll_Write_One_Line(temp1, &folder_icon); current_text_column ++; temp1 ++; } } TFT_Ext_Image(_MP3_BIGIMAGE_VLINE, _SCROLL_FIRST_LINE, mp3_player_note_bmp, 1); }
void DrawRoundButton(TButton_Round *Around_button) { unsigned int ALeft, ATop; if (Around_button->Visible != 0) { if (object_pressed == 1) { object_pressed = 0; TFT_Set_Brush(Around_button->Transparent, Around_button->Press_Color, Around_button->Gradient, Around_button->Gradient_Orientation, Around_button->Gradient_End_Color, Around_button->Gradient_Start_Color); } else { TFT_Set_Brush(Around_button->Transparent, Around_button->Color, Around_button->Gradient, Around_button->Gradient_Orientation, Around_button->Gradient_Start_Color, Around_button->Gradient_End_Color); } TFT_Set_Pen(Around_button->Pen_Color, Around_button->Pen_Width); TFT_Rectangle_Round_Edges(Around_button->Left + 1, Around_button->Top + 1, Around_button->Left + Around_button->Width - 2, Around_button->Top + Around_button->Height - 2, Around_button->Corner_Radius); if (Around_button->VerticalText != 0) TFT_Set_Font(Around_button->FontName, Around_button->Font_Color, FO_VERTICAL_COLUMN); else TFT_Set_Font(Around_button->FontName, Around_button->Font_Color, FO_HORIZONTAL); TFT_Write_Text_Return_Pos(Around_button->Caption, Around_button->Left, Around_button->Top); if (Around_button->TextAlign == _taLeft) ALeft = Around_button->Left + 4; else if (Around_button->TextAlign == _taCenter) ALeft = Around_button->Left + (Around_button->Width - caption_length) / 2; else if (Around_button->TextAlign == _taRight) ALeft = Around_button->Left + Around_button->Width - caption_length - 4; if (Around_button->TextAlignVertical == _tavTop) ATop = Around_button->Top + 3; else if (Around_button->TextAlignVertical == _tavMiddle) ATop = Around_button->Top + (Around_button->Height - caption_height) / 2; else if (Around_button->TextAlignVertical == _tavBottom) ATop = Around_button->Top + Around_button->Height - caption_height - 4; TFT_Write_Text(Around_button->Caption, ALeft, ATop); } }
void UI_UpdateFilesList() { unsigned char i; for (i = 0; i < 12; i++) { memcpy(FileList_Labels[i]->Caption, FilesList[i+filesListOffset].Name, FilesList[i+filesListOffset].NameLength); FileList_Labels[i]->Caption[FilesList[i+filesListOffset].NameLength] = 0x00; } TFT_Set_Pen(MainScreen.Color, 0); TFT_Set_Brush(1, MainScreen.Color, 0, LEFT_TO_RIGHT, CL_WHITE, CL_WHITE); TFT_Rectangle(FileList_Labels[0]->Left, FileList_Labels[0]->Top, 240, 230); TFT_Set_Font(FileList_Labels[0]->FontName, FileList_Labels[0]->Font_Color, FO_HORIZONTAL); for (i = 0; i < 12; i++) { TFT_Write_Text(FileList_Labels[i]->Caption, FileList_Labels[i]->Left, FileList_Labels[i]->Top); } }
/******************************************************************************* * Function Roller_Deactivate(TRoller *Roller, unsigned int xpos, unsigned int ypos) * ------------------------------------------------------------------------------ * Overview: Function deactivates roller and displays its value instead * Input: pointer to roller, coordinates where it should display * Output: Nothing *******************************************************************************/ void Roller_Deactivate(TRoller *Roller, unsigned int xpos, unsigned int ypos){ char text[2]; TFT_Set_Pen(Clock.Color, 0); TFT_Set_Brush(1, Clock.Color, 0, 0, 0, 0); TFT_Rectangle(Roller->Left, Roller->Top, Roller->Left + Roller->Width, Roller->Top + Roller->Height); text[0] = Roller->currentlevel + 48; text[1] = 0; TFT_Set_Font(Label15.FontName, CL_WHITE, FO_HORIZONTAL); if (Roller == &AmPm){ if (Roller->currentlevel == 0) TFT_Write_Text("AM", xpos, ypos); else if (Roller->currentlevel == 1) TFT_Write_Text("PM", xpos, ypos); } else TFT_Write_Text(text, xpos, ypos); }
static void tft_update() { static float last_angle; static line_t last_line; float *read_angle; line_t current_line; float total = 0; char tmp_txt[20]; int i; for( i = 0; i < 10; i++ ) { read_angle = magneto_get_degrees( 1 ); if( magneto_error() ) { magneto_error_t *error = magneto_get_errors( 1 ); TFT_Set_Font( TFT_defaultFont, CL_RED, FO_HORIZONTAL ); TFT_Write_Text( "ERROR", 138, 25 ); } total += *read_angle; } total /= 10.0f; TFT_Set_Font( TFT_defaultFont, CL_WHITE, FO_HORIZONTAL ); TFT_Write_Text( "ERROR", 138, 25 ); sprintf( tmp_txt, "%3.1f", last_angle ); TFT_Write_Text( tmp_txt, 10, 25 ); TFT_Set_Font( TFT_defaultFont, CL_BLACK, FO_HORIZONTAL ); sprintf( tmp_txt, "%3.1f", total ); TFT_Write_Text( tmp_txt, 10, 25 ); last_angle = total; TFT_Set_Pen( CL_WHITE, 4 ); TFT_Line( last_line.x1, last_line.y1, last_line.x2, last_line.y2 ); TFT_Set_Pen( CL_RED, 4 ); if( total <= 90.0f ) { current_line.x1 = ( int )( X_CENTER + ( INNER_RADIUS * sin( 90.0f * ( PI / 180.0f ) ) ) ); current_line.y1 = ( int )( Y_CENTER + ( INNER_RADIUS * -cos( 90.0f * ( PI / 180.0f ) ) ) ); current_line.x2 = ( int )( X_CENTER + ( OUTER_RADIUS * sin( 90.0f * ( PI / 180.0f ) ) ) ); current_line.y2 = ( int )( Y_CENTER + ( OUTER_RADIUS * -cos( 90.0f * ( PI / 180.0f ) ) ) ); } else if( total >= 270.0f ) { current_line.x1 = ( int )( X_CENTER + ( INNER_RADIUS * sin( 270.0f * ( PI / 180.0f ) ) ) ); current_line.y1 = ( int )( Y_CENTER + ( INNER_RADIUS * -cos( 270.0f * ( PI / 180.0f ) ) ) ); current_line.x2 = ( int )( X_CENTER + ( OUTER_RADIUS * sin( 270.0f * ( PI / 180.0f ) ) ) ); current_line.y2 = ( int )( Y_CENTER + ( OUTER_RADIUS * -cos( 270.0f * ( PI / 180.0f ) ) ) ); } else { current_line.x1 = ( int )( X_CENTER + ( INNER_RADIUS * sin( total * ( PI / 180.0f ) ) ) ); current_line.y1 = ( int )( Y_CENTER + ( INNER_RADIUS * -cos( total * ( PI / 180.0f ) ) ) ); current_line.x2 = ( int )( X_CENTER + ( OUTER_RADIUS * sin( total * ( PI / 180.0f ) ) ) ); current_line.y2 = ( int )( Y_CENTER + ( OUTER_RADIUS * -cos( total * ( PI / 180.0f ) ) ) ); } TFT_Line( current_line.x1, current_line.y1, current_line.x2, current_line.y2 ); memcpy( &last_line, ¤t_line, sizeof( line_t ) ); update_flag = false; }