Skip to content

Adding submenus

As my basic menu system is now working (including looping menu scrolling)

The above video shows the scrolling in action on both the main menu and the waypoints menu.  Due to how my code is set up, it would be easy for me to add the capability to hold more waypoints.  At this point in time I am unsure how many waypoints I will need.  I am thinking Waypoint 1 could be the “home” waypoint, i.e. the location at which the UAV is launched.  2 and 3 could be set using the computer, and perhaps be the two locations that the UAV is frequently flown over at the falconry center.  4 and potentially 5 could be waypoints that are customisable in the field.  The user could walk to where they would like the UAV to hover, press a button to set their current GPS location as a waypoint, then be able to tell the UAV to fly to above that point with a single press.  This could be useful for falconry shows where spending large amounts of time carefully controlling the flight of the UAV may be undesirable.  Height would still need to be manually input however.

The video demonstrates that proceeding through the menu system causes the menu item pointer to remain at the previous screen’s location.  This should not be too difficult to fix.

I have recently installed Git, and have been uploading my code to GitHub.  It can be seen here: https://github.com/Birdress

I have decided to add an extra button to my breadboard prototype at this stage.  I already have up/down/back/ok buttons, which could make up the D-pad seen in the following design:

controller 5

I have found the back button I am currently using to act more like the Menu button, in that it returns to the top level menu.  This is because the menu system only really goes one level deep (aside from the top level) before you are entering in to flight modes etc. that you do not want to be able to back out of with the D-pad buttons.  I will almost certainly be refining the design of the controller based on the experience I have had so far.  The intended functionality of the button I have added will mostly resemble the “OK” button on the above diagram.  When the user has selected the submenu option they want using the cursor (such as flight mode up/down), they will then be able to press this button to toggle being in the mode.  When in this mode you may be using all four of the D-pad buttons to control the device, and so a seperate escape button is needed.  The up/down flight menu only really needs the up/down buttons, and so i attempted to combine it with the regular menu.  I attempted to add the following code under the switchok button’s code:

if (menuLevel==1 && menuItem==2){
int testval=5;
subMenu=1;
Serial.println(“In up/down mode”);
lcd.clear();
lcd.setCursor (0,0);
lcd.print(“Up/down mode”);
lcd.setCursor (0, 1);
lcd.print(“Press up/down”);
lcd.setCursor (0, 2);
lcd.print(“Height:”);
lcd.setCursor (8, 2);
lcd.print(testval);
}

This however causes the menu to go straight in to this mode when the user selects the flight control submenu.  I have also experienced issues with the values being printed in this mode being overwritten by the menu redraw.  I am hoping that implementing the extra button will help escape this.  I can use a variable to keep track of if I am in “menu mode” or not, hopefully avoiding all of the existing menu code if I am not in the menu.  This will probably lead to some messy code as I will be writing pieces of code for every individual submenu item, but I do not feel that I can easily generalise across them because they all ask for different behaviors.  It is possible that I will be able to refactor the code for simplicities sake at a later date.

Published inBSc Dissertation

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *