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 /* ILI9341 interface for the NRF52832 00002 */ 00003 00004 #include "mbed.h" 00005 #include "display.h" 00006 /* Serial */ 00007 #define BAUDRATE 9600 00008 Serial g_Serial_pc(P0_18, P0_14, BAUDRATE); 00009 00010 /* DigitalOut */ 00011 #define LED_ON 0 00012 #define LED_OFF 1 00013 00014 DigitalOut DataLED(A5, LED_OFF); 00015 00016 Display display; 00017 00018 uint32_t prbs() 00019 { 00020 // This is an unverified 31 bit PRBS generator 00021 // It should be maximum length but this has not been verified 00022 static uint32_t shift_register=0xaa551199; 00023 unsigned long new_bit=0; 00024 static int busy=0; // need to prevent re-entrancy here 00025 if (!busy) 00026 { 00027 busy=1; 00028 new_bit= ((shift_register & (1<<27))>>27) ^ ((shift_register & (1<<30))>>30); 00029 new_bit= ~new_bit; 00030 new_bit = new_bit & 1; 00031 shift_register=shift_register << 1; 00032 shift_register=shift_register | (new_bit); 00033 busy=0; 00034 } 00035 return shift_register & 0x7ffffff; // return 31 LSB's 00036 } 00037 uint32_t random(uint32_t lower,uint32_t upper) 00038 { 00039 return (prbs()%(upper-lower))+lower; 00040 } 00041 int main(void) { 00042 00043 int count; 00044 00045 00046 display.begin(); 00047 while(1) 00048 { 00049 DataLED = !DataLED; 00050 if (display.penDown()) 00051 { 00052 display.print(display.readXTouch(),10,10,display.RGBToWord(0xff,0xff,0),display.RGBToWord(0,0,0)); 00053 display.print(display.readYTouch(),80,10,display.RGBToWord(0xff,0xff,0),display.RGBToWord(0,0,0)); 00054 } 00055 display.drawRectangle(random(0,240),random(0,320),random(0,240),random(0,320),random(0,0xffff)); 00056 //display.fillRectangle(random(0,240),random(0,320),random(0,240),random(0,320),random(0,0xffff)); 00057 display.drawCircle(random(0,240),random(0,240),random(0,320),random(0,0xffff)); 00058 //display.fillCircle(random(0,240),random(0,320),random(0,120),random(0,0xffff)); 00059 count++; 00060 if (count >= 10) 00061 { 00062 display.fillRectangle(0,0,SCREEN_WIDTH,SCREEN_HEIGHT,0); 00063 count = 0; 00064 } 00065 00066 } 00067 00068 return 0; 00069 }
Generated on Sun Jul 17 2022 14:12:37 by
1.7.2