/*Author: Travis Schriner * Date 21 Oct 2013 * Description: This program interacts with the * LCD in the geekbox and allows me to write to it * */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer initSPI(); LCDinit(); LCDclear(); char *topMessage = "ECE382 is my Favorite Class!"; char *prompt = "Message?"; char *promptKey = "Press123"; char *message1 = "This is message 1 fool!"; char *message2 = "This is message 2 fool!"; char *message3 = "This is message 3 fool!"; cursorToLineOne(); writeString(prompt); cursorToLineTwo(); writeString(promptKey); configureP1PinAsButton(BIT1|BIT2|BIT3); // configure pins 1, 2, and 3 as buttons P1DIR |= BIT0|BIT6; // set launchpad LEDs to output char buttons[] = {BIT1, BIT2, BIT3}; char pressedButton = pollP1Buttons(buttons, 3); switch (pressedButton) { case BIT1: waitForP1ButtonRelease(BIT1); scrollString(topMessage, message1); break; case BIT2: waitForP1ButtonRelease(BIT2); scrollString(topMessage, message2); break; case BIT3: waitForP1ButtonRelease(BIT3); scrollString(topMessage, message3); break; } while(1){ } }
/* * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer //Create strings of text to output to the user char * requiredMsg = "ECE382 is my favorite class! "; char * prompt = "Message?"; char * promptKey = "Press123"; char * message1 = "Learn from yesterday... "; char * message2 = "Live for today... "; char * message3 = "Hope for tomorrow. "; //SPI initialization function initSPI(); // LCD initialization function LCDinit(); //Clear the LCD screen LCDclr(); //Position the cursor to write the prompt to the user. cursorToLineOne(); writeString(prompt); cursorToLineTwo(); writeString(promptKey); int buttonPushed = 0; //A different value is returned depending on which button is pushed. buttonPushed = pollButton(); //Move the selected message to the screen if (buttonPushed == 1) { scrollString(requiredMsg, message1); } if (buttonPushed == 2) { scrollString(requiredMsg, message2); } if (buttonPushed == 3) { scrollString(requiredMsg, message3); } return 0; }
int main(void){ WDTCTL = WDTPW | WDTHOLD; char message[] = "ECE 382 is my favorite class! "; char message2[]= "I got 99 problems... but a git ain't one. "; initSPI(); LCDinit(); LCDclear(); cursorToLineOne(); scrollString(message,message2); while (1){}; }
int main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer char mainMESSAGE[] = { 'E', 'C', 'E', '3', '8', '2', ' ', 'i', 's', ' ', 'm', 'y', ' ', 'f', 'a', 'v', 'o', 'r', 'i', 't', 'e', ' ', 'c', 'l', 'a', 's', 's', '!'}; int mainMessageLength = 29; char * mainMessagePointer = &mainMESSAGE[0]; initSPI(); LCDinit(); LCDclear(); while (1) { scrollString(mainMessagePointer, mainMessagePointer, mainMessageLength); } return 0; }