Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7874917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T02:53:40+00:00 2026-06-03T02:53:40+00:00

Background I am working with and 8052 based microcontroller. I have an LCD and

  • 0

Background

I am working with and 8052 based microcontroller. I have an LCD and and encoder wheel hooked up. The user can navigate a menu displayed on the LCD by rotating and pressing the encoder wheel.

The rotation of the encoder wheel is interrupt based.

The direction the encoder wheel is being rotated (encoder_turn) is set inside of the encoder interrupt.

I call update_lcd() inside of a loop.

New Responsive Code

void update_lcd()                           
{

        //ENCODER TURN      
        switch(encoder_turn)
        {
            case RIGHT:
                 lcd_clear();
                 next_screen();
                 break;
            case LEFT:
                lcd_clear();
                previous_screen();
                break;
            default:
                break;
        }
 }

void next_screen()
{
    if(current_test_screen < screen5)
    {
        current_test_screen++;
    }

    draw_current_test_screen(); 
}

void draw_current_test_screen()
{
    switch(current_test_screen)
    {
        case screen1:
            draw_screen1();
            break;
        case screen2:
            draw_screen2();
            break;
        case screen3:
            draw_screen3();
            break;
        case screen4:
            draw_screen4();
            break;
        case screen5:
            draw_screen5();
            break;      
        default:
        break;
    }
}

Old Unresponsive Code

void update_lcd()                           
{

        //ENCODER TURN      
        switch(encoder_turn)
        {
            case RIGHT:
                 lcd_clear();
                 next_screen();
                 break;
            case LEFT:
                lcd_clear();
                previous_screen();
                break;
            default:
                break;
        }

        switch(current_test_screen)
        {
            case screen1:
                draw_screen1();
                break;
            case screen2:
                draw_screen2();
                break;
            case screen3:
                draw_screen3();
                break;
            case screen4:
                draw_screen4();
                break;
            case screen5:
               draw_screen5();
               break;       
            default:
               break;
       }


 }

void next_screen()
{
    if(current_test_screen < screen5)
    {
        current_test_screen++;
    }
}

The Question

Why is one responsive and the other completely useless?

When I say responsive I am referring to the fact that when I rotate the encoder the screen change is responsive. Both methods “work” but one is unacceptable from a usage standpoint.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T02:53:41+00:00Added an answer on June 3, 2026 at 2:53 am

    Those two pieces of code are almost equivalent, apart from one very subtle difference.

    If you try refactoring your old code to try make it look more like your new code, you find that your old code makes one extra function call. Look carefully at the difference:

    void update_lcd()                           
    {
            //ENCODER TURN      
            switch(encoder_turn)
            {
                case RIGHT:
                     lcd_clear();
                     next_screen();
                     break;
                case LEFT:
                    lcd_clear();
                    previous_screen();
                    break;
                default:
                    draw_current_test_screen();   // <--- your new code omits this call
                    break;
            }
     }
    

    Try taking your new code and adding that line and see if it causes the unresponsiveness problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: working a user q&a site where users logged,etc. What user/visitor data should be
I read this post but I can't get it working: Change Background Color... I
Background - I can get HttpListener working fine for HTTP traffic. I'm having trouble
Some background I'm currently working on a mobile site so I keep switching user
background:Me and my coworkers are working on asp.net mvc project ... we have a
Background I'm working on an application which requires user-entered content, and I've decided to
Background : I am working on a framework that generates C++ code based on
Background: I am working on a legacy DB2 database, so I have no control
Background: I am working on a proposal for a PHP/web-based P2P replication layer for
Background I'm working on a an educational JavaScript application/site (SPA) that will eventually have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.