This is the test firmware for the interfaceBoard for the DIY 3D Printable Raspberry Pi Raman Spectrometer For more details visit http://hackaday.io/project/1279
Dependencies: SDFileSystem SPI_TFT_ILI9341 mbed
main.cpp
00001 #include "stdio.h" 00002 #include "mbed.h" 00003 #include "SPI_TFT_ILI9341.h" 00004 #include "string" 00005 #include "Arial12x12.h" 00006 #include "Arial24x23.h" 00007 #include "Arial28x28.h" 00008 #include "font_big.h" 00009 #include "MPR121.h" 00010 00011 I2C i2c(PB_9, PB_8); 00012 InterruptIn irq(PC_8); 00013 MPR121 touch_pad(i2c, irq, MPR121::ADDR_VSS ); 00014 00015 extern unsigned char p1[]; // the mbed logo graphic 00016 DigitalOut LCD_LED(D7); 00017 DigitalOut led1(LED1); 00018 00019 SPI_TFT_ILI9341 TFT(D11, D12, D13, D8, D9, D10,"TFT"); // mosi, miso, sclk, cs, reset, dc 00020 00021 Serial raspi(USBTX, USBRX); 00022 00023 int splashScreen() 00024 { 00025 double s; 00026 int i; 00027 00028 TFT.set_orientation(1); 00029 TFT.background(Black); 00030 TFT.foreground(White); 00031 TFT.cls(); 00032 00033 TFT.set_orientation(0); 00034 TFT.background(Black); 00035 TFT.cls(); 00036 00037 TFT.set_orientation(1); 00038 for (i=0; i<320; i++) { 00039 s =40 * sin((long double) i / 10 ); 00040 TFT.pixel(i+s,180 + (int)s+(s-i) ,Red); 00041 } 00042 00043 for (i=0; i<320; i++) { 00044 s =40 * sin((long double) i / 10 ); 00045 TFT.pixel(i,180 + (int)s+(s-i) ,Green); 00046 } 00047 00048 for (i=0; i<320; i++) { 00049 s =40 * sin((long double) i / 10 ); 00050 TFT.pixel(i-s,180 + (int)s+(s-i) ,Blue); 00051 } 00052 TFT.rect(0,0,320,240,Blue); 00053 TFT.set_font((unsigned char*) Neu42x35); 00054 TFT.locate(20,70); 00055 TFT.printf("meridian"); 00056 TFT.locate(110,100); 00057 TFT.printf("Scientific"); 00058 TFT.set_font((unsigned char*) Arial24x23); 00059 TFT.locate(30,140); 00060 TFT.printf("ramanSpectrometer"); 00061 TFT.set_font((unsigned char*) Arial12x12); 00062 TFT.locate(160,165); 00063 printf("version0.1a (2014)"); 00064 TFT.foreground(DarkGrey); 00065 TFT.locate(5,225); 00066 printf("http://www.meridian-scientific.com"); 00067 return 0; 00068 } 00069 00070 int startupScreen() 00071 { 00072 TFT.foreground(White); 00073 TFT.background(Blue); 00074 TFT.cls(); 00075 TFT.set_font((unsigned char*) Arial24x23); 00076 TFT.locate(0,0); 00077 TFT.printf("meridianScientific"); 00078 TFT.locate(0,20); 00079 TFT.printf("ramanSpectrometer"); 00080 TFT.foreground(Green); 00081 TFT.set_font((unsigned char*) Arial12x12); 00082 TFT.locate(0,50); 00083 printf("> version0.1a (2014)"); 00084 TFT.locate(0,65); 00085 printf("> system initialization..."); 00086 TFT.locate(10,80); 00087 printf("waiting for raspiComm.."); 00088 return 0; 00089 } 00090 00091 int shit() 00092 { 00093 TFT.foreground(White); 00094 TFT.background(Blue); 00095 TFT.cls(); 00096 TFT.set_font((unsigned char*) Arial24x23); 00097 TFT.locate(0,0); 00098 TFT.printf("meridianScientific"); 00099 TFT.locate(0,20); 00100 TFT.printf("ramanSpectrometer"); 00101 TFT.foreground(Green); 00102 TFT.set_font((unsigned char*) Arial12x12); 00103 return 0; 00104 } 00105 00106 int setScr(){ 00107 TFT.foreground(White); 00108 TFT.background(Blue); 00109 TFT.cls(); 00110 TFT.set_font((unsigned char*) Neu42x35); 00111 return 0; 00112 } 00113 00114 int main() 00115 { 00116 LCD_LED = 1; 00117 00118 TFT.claim(stdout); 00119 00120 touch_pad.init(); 00121 touch_pad.enable(); 00122 touch_pad.registerDump(raspi); 00123 00124 splashScreen(); 00125 wait(5); 00126 startupScreen(); 00127 00128 while(1) { 00129 led1=0; 00130 if(touch_pad.isPressed()) { 00131 uint16_t button_val = touch_pad.buttonPressed(); 00132 led1 = (button_val>0) ? 1 : 0; 00133 raspi.printf("button = 0x%04x\r\n", button_val); 00134 switch (button_val) { 00135 case 0: 00136 break; 00137 case 1: 00138 setScr(); 00139 TFT.locate(20,70); 00140 TFT.printf("UP"); 00141 TFT.locate(110,100); 00142 TFT.printf("ARROW"); 00143 break; 00144 case 2: 00145 setScr(); 00146 TFT.locate(20,70); 00147 TFT.printf("RIGHT"); 00148 TFT.locate(110,100); 00149 TFT.printf("ARROW"); 00150 break; 00151 case 4: 00152 setScr(); 00153 TFT.locate(20,70); 00154 TFT.printf("DOWN"); 00155 TFT.locate(110,100); 00156 TFT.printf("ARROW"); 00157 break; 00158 case 8: 00159 setScr(); 00160 TFT.locate(20,70); 00161 TFT.printf("LEFT"); 00162 TFT.locate(110,100); 00163 TFT.printf("ARROW"); 00164 break; 00165 case 16: 00166 startupScreen(); 00167 TFT.locate(20,120); 00168 TFT.printf("5"); 00169 break; 00170 case 32: 00171 startupScreen(); 00172 TFT.locate(30,120); 00173 TFT.printf("6"); 00174 break; 00175 case 64: 00176 startupScreen(); 00177 TFT.locate(10,130); 00178 TFT.printf("7"); 00179 break; 00180 case 128: 00181 startupScreen(); 00182 TFT.locate(20,130); 00183 TFT.printf("8"); 00184 break; 00185 case 256: 00186 startupScreen(); 00187 TFT.locate(30,130); 00188 TFT.printf("9"); 00189 break; 00190 default: 00191 break; 00192 } 00193 00194 } 00195 } 00196 }
Generated on Mon Jul 25 2022 07:15:37 by
1.7.2