void menu_go(menuNode** menu, Controls* control){ move_arrow(&((*menu)->arrowLevel), &control->jsY, (*menu)->nChildren); OLED_clear(); OLED_print((*menu)->text,0,0); //Prints the title //Iterates through submenues and prints them for(int i=1; i<=(*menu)->nChildren; ++i){ //Prints a spaceinvader at the current arrow level. if((*menu)->arrowLevel == i){ OLED_print("-s",i,0); } else{ OLED_print(" ",i,0); } //The menu text is offset to the right by 2 to make room for the possible arrow OLED_print((*menu)->child[i-1]->text,i,2); } //Left/right joystick changes the menu level. //Go to the child currently pointed at if(control->jsX.descreet_edge > 0){ if((*menu)->arrowLevel !=0 &&((*menu)->arrowLevel <= (*menu)->nChildren)){ *menu = (*menu)->child[((*menu)->arrowLevel)-1]; } } //Go to parent else if(control->jsX.descreet_edge < 0){ if((*menu)->parent != NULL){ *menu = (*menu)->parent; } } }
void MENU_init(void) { OLED_clear(); OLED_write_align_center(64,1,"MENU"); OLED_write_align_left(36,3,"PLAY"); OLED_scroll_page_right(3,0); OLED_write_align_left(36,4,"OPTIONS"); OLED_write_align_left(36,5,"INFO"); }
void MENU_draw_loose(void) { OLED_clear(); OLED_write_align_center(64,1,"YOU LOOSE!"); OLED_write_align_center(64,2,"LIVES LEFT: "); OLED_write_char((lives + '0')); OLED_write_align_center(64,4,"NEW GAME"); OLED_scroll_page_right(4,0); OLED_write_align_center(64,5,"CONTINUE"); }
void OLED_init() { // Init the I2C interface (pins A4 and A5 on the Arduino Uno board) in Master Mode. Wire.begin(); // keywords: // SEG = COL = segment = column byte data on a page // Page = 8 pixel tall row. Has 128 SEGs and 8 COMs // COM = row // Begin the I2C comm with SSD1306's address (SLA+Write) Wire.beginTransmission(OLED_I2C_ADDRESS); // Tell the SSD1306 that a command stream is incoming Wire.write(OLED_CONTROL_BYTE_CMD_STREAM); // Follow instructions on pg.64 of the dataSheet for software configuration of the SSD1306 // Turn the Display OFF Wire.write(OLED_CMD_DISPLAY_OFF); // Set mux ration tp select max number of rows - 64 Wire.write(OLED_CMD_SET_MUX_RATIO); Wire.write(0x3F); // Set the display offset to 0 Wire.write(OLED_CMD_SET_DISPLAY_OFFSET); Wire.write(0x00); // Display start line to 0 Wire.write(OLED_CMD_SET_DISPLAY_START_LINE); // Mirror the x-axis. In case you set it up such that the pins are north. // Wire.write(0xA0); - in case pins are south - default Wire.write(OLED_CMD_SET_SEGMENT_REMAP); //Wire.write(0xA0); // Mirror the y-axis. In case you set it up such that the pins are north. // Wire.write(0xC0); - in case pins are south - default Wire.write(OLED_CMD_SET_COM_SCAN_MODE); //Wire.write(0xC0); // Default - alternate COM pin map Wire.write(OLED_CMD_SET_COM_PIN_MAP); Wire.write(0x12); // set contrast Wire.write(OLED_CMD_SET_CONTRAST); Wire.write(0x7F); // Set display to enable rendering from GDDRAM (Graphic Display Data RAM) Wire.write(OLED_CMD_DISPLAY_RAM); // Normal mode! Wire.write(OLED_CMD_DISPLAY_NORMAL); // Default oscillator clock Wire.write(OLED_CMD_SET_DISPLAY_CLK_DIV); Wire.write(0x80); // Enable the charge pump Wire.write(OLED_CMD_SET_CHARGE_PUMP); Wire.write(0x14); // Set precharge cycles to high cap type Wire.write(OLED_CMD_SET_PRECHARGE); Wire.write(0x22); // Set the V_COMH deselect volatage to max Wire.write(OLED_CMD_SET_VCOMH_DESELCT); Wire.write(0x30); // Horizonatal addressing mode - same as the KS108 GLCD Wire.write(OLED_CMD_SET_MEMORY_ADDR_MODE); Wire.write(0x00); // Turn the Display ON Wire.write(OLED_CMD_DISPLAY_ON); // End the I2C comm with the SSD1306 Wire.endTransmission(); OLED_clear(); }
void MENU_draw_ingame(void) { OLED_clear(); OLED_write_align_center(64,1,"IN GAME"); OLED_write_align_center(64,4,"LIVES : "); OLED_write_char((lives + '0')); }
void MENU_draw_mode_select(void) { OLED_clear(); OLED_write_align_left(36,3,"MANUAL"); OLED_scroll_page_right(3,0); OLED_write_align_left(36,4,"AUTO"); }
void MENU_draw_info(void) { OLED_clear(); OLED_write_align_left(36,2,"Made by:"); OLED_write_align_center(64,4,"Christoffer RE &"); OLED_write_align_center(64,5,"Erlend H"); }
void MENU_draw_options(void) { OLED_clear(); OLED_write_align_center(64,3,"There are no"); OLED_write_align_center(64,4,"options at the"); OLED_write_align_center(64,5,"moment"); }
void MENU_draw_play(void) { OLED_clear(); OLED_write_align_center(64,3,"PLAYING..."); }