Create a switch case in simulink and generate a .c file

4 visualizaciones (últimos 30 días)
raj sakthi
raj sakthi el 7 de Mzo. de 2024
Respondida: Mark McBroom el 14 de Mzo. de 2024
u8 App_Lin_GetFullBrightnessLevel(u8 level)
{
  u8 l_Brightness = LIGHT_OFF;
  switch(level)
  {
    case 0u:{
      l_Brightness = FULL_BRIGHTNESS_LEVEL0;
      break;
    }
    case 1u:{
      l_Brightness = FULL_BRIGHTNESS_LEVEL1;
      break;
    }
    case 2u:{
      l_Brightness = FULL_BRIGHTNESS_LEVEL2;;
      break;
    }
    case 3u: {
      l_Brightness = FULL_BRIGHTNESS_LEVEL3;
      break;
    }
    case 4u: {
      l_Brightness = FULL_BRIGHTNESS_LEVEL4;
      break;
    }
    case 5u: {
      l_Brightness = FULL_BRIGHTNESS_LEVEL5;
      break;
    }
    case 6u:{
      l_Brightness = FULL_BRIGHTNESS_LEVEL6;
      break;
    }
    default:{
      l_Brightness = FULL_BRIGHTNESS_LEVEL0;
      break;
    }
  }
  return l_Brightness;
}
I just want like this

Respuestas (1)

Mark McBroom
Mark McBroom el 14 de Mzo. de 2024
You can do this in Simulink with a multi-port switch block and then generate code with Simulink coder or Embedded Coder.

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by