Ejemplo n.º 1
0
void OledClear()
{

	OledClearBuffer();
	OledUpdate();

}
Ejemplo n.º 2
0
void PrintMaze() {
    //OledClearBuffer();
    const int grid[]={27,30,44,47,70,73,107,110,127,
                      50,53,79,82,90,93,127,
                      20,23,67,70,106,109,127};
    OledMoveTo(0,0);OledDrawRect(127,31);
    uint32_t xc = 0;
    uint32_t yc = 7;
    uint32_t ind = 0;
    OledMoveTo(xc,yc);
    while(1) {
    OledLineTo(grid[ind],yc);
    if (grid[ind++]==127) {
    yc+=8;
    OledMoveTo(0,yc);
    if(yc>30) break; //we're done
    }
    else OledMoveTo(grid[ind++],yc);
    }
    OledMoveTo(64,0);
    OledLineTo(64,23);
    OledMoveTo(40,7);
    OledLineTo(40,15);
    OledMoveTo(85,7);
    OledLineTo(85,23);
    OledMoveTo(96,23);
    OledLineTo(96,31);
    OledUpdate();
}
Ejemplo n.º 3
0
/*
    Initializes the OLED for debugging purposes
*/
void beginMyOled(){
   DelayInit();
   OledInit();

   OledSetCursor(0, 0);
   OledClearBuffer();
   OledUpdate();
}
Ejemplo n.º 4
0
void
OledPutChar(char ch)
	{

	OledDrawGlyph(ch);
	OledAdvanceCursor();
	if (fOledCharUpdate) {
		OledUpdate();
	}

}
Ejemplo n.º 5
0
void DisplayModeSelect() {
	// Print the mode select screen
	OledClearBuffer();
	OledSetCursor(0,0);
	OledPutString("Enter Interface");
	OledSetCursor(0,2);
	OledPutString("Button 1 = SPI");
	OledSetCursor(0,3);
	OledPutString("Button 2 = I2C");
	OledUpdate();
}
Ejemplo n.º 6
0
void DisplaySplashScreen() {
    // Print the splash screen before starting game
    OledClearBuffer();
    OledSetCursor(0,0);
    OledPutString("FC");
    OledSetCursor(3,1);
    OledPutString("Cerebot");
    OledSetCursor(2,2);
    OledPutString("Maze Puzzle");
    OledUpdate();
}
Ejemplo n.º 7
0
void
OledPutString(char * sz)
	{

	while (*sz != '\0') {
		OledDrawGlyph(*sz);
		OledAdvanceCursor();
		sz += 1;
	}

	if (fOledCharUpdate) {
		OledUpdate();
	}

}
Ejemplo n.º 8
0
void updateScreen()
{
    if (mevent == MORSE_EVENT_DOT) {
        tempsymb = ".";
        appendBot();
    } else if (mevent == MORSE_EVENT_DASH) {
        tempsymb = "-";
        appendBot();
    } else if (mevent == MORSE_EVENT_INTER_LETTER) {
        clrSymb();
        appendTop();
    } else if (mevent == MORSE_EVENT_INTER_WORD) {
        clrSymb();
        appendTop();
    }
    sprintf(display, "%s\n\n\n%s", clet, csymb);
    //    printf("\n%s", display);
    OledDrawString(display);
    OledUpdate();
}
Ejemplo n.º 9
0
/***	void IOShieldOledClass::updateDisplay(void)
**
**	Parameters:
**		none
**
**	Return Value:
**		none
**
**	Errors:
**		none
**
**	Description:
**		Update the OLED display with the contents of the memory buffer
*/
void IOShieldOledClass::updateDisplay(void)
{
	OledUpdate();
}
Ejemplo n.º 10
0
int main() {

    char t[2];
    char pos[2];
    DelayInit();                             //initializations and state resets
    OledInit();
    Timer2Init();
    initLEDs();
    initButtons();
    initRotary();
    setLEDstate(0);
    unsigned int time = 0;

    OledClearBuffer();                        //the OLED is cleared
    OledSetCursor(0, 0);                      //OLED cursor reset to first line
    OledPutString("ECE 2534 Lab 2");          //message displayed
    OledSetCursor(0, 1);                      //cursor moves to second line
    OledPutString("Thomas Yu");               //message displayed
    OledSetCursor(0, 2);                      //cursor moves to third
    OledPutString("LOCKED");                  //message displayed
    OledSetCursor(0, 3);                      //cursor moves to third
    OledPutString("0");                       //message displayed
    OledUpdate();

    while (1)
    {
        OledSetCursor(0, 3);                      //cursor moves to third
        sprintf(pos, "%-2d", state);              //state(int) converted to string
        OledPutString(pos);                       //message displayed
        OledUpdate();

        if (go == 1)
        {
            sec1000 = 0;                          //time reset
            while (sec1000 < 15000)               //increments for 15000 ms, or 15 secs
            {
                OledSetCursor(0, 3);                      //cursor moves to third
                sprintf(pos, "%-2d", state);
                OledPutString(pos);                       //current state updated
                OledUpdate();

                OledSetCursor(14,3);                        //the countdown is updated
                sprintf(t, "%-2u", (15 - (sec1000/1000)));  //the current time left in seconds is the
                OledPutString(t);                           //elapsed ms subtracted from 15000
                OledUpdate();

                if (unlocked == 1)
                {
                    setLEDstate(1);                         //if unlocked then the led is turned on
                    OledSetCursor(14,3);
                    OledPutString("  ");                    //the countdown is cleared
                    OledSetCursor(0,2);
                    OledPutString("OPEN  ");                //open is displayed
                    OledUpdate();

                    while (!getButtonState())               //this runs until button1 is pressed
                    {
                        OledSetCursor(0, 3);                // this block of code continues to update
                        sprintf(pos, "%-2d", state);        //the rotary position as it is moved
                        OledPutString(pos);                       
                        OledUpdate();
                    }

                    OledSetCursor(0,2);                     //after button1 is pressed, the lock is reset
                    OledPutString("LOCKED");
                    setLEDstate(0);
                    go = 0;
                    unlocked = 0;
                    r1 = 0;
                    lock = 0;
                }
            }

            if ( go != 0)                             //if go was never set back to zero, then the
            {                                         //correct combination was never entered
                unsigned int a = sec1000;             //and the timer ran out
                while (sec1000 < a + 1000)            //this while loop runs for 1 second
                {
                    OledSetCursor(7,3);               //Time Out! is displayed for the duration
                    OledPutString("Time Out!");
                    OledUpdate();
                }
                OledSetCursor(7,3);                   //Time Out! is cleared and the lock is reset
                OledPutString("         ");
                OledUpdate();
                go = 0;
                r1 = 0;
                lock = 0;
            }
            
        }
    }


   return 0;
}
Ejemplo n.º 11
0
int main()
{
    // Configure the device for maximum performance but do not change the PBDIV
    // Given the options, this function will change the flash wait states, RAM
    // wait state and enable prefetch cache but will not change the PBDIV.
    // The PBDIV value is already set via the pragma FPBDIV option above..
    SYSTEMConfig(F_SYS, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

    // Auto-configure the PIC32 for optimum performance at the specified operating frequency.
    SYSTEMConfigPerformance(F_SYS);

    // osc source, PLL multipler value, PLL postscaler , RC divisor
    OSCConfig(OSC_POSC_PLL, OSC_PLL_MULT_20, OSC_PLL_POST_1, OSC_FRC_POST_1);

    // Configure the PB bus to run at 1/4th the CPU frequency, so 20MHz.
    OSCSetPBDIV(OSC_PB_DIV_4);

    // Enable multi-vector interrupts
    INTEnableSystemMultiVectoredInt();
    INTEnableInterrupts();

    // Configure Timer 2 using PBCLK as input. We configure it using a 1:16 prescalar, so each timer
    // tick is actually at F_PB / 16 Hz, so setting PR2 to F_PB / 16 / 100 yields a .01s timer.
    OpenTimer2(T2_ON | T2_SOURCE_INT | T2_PS_1_16, F_PB / 16 / 100);

    // Set up the timer interrupt with a medium priority of 4.
    INTClearFlag(INT_T2);
    INTSetVectorPriority(INT_TIMER_2_VECTOR, INT_PRIORITY_LEVEL_4);
    INTSetVectorSubPriority(INT_TIMER_2_VECTOR, INT_SUB_PRIORITY_LEVEL_0);
    INTEnable(INT_T2, INT_ENABLED);

/******************************** Your custom code goes below here ********************************/
    int check;
    OledInit();
    AdcInit();
    LEDS_INIT();
    check = GameInit();

    if(check == STANDARD_ERROR) {
        FATAL_ERROR();
    }
    float currPage;
    float binSize;
    float titleSize;
    float descSize;
    float numPages;
    uint8_t roomExit;
    uint16_t adcValue = 0;

    while(1) {
        roomExit = GameGetCurrentRoomExits();
        LEDS_SET(roomExit);
        while(buttonEvents == 0) {
            descSize = GameGetCurrentRoomDescription(roomData.description);
            titleSize = GameGetCurrentRoomTitle(roomData.title);

            numPages = ((titleSize + descSize) / MAX_OLED_PIXELS);
            binSize = (ADC_MAX_VALUE / numPages);

            if(AdcChanged()) {
                adcValue = AdcRead();
            }

            currPage = (adcValue / binSize);
            if(currPage < 1) {
                char titleArray[TITLE_OLED_SPACE] = {0};
                char descriptionBuffer[FIRST_PG_DESCRIPTION_OLED_SPACE] = {0};

                strncpy(descriptionBuffer, roomData.description, DESCRIPTION_COPY);
                sprintf(titleArray, "%s\n%s", roomData.title, descriptionBuffer);

                OledClear(OLED_COLOR_BLACK);
                OledDrawString(titleArray);
            } else {
                char buffer[MAX_OLED_PIXELS] = {0};
                int buffIndex;
                buffIndex = (int)currPage * MAX_OLED_PIXELS;
                strncpy(buffer, (roomData.description + buffIndex - OFFSET), MAX_OLED_PIXELS);

                OledClear(OLED_COLOR_BLACK);
                OledDrawString(buffer);
            }
            OledUpdate();
        }

        if((buttonEvents & BUTTON_EVENT_4UP) && (roomExit & GAME_ROOM_EXIT_NORTH_EXISTS)) {
            GameGoNorth();
        } else if((buttonEvents & BUTTON_EVENT_3UP) && (roomExit & GAME_ROOM_EXIT_EAST_EXISTS)) {
            GameGoEast();
        } else if((buttonEvents & BUTTON_EVENT_2UP) && (roomExit & GAME_ROOM_EXIT_SOUTH_EXISTS)) {
            GameGoSouth();
        } else if((buttonEvents & BUTTON_EVENT_1UP) && (roomExit & GAME_ROOM_EXIT_WEST_EXISTS)) {
            GameGoWest();
        }
        buttonEvents = BUTTON_EVENT_NONE;
    }



/**************************************************************************************************/
    while (1);
}