 |
|
03-15-2011, 11:49 AM
|
#21
|
Aquarium Advice FINatic
Join Date: Sep 2008
Location: Boise ID
Posts: 757
|
Clean. if only my code was as pretty =( It gets the job done but it takes up way more memory than it needs to. (my code that is). I may steal your update time. Maybe you could help my with some code? I am using a voltage divider to run 3 buttons up down and enter and i have room for a forth, back or escpae. For the life of me I can wrap my head around using them to navigate a menu on the lcd. I want to have 4 choices on the screen and be able to go up and down the menu items until i hit enter and then it takes me to that submenu. I can figure out how to go down a tree
ie
hit enter
meny screen comes up
4 choices
a
b
c
d
if i hit down i can go to a b c or d if i over shood it can go d c b a. when i have selected something it goes to that menus sub menu ie a1 or b1 and so forth... I tried asking in the arduino forums but people just send me to libraries and things on the playground for things i dont want.
Sorry to hijack.
__________________
~Jason
36 BowFront Reef
LED PoweredPlanted 3G Picotope ( Build thread)
|
|
|
03-15-2011, 12:06 PM
|
#22
|
Aquarium Advice FINatic
Join Date: Aug 2009
Location: Cincinnati, OH
Posts: 581
|
If I understand what you're asking correctly, you could use a variable to denote where the cursor is. I'm not 100% clear on your interface so hopefully this will be enough to get you going:
Code:
void DrawCursor(int row) {
//clear off old cursor
lcd.setCursor(0, 0);
lcd.print(" ");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.setCursor(0, 2);
lcd.print(" ");
lcd.setCursor(0, 3);
lcd.print(" ");
//draw new cursor
lcd.setCursor(0, row);
lcd.print("*");
}
int cursor = 0;
//output menu options
lcd.setCursor(2, 0);
lcd.print("A");
lcd.setCursor(2, 1);
lcd.print("B");
lcd.setCursor(2, 2);
lcd.print("C");
lcd.setCursor(2, 3);
lcd.print("D");
do {
if (UP button pressed) {
cursor++;
if (cursor > 3) {
cursor = 3;
}
}
if (DOWN button pressed) {
cursor--;
if (cursor < 0) {
cursor = 0;
}
}
DrawCursor(cursor);
} while (OK button not pressed);
//cursor will now hold the value of what they selected
__________________
-Adam Horton-
|
|
|
03-15-2011, 04:28 PM
|
#23
|
Aquarium Advice FINatic
Join Date: Sep 2008
Location: Boise ID
Posts: 757
|
see simple and exactly what I wanted.
and then something to the effect
if(ok button pressed)
}
go to sub menu for cursor number
}
thank you.
__________________
~Jason
36 BowFront Reef
LED PoweredPlanted 3G Picotope ( Build thread)
|
|
|
03-15-2011, 09:04 PM
|
#24
|
Aquarium Advice FINatic
Join Date: Aug 2009
Location: Cincinnati, OH
Posts: 581
|
Actually you don't even need your if (ok button pressed). You can just check the value of cursor after that last do/while loop, like this:
Code:
if (cursor == 0) {
//do stuff for first sub-menu option
} else if (cursor == 1) {
//...
}
In other news, it turns out that the orange LEDs I bought, that said they were waterproof... well, they aren't waterproof. One of them is shorting out. Looks like I'll be shopping for more orange LEDs...
__________________
-Adam Horton-
|
|
|
03-16-2011, 11:39 AM
|
#25
|
Aquarium Advice FINatic
Join Date: Sep 2008
Location: Boise ID
Posts: 757
|
That is usually the case. I bought submerisble LEDs for my reef tank I wanted to use them to highlight some corals at night. Plugged them in they seemed to work fine for a day or two but then at night the stopped coming on and my corals all looked pissed. My alarm kicked in on my PH meter well it was the stray voltage from the submerisbles good thing it was low voltage and the transformer only suppled like 100mA. I have seen people use a vacuum sealer to water proof and still keep the clarity...
__________________
~Jason
36 BowFront Reef
LED PoweredPlanted 3G Picotope ( Build thread)
|
|
|
03-16-2011, 11:41 AM
|
#26
|
Aquarium Advice FINatic
Join Date: Sep 2008
Location: Boise ID
Posts: 757
|
Quote:
Originally Posted by AdamHorton
Actually you don't even need your if (ok button pressed). You can just check the value of cursor after that last do/while loop, like this:
Code:
if (cursor == 0) {
//do stuff for first sub-menu option
} else if (cursor == 1) {
//...
}
In other news, it turns out that the orange LEDs I bought, that said they were waterproof... well, they aren't waterproof. One of them is shorting out. Looks like I'll be shopping for more orange LEDs...
|
I thought of that last night while I was incorporating the coding you came up with. and instead of if and else if I just used switch case to clean it up a bit.
__________________
~Jason
36 BowFront Reef
LED PoweredPlanted 3G Picotope ( Build thread)
|
|
|
03-16-2011, 06:17 PM
|
#27
|
Aquarium Advice FINatic
Join Date: Aug 2009
Location: Cincinnati, OH
Posts: 581
|
For posterity, I'm going to post a link to the new orange LEDs I'm buying. I'm going to replace the other side as well, even though it didn't break.
Flexible LED Strips
__________________
-Adam Horton-
|
|
|
03-19-2011, 11:02 PM
|
#28
|
Aquarium Advice FINatic
Join Date: Aug 2009
Location: Cincinnati, OH
Posts: 581
|
Well the LED strips came in today, a lot faster than expected. I replaced both sides with the new orange LED strips, and tested everything and it all looks great. I'll probably take some new pictures/video soon, but the tank is looking like it could be ready for fish in a week or so and so I'd rather wait for that, at least there will be something interesting to take a picture of.
__________________
-Adam Horton-
|
|
|
03-23-2011, 11:21 AM
|
#29
|
Aquarium Advice FINatic
Join Date: Sep 2008
Location: Boise ID
Posts: 757
|
nice!
__________________
~Jason
36 BowFront Reef
LED PoweredPlanted 3G Picotope ( Build thread)
|
|
|
 |
|
Thread Tools |
Search this Thread |
|
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|

» Vendor Spotlight (Deals & More) |
|
|
|
|
|
|
|
|
» Photo Contest Winners |
|
» Saltwater Discussions |
|
|
|
|
|
|
|
» Freshwater Discussions |
|
|
|
|
|
|
|
|
|
|
|
|
» Other Discussions & Classifieds |
|
|
|
|
|
|
|
|
|
|
|
|
|