Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /* Hello World! for the Emwin TFT Library */ 00002 00003 #include "mbed.h" 00004 #include "GUI.h" 00005 #include "cy8ckit_028_tft.h" 00006 #include "PinDetect.h" 00007 00008 PinDetect pb1(SWITCH2); 00009 volatile bool keypressed = true; 00010 00011 // Callback routine is interrupt activated by a debounced pb1 hit 00012 void pb1_hit_callback (void) 00013 { 00014 keypressed = true; 00015 } 00016 00017 00018 void Display_Init(void) 00019 { 00020 00021 /* Set font size, foreground and background Colours */ 00022 GUI_SetFont(GUI_FONT_16B_1); 00023 GUI_SetColor(GUI_WHITE); 00024 GUI_SetBkColor(GUI_BLACK); 00025 00026 /* Clear screen and print splash screen */ 00027 GUI_Clear(); 00028 GUI_SetTextAlign(GUI_TA_HCENTER); 00029 GUI_DispStringAt("TFT Demo", 160, 20); 00030 } 00031 00032 int main() 00033 { 00034 uint8 counter = 0; 00035 /* Initialise EmWin driver*/ 00036 GUI_Init(); 00037 00038 /* Initialise display */ 00039 Display_Init(); 00040 pb1.mode(PullUp); 00041 // Delay for initial pullup to take effect 00042 ThisThread::sleep_for(10); 00043 // Setup Interrupt callback functions for a pb hit 00044 pb1.attach_deasserted(&pb1_hit_callback); 00045 00046 // Start sampling pb inputs using interrupts 00047 pb1.setSampleFrequency(); 00048 00049 00050 GUI_SetFont(GUI_FONT_8X16X2X2); 00051 GUI_SetTextAlign(GUI_TA_HCENTER); 00052 GUI_DispStringAt("Hello World!", 160, 200); 00053 while(1) { 00054 if(keypressed == true) { 00055 GUI_SetTextAlign(GUI_TA_HCENTER); 00056 GUI_DispBinAt(counter++, 160, 100, 8); 00057 ThisThread::sleep_for(100); 00058 keypressed = false; 00059 } 00060 } 00061 } 00062 00063 00064
Generated on Sat Jul 16 2022 14:05:14 by
1.7.2