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 main.cpp Source File

main.cpp

00001 /** **************************************
00002 In un tempo variabile tra 1 e 5 secondi, refreshticker cambia scritta e nel contempo cambia:
00003 - temporizzazione di led0: meta' tempo acceso l'altra meta' spento
00004 - temporizzazione di led1: meta' tempo lampeggia, l'altra meta' (controllata dal'evento led0) resta acceso
00005 - accende io jecko che viene spento da led0
00006 I tasti rispondono, il sensore pure
00007 
00008 
00009 */
00010 
00011 #include "EFM32_SegmentLCD.h"
00012 #include "EFM32_CapSenseSlider.h"
00013 
00014 /******************** Define I/O *****************************/
00015 InterruptIn in0(PB9);
00016 InterruptIn in1(PB10);
00017 
00018 silabs::EFM32_SegmentLCD segmentDisplay;
00019 silabs::EFM32_CapSenseSlider capSlider;
00020 
00021 DigitalOut myled1(LED1);
00022 DigitalOut myled0(LED0);
00023 
00024 Serial pc(USBTX, USBRX); //Apertura della seriale 2
00025 
00026 /******************** Define Timers *****************************/
00027 // devo separare i timers. Non so il perche'
00028 LowPowerTicker refreshTicker;
00029 LowPowerTicker ledTicker0;
00030 LowPowerTicker ledTicker1;
00031 LowPowerTicker timeTicker;
00032 
00033 /***************** Define global variables **********************/
00034 #define INIT_SECONDS        0
00035 #define TEST_DURATION       10
00036 
00037 volatile uint32_t seconds = INIT_SECONDS;
00038 int count = -1;
00039 
00040 
00041 /***************** Define callback handlers *********************/
00042 void tickerCallback(void);
00043 void in0_handler();
00044 void in1_handler();
00045 void touchCallback(void);
00046 void slideCallback(void);
00047 
00048 //------------ Funzioni -------------
00049 
00050 #include "Functions.h"
00051 
00052 
00053 /*************************** MAIN *******************************/
00054 int main()
00055 {
00056     // Initialize pushbutton handler
00057     in0.rise(NULL);
00058     in0.fall(in0_handler);
00059 
00060     in1.rise(NULL);
00061     in1.fall(in1_handler);
00062 
00063     // Enable the capacitive slider
00064     capSlider.start();
00065     capSlider.attach_touch(touchCallback);
00066     capSlider.attach_untouch(touchCallback);
00067     capSlider.attach_slide(-1, slideCallback);
00068 
00069     // Start generating the 1Hz timebase
00070     refreshTicker.attach(&tickerCallback, 1.0f);
00071     timeTicker.attach(&timeDisp, 1.0f);
00072     ledTicker0.attach(&ledTogglerGen, 0.5f);
00073         ledTicker1.attach(&ledToggler, 0.1f);
00074 
00075     printf("Initialization done! \n\r");
00076     wait(0.01f); //Need to delay slightly to give the serial transmission a chance to flush out its buffer
00077 
00078     //inizializza random
00079     srand (time(NULL));
00080 
00081     // Go into sleeping mode
00082     while(1) {
00083         sleep();
00084     }
00085 }
00086