Merge pull request #1056 from mkbel/prdel

Reserve space for MENU_ITEM_EDIT_int3_P in shared memory
This commit is contained in:
PavelSindler 2018-08-25 16:55:56 +02:00 committed by GitHub
commit 255cd2f34e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 35 deletions

View File

@ -14,10 +14,14 @@
extern int32_t lcd_encoder; extern int32_t lcd_encoder;
#define MENU_DEPTH_MAX 4
menu_record_t menu_stack[MENU_DEPTH_MAX]; static menu_record_t menu_stack[MENU_DEPTH_MAX];
uint8_t menu_data[MENU_DATA_SIZE]; uint8_t menu_data[MENU_DATA_SIZE];
#ifndef __AVR__
#error "menu_data is non-portable to non 8bit processor"
#endif
uint8_t menu_depth = 0; uint8_t menu_depth = 0;
@ -33,6 +37,8 @@ uint8_t menu_leaving = 0;
menu_func_t menu_menu = 0; menu_func_t menu_menu = 0;
static_assert(sizeof(menu_data)>= sizeof(menu_data_edit_t),"menu_data_edit_t doesn't fit into menu_data");
void menu_goto(menu_func_t menu, const uint32_t encoder, const bool feedback, bool reset_menu_state) void menu_goto(menu_func_t menu, const uint32_t encoder, const bool feedback, bool reset_menu_state)
{ {
@ -296,15 +302,6 @@ void menu_draw_float13(char chr, const char* str, float val)
lcd_printf_P(menu_fmt_float13, chr, str, spaces, val); lcd_printf_P(menu_fmt_float13, chr, str, spaces, val);
} }
typedef struct
{
//Variables used when editing values.
const char* editLabel;
void* editValue;
int32_t minEditValue;
int32_t maxEditValue;
} menu_data_edit_t;
void _menu_edit_int3(void) void _menu_edit_int3(void)
{ {
menu_data_edit_t* _md = (menu_data_edit_t*)&(menu_data[0]); menu_data_edit_t* _md = (menu_data_edit_t*)&(menu_data[0]);

View File

@ -4,9 +4,7 @@
#include <inttypes.h> #include <inttypes.h>
#define MENU_DEPTH_MAX 4
#define MENU_DATA_SIZE 32 #define MENU_DATA_SIZE 32
#define MENU_DATA_EDIT_SIZE 12
//Function pointer to menu functions. //Function pointer to menu functions.
typedef void (*menu_func_t)(void); typedef void (*menu_func_t)(void);
@ -17,7 +15,14 @@ typedef struct
int8_t position; int8_t position;
} menu_record_t; } menu_record_t;
extern menu_record_t menu_stack[MENU_DEPTH_MAX]; typedef struct
{
//Variables used when editing values.
const char* editLabel;
void* editValue;
int32_t minEditValue;
int32_t maxEditValue;
} menu_data_edit_t;
extern uint8_t menu_data[MENU_DATA_SIZE]; extern uint8_t menu_data[MENU_DATA_SIZE];

View File

