void DrawScreen(TScreen *aScreen) { int order; char save_bled, save_bled_direction; object_pressed = 0; order = 0; CurrentScreen = aScreen; if ((display_width != CurrentScreen->Width) || (display_height != CurrentScreen->Height)) { save_bled = TFT_BLED; save_bled_direction = TFT_BLED_Direction; TFT_BLED_Direction = 0; TFT_BLED = 0; TFT_Set_Active(Set_Index, Write_Command, Write_Data); TFT_Init(CurrentScreen->Width, CurrentScreen->Height); TFT_Set_Ext_Buffer(TFT_Get_Data); TP_TFT_Init(CurrentScreen->Width, CurrentScreen->Height, 13, 12); // Initialize touch panel TP_TFT_Set_ADC_Threshold(ADC_THRESHOLD); // Set touch panel ADC threshold TFT_Fill_Screen(CurrentScreen->Color); display_width = CurrentScreen->Width; display_height = CurrentScreen->Height; TFT_BLED = save_bled; TFT_BLED_Direction = save_bled_direction; } else TFT_Fill_Screen(CurrentScreen->Color); while (order < CurrentScreen->ObjectsCount) { } }
void Start_TP() { Init_MCU(); InitializeTouchPanel(); Delay_ms(1000); TFT_Fill_Screen(0); Calibrate(); TFT_Fill_Screen(0); InitializeObjects(); display_width = Screen1.Width; display_height = Screen1.Height; DrawScreen(&Screen1); }
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 ); }
void Initialize() { short int i = 0; // variable initialization LQI = 0; RSSI2 = 0; SEQ_NUMBER = 0x23; lost_data = 0; address_RX_FIFO = 0x300; address_TX_normal_FIFO = 0; for (i = 0; i < 2; i++) { ADDRESS_short_1[i] = 1; ADDRESS_short_2[i] = 2; PAN_ID_1[i] = 3; PAN_ID_2[i] = 3; } for (i = 0; i < 8; i++) { ADDRESS_long_1[i] = 1; ADDRESS_long_2[i] = 2; } // Set Chip Select pin as Output GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_13); GPIO_Digital_Output(&GPIOD_BASE, _GPIO_PINMASK_10); GPIO_Digital_Output(&GPIOC_BASE, _GPIO_PINMASK_2); // Set PD0 and PD1 as digital input GPIO_Digital_Input(&GPIOD_BASE, _GPIO_PINMASK_0); Delay_ms(5); // SPI config SPI3_Init_Advanced(_SPI_FPCLK_DIV4, _SPI_MASTER | _SPI_8_BIT | _SPI_CLK_IDLE_LOW | _SPI_FIRST_CLK_EDGE_TRANSITION | _SPI_MSB_FIRST | _SPI_SS_DISABLE | _SPI_SSM_ENABLE | _SPI_SSI_1, &_GPIO_MODULE_SPI3_PC10_11_12); TFT_BLED = 1; // Turn on TFT Backlight TFT_Init(320, 240); // Initialize TFT display TFT_Fill_Screen(CL_WHITE); // Clear Screen pin_reset(); // Activate reset from pin software_reset(); // Activate software reset RF_reset(); // RF reset set_WAKE_from_pin(); // Set wake from pin set_long_address(ADDRESS_long_2); // Set long address set_short_address(ADDRESS_short_2); // Set short address set_PAN_ID(PAN_ID_2); // Set PAN_ID init_ZIGBEE_nonbeacon(); // Initialize ZigBee module nonbeacon_PAN_coordinator_device(); set_TX_power(31); // Set max TX power set_frame_format_filter(1); // 1 all frames, 3 data frame only set_reception_mode(1); // 1 normal mode pin_wake(); // Wake from pin }
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; } }
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 Screen_init(void) { PenColor=1; shape=0; painted=0; TFT_Set_Default_Mode(); //TFT_Init_ILI9341_8bit(240,320); TFT_Init_ILI9341_8bit(320,240); ADC_Set_Input_Channel(_ADC_CHANNEL_8 | _ADC_CHANNEL_9); ADC1_Init(); TP_TFT_Init(320, 240, 8, 9); TP_TFT_Set_ADC_Threshold(600); TFT_Fill_Screen(colors[14]); TP_TFT_Calibrate_Min(); Delay_ms(500); TP_TFT_Calibrate_Max(); }
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 ); }
// This function draws to the screen static void RenderScreen(){ TFT_Fill_Screen(bg_color); computeXform(); //calculate translation matrix drawModel(); //render polygons to LCD TFT_Write_Text(rotationString, 10, 240-25); //write the rotation values Delay_ms(50); //increment the current frame number frame_counter++; //Save the settings from the previous frame SavePrevious(); }
void UI_Setup() { GPIO_Config(&GPIO_PORTA, 0b00001000, _GPIO_DIR_OUTPUT, _GPIO_CFG_DIGITAL_ENABLE | _GPIO_CFG_DRIVE_8mA, 0); // Init back light GPIO TFT_BACKLIGHT = 0; // We need to Unlock PR7 before we can use it as GPIO (MCU specific) GPIO_Unlock(_GPIO_COMMIT_PIN_B7); GPIO_Digital_Input(&GPIO_PORTB, _GPIO_PINMASK_0 | _GPIO_PINMASK_7); // Set Up and Left as digital input GPIO_Digital_Input(&GPIO_PORTE, _GPIO_PINMASK_4 | _GPIO_PINMASK_5); // Set Right and Down as digital input GPIO_Digital_Input(&GPIO_PORTH, _GPIO_PINMASK_2); // Set Center as digital input Delay_100ms(); TFT_Init(320, 240); TFT_Fill_Screen(0); InitializeObjects(); display_width = LoadingScreen.Width; display_height = LoadingScreen.Height; UI_LoadingScreen("Fetching IP address"); TFT_BACKLIGHT = 1; }
void main() { Start_TP(); //initalize variables on startup initVariables(); //translate.z = 10.0; scale.x = 95.0; //x scale scale.y = 95.0; //y scale scale.z = 95.0; //z scale bg_color = TFT_RGBToColor16bit(92, 92, 92); //Clear the screen //TFT_Fill_Screen(CL_BLACK); TFT_Fill_Screen(bg_color); ACCEL_Start(&cACCEL_test_status); while (1){ //read the accelerometer ACCEL_Test(); //Check for user input GetInput(); //animate the objects in the frame //AnimateFrame(); //Draw the graphics RenderScreen(); frame_counter++; } }
void Paint_Init(void) { TFT_Fill_Screen(colors[14]); TFT_Set_Pen(colors[14],20); TFT_Rectangle(0,0,20,20); TFT_Write_Text("Clear",2,8); TFT_Set_Pen(colors[1],20); TFT_Rectangle(50,0,70,20); TFT_Set_Pen(colors[2],20); TFT_Rectangle(100,0,120,20); TFT_Set_Pen(colors[3],20); TFT_Rectangle(150,0,170,20); TFT_Set_Pen(colors[4],20); TFT_Rectangle(200,0,220,20); TFT_Set_Pen(colors[5],20); TFT_Rectangle(250,0,270,20); TFT_Set_Pen(colors[6],20); TFT_Rectangle(300,0,320,20); /////////////////////////////////////////// TFT_Set_Pen(colors[2],1); TFT_Rectangle(5,50,45,90); TFT_Set_Pen(colors[1],10); TFT_Circle(25,70,1); TFT_Set_Pen(colors[2],1); TFT_Rectangle(5,100,45,140); TFT_Set_Pen(colors[1],20); TFT_Circle(25,120,1); TFT_Set_Pen(colors[2],1); TFT_Rectangle(5,150,45,190); TFT_Set_Pen(colors[1],3); TFT_Circle(25,170,15); TFT_Set_Pen(colors[2],1); TFT_Rectangle(5,200,45,240); TFT_Set_Pen(colors[1],3); TFT_Rectangle(10,210,40,230); TFT_Set_Pen(colors[1],1); TFT_Rectangle(50,45,310,215); //////////////////////////////////////////// TFT_Write_Text("Back->",270,220); }
void DrawScreen(TScreen *aScreen) { int order; unsigned short button_idx; TButton *local_button; unsigned short image_idx; TImage *local_image; unsigned short radio_button_idx; TRadioButton *local_radio_button; char save_bled, save_bled_direction; object_pressed = 0; order = 0; button_idx = 0; image_idx = 0; radio_button_idx = 0; CurrentScreen = aScreen; if ((display_width != CurrentScreen->Width) || (display_height != CurrentScreen->Height)) { save_bled = TFT_BLED; save_bled_direction = TFT_BLED_Direction; TFT_BLED_Direction = 0; TFT_BLED = 0; TFT_Set_Active(Set_Index, Write_Command, Write_Data); TFT_Init(CurrentScreen->Width, CurrentScreen->Height); TFT_Set_Ext_Buffer(TFT_Get_Data); TP_TFT_Init(CurrentScreen->Width, CurrentScreen->Height, 13, 12); // Initialize touch panel TP_TFT_Set_ADC_Threshold(ADC_THRESHOLD); // Set touch panel ADC threshold TFT_Fill_Screen(CurrentScreen->Color); display_width = CurrentScreen->Width; display_height = CurrentScreen->Height; TFT_BLED = save_bled; TFT_BLED_Direction = save_bled_direction; } else TFT_Fill_Screen(CurrentScreen->Color); while (order < CurrentScreen->ObjectsCount) { if (button_idx < CurrentScreen->ButtonsCount) { local_button = GetButton(button_idx); if (order == local_button->Order) { button_idx++; order++; DrawButton(local_button); } } if (image_idx < CurrentScreen->ImagesCount) { local_image = GetImage(image_idx); if (order == local_image->Order) { image_idx++; order++; DrawImage(local_image); } } if (radio_button_idx < CurrentScreen->RadioButtonsCount) { local_radio_button = GetRadioButton(radio_button_idx); if (order == local_radio_button->Order) { radio_button_idx++; order++; DrawRadioButton(local_radio_button); } } } }
void DrawScreen(TScreen *aScreen) { unsigned int order; unsigned short round_button_idx; TButton_Round *local_round_button; unsigned short label_idx; TLabel *local_label; unsigned short image_idx; TImage *local_image; char save_bled, save_bled_direction; object_pressed = 0; order = 0; round_button_idx = 0; label_idx = 0; image_idx = 0; CurrentScreen = aScreen; if ((display_width != CurrentScreen->Width) || (display_height != CurrentScreen->Height)) { save_bled = TFT_BLED; save_bled_direction = TFT_BLED_Direction; TFT_BLED_Direction = 0; TFT_BLED = 0; TFT_Set_Active(Set_Index, Write_Command, Write_Data); TFT_Init(CurrentScreen->Width, CurrentScreen->Height); TP_TFT_Init(CurrentScreen->Width, CurrentScreen->Height, 13, 12); // Initialize touch panel TP_TFT_Set_ADC_Threshold(ADC_THRESHOLD); // Set touch panel ADC threshold TFT_Fill_Screen(CurrentScreen->Color); display_width = CurrentScreen->Width; display_height = CurrentScreen->Height; TFT_BLED = save_bled; TFT_BLED_Direction = save_bled_direction; } else TFT_Fill_Screen(CurrentScreen->Color); while (order < CurrentScreen->ObjectsCount) { if (round_button_idx < CurrentScreen->Buttons_RoundCount) { local_round_button = GetRoundButton(round_button_idx); if (order == local_round_button->Order) { round_button_idx++; order++; DrawRoundButton(local_round_button); } } if (label_idx < CurrentScreen->LabelsCount) { local_label = GetLabel(label_idx); if (order == local_label->Order) { label_idx++; order++; DrawLabel(local_label); } } if (image_idx < CurrentScreen->ImagesCount) { local_image = GetImage(image_idx); if (order == local_image->Order) { image_idx++; order++; DrawImage(local_image); } } } }