//------------------Task 2-------------------------------- // background thread executes with SW1 button // one foreground task created with button push // foreground treads run for 2 sec and die // ***********ButtonWork************* void ButtonWork(void){ unsigned long myId = OS_Id(); PE1 ^= 0x02; ST7735_Message(1,0,"NumCreated =",NumCreated); PE1 ^= 0x02; OS_Sleep(50); // set this to sleep for 50msec ST7735_Message(1,1,"PIDWork =",PIDWork); ST7735_Message(1,2,"DataLost =",DataLost); ST7735_Message(1,3,"Jitter 0.1us=",MaxJitter); PE1 ^= 0x02; OS_Kill(); // done, OS does not return from a Kill }
//******** Display *************** // foreground thread, accepts data from consumer // displays calculated results on the LCD // inputs: none // outputs: none void Display(void){ unsigned long data,voltage; //OS_DisableInterrupts(); ST7735_Message(0,1,"Run length = ",(RUNLENGTH)/FS); // top half used for Display //OS_EnableInterrupts(); while(NumSamples < RUNLENGTH) { data = OS_MailBox_Recv(); voltage = 3000*data/4095; // calibrate your device so voltage is in mV PE3 = 0x08; ST7735_Message(0,2,"v(mV) =",voltage); PE3 = 0x00; } OS_Kill(); // done }
void LCD_test(uint8_t device, char * message) { ST7735_Message (device, 0, message, strlen(message)); }
/* =================================================================================================== COMMAND HANDLER :: helloBottomScreenHandler - test print for bottom screen - return success value =================================================================================================== */ int helloBottomScreenHandler(char** tokens, uint8_t numTokens){ printf(" Writing something to the bottom screen...\n\n"); ST7735_Message(1, 0, "Hello bottom screen!", 42); return CMD_SUCCESS; }
/* =================================================================================================== COMMAND HANDLER :: helloTopScreenHandler - test print for upper screen - return success value =================================================================================================== */ int helloTopScreenHandler(char** tokens, uint8_t numTokens){ printf(" Writing something to the top screen...\n\n"); ST7735_Message(0, 0, "Hello top screen!", 42); return CMD_SUCCESS; }