1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 16:25:31 +03:00

Correct switch indentation and function name

This commit is contained in:
Dan Nixon 2016-09-24 16:26:21 +01:00
parent bd699f1353
commit 814c043d01

View file

@ -755,120 +755,120 @@ uint8_t osdHandleKey(uint8_t key)
p = currentMenu + currentMenuPos; p = currentMenu + currentMenuPos;
switch (p->type) { switch (p->type) {
case OME_POS: case OME_POS:
if (key == KEY_RIGHT) {
uint32_t address = (uint32_t)p->data;
uint16_t *val;
val = (uint16_t *)address;
if (!(*val & VISIBLE_FLAG)) // no submenu for hidden elements
break;
}
case OME_Submenu:
case OME_OSD_Exit:
if (p->func && key == KEY_RIGHT) {
p->func(p->data);
res = BUTTON_PAUSE;
}
break;
case OME_Back:
osdMenuBack();
res = BUTTON_PAUSE;
break;
case OME_Bool:
if (p->data) {
uint8_t *val = p->data;
if (key == KEY_RIGHT)
*val = 1;
else
*val = 0;
}
break;
case OME_VISIBLE:
if (p->data) {
uint32_t address = (uint32_t)p->data;
uint16_t *val;
val = (uint16_t *)address;
if (key == KEY_RIGHT)
*val |= VISIBLE_FLAG;
else
*val %= ~VISIBLE_FLAG;
}
break;
case OME_UINT8:
case OME_FLOAT:
if (p->data) {
OSD_UINT8_t *ptr = p->data;
if (key == KEY_RIGHT) { if (key == KEY_RIGHT) {
if (*ptr->val < ptr->max) uint32_t address = (uint32_t)p->data;
*ptr->val += ptr->step; uint16_t *val;
}
else {
if (*ptr->val > ptr->min)
*ptr->val -= ptr->step;
}
}
break;
case OME_TAB:
if (p->type == OME_TAB) {
OSD_TAB_t *ptr = p->data;
if (key == KEY_RIGHT) { val = (uint16_t *)address;
if (*ptr->val < ptr->max) if (!(*val & VISIBLE_FLAG)) // no submenu for hidden elements
*ptr->val += 1; break;
} }
else { case OME_Submenu:
if (*ptr->val > 0) case OME_OSD_Exit:
*ptr->val -= 1; if (p->func && key == KEY_RIGHT) {
}
if (p->func)
p->func(p->data); p->func(p->data);
} res = BUTTON_PAUSE;
break;
case OME_INT8:
if (p->data) {
OSD_INT8_t *ptr = p->data;
if (key == KEY_RIGHT) {
if (*ptr->val < ptr->max)
*ptr->val += ptr->step;
} }
else { break;
if (*ptr->val > ptr->min) case OME_Back:
*ptr->val -= ptr->step; osdMenuBack();
res = BUTTON_PAUSE;
break;
case OME_Bool:
if (p->data) {
uint8_t *val = p->data;
if (key == KEY_RIGHT)
*val = 1;
else
*val = 0;
} }
} break;
break; case OME_VISIBLE:
case OME_UINT16: if (p->data) {
if (p->data) { uint32_t address = (uint32_t)p->data;
OSD_UINT16_t *ptr = p->data; uint16_t *val;
if (key == KEY_RIGHT) {
if (*ptr->val < ptr->max) val = (uint16_t *)address;
*ptr->val += ptr->step;
if (key == KEY_RIGHT)
*val |= VISIBLE_FLAG;
else
*val %= ~VISIBLE_FLAG;
} }
else { break;
if (*ptr->val > ptr->min) case OME_UINT8:
*ptr->val -= ptr->step; case OME_FLOAT:
if (p->data) {
OSD_UINT8_t *ptr = p->data;
if (key == KEY_RIGHT) {
if (*ptr->val < ptr->max)
*ptr->val += ptr->step;
}
else {
if (*ptr->val > ptr->min)
*ptr->val -= ptr->step;
}
} }
} break;
break; case OME_TAB:
case OME_INT16: if (p->type == OME_TAB) {
if (p->data) { OSD_TAB_t *ptr = p->data;
OSD_INT16_t *ptr = p->data;
if (key == KEY_RIGHT) { if (key == KEY_RIGHT) {
if (*ptr->val < ptr->max) if (*ptr->val < ptr->max)
*ptr->val += ptr->step; *ptr->val += 1;
}
else {
if (*ptr->val > 0)
*ptr->val -= 1;
}
if (p->func)
p->func(p->data);
} }
else { break;
if (*ptr->val > ptr->min) case OME_INT8:
*ptr->val -= ptr->step; if (p->data) {
OSD_INT8_t *ptr = p->data;
if (key == KEY_RIGHT) {
if (*ptr->val < ptr->max)
*ptr->val += ptr->step;
}
else {
if (*ptr->val > ptr->min)
*ptr->val -= ptr->step;
}
} }
} break;
break; case OME_UINT16:
case OME_Label: if (p->data) {
case OME_END: OSD_UINT16_t *ptr = p->data;
break; if (key == KEY_RIGHT) {
if (*ptr->val < ptr->max)
*ptr->val += ptr->step;
}
else {
if (*ptr->val > ptr->min)
*ptr->val -= ptr->step;
}
}
break;
case OME_INT16:
if (p->data) {
OSD_INT16_t *ptr = p->data;
if (key == KEY_RIGHT) {
if (*ptr->val < ptr->max)
*ptr->val += ptr->step;
}
else {
if (*ptr->val > ptr->min)
*ptr->val -= ptr->step;
}
}
break;
case OME_Label:
case OME_END:
break;
} }
return res; return res;
} }
@ -968,87 +968,88 @@ void osdDrawMenu(void)
max7456_write(LEFT_MENU_COLUMN + 2, i + top, p->text); max7456_write(LEFT_MENU_COLUMN + 2, i + top, p->text);
switch (p->type) { switch (p->type) {
case OME_POS: { case OME_POS: {
uint32_t address = (uint32_t)p->data;
uint16_t *val;
val = (uint16_t *)address;
if (!(*val & VISIBLE_FLAG))
break;
}
case OME_Submenu:
max7456_write(RIGHT_MENU_COLUMN, i + top, ">");
break;
case OME_Bool:
if (p->data) {
if (*((uint8_t *)(p->data)))
max7456_write(RIGHT_MENU_COLUMN, i + top, "YES");
else
max7456_write(RIGHT_MENU_COLUMN, i + top, "NO ");
}
break;
case OME_TAB: {
OSD_TAB_t *ptr = p->data;
max7456_write(RIGHT_MENU_COLUMN - 5, i + top, (char *)ptr->names[*ptr->val]);
} break;
case OME_VISIBLE:
if (p->data) {
uint32_t address = (uint32_t)p->data; uint32_t address = (uint32_t)p->data;
uint16_t *val; uint16_t *val;
val = (uint16_t *)address; val = (uint16_t *)address;
if (!(*val & VISIBLE_FLAG))
break;
}
case OME_Submenu:
max7456_write(RIGHT_MENU_COLUMN, i + top, ">");
break;
case OME_Bool:
if (p->data) {
if (*((uint8_t *)(p->data)))
max7456_write(RIGHT_MENU_COLUMN, i + top, "YES");
else
max7456_write(RIGHT_MENU_COLUMN, i + top, "NO ");
}
break;
case OME_TAB: {
OSD_TAB_t *ptr = p->data;
max7456_write(RIGHT_MENU_COLUMN - 5, i + top, (char *)ptr->names[*ptr->val]);
break;
}
case OME_VISIBLE:
if (p->data) {
uint32_t address = (uint32_t)p->data;
uint16_t *val;
if (VISIBLE(*val)) val = (uint16_t *)address;
max7456_write(RIGHT_MENU_COLUMN, i + top, "YES");
else if (VISIBLE(*val))
max7456_write(RIGHT_MENU_COLUMN, i + top, "NO "); max7456_write(RIGHT_MENU_COLUMN, i + top, "YES");
} else
break; max7456_write(RIGHT_MENU_COLUMN, i + top, "NO ");
case OME_UINT8: }
if (p->data) { break;
OSD_UINT8_t *ptr = p->data; case OME_UINT8:
itoa(*ptr->val, buff, 10); if (p->data) {
max7456_write(RIGHT_MENU_COLUMN, i + top, " "); OSD_UINT8_t *ptr = p->data;
max7456_write(RIGHT_MENU_COLUMN, i + top, buff); itoa(*ptr->val, buff, 10);
} max7456_write(RIGHT_MENU_COLUMN, i + top, " ");
break; max7456_write(RIGHT_MENU_COLUMN, i + top, buff);
case OME_INT8: }
if (p->data) { break;
OSD_INT8_t *ptr = p->data; case OME_INT8:
itoa(*ptr->val, buff, 10); if (p->data) {
max7456_write(RIGHT_MENU_COLUMN, i + top, " "); OSD_INT8_t *ptr = p->data;
max7456_write(RIGHT_MENU_COLUMN, i + top, buff); itoa(*ptr->val, buff, 10);
} max7456_write(RIGHT_MENU_COLUMN, i + top, " ");
break; max7456_write(RIGHT_MENU_COLUMN, i + top, buff);
case OME_UINT16: }
if (p->data) { break;
OSD_UINT16_t *ptr = p->data; case OME_UINT16:
itoa(*ptr->val, buff, 10); if (p->data) {
max7456_write(RIGHT_MENU_COLUMN, i + top, " "); OSD_UINT16_t *ptr = p->data;
max7456_write(RIGHT_MENU_COLUMN, i + top, buff); itoa(*ptr->val, buff, 10);
} max7456_write(RIGHT_MENU_COLUMN, i + top, " ");
break; max7456_write(RIGHT_MENU_COLUMN, i + top, buff);
case OME_INT16: }
if (p->data) { break;
OSD_UINT16_t *ptr = p->data; case OME_INT16:
itoa(*ptr->val, buff, 10); if (p->data) {
max7456_write(RIGHT_MENU_COLUMN, i + top, " "); OSD_UINT16_t *ptr = p->data;
max7456_write(RIGHT_MENU_COLUMN, i + top, buff); itoa(*ptr->val, buff, 10);
} max7456_write(RIGHT_MENU_COLUMN, i + top, " ");
break; max7456_write(RIGHT_MENU_COLUMN, i + top, buff);
case OME_FLOAT: }
if (p->data) { break;
OSD_FLOAT_t *ptr = p->data; case OME_FLOAT:
simple_ftoa(*ptr->val * ptr->multipler, buff); if (p->data) {
max7456_write(RIGHT_MENU_COLUMN - 1, i + top, " "); OSD_FLOAT_t *ptr = p->data;
max7456_write(RIGHT_MENU_COLUMN - 1, i + top, buff); simple_ftoa(*ptr->val * ptr->multipler, buff);
} max7456_write(RIGHT_MENU_COLUMN - 1, i + top, " ");
break; max7456_write(RIGHT_MENU_COLUMN - 1, i + top, buff);
case OME_OSD_Exit: }
case OME_Label: break;
case OME_END: case OME_OSD_Exit:
case OME_Back: case OME_Label:
break; case OME_END:
case OME_Back:
break;
} }
i++; i++;
@ -1245,18 +1246,18 @@ void osdUpdate(uint8_t guiKey)
x = OSD_X(*currentElement); x = OSD_X(*currentElement);
y = OSD_Y(*currentElement); y = OSD_Y(*currentElement);
switch (key) { switch (key) {
case KEY_UP: case KEY_UP:
y--; y--;
break; break;
case KEY_DOWN: case KEY_DOWN:
y++; y++;
break; break;
case KEY_RIGHT: case KEY_RIGHT:
x++; x++;
break; break;
case KEY_LEFT: case KEY_LEFT:
x--; x--;
break; break;
} }
*currentElement &= 0xFC00; *currentElement &= 0xFC00;
@ -1414,7 +1415,7 @@ void osdOpenMenu(void)
#endif // LED_STRIP #endif // LED_STRIP
} }
void drawElementPositioningHelp(void) void osdDrawElementPositioningHelp(void)
{ {
max7456_write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), "--- HELP --- "); max7456_write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), "--- HELP --- ");
max7456_write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 1, "USE ROLL/PITCH"); max7456_write(OSD_X(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]), OSD_Y(OSD_cfg.item_pos[OSD_ARTIFICIAL_HORIZON]) + 1, "USE ROLL/PITCH");
@ -1428,7 +1429,7 @@ void osdDrawElements(void)
max7456_clear_screen(); max7456_clear_screen();
if (currentElement) if (currentElement)
drawElementPositioningHelp(); osdDrawElementPositioningHelp();
else if (sensors(SENSOR_ACC) || inMenu) else if (sensors(SENSOR_ACC) || inMenu)
osdDrawSingleElement(OSD_ARTIFICIAL_HORIZON); osdDrawSingleElement(OSD_ARTIFICIAL_HORIZON);