Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Poderia ter uma função para abordar todos esses casos + callback se necessário #3

Open
eduardomarossi opened this issue May 1, 2019 · 2 comments

Comments

@eduardomarossi
Copy link

void slice_right_callback(void){
if(unlocked_flag){
draw_screen();
if(laundry_event == 0){
laundry_event = 1;
draw_heavy_page();
botoes[0] = botaoLavagemPesada;
}
else if(laundry_event == 1){
laundry_event = 2;
draw_fast_page();
botoes[0] = botaoLavagemRapida;
}
else if(laundry_event == 2){
laundry_event = 0;
draw_diary_page();
botoes[0] = botaoLavagemDiaria;
}
botoes[1] = botaoDireita;
botoes[2] = botaoEsquerda;
botoes[3] = botaoUnlock;
botoes[4] = botaoLock;
n_botoes_na_tela = 5;
}
}
void slice_left_callback(void){
if(unlocked_flag){
draw_screen();
if(laundry_event == 0){
laundry_event = 2;
draw_fast_page();
botoes[0] = botaoLavagemRapida;
}
else if(laundry_event == 1){
laundry_event = 0;
draw_diary_page();
botoes[0] = botaoLavagemDiaria;
}
else if(laundry_event == 2){
laundry_event = 1;
draw_heavy_page();
botoes[0] = botaoLavagemPesada;
}
botoes[1] = botaoDireita;
botoes[2] = botaoEsquerda;
botoes[3] = botaoUnlock;
botoes[4] = botaoLock;
n_botoes_na_tela = 5;
}
}

@Veguinho
Copy link
Collaborator

Veguinho commented May 2, 2019

Mas qual parte poderia ter sido colocada em uma função? Porque essa função já faz apenas uma tarefa, que é mudar a pagina na navegação...

@eduardomarossi
Copy link
Author

Um possível exemplo.

void slice_right_callback(void){ 
      laundry_event = (laundry_event + 1) % 3;
      draw_laundry_screen(laundry_event);
}

void slice_right_callback(void){ 
      laundry_event = laundry_event - 1;
     if(laundry_event < 0) laundry_event = 2;
      draw_laundry_screen(laundry_event);
}



void draw_laundry_screen(int laundry_type) {
if(!unlocked_flag) return;
draw_screen(); 
switch(laundry_type) {
     case 0: 
              laundry_event = 1; 
 	      draw_heavy_page(); 
 	     botoes[0] = botaoLavagemPesada; 
            break;

     ... (mesmo pros outros casos)
}
botoes[1] = botaoDireita; 
 botoes[2] = botaoEsquerda; 
 botoes[3] = botaoUnlock; 
 botoes[4] = botaoLock; 
 n_botoes_na_tela = 5;
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants