Rickooo
Member level 3
Hello, I am working on nmenu code and I want to do switching ON the LED by using push button which then select the desired menu on OLED SSD1306 . There are three button, up down and select which is connected to b5, b6, b7 pin and I want output at bo, b1, b2. Please look to the image added below the text. Now how do I switch ON the led when I select the desired menu on OLED and that time other 2 led is off.
I have used this switch logic;
I don't know how do I frame this loop.
m2==1 mean that there is menu which is considered as m2==1
for eg:
1. ABC
2. DEF
3. GHI
and when m2==2 mean that when we go to sub menu of 1. ABC 2. DEF 3. GHI
and I wanna select sub menu of ABC, which is
1. 5V 1A
2. 5V 2A
3. 5V 3A
4. Back
If I just go with m2==2 then program get confuse with which menu it will go with, either ABC, DEF or GHI
Guide me what syntax do I use in it..
Awaiting your response.
Here is the image link:
http://postimg.cc/68js4q64
I have used this switch logic;
Code:
void discharging_USB() {
SSD1306_ClearDisplay();
cursor(starting_row);
SSD1306_GotoXY(starting_col, starting_row);
SSD1306_PutC("1. 5V 1A");
delay_ms(10);
start_row = starting_row;
start_row +=1;
SSD1306_GotoXY(starting_col, start_row);
SSD1306_PutC("2. 5V 2A");
delay_ms(10);
start_row +=1;
SSD1306_GotoXY(starting_col, start_row);
SSD1306_PutC("3. 5V 3A");
delay_ms(10);
start_row +=1;
SSD1306_GotoXY(starting_col, start_row);
SSD1306_PutC("4. Back");
delay_ms(100);
if (m2==1 && row_Ind == 1 && button_select==0){
m2++;
if( m2==2 && row_Ind ==1)
{
output_low(PIN_B0);
output_low(PIN_B1);
output_high(PIN_B2);
button_select==1;
}
else if (m2==2 && row_Ind ==2){
output_high(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
button_select==1;
}
else if (m2==3 && row_Ind ==3){
output_high(PIN_B0);
output_low(PIN_B1);
output_low(PIN_B2);
button_select==1;
}
else
{
output_low(PIN_B0);
output_low(PIN_B1);
output_high(PIN_B2);
button_select==1;
}
}
}
I don't know how do I frame this loop.
m2==1 mean that there is menu which is considered as m2==1
for eg:
1. ABC
2. DEF
3. GHI
and when m2==2 mean that when we go to sub menu of 1. ABC 2. DEF 3. GHI
and I wanna select sub menu of ABC, which is
1. 5V 1A
2. 5V 2A
3. 5V 3A
4. Back
If I just go with m2==2 then program get confuse with which menu it will go with, either ABC, DEF or GHI
Guide me what syntax do I use in it..
Awaiting your response.
Here is the image link:
http://postimg.cc/68js4q64
Last edited by a moderator: