void displayClock(){ char debugmode[20]; switch(timeMode){ case 0: debugmode[0] = 0; break; case 1: sprintf(debugmode, "Digital Time"); break; case 2: sprintf(debugmode, "Stopwatch"); break; case 3: sprintf(debugmode, "Countdown Mode"); break; case 4: sprintf(debugmode, "Metronome"); break; } RIT128x96x4StringDraw(debugmode, 10, 10, 15); switch(timeMode){ case 0: firstNotAnalog = 1; analogClockDraw(); firstDigital=1; break; case 1: if (firstNotAnalog == 1 || firstDigital ==1) RIT128x96x4Clear(); firstNotAnalog = 0; firstDigital=0; firstStopWatch = 1; digitalClockDraw(); break; case 2: if (firstStopWatch==1) RIT128x96x4Clear(); firstStopWatch=0; firstCountDown = 1; timerDraw(); break; case 3: if (firstCountDown ==1) RIT128x96x4Clear(); firstCountDown=0; countdownDraw(); break; case 4: metronomeDraw(); break; } }
//UART1 interrupt handler void UARTIntHandler1 () { unsigned long ulStatus; unsigned long c; int display_offset = 0; int i; int errorFlag = 0; // Get the interrrupt status. ulStatus = UARTIntStatus(UART1_BASE, true); // Clear the asserted interrupts. UARTIntClear(UART1_BASE, ulStatus); // Loop while there are characters in the receive FIFO. while(UARTCharsAvail(UART1_BASE)) { c = UARTCharGet(UART1_BASE); display2[display_offset++] = (char)c; } display2[display_offset-1] = '\0'; for(i = 0; i < (display_offset - 1); i++) { if(display2[i] == 'p') { errorFlag = 1; } } if(errorFlag == 1) { RIT128x96x4Clear(); RIT128x96x4StringDraw("----------------------", 0, 50, 15); RIT128x96x4StringDraw("Error", 50, 75, 15); RIT128x96x4StringDraw(display, 0, 0, 15); } else { RIT128x96x4Clear(); RIT128x96x4StringDraw("----------------------", 0, 50, 15); RIT128x96x4StringDraw(display, 0, 0, 15); RIT128x96x4StringDraw(display2, 0, 60, 15); } }
//***************************************************************************** // // Flash "A B C D" to the board. // //***************************************************************************** int main(void) { unsigned long flashDelay = 8000; // Delay between flashes char *characters = "ABCD"; // Characters to flash // Set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // Initialize display RIT128x96x4Init(OLED_CLK); // Flash the letters ABCD unsigned int xVal = 15; unsigned int yVal = 15; while(TRUE) { RIT128x96x4StringDraw(characters, xVal, yVal, 15); delay(flashDelay); RIT128x96x4Clear(); delay(flashDelay); } }
void GPIOFIntHandler(void) { // Clear the GPIO interrupt. GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1); y = 0; // Counter for how long the snooze button was pressed while (GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1)==0){ y++; } // If the snooze button was held long enough, add 5 minutes to the alarm if (y>500000){ int z; for (z=0; z<5; z++){ IncrementTimeA(); } } // Clear the screen RIT128x96x4Clear(); // Turn off the LED GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); // Turn off the alarm PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, false); PWMGenDisable(PWM0_BASE, PWM_GEN_0); // Disable the interrupt so that snooze and turn off alarm cannot be used GPIOPinIntDisable(GPIO_PORTF_BASE, GPIO_PIN_1); }
//Clear the screen void oled_d_clear(void) { IntMasterDisable(); RIT128x96x4Clear(); IntMasterEnable(); }
//***************************************************************************** // // Interrupt handlers // //***************************************************************************** void SysTickIntHandler(void){ // Handle state changes if (done){ tick++; if (tick>1){ if (lose){ // Turn off the noise PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, false); PWMGenDisable(PWM0_BASE, PWM_GEN_0); unsigned long ulPeriod = SysCtlClockGet() / 220; // Set the PWM period to 220 (A) Hz. PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod); // Make some noise again PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true); PWMGenEnable(PWM0_BASE, PWM_GEN_0); } } if (tick>2){ if (lose){ // Turn off the noise PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, false); PWMGenDisable(PWM0_BASE, PWM_GEN_0); unsigned long ulPeriod = SysCtlClockGet() / 440; // Set the PWM period to 440 (A) Hz. again PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod); lose = 0; } if (state==1){ startClassic(); tick = 0; done = 0; } else if(state==2){ if(tick>4){ RIT128x96x4Clear(); initMain(); state = 0; pointer = 0; tick = 0; done = 0; } } else if (state==3){ startContinuous(); tick = 0; done = 0; } } } }
//***************************************************************************** // //! Initialize the OLED display. //! //! \param ulFrequency specifies the SSI Clock Frequency to be used. //! //! This function initializes the SSI interface to the OLED display and //! configures the SSD1329 controller on the panel. //! //! \return None. // //***************************************************************************** void RIT128x96x4Init(unsigned long ulFrequency) { unsigned long ulIdx; // Initialize the semaphore OS_InitSemaphore(&oLEDFree, 1); // // Enable the SSI0 and GPIO port blocks as they are needed by this driver. // SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIO_OLEDDC); // // Configure the SSI0CLK and SSIOTX pins for SSI operation. // GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5); GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU); // // Configure the GPIO port pin used as a D/Cn signal for OLED device, // and the port pin used to enable power to the OLED panel. // GPIOPinTypeGPIOOutput(GPIO_OLEDDC_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN); GPIOPadConfigSet(GPIO_OLEDDC_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPinWrite(GPIO_OLEDDC_BASE, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN, GPIO_OLEDDC_PIN | GPIO_OLEDEN_PIN); HWREGBITW(&g_ulSSIFlags, FLAG_DC_HIGH) = 1; // // Configure and enable the SSI0 port for master mode. // RIT128x96x4Enable(ulFrequency); // // Clear the frame buffer. // RIT128x96x4Clear(); // // Initialize the SSD1329 controller. Loop through the initialization // sequence array, sending each command "string" to the controller. // for(ulIdx = 0; ulIdx < sizeof(g_pucRIT128x96x4Init); ulIdx += g_pucRIT128x96x4Init[ulIdx] + 1) { // // Send this command. // RITWriteCommand(g_pucRIT128x96x4Init + ulIdx + 1, g_pucRIT128x96x4Init[ulIdx] - 1); } }
int main (void) { char string1[] = "Serial Analyzer Transmit and Receive Test"; //char string2[] = {0x48, 0x65, 0x6C, 0x6C, 0x6F}; //hello RIT128x96x4Clear(); #ifdef TX DriverRegisters SADreg; // push a string onto the circle buffer if((pushchunk_cbuff(&SADreg.circbuf, string1, sizeof(string1)/sizeof(string1[0])))<=0) { RIT128x96x4Clear(); RIT128x96x4StringDraw("Circle Buff Failure!", 32, 24, 15); while(1) { // Stop program and display failure message } } //Intitialize driver, can set baud rate to 1200, 2400, 9600, or 38400 SAD_Initialize( &SADreg, TXER, 9600); // RIT128x96x4StringDraw("Transmitter", 32, 24, 15); while (1){ SAD_StateMachine(&SADreg); } #endif /* TX */ #ifdef RX DriverRegisters SADreg; //Intitialize driver, can set baud rate to 1200, 2400, 9600, or 38400 SAD_Initialize(&SADreg, RXER, 2400); // RIT128x96x4StringDraw("Receiver", 32, 24, 15); while(1){ SAD_StateMachine(&SADreg); } #endif /* RX */ return 0; }
void displaySet(){ char debugmode[20]; firstDigital=1; firstCountDown = 1; firstStopWatch = 1; switch(setMode){ case 0: if (firstNotAnalog == 1) RIT128x96x4Clear(); firstNotAnalog = 0; sprintf(debugmode, "Set Time"); break; case 1: if (firstNotAnalog == 1) RIT128x96x4Clear(); firstNotAnalog = 0; sprintf(debugmode, "Set Alarm"); break; case 2: sprintf(debugmode, "Set Countdown"); break; } RIT128x96x4StringDraw(debugmode, 10, 10, 15); if (setMode ==0){ //set time drawInactiveTimer(); drawDigitalValue(hours24_temp, minutes_temp, seconds_temp); } else if (setMode ==1){ //set alarm drawInactiveTimer(); drawDigitalValue(a_hours24_temp, a_minutes_temp, a_seconds_temp); } else if (setMode ==2) // set countdown { char time[20]; drawInactiveTimer(); sprintf(time, " %02d:%02d ", countMin_temp, countSec_temp); RIT128x96x4StringDraw(time, 30, 44, 15); } }
static void resetContinuous(void){ // Method for resetting all the variables for the game int i; for (i=0; i<26; i++){ selected[i] = "!"; } wotd = -1; correct = 0; position = 0; position2 = 0; RIT128x96x4Clear(); }
//------------Output_Clear------------ // Clears the OLED display. // Input: none // Output: none void Output_Clear(void){ int i, j; RIT128x96x4Clear(); // clear the screen for(i=0; i<TOTALCHARROWS; i=i+1){ for(j=0; j<TOTALCHARCOLUMNS; j=j+1){ CharBuffer[i][j] = 0; // clear screen contents ColorBuffer[i][j] = 0; } } CursorX = 0; // reset the cursors CursorY = 0; }
/* Pop messages from the queue and send to the OLED * display and UART. */ static void vSendTask( void *pvParameters ) { portBASE_TYPE xStatus; xQueueMessage xMessage; static portCHAR cMessage[ 100 ]; static unsigned int ulY, ulMaxY = mainMAX_ROWS_96; ulY = ulMaxY; for( ;; ) { /* Wait for a message to arrive that requires displaying. */ xStatus = xQueueReceive( xSendQueue, &xMessage, portMAX_DELAY ); /* Write the message on the next available row. */ ulY += mainCHARACTER_HEIGHT; if( ulY >= ulMaxY ) { ulY = mainCHARACTER_HEIGHT; RIT128x96x4Clear(); } if (xStatus == pdPASS) { switch (xMessage.type) { case (CURRENT_ALTITUDE): sprintf(cMessage, "Current Alt: %d", xMessage.pcMessage); break; case (DESIRED_ALTITUDE): sprintf(cMessage, "Desired Alt: %d", xMessage.pcMessage); break; case (PWM_DUTY): sprintf(cMessage, "PWM Duty: %d", xMessage.pcMessage); break; default: sprintf(cMessage, "Other: %d", xMessage.pcMessage); } RIT128x96x4StringDraw(cMessage, 0, ulY, 8); /* Uncomment to send on the UART as well */ // UARTSend( cMessage, 100 ); } } }
//! With this setup it would seem like main() must be the first function in this file, otherwise //! the wrong function gets called on reset. void main(void) { volatile INT32U ulLoop; volatile INT16U event; volatile INT16U push; //Hardware upstarts initHW(); //! Start the OLED display and write a message on it RIT128x96x4Init(ulSSI_FREQUENCY); RIT128x96x4StringDraw("EMP", 15, 42, mainFULL_SCALE); RIT128x96x4StringDraw("enter the code.....", 5, 49, mainFULL_SCALE); RIT128x96x4StringDraw("SW2 SW3 SW4 SW5 SW6", 15, 57, mainFULL_SCALE); // Entry Password see under inputs // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)); // Clean the OLED display. RIT128x96x4Clear(); // // Loop forever. // while (1) { // Statmashine function // This is where a statemachine could be added event = GetKeyEvents(); push = select_button(); statemashine(event , push); //all functions the } }
//! With this setup it would seem like main() must be the first function in this file, otherwise //! the wrong function gets called on reset. int main(void) { volatile unsigned long ulLoop; volatile int event; //Hardware upstarts initHW(); //! Start the OLED display and write a message on it RIT128x96x4Init(ulSSI_FREQUENCY); RIT128x96x4StringDraw("Home App Control", 5, 42, mainFULL_SCALE); RIT128x96x4StringDraw("enter the code.....", 5, 49, mainFULL_SCALE); // Entry Password see under inputs // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTF_BASE, GPIO_PIN_1)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)); // Wait for the select key to be pressed while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)); // Clean the OLED display. RIT128x96x4Clear(); // // Loop forever. // while (1) { // This is where a statemachine could be added // Statmashine function // This is where a statemachine could be added // event = GetKeyEvents(); statemashine(GetKeyEvents()); //all functions the } }
//***************************************************************************** // // Task to Display the systick count // //***************************************************************************** void Display(void *pvParameters){ char TimeString[32]; portTickType TaskStartTime; // // Initialize the OLED display and write status. // RIT128x96x4Clear(); RIT128x96x4StringDraw("FreeRTOS_Blinky", 8, 0, 8); // // Set up periodic execution // TaskStartTime = xTaskGetTickCount(); while(1){ sprintf(TimeString, "Chinmay: %d", xPortSysTickCount); RIT128x96x4StringDraw(TimeString, 24, 16, 15); vTaskDelayUntil(&TaskStartTime, 500); } }
int main(void) { /* Initialization Functions */ //Section to initialize switches and displays //Initialize display //used for system clock //Initialize Buttons LEDBARInit(); DIPSWInit(); PBSwInit(); RGB_LEDInit(); sysTickInit(); // potentiometersInit(); RIT128x96x4Init(1000000); RGB_LEDInit(); potentiometersInit(); RIT128x96x4Clear(); while(!progress) { //start on any button press progress = progress || read_PBSwitchNum(1) || read_PBSwitchNum(2) || read_PBSwitchNum(3); RIT128x96x4StringDraw("Tron", 100, 64, 15); //char is 6 wide by 8 tall, Tron = 24w, 8h //res 240 by 96 } progress = 0; //Display instructions while(!progress) { //40 chars will fill the screen progress = progress || read_PBSwitchNum(1) || read_PBSwitchNum(2) || read_PBSwitchNum(3); RIT128x96x4StringDraw("Navigate your", 0, 0, 15); RIT128x96x4StringDraw("lightcycle and avoid", 0, 8, 15); RIT128x96x4StringDraw("touching the paths", 0, 16, 15); RIT128x96x4StringDraw("First player to be", 0, 24, 15); RIT128x96x4StringDraw("trapped by a trail", 0, 32, 15); RIT128x96x4StringDraw("will be derezzed-lose", 0, 40, 15); } progress = 0; //Reset variables to initial state cpuX = 0; cpuY = 48; playerX = 239; playerY = 48; cpuDir = 2; playerDir = 0; while(!progress){ sysTickWait1mS(100); //read buttons to update player direction //rotate counter-clockwise playerDir = (playerDir - read_PBSwitchNum(1))%4; //rotate clockwise playerDir = (playerDir + read_PBSwitchNum(3))%4; //generate random direction for CPU //x = random(); //} //Update Coordinates in array and variables //Check for collisions //No collisions: display the array to the screen //Collision: Determine who collided and display win/lose screen //Go back to instruction screen } }
static void AppTaskDisplay(void *p_arg) { CPU_INT08U state; CPU_INT16U sec; OS_ERR err; (void)&p_arg; sec = 1u; state = 0u; while (DEF_ON) { OSTimeDlyHMSM(0u, 0u, sec, 300u, OS_OPT_TIME_HMSM_STRICT, &err); switch(state) { case 0: RIT128x96x4StringDraw("TEXAS", 29u, 0u, 15); RIT128x96x4StringDraw("INSTRUMENTS", 11u, 9u, 15); sec = 5u; state = 1u; break; case 1: RIT128x96x4Clear(); sec = 1u; state = 2u; break; case 2: RIT128x96x4StringDraw("EKS-LM3S8962", 21u, 0u, 15); RIT128x96x4StringDraw("CCS 5.3 - EX1", 18u, 9u, 15); RIT128x96x4StringDraw("$Rev:: 16 $", 18u, 18u, 15); sec = 5u; state = 3u; break; case 3: RIT128x96x4Clear(); sec = 1u; state = 4u; break; case 4: RIT128x96x4StringDraw( "MICRIUM", 27u, 0u, 15); RIT128x96x4StringDraw( "uC/OS-III", 21u, 9u, 15); sec = 5u; state = 5u; break; case 5: RIT128x96x4Clear(); sec = 1u; state = 0u; break; default: sec = 1u; state = 0u; break; } } }
void GPIOEIntHandler(void) { // Clear the GPIO interrupt GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3); // Disable Interrupts GPIOPinIntDisable(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3); GPIOPinIntDisable(GPIO_PORTF_BASE, GPIO_PIN_0); // If the clock has been set before, we need to disable SysTickInt if (start==1){ SysTickIntDisable(); } // Clear the OLED RIT128x96x4Clear(); // If the left button got us here, display that we are in set clock mode // If the right button got us here, display that we are in set alarm mode if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)==0){ RIT128x96x4StringDraw("Set Clock", 40, 0, 15); DisplayTime(); } else if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)==0){ RIT128x96x4StringDraw("Set Alarm", 40, 0, 15); DisplayTimeA(); } // If the left button is held down enable the time to be set while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)==0){ // While the up button is being pressed, the clock will increment if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==0){ // In order to slow the incrementing we count to 10000 first x++; if (x>9999){ // Show the increment DisplayIncrementedTime(); x = 0; } } // While the down button is being pressed, the clock will decrement if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==0){ // In order to slow the decrementing we count to 10000 first x++; if (x>9999){ // Show the decrement DisplayDecrementedTime(); x = 0; } } } // If the right button is held down enable the alarm to be set while (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)==0){ // While the up button is being pressed, the clock will increment if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==0){ // In order to slow the decrementing we count to 10000 first x++; if (x>9999){ // Show the increment DisplayIncrementedAlarm(); x = 0; } } // While the down button is being pressed, the clock will decrement if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==0){ // In order to slow the decrementing we count to 10000 first x++; if (x>9999){ // Show the decrement DisplayDecrementedAlarm(); x = 0; } } alarmSet = 1; } RIT128x96x4Clear(); // Enable the interrupts GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3); GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_0); // If the start variable is not set, we set it and start SysTick if (!start){ start++; t = 0; SysTickIntEnable(); SysTickEnable(); } else { SysTickIntEnable(); } }
// This method is the task that runs the User-Interface system for the RoboTank system on the OLED display. // It starts off with a screen asking to press select, then asks the user to press manual mode // or autonomous mode. Then once a mode is chosen, the user is prompted with an option to run in fast/slow mode. // Then, once that is chosen the menu displays the distance values from the sensor. void vTaskDisplay(void *vParameters) { while(1) { if (pastKey != currentKey) { pastKey = currentKey; int prev = state; /****************************/ // This if/else structures controls what state to go into. The state // corresponds to what is being displayed on the OLED display. if (state == 0) { state = 1; } else if (state == 1) { if (currentKey == 5) { state = 2; RIT128x96x4Clear(); } } else if (state == 2) { if (currentKey == 1) { state = 7; } else if (currentKey == 2) { state = 3; } else if (currentKey == 5) { state = 4; } } else if (state == 3) { if (currentKey == 1) { state = 2; } else if (currentKey == 2) { state = 7; } else if (currentKey == 5) { state = 5; auton = 1; GPIO_PORTD_DATA_R = 0x40; } } else if (state == 4) { if(currentKey == 1){ fast = 1; state = 6; GPIO_PORTD_DATA_R = 0x40; } else if(currentKey == 2){ fast = 0; state = 6; GPIO_PORTD_DATA_R = 0x40; } } else if (state == 5) { if (currentKey == 5) { state = 2; auton = 0; GPIO_PORTD_DATA_R &= ~(0x40); } } else if(state == 6){ if (currentKey == 5) { state = 2; fast = 0; GPIO_PORTD_DATA_R &= ~(0x40); } } else if (state == 7) { if (currentKey == 1) { state = 3; } else if (currentKey == 2) { state = 2; } else if (currentKey == 5) { state = 8; } } else if (state == 8) { if(currentKey == 1){ fast = 1; auton = 3; state = 9; GPIO_PORTD_DATA_R = 0x40; } else if(currentKey == 2){ fast = 0; auton = 3; state = 9; GPIO_PORTD_DATA_R = 0x40; } } else if (state == 9) { if (currentKey == 5) { fast = 0; auton = 0; state = 2; } } /****************************/ // This if/else structure indicates what to print out to the OLED display // depending on what state it is in from the previous if/else statement. if (prev != state) { RIT128x96x4Clear(); if (state == 1) { RIT128x96x4StringDraw("ROBO TANK!\0", 40, 0, 15); RIT128x96x4StringDraw("Press, SEL to start \0", 10, 10, 15); RIT128x96x4StringDraw("Denny Ly\0", 10, 30, 15); RIT128x96x4StringDraw("Eeshan Londhe\0", 10, 40, 15); RIT128x96x4StringDraw("Ruchira Kulkarni\0", 10, 50, 15); } else if (state == 2) { printState2Or3(40); } else if (state == 3) { printState2Or3(60); } else if(state == 4){ chooseSpeed(); } else if (state == 6) { RIT128x96x4StringDraw("Manual Mode \0", 33, 0, 15); printADCString(); } else if (state == 5) { RIT128x96x4StringDraw("Autonomous Mode\0", 23, 0, 15); printADCString(); } else if (state == 7) { printState2Or3(80); } else if (state == 8) { chooseSpeed(); } else if (state == 9) { RIT128x96x4StringDraw("Semi-Auto Mode\0", 26, 0, 15); printADCString(); } } } vTaskDelay(10); // delay of about 10 ms } }
void GPIOFIntHandler(void){ // Method for handling multiple functions for a select button press // Clear the GPIO interrupt GPIOPinIntClear(GPIO_PORTF_BASE, GPIO_PIN_1); // Disable Interrupts GPIOPinIntDisable(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPinIntDisable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3); // Check which state we are in if (state==0){ // This state handles the main menu if (pointer==0){ // Begin Classic Mode state = 1; startClassic(); } else if (pointer==1){ // Begin Continuous Mode state = 3; startClassic(); } else if (pointer==2){ // Show the instructions state = 2; RIT128x96x4Clear(); displayInstructions(); done = 1; } else if (pointer==3){ // Show the high scores state = 2; RIT128x96x4Clear(); displayScores(); done = 1; } else if (pointer==4){ state = 0; initMain(); } } else if (state==1){ // This state handles classic mode // Black out the letter that was selected int idx = position + position2; int pos = 0; char *puc_letter = alpha[idx]; if (idx>12){ pos = position2 * 10; RIT128x96x4StringDraw(puc_letter, pos, 87, 2); } else { pos = position * 10; RIT128x96x4StringDraw(puc_letter, pos, 75, 2); } // Add the letter to the list of selected letters int i; int wrong = 1; int used = 0; // Loop through the list until we find an empty spot to place the letter for (i=0; i<26; i++){ if (strcmp(selected[i],"!")==0){ selected[i] = puc_letter; break; } if (strcmp(selected[i],puc_letter)==0){ wrong = 0; used = 1; break; } } // Check to see if the letter was already used if (!used){ // Check the word to see if a letter matches the one selected. If it // does, we need to display the letters instead of an underscore for (i=0; i<strlen(words[wotd]); i++){ char w_let = words[wotd][i]; static char g[3]; usprintf(g, "%d", w_let); char p_let = *puc_letter; if (w_let==p_let){ wrong = 0; // Display the letter selected RIT128x96x4StringDraw(puc_letter, 10+i*10, 53, 15); correct++; } } } // Check to see if it was a wrong selection if (wrong==1){ // Increment the number of wrong attempts try++; // If the selection was wrong, we need to draw a piece of the hangman if (try==1){ drawHead(); } else if (try==2){ drawBody(); } else if (try==3){ drawRightArm(); } else if (try==4){
//***************************************************************************** // // Main Program // //***************************************************************************** int main(void) { unsigned long ulPeriod; // Set the clocking to run directly from the crystal. SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN | SYSCTL_XTAL_8MHZ); // Initialize the OLED display and write status. RIT128x96x4Init(1000000); // Enable the peripherals used by this application SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG); // Set GPIO F0 and G1 as PWM pins. They are used to output the PWM0 and // PWM1 signals. GPIOPinTypePWM(GPIO_PORTG_BASE, GPIO_PIN_1); // Compute the PWM period based on the system clock. ulPeriod = SysCtlClockGet() / 440; // Set the PWM period to 440 (A) Hz. PWMGenConfigure(PWM0_BASE, PWM_GEN_0, PWM_GEN_MODE_UP_DOWN | PWM_GEN_MODE_NO_SYNC); PWMGenPeriodSet(PWM0_BASE, PWM_GEN_0, ulPeriod); // Set PWM0 to a duty cycle of 25% and PWM1 to a duty cycle of 75%. PWMPulseWidthSet(PWM0_BASE, PWM_OUT_0, ulPeriod / 4); PWMPulseWidthSet(PWM0_BASE, PWM_OUT_1, ulPeriod * 3 / 4); // Enable the PWM0 and PWM1 output signals. PWMOutputState(PWM0_BASE, PWM_OUT_0_BIT | PWM_OUT_1_BIT, true); // Configure the 'up' button as input and enable the pin to interrupt on // the falling edge (i.e. when the push button is pressed). GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_0); GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_0, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Configure the 'down' button as input and enable the pin to interrupt on // the falling edge (i.e. when the push button is pressed). GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_1); GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Configure the 'left' button as input and enable the pin to interrupt on // the falling edge (i.e. when the push button is pressed). GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_2); GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_2, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); // Configure the 'right' button as input and enable the pin to interrupt on // the falling edge (i.e. when the push button is pressed). GPIOPinTypeGPIOInput(GPIO_PORTE_BASE, GPIO_PIN_3); GPIOPadConfigSet(GPIO_PORTE_BASE, GPIO_PIN_3, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOIntTypeSet(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3, GPIO_FALLING_EDGE); GPIOPortIntRegister(GPIO_PORTE_BASE, GPIOEIntHandler); GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_2 | GPIO_PIN_3); IntEnable(INT_GPIOE); // Configure the LED GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); // Configure the select buttons as input and enable the pin to interrupt on // the falling edge (i.e. when the push button is pressed). GPIOPinTypeGPIOInput(GPIO_PORTF_BASE, GPIO_PIN_1); GPIOPadConfigSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU); GPIOIntTypeSet(GPIO_PORTF_BASE, GPIO_PIN_1, GPIO_FALLING_EDGE); GPIOPortIntRegister(GPIO_PORTF_BASE, GPIOFIntHandler); GPIOPinIntEnable(GPIO_PORTF_BASE, GPIO_PIN_1); IntEnable(INT_GPIOF); // Initial time to display static char pcInitTime[10]; usprintf(pcInitTime, "%d%d:%d%d AM", h2, h1, m2, m1); // Set the time between SysTick interrupts and register the interrupt handle SysTickPeriodSet(SysCtlClockGet()); SysTickIntRegister(SysTickIntHandler); // Begin a blinking display of the initial start message while (!start){ int a; for (a=0; a<300000; a++){ if (a%20000==0){ RIT128x96x4StringDraw(pcInitTime, 40, 40, a/20000); } } } // The clock has started so we can clear the message RIT128x96x4Clear(); // Loop forever while(1) { // Display the updated time DisplayTime(); // Check if we should sound the alarm TisA(); } }
// convert button to character output void decodeLetter (char input) { if (input == '1') { display2[dLocx++] = '1'; } else if (input == 'U') { screenY--; if(motorOn) spin(1000); } else if (input == 'D') { screenY++; if(motorOn) spin(-1000); } else if (input == 'L') { if(motorOn==1) { PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, 1); motorOn = 0; } } else if (input == 'R') { PWMOutputState(PWM0_BASE, (PWM_OUT_2_BIT | PWM_OUT_3_BIT), true); if(motorOn==0) { PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, period); motorOn = 1; } PWMPulseWidthSet(PWM0_BASE, PWM_OUT_2, period); } else if (input == 'T') { if(dLocx != 0) { dLocx--; display2[dLocx] = '\0'; } } else if (input == 'S') { spinManual(atoi(display2)); RIT128x96x4Clear(); RIT128x96x4StringDraw("----------------------", 0, 50, 15); RIT128x96x4StringDraw(display, 0, 0, 15); display2[0] = '\0'; dLocx=0; return; } else if(input == 'P') { showError(); // Error } if (input == '2') { display2[dLocx++] = '2'; } else if (input == '3') { display2[dLocx++] = '3'; } else if (input == '4') { display2[dLocx++] = '4'; } else if (input == '5') { display2[dLocx++] = '5'; } else if (input == '6') { } else if (input == '7') { display2[dLocx++] = '7'; } else if (input == '8') { display2[dLocx++] = '8'; } else if (input == '9') { display2[dLocx++] = '9'; } else if (input == '0') { if (flag == 1) { if(dLocx != 0) { if (display2[dLocx - 1] == '0') display2[dLocx - 1] = ' '; else if (display2[dLocx - 1] == ' ') display2[dLocx - 1] = '0'; else display2[dLocx++] = '0'; } else display2[dLocx++] = '0'; } else display2[dLocx++] = '0'; } display2[dLocx] = '\0'; }
void dspRst(){ RIT128x96x4Clear(); cursorX=0; cursorY=0; }
//***************************************************************************** // //! Initialize the OLED display. //! //! \param ulFrequency specifies the SSI Clock Frequency to be used. //! //! This function initializes the SSI interface to the OLED display and //! configures the SSD1329 controller on the panel. //! //! This function is contained in <tt>rit128x96x4.c</tt>, with //! <tt>rit128x96x4.h</tt> containing the API definition for use by //! applications. //! //! \return None. // //***************************************************************************** void RIT128x96x4Init(unsigned long ulFrequency) { unsigned long ulIdx; /* Determine which board is being used. */ if( SysCtlPeripheralPresent( SYSCTL_PERIPH_ETH ) ) { /* Ethernet is present, we must be using the LM3S8962 EK. */ ulGPIOId = LM3S8962_SYSCTL_PERIPH_GPIO_OLEDDC; ulGPIOBase = LM3S8962_GPIO_OLEDDC_BASE; ulOLEDDC_PIN = GPIO_PIN_6; ulOLEDEN_PIN = GPIO_PIN_7; } else { /* Ethernet is not present, we must be using the LM3S1968 EK. */ ulGPIOId = LM3S1968_SYSCTL_PERIPH_GPIO_OLEDDC; ulGPIOBase = LM3S1968_GPIO_OLEDDC_BASE; ulOLEDDC_PIN = GPIO_PIN_2; ulOLEDEN_PIN = GPIO_PIN_3; } // // Enable the SSI0 and GPIO port blocks as they are needed by this driver. // SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(ulGPIOId); // // Configure the SSI0CLK and SSIOTX pins for SSI operation. // GPIOPinTypeSSI(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5); GPIOPadConfigSet(GPIO_PORTA_BASE, GPIO_PIN_2 | GPIO_PIN_3 | GPIO_PIN_5, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD_WPU); // // Configure the GPIO port pin used as a D/Cn signal for OLED device, // and the port pin used to enable power to the OLED panel. // GPIOPinTypeGPIOOutput(ulGPIOBase, ulOLEDDC_PIN | ulOLEDEN_PIN); GPIOPadConfigSet(ulGPIOBase, ulOLEDDC_PIN | ulOLEDEN_PIN, GPIO_STRENGTH_8MA, GPIO_PIN_TYPE_STD); GPIOPinWrite(ulGPIOBase, ulOLEDDC_PIN | ulOLEDEN_PIN, ulOLEDDC_PIN | ulOLEDEN_PIN); // // Configure and enable the SSI0 port for master mode. // RIT128x96x4Enable(ulFrequency); // // Clear the frame buffer. // RIT128x96x4Clear(); // // Initialize the SSD1329 controller. Loop through the initialization // sequence array, sending each command "string" to the controller. // for(ulIdx = 0; ulIdx < sizeof(g_pucRIT128x96x4Init); ulIdx += g_pucRIT128x96x4Init[ulIdx] + 1) { // // Send this command. // RITWriteCommand(g_pucRIT128x96x4Init + ulIdx + 1, g_pucRIT128x96x4Init[ulIdx] - 1); } }
void threadOLED(void) { volatile unsigned i; RIT128x96x4StringDraw("potatOS", 40, 40, 15); for(i=0; i<1000000; i++); RIT128x96x4Clear(); }
// ******************************************************* // clears the display void mDisplayClear(void) { RIT128x96x4Clear(); }
// convert button to character output void decodeLetter (char input) { if (input == '1') { display[dLocx++] = '1'; } else if (input == 'U') { screenY--; } else if (input == 'D') { screenY++; } else if (input == 'L') { screenX--; } else if (input == 'R') { screenX++; } else if (input == 'T') { if(dLocx != 0) { dLocx--; display[dLocx] = '\0'; } } else if (input == 'S') { // output display buffer to OLED display int i; createBuffer(); UARTSend (buffer, dLocx+9); RIT128x96x4Clear(); RIT128x96x4StringDraw("----------------------", 0, 50, 15); RIT128x96x4StringDraw(display, 0, 0, 15); RIT128x96x4StringDraw(display2, 0, 60, 15); for(i=0; i<dLocx + 1; i++) display[i]='\0'; dLocx=0; return; } else if(input == 'P') { showError(); // Error } if (dLocx != 0) { if (input == '2') { if (flag == 1) { if (display[dLocx - 1] == 'A') display[dLocx - 1] = 'B'; else if (display[dLocx - 1] == 'B') display[dLocx - 1] = 'C'; else if (display[dLocx - 1] == 'C') display[dLocx - 1] = '2'; else if (display[dLocx - 1] == '2') display[dLocx - 1] = 'A'; else display[dLocx++] = 'A'; } else { display[dLocx++] = 'A'; } } else if (input == '3') { if (flag == 1) { if (display[dLocx - 1] == 'D') display[dLocx - 1] = 'E'; else if (display[dLocx - 1] == 'E') display[dLocx - 1] = 'F'; else if (display[dLocx - 1] == 'F') display[dLocx - 1] = '3'; else if (display[dLocx - 1] == '3') display[dLocx - 1] = 'D'; else display[dLocx++] = 'D'; } else { display[dLocx++] = 'D'; } } else if (input == '4') { if (flag == 1) { if (display[dLocx - 1] == 'G') display[dLocx - 1] = 'H'; else if (display[dLocx - 1] == 'H') display[dLocx - 1] = 'I'; else if (display[dLocx - 1] == 'I') display[dLocx - 1] = '4'; else if (display[dLocx - 1] == '4') display[dLocx - 1] = 'G'; else display[dLocx++] = 'G'; } else { display[dLocx++] = 'G'; } } else if (input == '5') { if (flag == 1) { if (display[dLocx - 1] == 'J') display[dLocx - 1] = 'K'; else if (display[dLocx - 1] == 'K') display[dLocx - 1] = 'L'; else if (display[dLocx - 1] == 'L') display[dLocx - 1] = '5'; else if (display[dLocx - 1] == '5') display[dLocx - 1] = 'J'; else display[dLocx++] = 'J'; } else { display[dLocx++] = 'J'; } } else if (input == '6') { if (flag == 1) { if (display[dLocx - 1] == 'M') display[dLocx - 1] = 'N'; else if (display[dLocx - 1] == 'N') display[dLocx - 1] = 'O'; else if (display[dLocx - 1] == 'O') display[dLocx - 1] = '6'; else if (display[dLocx - 1] == '6') display[dLocx - 1] = 'M'; else display[dLocx++] = 'M'; } else { display[dLocx++] = 'M'; } } else if (input == '7') { if (flag == 1) { if (display[dLocx - 1] == 'P') display[dLocx - 1] = 'Q'; else if (display[dLocx - 1] == 'Q') display[dLocx - 1] = 'R'; else if (display[dLocx - 1] == 'R') display[dLocx - 1] = 'S'; else if (display[dLocx - 1] == 'S') display[dLocx - 1] = '7'; else if (display[dLocx - 1] == '7') display[dLocx - 1] = 'P'; else display[dLocx++] = 'P'; } else { display[dLocx++] = 'P'; } } else if (input == '8') { if (flag == 1) { if (display[dLocx - 1] == 'T') display[dLocx - 1] = 'U'; else if (display[dLocx - 1] == 'U') display[dLocx - 1] = 'V'; else if (display[dLocx - 1] == 'V') display[dLocx - 1] = '8'; else if (display[dLocx - 1] == '8') display[dLocx - 1] = 'T'; else display[dLocx++] = 'T'; } else { display[dLocx++] = 'T'; } } else if (input == '9') { if (flag == 1) { if (display[dLocx - 1] == 'W') display[dLocx - 1] = 'X'; else if (display[dLocx - 1] == 'X') display[dLocx - 1] = 'Y'; else if (display[dLocx - 1] == 'Y') display[dLocx - 1] = 'Z'; else if (display[dLocx - 1] == 'Z') display[dLocx - 1] = '9'; else if (display[dLocx - 1] == '9') display[dLocx - 1] = 'W'; else display[dLocx++] = 'W'; } else { display[dLocx++] = 'W'; } } else if (input == '0') { if (flag == 1) { if (display[dLocx - 1] == ' ') display[dLocx - 1] = '0'; else if (display[dLocx - 1] == '0') display[dLocx - 1] = ' '; else display[dLocx++] = ' '; } else { display[dLocx++] = ' '; } } } else { if (input == '2') { display[dLocx++] = 'A'; } else if (input == '3') { display[dLocx++] = 'D'; } else if (input == '4') { display[dLocx++] = 'G'; } else if (input == '5') { display[dLocx++] = 'J'; } else if (input == '6') { display[dLocx++] = 'M'; } else if (input == '7') { display[dLocx++] = 'P'; } else if (input == '8') { display[dLocx++] = 'T'; } else if (input == '9') { display[dLocx++] = 'W'; } else if (input == '0') { display[dLocx++] = ' '; } } display[dLocx] = '\0'; }