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 00007 #define LED_DIAMETER (25) 00008 #define LED_RADIUS (LED_DIAMETER/2) 00009 #define DISPLAY_X (320) 00010 #define DISPLAY_Y (240) 00011 #define NUMLEDS_X (DISPLAY_X/LED_DIAMETER) 00012 #define NUMLEDS_Y (DISPLAY_Y/LED_DIAMETER) 00013 #define LED_OFF (0) 00014 #define LED_ON (1) 00015 #define TITLE_OFFSET (16+LED_RADIUS) 00016 00017 void Display_Init(void) 00018 { 00019 /* Initialise EmWin driver*/ 00020 GUI_Init(); 00021 00022 /* Set font size, foreground and background Colours */ 00023 GUI_SetFont(GUI_FONT_16B_1); 00024 GUI_SetColor(GUI_DARKCYAN); 00025 GUI_SetBkColor(GUI_DARKRED); 00026 00027 /* Clear screen and print splash screen */ 00028 GUI_Clear(); 00029 GUI_SetTextAlign(GUI_TA_HCENTER); 00030 GUI_DispStringAt("MONKTON", 100, 0); 00031 } 00032 00033 int main() 00034 { 00035 /* Initialise display */ 00036 Display_Init(); 00037 00038 printf("Starting Supercomputer\r\n"); 00039 00040 GUI_SetFont(GUI_FONT_8X16X2X2); 00041 GUI_SetColor(GUI_DARKYELLOW); 00042 uint8_t array[NUMLEDS_X][NUMLEDS_Y]; 00043 for (int j=0; j < NUMLEDS_Y; j++) { 00044 for (int i=0; i < NUMLEDS_X; i++) { 00045 array[i][j]=LED_OFF; 00046 GUI_SetColor(GUI_DARKYELLOW); 00047 GUI_FillCircle(LED_RADIUS+(i)*LED_DIAMETER, TITLE_OFFSET+(j*LED_DIAMETER), LED_RADIUS); 00048 } 00049 } 00050 while(1) { 00051 int ledx = rand()%NUMLEDS_X; 00052 int ledy = rand()%NUMLEDS_Y; 00053 if (array[ledx][ledy]==LED_OFF) { 00054 GUI_SetColor(GUI_YELLOW); 00055 GUI_FillCircle(LED_RADIUS+(ledx)*LED_DIAMETER, TITLE_OFFSET+LED_DIAMETER*(ledy), LED_RADIUS); 00056 array[ledx][ledy] = LED_ON; 00057 } 00058 else { 00059 GUI_SetColor(GUI_DARKYELLOW); 00060 GUI_FillCircle(LED_RADIUS+(ledx)*LED_DIAMETER, TITLE_OFFSET+LED_DIAMETER*(ledy), LED_RADIUS); 00061 // GUI_FillCircle(8+(ledx)*16, 24+16*(ledy), 8); 00062 array[ledx][ledy] = LED_OFF; 00063 } 00064 } 00065 } 00066 00067 00068
Generated on Sat Jul 23 2022 02:29:21 by
1.7.2