In the microcontroller program, I have several instructions that I would like to follow for each case on the switch, except for the default value. However, I do not want to write a function call or use a macro for each case.
Since this is for a microcontroller operating at a speed of 3-7 MHz, speed and code space are important. For instance:
switch(letter) { case a: ShowApple(); printf("You entered an english letter."); break; case b: ShowBananna(); printf("You entered an english letter."); break; ... case z: ShowZebra(); printf("You entered an english letter."); break; default: printf("You did not enter an english letter. Silly human!"); break; }
source share