void lcd_init(){ Dogs102x64_UC1701Init(); GrContextInit(&g_sContext, &g_sDogs102x64_UC1701); GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrContextFontSet(&g_sContext, &g_sFontFixed6x8); GrClearDisplay(&g_sContext); }
/******************************************************************************* * @fn devpkLcdClear * * @brief Clears the display * * @return true if success */ bool devpkLcdClear(void) { if (hLcdPin != NULL) { GrClearDisplay(&g_sContext); GrFlush(&g_sContext); } return hLcdPin != 0; }
void main(void) { CAP_BUTTON keypressed_state; int countdownCount; State state = STATE_WELCOME; // Stop WDT WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //Perform initializations (see peripherals.c) configTouchPadLEDs(); configDisplay(); configCapButtons(); GrClearDisplay(&g_sContext); GrStringDrawCentered(&g_sContext, "MSP430 H3R0", AUTO_STRING_LENGTH, 51, 32, TRANSPARENT_TEXT); GrFlush(&g_sContext); /* Monitor Capacitive Touch Pads in endless "forever" loop */ while(1) { switch(state) { case STATE_WELCOME: if(checkButtons() & BUTTON1) { state = STATE_COUNTDOWN; } break; case STATE_COUNTDOWN: centerText("3"); configLED1_3(BIT3); wait(COUNTDOWN_TIMER); centerText("2"); configLED1_3(BIT2); wait(COUNTDOWN_TIMER); centerText("1"); configLED1_3(BIT1); wait(COUNTDOWN_TIMER); centerText("GO!"); configLED1_3(BIT3 | BIT2 | BIT1); wait(COUNTDOWN_TIMER); //TODO: next state break; } } }
void configDisplay(void) { // Enable use of external clock crystals P5SEL |= (BIT5|BIT4|BIT3|BIT2); // Set up LCD -- These function calls are part on a TI supplied library Dogs102x64_UC1701Init(); GrContextInit(&g_sContext, &g_sDogs102x64_UC1701); GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrContextFontSet(&g_sContext, &g_sFontFixed6x8); GrClearDisplay(&g_sContext); GrFlush(&g_sContext); }
/******************************************************************************* * @fn devpkLcdInvert * * @brief Inverts the foreground and background colours * * @return true if success */ bool devpkLcdInvert(void) { if (hLcdPin != NULL) { uint32_t tmp; // Swap background and foreground tmp = display.fg; display.fg = display.bg; display.bg = tmp; GrContextForegroundSet(&g_sContext, display.fg); GrContextBackgroundSet(&g_sContext, display.bg); GrClearDisplay(&g_sContext); GrFlush(&g_sContext); } return hLcdPin != 0; }
/******************************************************************************* * @fn devpkLcdOpen * * @brief Initialize the LCD * * @descr Initializes the pins used by the LCD, creates resource access * protection semaphore, turns on the LCD device, initializes the * frame buffer, initializes to white background/dark foreground, * and finally clears the display. * * @return true if success */ bool devpkLcdOpen(void) { hLcdPin = PIN_open(&pinState, BoardDevpackLCDPinTable); if (hLcdPin != 0) { display.bg = ClrBlack; display.fg = ClrWhite; // Open the SPI driver bspSpiOpen(); // Exclusive access Semaphore_Params_init(&semParamsLCD); semParamsLCD.mode = Semaphore_Mode_BINARY; Semaphore_construct(&semLCD, 1, &semParamsLCD); hSemLCD = Semaphore_handle(&semLCD); // Turn on the display PIN_setOutputValue(hLcdPin,Board_DEVPK_LCD_DISP,1); // Graphics library init GrContextInit(&g_sContext, &g_sharp96x96LCD); // Graphics properties GrContextForegroundSet(&g_sContext, display.fg); GrContextBackgroundSet(&g_sContext, display.bg); GrContextFontSet(&g_sContext, &g_sFontFixed6x8); // Clear display GrClearDisplay(&g_sContext); GrFlush(&g_sContext); } return hLcdPin != 0; }
void main(void) { // Stop WDT WDTCTL = WDTPW + WDTHOLD; // Initialize the boards boardInit(); clockInit(); timerInit(); flashInit(); __bis_SR_register(GIE); // Set up the LCD LCDInit(); GrContextInit(&g_sContext, &g_sharp96x96LCD); GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrContextFontSet(&g_sContext, &g_sFontFixed6x8); GrClearDisplay(&g_sContext); GrFlush(&g_sContext); // Intro Screen GrStringDrawCentered(&g_sContext, "How to use", AUTO_STRING_LENGTH, 48, 15, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "the MSP430", AUTO_STRING_LENGTH, 48, 35, TRANSPARENT_TEXT); GrStringDraw(&g_sContext, "Graphics Library", AUTO_STRING_LENGTH, 1, 51, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "Primitives", AUTO_STRING_LENGTH, 48, 75, TRANSPARENT_TEXT); GrFlush(&g_sContext); Delay_long(); GrClearDisplay(&g_sContext); // Draw pixels and lines on the display GrStringDrawCentered(&g_sContext, "Draw Pixels", AUTO_STRING_LENGTH, 48, 5, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "& Lines", AUTO_STRING_LENGTH, 48, 15, TRANSPARENT_TEXT); GrPixelDraw(&g_sContext, 30, 30); GrPixelDraw(&g_sContext, 30, 32); GrPixelDraw(&g_sContext, 32, 32); GrPixelDraw(&g_sContext, 32, 30); GrLineDraw(&g_sContext, 35, 35, 90, 90); GrLineDraw(&g_sContext, 5, 80, 80, 20); GrLineDraw(&g_sContext, 0, GrContextDpyHeightGet(&g_sContext) - 1, GrContextDpyWidthGet(&g_sContext) - 1, GrContextDpyHeightGet(&g_sContext) - 1); GrFlush(&g_sContext); Delay_long(); GrClearDisplay(&g_sContext); // Draw circles on the display GrStringDraw(&g_sContext, "Draw Circles", AUTO_STRING_LENGTH, 10, 5, TRANSPARENT_TEXT); GrCircleDraw(&g_sContext, 30, 70, 20); GrCircleFill(&g_sContext, 60, 50, 30); GrFlush(&g_sContext); Delay_long(); GrClearDisplay(&g_sContext); // Draw rectangles on the display GrStringDrawCentered(&g_sContext, "Draw Rectangles", AUTO_STRING_LENGTH, 48, 5, TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangle1); GrRectFill(&g_sContext, &myRectangle2); GrFlush(&g_sContext); Delay_long(); GrClearDisplay(&g_sContext); // Combining Primitive screen GrStringDrawCentered(&g_sContext, "Combining", AUTO_STRING_LENGTH, 48, 15, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "Primitives to", AUTO_STRING_LENGTH, 48, 35, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "create menus", AUTO_STRING_LENGTH, 48, 51, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "and animations", AUTO_STRING_LENGTH, 48, 75, TRANSPARENT_TEXT); GrFlush(&g_sContext); Delay_long(); GrClearDisplay(&g_sContext); // Draw a Menu screen GrStringDrawCentered(&g_sContext, "Create a Menu", AUTO_STRING_LENGTH, 48, 5, TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangleOption1); GrStringDraw(&g_sContext,"Option #1", 10,15,15,TRANSPARENT_TEXT); GrRectFill(&g_sContext, &myRectangleOption2); GrStringDraw(&g_sContext,"Option #2", 10,15,25,TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangleOption3); GrStringDraw(&g_sContext,"Option #3", 10,15,35,TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangleOption4); GrStringDraw(&g_sContext,"Option #4", 10,15,45,TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangleOption5); GrStringDraw(&g_sContext,"Option #5", 10,15,55,TRANSPARENT_TEXT); GrFlush(&g_sContext); Delay_long(); GrClearDisplay(&g_sContext); // Show progress bar screen // The following animation consist on displaying a progress bar and // updating the progress bar in increments of 25%. GrStringDrawCentered(&g_sContext, "Show progress", AUTO_STRING_LENGTH, 48, 5, TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangleFrame); GrStringDrawCentered(&g_sContext, "Processing...", AUTO_STRING_LENGTH, 48, 75, TRANSPARENT_TEXT); GrFlush(&g_sContext); Delay_short(); // Update display with 25 %. Initial value of "myRectangleProgress" are set // to update bar with a 25 % increment. GrRectFill(&g_sContext, &myRectangleProgress); GrFlush(&g_sContext); Delay_short(); // Set myRectangleProgress values to update progress bar with 50 % myRectangleProgress.sXMin = 30; myRectangleProgress.sYMin = 40; myRectangleProgress.sXMax = 50; myRectangleProgress.sYMax = 60; GrRectFill(&g_sContext, &myRectangleProgress); GrFlush(&g_sContext); Delay_short(); // Set myRectangleProgress values to update progress bar with 75 % myRectangleProgress.sXMin = 50; myRectangleProgress.sYMin = 40; myRectangleProgress.sXMax = 70; myRectangleProgress.sYMax = 60; GrRectFill(&g_sContext, &myRectangleProgress); GrFlush(&g_sContext); Delay_short(); // Set myRectangleProgress values to update progress bar with 100 % myRectangleProgress.sXMin = 70; myRectangleProgress.sYMin = 40; myRectangleProgress.sXMax = 90; myRectangleProgress.sYMax = 60; GrRectFill(&g_sContext, &myRectangleProgress); GrStringDrawCentered(&g_sContext, "DONE!", AUTO_STRING_LENGTH, 48, 85, TRANSPARENT_TEXT); GrFlush(&g_sContext); Delay_long(); while(1); }
void main(void) { set_up(); buttonsPressed = 0; while(1){ exec_counter=0; //to select menu if (buttonsPressed & BUTTON_S2){ if(menu==0) { menu=option+1; option=0; } else exec_counter=1; disp_counter=1; buttonsPressed = 0; } //to scroll options if (buttonsPressed & BUTTON_S1){ if(option<(total_options[menu]-1)){ option++; } else option=0; disp_counter=1; buttonsPressed = 0; } if(disp_counter==1){ disp_counter=0;//to prevent writing if no change GrClearDisplay(&g_sContext); switch(menu){ case 0: print_string(0,0,"=====Menu===="); print_string(0,8,"1.Calibrate"); print_string(0,16,"2.View Thresholds"); print_string(0,24,"3.Enable Eye "); print_string(0,32,"4.View Signal"); switch(option){ case 1: highlight_and_print_string(0,16,"2.View Thresholds"); break; case 2: highlight_and_print_string(0,24,"3.Enable Eye "); break; case 3: highlight_and_print_string(0,32,"4.View Signal"); break; default: highlight_and_print_string(0,8,"1.Calibrate"); option=0; break; } break; case 1: print_string(0,0,"===Calibrate==="); print_string(0,8,"1.Steady Values"); print_string(0,16,"2.Peak"); print_string(0,24,"3.Fourier "); print_string(0,32,"4.Back"); switch(option){ case 1: highlight_and_print_string(0,16,"2.Peak"); if(exec_counter==1){ exec_counter=0; lcd_clear(); //to calibrate small blink adc Thresholds;cannot view adc values till out while(!(buttonsPressed & BUTTON_S2)){ if(calibrated_adc==0) { AdcThreshold=255; lcd_clear(); print_string(0,0,"Blink to calibrate"); print_string(56,0,"*S2=ESC*"); _delay_ms(1000); lcd_clear(); } temp = adc_read(); _delay_ms(20); crest=0; // to check crest while(temp<adc_read()){ temp = adc_read(); _delay_ms(20); crest=1; } if(crest && temp>steady_crest && temp<AdcThreshold){ AdcThreshold=temp; } calibrated_adc=1; lcd_clear(); // print_string(0,0,"Blink to calibrate"); //print_string(56,0,"*S2=ESC*"); print_int(50,30,AdcThreshold); _delay_ms(100); } if(AdcThreshold==255) AdcThreshold=steady_crest;//if 50 hz noise lcd_clear(); buttonsPressed=0; disp_counter=1; } break; case 2: highlight_and_print_string(0,24,"3.Fourier Threshold"); break; case 3: highlight_and_print_string(0,32,"4.Back"); if(exec_counter==1){ menu=0; option=0; disp_counter=1; } break; default: highlight_and_print_string(0,8,"1.Steady Values"); option=0; break; } break; case 2: print_string(0,0,"===Thresholds==="); print_string(0,8,"1.DC"); print_string(0,16,"2.Steady Peak"); print_string(0,24,"3.Peak"); print_string(0,32,"4.Fourier Threshold"); print_string(0,40,"5.Back"); switch(option){ case 1: highlight_and_print_string(0,16,"2.Steady Peak"); break; case 2: highlight_and_print_string(0,24,"3.Peak"); break; case 3: highlight_and_print_string(0,32,"4.Fourier Threshold"); break; case 4: highlight_and_print_string(0,40,"5.Back"); if(exec_counter==1){ menu=0; option=0; disp_counter=1; } break; default: highlight_and_print_string(0,8,"1.DC"); option=0; break; } break; case 3: print_string(0,0,"===Eye Control==="); print_string(0,8,"1.Wait"); print_string(0,16,"2.Left"); print_string(0,24,"3.Right"); print_string(0,32,"4.Forward"); print_string(0,40,"5.Backward"); print_string(0,48,"6.Main menu"); switch(option){ case 1: highlight_and_print_string(0,16,"2.Left"); break; case 2: highlight_and_print_string(0,24,"3.Right"); break; case 3: highlight_and_print_string(0,32,"4.Forward"); break; case 4: highlight_and_print_string(0,40,"5.Backward"); if(exec_counter==1){ menu=0; disp_counter=1; } break; case 5: highlight_and_print_string(0,48,"6.Main Menu"); if(exec_counter==1){ menu=0; option=0; disp_counter=1; } break; default: highlight_and_print_string(0,8,"1.Wait"); option=0; break; } break; case 4: print_string(0,0,"S1 pause/resume"); print_string(0,56,"S2 Back"); plot(); menu=0;option=0; disp_counter=1; break; default:break; } } } }
//draws given text centered on screen void centerText(char* text) { GrClearDisplay(&g_sContext); GrStringDrawCentered(&g_sContext, text, AUTO_STRING_LENGTH, 51, 32, TRANSPARENT_TEXT); GrFlush(&g_sContext); }
void main(void){ WDT_A_hold(WDT_A_BASE); // Stop WDT boardInit(); // Basic GPIO initialization clockInit(8000000); // Config clocks. MCLK=SMCLK=FLL=8MHz; ACLK=REFO=32kHz Sharp96x96_LCDInit(); // Set up the LCD GrContextInit(&g_sContext, &g_sharp96x96LCD); GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrContextFontSet(&g_sContext, &g_sFontFixed6x8); GrClearDisplay(&g_sContext); GrFlush(&g_sContext); while(1){ // Intro Screen GrClearDisplay(&g_sContext); GrStringDrawCentered(&g_sContext, "How to use", AUTO_STRING_LENGTH, 48, 15, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "the MSP430", AUTO_STRING_LENGTH, 48, 35, TRANSPARENT_TEXT); GrStringDraw(&g_sContext, "Graphics Library", AUTO_STRING_LENGTH, 1, 51, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "Primitives", AUTO_STRING_LENGTH, 48, 75, TRANSPARENT_TEXT); GrFlush(&g_sContext); Delay(); GrClearDisplay(&g_sContext); // Draw pixels and lines on the display GrStringDrawCentered(&g_sContext, "Draw Pixels", AUTO_STRING_LENGTH, 48, 5, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "& Lines", AUTO_STRING_LENGTH, 48, 15, TRANSPARENT_TEXT); GrPixelDraw(&g_sContext, 30, 30); GrPixelDraw(&g_sContext, 30, 32); GrPixelDraw(&g_sContext, 32, 32); GrPixelDraw(&g_sContext, 32, 30); GrLineDraw(&g_sContext, 35, 35, 90, 90); GrLineDraw(&g_sContext, 5, 80, 80, 20); GrLineDraw(&g_sContext, 0, GrContextDpyHeightGet(&g_sContext) - 1, GrContextDpyWidthGet(&g_sContext) - 1, GrContextDpyHeightGet(&g_sContext) - 1); GrFlush(&g_sContext); Delay(); GrClearDisplay(&g_sContext); // Draw circles on the display GrStringDraw(&g_sContext, "Draw Circles", AUTO_STRING_LENGTH, 10, 5, TRANSPARENT_TEXT); GrCircleDraw(&g_sContext, 30, 70, 20); GrCircleFill(&g_sContext, 60, 50, 30); GrFlush(&g_sContext); Delay(); GrClearDisplay(&g_sContext); // Draw rectangles on the display GrStringDrawCentered(&g_sContext, "Draw Rectangles", AUTO_STRING_LENGTH, 48, 5, TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangle1); GrRectFill(&g_sContext, &myRectangle2); // Text below won't be visible on screen due to transparency // (foreground colors match) GrStringDrawCentered(&g_sContext, "Normal Text", AUTO_STRING_LENGTH, 50, 50, TRANSPARENT_TEXT); // Text below draws foreground and background for opacity GrStringDrawCentered(&g_sContext, "Opaque Text", AUTO_STRING_LENGTH, 50, 65, OPAQUE_TEXT); GrContextForegroundSet(&g_sContext, ClrWhite); GrContextBackgroundSet(&g_sContext, ClrBlack); GrStringDrawCentered(&g_sContext, "Invert Text", AUTO_STRING_LENGTH, 50, 80, TRANSPARENT_TEXT); GrFlush(&g_sContext); Delay(); // Invert the foreground and background colors GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrRectFill(&g_sContext, &myRectangle3); GrContextForegroundSet(&g_sContext, ClrWhite); GrContextBackgroundSet(&g_sContext, ClrBlack); GrStringDrawCentered(&g_sContext, "Invert Colors", AUTO_STRING_LENGTH, 48, 5, TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangle1); GrRectFill(&g_sContext, &myRectangle2); // Text below won't be visible on screen due to // transparency (foreground colors match) GrStringDrawCentered(&g_sContext, "Normal Text", AUTO_STRING_LENGTH, 50, 50, TRANSPARENT_TEXT); // Text below draws foreground and background for opacity GrStringDrawCentered(&g_sContext, "Opaque Text", AUTO_STRING_LENGTH, 50, 65, OPAQUE_TEXT); // Text below draws with inverted foreground color to become visible GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrStringDrawCentered(&g_sContext, "Invert Text", AUTO_STRING_LENGTH, 50, 80, TRANSPARENT_TEXT); GrFlush(&g_sContext); Delay(); GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrClearDisplay(&g_sContext); // Draw Images on the display GrImageDraw(&g_sContext, &LPRocket_96x37_1BPP_UNCOMP, 3, 28); GrFlush(&g_sContext); Delay(); GrClearDisplay(&g_sContext); GrImageDraw(&g_sContext, &TI_Logo_69x64_1BPP_UNCOMP, 15, 15); GrFlush(&g_sContext); Delay(); // __bis_SR_register(LPM0_bits+GIE); //enter low power mode 0 with interrupts } }
void main(void) { tRectangle myRectangle1 = { 5, 10, 60, 50}; tRectangle myRectangle2 = { 30, 20, 100, 60}; tRectangle myRectangle3 = { 0, 0, 101, 63}; // Stop WDT WDT_A_hold(WDT_A_BASE); // Basic GPIO initialization Board_init(); Clock_init(); // Set up LCD Dogs102x64_UC1701Init(); GrContextInit(&g_sContext, &g_sDogs102x64_UC1701); GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrContextFontSet(&g_sContext, &g_sFontFixed6x8); GrClearDisplay(&g_sContext); // Intro Screen GrStringDrawCentered(&g_sContext, "How to use MSP430", AUTO_STRING_LENGTH, 51, 16, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "Graphics Library", AUTO_STRING_LENGTH, 51, 32, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "Primitives", AUTO_STRING_LENGTH, 51, 48, TRANSPARENT_TEXT); Delay(); GrClearDisplay(&g_sContext); // Draw pixels and lines on the display GrStringDraw(&g_sContext, "Draw Pixels", AUTO_STRING_LENGTH, 20, 0, TRANSPARENT_TEXT); GrStringDraw(&g_sContext, "& Lines", AUTO_STRING_LENGTH, 30, 10, TRANSPARENT_TEXT); GrPixelDraw(&g_sContext, 10, 10); GrPixelDraw(&g_sContext, 10, 12); GrPixelDraw(&g_sContext, 12, 12); GrPixelDraw(&g_sContext, 12, 10); GrLineDraw(&g_sContext, 15, 15, 60, 60); GrLineDraw(&g_sContext, 10, 50, 90, 10); GrLineDraw(&g_sContext, 0, GrContextDpyHeightGet(&g_sContext) - 1, GrContextDpyWidthGet(&g_sContext) - 1, GrContextDpyHeightGet(&g_sContext) - 1); Delay(); GrClearDisplay(&g_sContext); // Draw circles on the display GrStringDrawCentered(&g_sContext, "Draw Circles", AUTO_STRING_LENGTH, 51, 5, TRANSPARENT_TEXT); GrCircleDraw(&g_sContext, 30, 50, 10); GrCircleFill(&g_sContext, 65, 37, 23); Delay(); GrClearDisplay(&g_sContext); // Draw rectangles on the display GrStringDrawCentered(&g_sContext, "Draw Rectangles", AUTO_STRING_LENGTH, 51, 5, TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangle1); GrRectFill(&g_sContext, &myRectangle2); // Text won't be visible on screen due to transparency GrStringDrawCentered(&g_sContext, "Normal Text", AUTO_STRING_LENGTH, 65, 30, TRANSPARENT_TEXT); // Text draws foreground and background for opacity GrStringDrawCentered(&g_sContext, "Opaque Text", AUTO_STRING_LENGTH, 65, 40, OPAQUE_TEXT); GrContextForegroundSet(&g_sContext, ClrWhite); GrContextBackgroundSet(&g_sContext, ClrBlack); // Text draws with inverted color to become visible GrStringDrawCentered(&g_sContext, "Invert Text", AUTO_STRING_LENGTH, 65, 50, TRANSPARENT_TEXT); Delay(); GrClearDisplay(&g_sContext); // Invert the foreground and background colors GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrRectFill(&g_sContext, &myRectangle3); GrContextForegroundSet(&g_sContext, ClrWhite); GrContextBackgroundSet(&g_sContext, ClrBlack); GrStringDrawCentered(&g_sContext, "Invert Colors", AUTO_STRING_LENGTH, 51, 5, TRANSPARENT_TEXT); GrRectDraw(&g_sContext, &myRectangle1); GrRectFill(&g_sContext, &myRectangle2); // Text won't be visible on screen due to transparency GrStringDrawCentered(&g_sContext, "Normal Text", AUTO_STRING_LENGTH, 65, 30, TRANSPARENT_TEXT); // Text draws foreground and background for opacity GrStringDrawCentered(&g_sContext, "Opaque Text", AUTO_STRING_LENGTH, 65, 40, OPAQUE_TEXT); GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); // Text draws with inverted color to become visible GrStringDrawCentered(&g_sContext, "Invert Text", AUTO_STRING_LENGTH, 65, 50, TRANSPARENT_TEXT); Delay(); GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrClearDisplay(&g_sContext); // Draw Images on the display GrImageDraw(&g_sContext, &LPRocket_96x37_1BPP_UNCOMP, 3, 13); Delay(); GrClearDisplay(&g_sContext); GrImageDraw(&g_sContext, &TI_Logo_69x64_1BPP_UNCOMP, 16, 0); while(1) { } }
void main(void) { set_up(); buttonsPressed = 0; while(1){ exec_counter=0; //to select menu //store only when any value has changed if(calibrated_adc==1||calibrated_F==1||calibrated_steady==1){ char storage[]={AdcThreshold, dcval, steady_crest, fourier_offset, FThreshold}; eeprom_write_bytes(storage,5);//check for FThreshold>255 } tempF=255; temp=0; //to refresh the thresholds only when switches are pressed calibrated_adc=0; calibrated_F=0; calibrated_steady=0; if (buttonsPressed & BUTTON_S2){ if(menu==0) { menu=option+1; option=0; } else exec_counter=1; disp_counter=1; buttonsPressed = 0; } //to scroll options if (buttonsPressed & BUTTON_S1){ if(option<(total_options[menu]-1)){ option++; } else option=0; disp_counter=1; buttonsPressed = 0; } if(disp_counter==1){ disp_counter=0;//to prevent writing if no change GrClearDisplay(&g_sContext); switch(menu){ case 0: print_string(0,0,"=====Menu===="); print_string(0,8,"1.Calibrate"); print_string(0,16,"2.View Thresholds"); print_string(0,24,"3.Enable Eye "); print_string(0,32,"4.View Signal"); switch(option){ case 1: highlight_and_print_string(0,16,"2.View Thresholds"); break; case 2: highlight_and_print_string(0,24,"3.Enable Eye "); break; case 3: highlight_and_print_string(0,32,"4.View Signal"); break; default: highlight_and_print_string(0,8,"1.Calibrate"); option=0; break; } break; case 1: print_string(0,0,"===Calibrate==="); print_string(0,8,"1.Steady Values"); print_string(0,16,"2.Peak"); print_string(0,24,"3.Fourier "); print_string(0,32,"4.Back"); tempF=255; temp=0; //to refresh the thresholds only when switches are pressed calibrated_adc=0; calibrated_F=0; calibrated_steady=0; switch(option){ case 1: highlight_and_print_string(0,16,"2.Peak"); if(exec_counter==1){ exec_counter=0; lcd_clear(); //to calibrate small blink adc Thresholds;cannot view adc values till out while(!(buttonsPressed & BUTTON_S2)){ if(calibrated_adc==0) { AdcThreshold=255; lcd_clear(); print_string(0,0,"Blink to calib"); print_int(50, 30, AdcThreshold); print_string(0,56,"*S2=ESC*"); _delay_ms(200); } temp = adc_read(); _delay_ms(20); crest=0; // to check crest while(temp<adc_read()){ temp = adc_read(); _delay_ms(20); crest=1; } if(crest && temp>steady_crest && temp<AdcThreshold){ AdcThreshold=temp; } calibrated_adc=1; lcd_clear(); // print_string(0,0,"Blink to calibrate"); //print_string(56,0,"*S2=ESC*"); print_string(0,0,"Blink to calib"); print_int(50, 30, AdcThreshold); print_string(0,56,"*S2=ESC*"); _delay_ms(200); } if(AdcThreshold==255) AdcThreshold=steady_crest;//if 50 hz noise lcd_clear(); buttonsPressed=0; disp_counter=1; } break; case 2: highlight_and_print_string(0,24,"3.Fourier"); if(exec_counter==1){ exec_counter=0; //calibrate FThreshold while(!(buttonsPressed & BUTTON_S2)){ if(calibrated_F==0){ //write anything that you want to execute only once in the loop lcd_clear(); } X=dft(); if(X>fourier_offset+10 && tempF>X){ //+10 is for lesser sensitivity. If offset is more use % of fourier_offset FThreshold=X; tempF=X; } calibrated_F=1; lcd_clear(); print_string(0,0,"Blink to calibrate"); print_string(0,56,"*S2=ESC*"); print_int(50,30,(int)X); _delay_ms(200); } lcd_clear(); buttonsPressed=0; disp_counter=1; } break; case 3: highlight_and_print_string(0,32,"4.Back"); if(exec_counter==1){ exec_counter=0; menu=0; option=0; disp_counter=1; } break; default: highlight_and_print_string(0,8,"1.Steady Values"); option=0; if(exec_counter==1){ exec_counter=0; //initialize before setting dcval=0; fourier_offset=0; steady_trough=255,steady_crest=0; lcd_clear(); print_string(0,0,"Focus on the dot"); print_string(32,16,"for 3s "); print_string(40,30,"(.)"); _delay_s(3); //compute fourier_offset for(i=0;i<10;i++){ //will check for 10*100 ms check_fourier_offset(); } //compute dc_val for(i=0;i<2000;i++){ //average 2000 samples collected over 2 sec input=adc_read(); dcval+=(float)input/2000; if(steady_crest<input) steady_crest=input; if(steady_trough>input) steady_trough=input; _delay_ms(1); } steady_crest=steady_crest+(steady_crest-dcval)*0; //0% more than the steady peak steady_trough=steady_trough-(dcval-steady_trough)*0; lcd_clear(); print_string(0,0,"Done Calibrating!"); print_string(0,16,"Fourier Off:"); print_int(80,16,fourier_offset); print_string(0,32,"DC:"); print_int(80,32,dcval); print_string(0,40,"Steady Crest:"); print_int(80,40,steady_crest); print_string(0,56,"*S2=ESC*"); _delay_s(3); while(!(buttonsPressed & BUTTON_S2)); lcd_clear(); calibrated_steady=1; //to display when it goes back buttonsPressed=0; disp_counter=1; } break; } break; case 2: print_string(0,0,"===Thresholds==="); print_string(0,8,"1.DC........."); print_int(80,8,dcval); print_string(0,16,"2.Steady Pk.."); print_int(80,16,steady_crest); print_string(0,24,"3.Peak......."); print_int(80,24,AdcThreshold); print_string(0,32,"4.Fourier...."); print_int(80,32,FThreshold); print_string(0,56,"*S2=ESC*"); while(!(buttonsPressed & BUTTON_S2)); //to check slope buttonsPressed=0; while(!(buttonsPressed & BUTTON_S2)){ X=dft(); print_int(48,24,max_input); print_int(48,32,max_slope); _delay_ms(200); lcd_clear() } buttonsPressed=0; menu=0; option=0; disp_counter=1; break; case 3: print_string(0,0,"===Eye Control==="); print_string(0,8,"1.Wait "); print_string(0,16,"2.Left "); print_string(0,24,"3.Right "); print_string(0,32,"4.Forward "); print_string(0,40,"5.Backward "); print_string(0,56,"*S2=ESC*"); eye_control(); menu=0; option=0; disp_counter=1; break; //debug signal on lcd case 4: print_string(0,0,"S1 pause/resume"); print_string(0,56,"S2 Back"); plot(); menu=0; option=0; disp_counter=1; break; default:break; } } }
void main(void) { // Stop WDT WDT_A_hold(WDT_A_BASE); // Basic GPIO initialization Board_init(); Clock_init(); // Set up LCD Dogs102x64_UC1701Init(); GrContextInit(&g_sContext, &g_sDogs102x64_UC1701); GrContextForegroundSet(&g_sContext, ClrBlack); GrContextBackgroundSet(&g_sContext, ClrWhite); GrContextFontSet(&g_sContext, &g_sFontFixed6x8); GrClearDisplay(&g_sContext); int toggle=0; while(1){ //GrClearDisplay(&g_sContext); print_string(0,0,"===Team Members==="); print_string(0,8,"Anson Bastos"); print_string(0,16,"Dhiraj Patil"); print_string(0,24,"Abhinendra Singh"); print_string(0,32,"Melroy Tellis"); print_string(0,40,"Abhishek Suryawanshi"); toggle=(toggle>4)?(0):(toggle); switch(toggle){ case 0: highlight_and_print_string(0,8,"Anson Bastos"); Delay(); toggle++; break; case 1: highlight_and_print_string(0,16,"Dhiraj Patil"); Delay(); toggle++; break; case 2: highlight_and_print_string(0,24,"Abhinendra Singh"); Delay(); toggle++; break; case 3: highlight_and_print_string(0,32,"Melroy Tellis"); Delay(); toggle++; break; case 4: highlight_and_print_string(0,40,"Abhishek Suryawanshi"); Delay(); toggle++; break; } } }
void main (void) { // Stop WDT WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer _BIS_SR(GIE); runtimerA2(); //Perform initializations (see peripherals.c) configTouchPadLEDs(); configDisplay(); configCapButtons(); CAP_BUTTON keypressed_state; while(1) { switch(state) { case WelcomeScreen: GrClearDisplay(&g_sContext); GrStringDrawCentered(&g_sContext, "MSP430 HERO!", AUTO_STRING_LENGTH, 51, 22, TRANSPARENT_TEXT); GrStringDrawCentered(&g_sContext, "Press S1 to Start", AUTO_STRING_LENGTH, 51, 42, TRANSPARENT_TEXT); GrFlush(&g_sContext); //Changes the state to Game Starting if button 1 is pressed if (configButtons() == 1) { state = GameStarting; } else state = WelcomeScreen; break; case GameStarting: if (led_on ==1) { GrClearDisplay(&g_sContext); GrStringDrawCentered(&g_sContext, "3", AUTO_STRING_LENGTH, 51, 22, TRANSPARENT_TEXT); GrFlush(&g_sContext); configLEDs(3); led_on = 0; } else if (led_on ==2) { GrClearDisplay(&g_sContext); GrStringDrawCentered(&g_sContext, "2", AUTO_STRING_LENGTH, 51, 22, TRANSPARENT_TEXT); GrFlush(&g_sContext); configLEDs(2); led_on = 0; } else if (led_on == 3) { GrClearDisplay(&g_sContext); GrStringDrawCentered(&g_sContext, "1", AUTO_STRING_LENGTH, 51, 22, TRANSPARENT_TEXT); GrFlush(&g_sContext); configLEDs(1); led_on = 0; } else if (led_on == 4) { GrClearDisplay(&g_sContext); GrStringDrawCentered(&g_sContext, "GO", AUTO_STRING_LENGTH, 51, 22, TRANSPARENT_TEXT); GrFlush(&g_sContext); configLEDs(0); led_on = 0; } break; } } }