Random terror phrases

Dependencies:   EFM32_CapSenseSlider EFM32_SegmentLCD mbed

Fork of EMF32-Segment-Touch-Demo by Max Scordamaglia

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Functions.h Source File

Functions.h

00001 #include <string>
00002 
00003 
00004 char* string2char(string sttde)
00005 {
00006     //ora aggiunge comunque l'EOS. Decidere se parametrizzare
00007     //sttde=addEOS(sttde);
00008     char *cstr = new char[sttde.length() + 1];
00009     strcpy(cstr, sttde.c_str());
00010     // delete [] cstr;
00011     return cstr;
00012 }
00013 
00014 //****************** FUNZIONI STANDARD NON MODIFICATE
00015 /**
00016  * Callback for pushbutton interrupt
00017  */
00018 
00019 void symbolGest()
00020 {
00021     if (count==7) {
00022         segmentDisplay.Symbol(LCD_SYMBOL_GECKO, true);
00023         segmentDisplay.Write("GeckoOn");
00024         pc.printf("Gecko! \n\r");
00025     } else {
00026         segmentDisplay.Symbol(LCD_SYMBOL_GECKO, false);
00027         if (count%2==0) segmentDisplay.Write("Scorda");
00028         else  segmentDisplay.Write("TataGek");
00029     }
00030 }
00031 
00032 
00033 void ledToggler(void)
00034 {
00035     myled1 = !myled1;
00036 }
00037 
00038 void ledTogglerGen(void)
00039 {
00040     myled0 = !myled0;
00041     segmentDisplay.Symbol(LCD_SYMBOL_GECKO, false);
00042     myled1=1;
00043     ledTicker1.detach();
00044 }
00045 
00046 
00047 void timeDisp()
00048 {
00049     seconds++;
00050     uint32_t clockValue = ((seconds / 60) % 60) * 100 + (seconds % 60);
00051     segmentDisplay.Number(clockValue);
00052     segmentDisplay.Symbol(LCD_SYMBOL_COL10, seconds & 0x1);
00053 
00054 }
00055 
00056 /**
00057  * Callback for display
00058  */
00059 void tickerCallback(void)
00060 {
00061     float rtime;
00062     int choicev;
00063     string mess;
00064 
00065     //choice
00066     choicev=rand()%15;
00067 
00068     switch (choicev) {
00069         case 0:
00070             mess="Vai Via";
00071             break;
00072         case 1:
00073             mess="Via!!";
00074             break;
00075         case 2:
00076             mess="Vattene";
00077             break;
00078         case 3:
00079             mess="Aiuto!";
00080             break;
00081         case 4:
00082             mess="Basta!";
00083             break;
00084         case 5:
00085             mess="Paura!";
00086             break;
00087         case 6:
00088             mess="No!";
00089             break;
00090         case 7:
00091             mess="No!No!!";
00092             break;
00093         case 8:
00094             mess="Noooooo";
00095             break;
00096         case 9:
00097             mess="Lontano";
00098             break;
00099         case 10:
00100             mess="Aaargh";
00101             break;
00102         case 11:
00103             mess="Aaahhh";
00104             break;
00105         case 12:
00106             mess="Orrore!";
00107             break;
00108         case 13:
00109             mess="Vattene";
00110             break;
00111         case 14:
00112             mess="Oddioo";
00113             break;
00114     }
00115 //display
00116     segmentDisplay.Write(string2char(mess));
00117     //ricalcolo ticker
00118     rtime=((rand()%4000)+1000)/1000;
00119     refreshTicker.detach();
00120     refreshTicker.attach(&tickerCallback, rtime);
00121     myled0 = 1;
00122     segmentDisplay.Symbol(LCD_SYMBOL_GECKO, true);
00123     ledTicker0.detach();
00124     ledTicker0.attach(&ledTogglerGen, rtime/2);
00125     ledTicker1.attach(&ledToggler, 0.1f);
00126 }
00127 
00128 /**
00129  * Callback for touching/untouching the cap slider
00130  */
00131 
00132 
00133 void touchCallback(void)
00134 {
00135     segmentDisplay.Symbol(LCD_SYMBOL_EFM32, capSlider.isTouched());
00136 
00137     if(!capSlider.isTouched()) {
00138         segmentDisplay.Write("Bestia!");
00139         printf("Touch in use \n\r");
00140     }
00141 }
00142 
00143 /**
00144  * Callback for sliding the cap slider
00145  */
00146 void slideCallback(void)
00147 {
00148     segmentDisplay.LowerNumber(capSlider.get_position());
00149 }
00150 
00151 //************************ FUNZIONI MODIFICATE
00152 void in0_handler()
00153 {
00154     segmentDisplay.Write("No 0!");
00155     /*
00156     pc.printf("Button 0 \n\r");
00157     count++;
00158     if (count>7) count=7;
00159     else segmentDisplay.ARing(count, true);
00160     symbolGest() ;
00161     */
00162 }
00163 
00164 void in1_handler()
00165 {
00166     segmentDisplay.Write("No 1!");
00167     /*
00168     printf("Button 1 \n\r");
00169     segmentDisplay.ARing(count, false);
00170     count--;
00171     if (count<0) count=-1;
00172     symbolGest() ;
00173     */
00174 }
00175 
00176 
00177 
00178 
00179