@ -2090,9 +2090,7 @@ static void lcd_support_menu()
uint8_t ip[4]; // 4bytes uint8_t ip[4]; // 4bytes
char ip_str[3*4+3+1]; // 16bytes char ip_str[3*4+3+1]; // 16bytes
} _menu_data_t; } _menu_data_t;
#if (22 > MENU_DATA_SIZE) static_assert(sizeof(menu_data)>= sizeof(_menu_data_t),"_menu_data_t doesn't fit into menu_data");
#error "check MENU_DATA_SIZE definition!"
#endif
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]); _menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if (_md->status == 0 || lcd_draw_update == 2) if (_md->status == 0 || lcd_draw_update == 2)
{ {
@ -2421,6 +2419,7 @@ static void lcd_menu_AutoLoadFilament()
} }
else else
{ {
static_assert(sizeof(menu_data)>=sizeof(ShortTimer), "ShortTimer doesn't fit into menu_data");
ShortTimer* ptimer = (ShortTimer*)&(menu_data[0]); ShortTimer* ptimer = (ShortTimer*)&(menu_data[0]);
if (!ptimer->running()) ptimer->start(); if (!ptimer->running()) ptimer->start();
lcd_set_cursor(0, 0); lcd_set_cursor(0, 0);
@ -2537,9 +2536,7 @@ static void _lcd_move(const char *name, int axis, int min, int max)
bool initialized; // 1byte bool initialized; // 1byte
bool endstopsEnabledPrevious; // 1byte bool endstopsEnabledPrevious; // 1byte
} _menu_data_t; } _menu_data_t;
#if (2 > MENU_DATA_SIZE) static_assert(sizeof(menu_data)>= sizeof(_menu_data_t),"_menu_data_t doesn't fit into menu_data");
#error "check MENU_DATA_SIZE definition!"
#endif
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]); _menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if (!_md->initialized) if (!_md->initialized)
{ {
@ -2743,9 +2740,7 @@ static void _lcd_babystep(int axis, const char *msg)
int babystepMem[3]; // 6bytes int babystepMem[3]; // 6bytes
float babystepMemMM[3]; // 12bytes float babystepMemMM[3]; // 12bytes
} _menu_data_t; } _menu_data_t;
#if (19 > MENU_DATA_SIZE) static_assert(sizeof(menu_data)>= sizeof(_menu_data_t),"_menu_data_t doesn't fit into menu_data");
#error "check MENU_DATA_SIZE definition!"
#endif
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]); _menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if (_md->status == 0) if (_md->status == 0)
{ {
@ -2826,16 +2821,14 @@ static void lcd_babystep_z()
typedef struct typedef struct
{ // 12bytes + 9bytes = 21bytes total { // 12bytes + 9bytes = 21bytes total
uint8_t reserved[MENU_DATA_EDIT_SIZE]; //12 bytes reserved for number editing functions menu_data_edit_t reserved; //12 bytes reserved for number editing functions
int8_t status; // 1byte int8_t status; // 1byte
int16_t left; // 2byte int16_t left; // 2byte
int16_t right; // 2byte int16_t right; // 2byte
int16_t front; // 2byte int16_t front; // 2byte
int16_t rear; // 2byte int16_t rear; // 2byte
} _menu_data_adjust_bed_t; } _menu_data_adjust_bed_t;
#if (21 > MENU_DATA_SIZE) static_assert(sizeof(menu_data)>= sizeof(_menu_data_adjust_bed_t),"_menu_data_adjust_bed_t doesn't fit into menu_data");
#error "check MENU_DATA_SIZE definition!"
#endif
void lcd_adjust_bed_reset(void) void lcd_adjust_bed_reset(void)
{ {
@ -5671,16 +5664,14 @@ static void lcd_colorprint_change() {
static void lcd_tune_menu() static void lcd_tune_menu()
{ {
typedef struct typedef struct
{ // 3bytes total {
// To recognize, whether the menu has been just initialized. menu_data_edit_t reserved; //!< reserved for number editing functions
int8_t status; // 1byte int8_t status; //!< To recognize, whether the menu has been just initialized.
// Backup of extrudemultiply, to recognize, that the value has been changed and //! Backup of extrudemultiply, to recognize, that the value has been changed and
// it needs to be applied. //! it needs to be applied.
int16_t extrudemultiply; // 2byte int16_t extrudemultiply;
} _menu_data_t; } _menu_data_t;
#if (3 > MENU_DATA_SIZE) static_assert(sizeof(menu_data)>= sizeof(_menu_data_t),"_menu_data_t doesn't fit into menu_data");
#error "check MENU_DATA_SIZE definition!"
#endif
_menu_data_t* _md = (_menu_data_t*)&(menu_data[0]); _menu_data_t* _md = (_menu_data_t*)&(menu_data[0]);
if (_md->status == 0) if (_md->status == 0)
{ {