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 OLED_print_string(char string[]){ for(uint8_t i = 0; i < strlen(string); i++){ OLED_print(string[i]); } }