Merge pull request #1153 from xinfab/negative_values_in_menu

Negative values in menu
This commit is contained in:
Bo Herrmannsen 2014-12-17 20:58:01 +01:00
commit 0b310ab6c5

View file

@ -1041,15 +1041,15 @@ void lcd_sdcard_menu()
#define menu_edit_type(_type, _name, _strFunc, scale) \ #define menu_edit_type(_type, _name, _strFunc, scale) \
void menu_edit_ ## _name () \ void menu_edit_ ## _name () \
{ \ { \
if ((int32_t)encoderPosition < minEditValue) \ if ((int32_t)encoderPosition < 0) \
encoderPosition = minEditValue; \ encoderPosition = 0; \
if ((int32_t)encoderPosition > maxEditValue) \ if ((int32_t)encoderPosition > maxEditValue) \
encoderPosition = maxEditValue; \ encoderPosition = maxEditValue; \
if (lcdDrawUpdate) \ if (lcdDrawUpdate) \
lcd_implementation_drawedit(editLabel, _strFunc(((_type)encoderPosition) / scale)); \ lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
if (LCD_CLICKED) \ if (LCD_CLICKED) \
{ \ { \
*((_type*)editValue) = ((_type)encoderPosition) / scale; \ *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
lcd_quick_feedback(); \ lcd_quick_feedback(); \
currentMenu = prevMenu; \ currentMenu = prevMenu; \
encoderPosition = prevEncoderPosition; \ encoderPosition = prevEncoderPosition; \
@ -1057,15 +1057,15 @@ void lcd_sdcard_menu()
} \ } \
void menu_edit_callback_ ## _name () \ void menu_edit_callback_ ## _name () \
{ \ { \
if ((int32_t)encoderPosition < minEditValue) \ if ((int32_t)encoderPosition < 0) \
encoderPosition = minEditValue; \ encoderPosition = 0; \
if ((int32_t)encoderPosition > maxEditValue) \ if ((int32_t)encoderPosition > maxEditValue) \
encoderPosition = maxEditValue; \ encoderPosition = maxEditValue; \
if (lcdDrawUpdate) \ if (lcdDrawUpdate) \
lcd_implementation_drawedit(editLabel, _strFunc(((_type)encoderPosition) / scale)); \ lcd_implementation_drawedit(editLabel, _strFunc(((_type)((int32_t)encoderPosition + minEditValue)) / scale)); \
if (LCD_CLICKED) \ if (LCD_CLICKED) \
{ \ { \
*((_type*)editValue) = ((_type)encoderPosition) / scale; \ *((_type*)editValue) = ((_type)((int32_t)encoderPosition + minEditValue)) / scale; \
lcd_quick_feedback(); \ lcd_quick_feedback(); \
currentMenu = prevMenu; \ currentMenu = prevMenu; \
encoderPosition = prevEncoderPosition; \ encoderPosition = prevEncoderPosition; \
@ -1083,8 +1083,8 @@ void lcd_sdcard_menu()
editLabel = pstr; \ editLabel = pstr; \
editValue = ptr; \ editValue = ptr; \
minEditValue = minValue * scale; \ minEditValue = minValue * scale; \
maxEditValue = maxValue * scale; \ maxEditValue = maxValue * scale - minEditValue; \
encoderPosition = (*ptr) * scale; \ encoderPosition = (*ptr) * scale - minEditValue; \
}\ }\
static void menu_action_setting_edit_callback_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue, menuFunc_t callback) \ static void menu_action_setting_edit_callback_ ## _name (const char* pstr, _type* ptr, _type minValue, _type maxValue, menuFunc_t callback) \
{ \ { \
@ -1097,8 +1097,8 @@ void lcd_sdcard_menu()
editLabel = pstr; \ editLabel = pstr; \
editValue = ptr; \ editValue = ptr; \
minEditValue = minValue * scale; \ minEditValue = minValue * scale; \
maxEditValue = maxValue * scale; \ maxEditValue = maxValue * scale - minEditValue; \
encoderPosition = (*ptr) * scale; \ encoderPosition = (*ptr) * scale - minEditValue; \
callbackFunc = callback;\ callbackFunc = callback;\
} }
menu_edit_type(int, int3, itostr3, 1) menu_edit_type(int, int3, itostr3, 1)