- Moved the menu texts to dedicated file to support future language switch option
- split the menu into core, elements as generic modules git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@270 05563f52-14a8-4384-a975-3d1654cca0fa
This commit is contained in:
@@ -0,0 +1,199 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file MenuCore.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file MenuCore.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef MENUCORE_H_
|
||||
#define MENUCORE_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "stm32f10x.h"
|
||||
|
||||
#include "Display.h"
|
||||
#include "KeyboardDevice.h"
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define MENUCORE_MAX_NUMBER_OF_ROWS (11)
|
||||
#define MENUCORE_MAX_NUMBER_OF_KEYS (16)
|
||||
#define MENUCORE_DISPLAY_ROW_LENGTH (20)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RM_MAINMENU = 0,
|
||||
RM_CATHODEMCP_SELECT,
|
||||
RM_REPAIRMENU,
|
||||
RM_ADMINMENU,
|
||||
RM_CALIBRATIONMENU,
|
||||
RM_PRESETMENU,
|
||||
RM_PRESET_PRINT,
|
||||
RM_START_REPAIR,
|
||||
RM_REPAIR_RUNNING,
|
||||
RM_REPAIR_ASK_PAUSE,
|
||||
RM_REPAIR_PAUSE,
|
||||
RM_FINISH_CONTROL,
|
||||
RM_FINISH,
|
||||
RM_ERROR_STATE,
|
||||
RM_WARNING_STATE,
|
||||
RM_NO_MENU,
|
||||
RM_NUMBER_OF_MENUS
|
||||
} T_MenuState;
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NO_ACTION = 0,
|
||||
HOTKEY_SELECT,
|
||||
SELECT,
|
||||
GOTO_STATE,
|
||||
EXECUTE_FUNCTION,
|
||||
SCROLL_UP,
|
||||
SCROLL_DOWN,
|
||||
DIGIT_INSERT
|
||||
} T_KeyAction;
|
||||
|
||||
struct MenuCore;
|
||||
typedef void (*MenuCoreFunctionCall)(struct MenuCore* self);
|
||||
|
||||
struct MenuRow
|
||||
{
|
||||
char text[MENUCORE_DISPLAY_ROW_LENGTH];
|
||||
int newState;
|
||||
MenuCoreFunctionCall actionPointer;
|
||||
};
|
||||
|
||||
struct KeyActionBinding
|
||||
{
|
||||
char key;
|
||||
Keypad_KeyState keyState;
|
||||
T_KeyAction action;
|
||||
int argument;
|
||||
MenuCoreFunctionCall actionPointer;
|
||||
};
|
||||
|
||||
struct MenuPage
|
||||
{
|
||||
bool hasCursor;
|
||||
int numberOfRows;
|
||||
int maxNumberOfRows;
|
||||
int numberOfKeys;
|
||||
int maxNumberOfKeys;
|
||||
struct MenuRow row[MENUCORE_MAX_NUMBER_OF_ROWS];
|
||||
struct KeyActionBinding keyActionBinding[NUMBER_OF_KEY_EVENTS * MENUCORE_MAX_NUMBER_OF_KEYS];
|
||||
};
|
||||
|
||||
struct MenuCore
|
||||
{
|
||||
TaskHandle_t taskHandle;
|
||||
int TaskPriority;
|
||||
uint16_t stackSize;
|
||||
bool runTask;
|
||||
bool initialized;
|
||||
struct Display* display;
|
||||
struct KeyboardDevice* keyboardDevice;
|
||||
int cursorIndex;
|
||||
int scrollOffset;
|
||||
T_MenuState menuState;
|
||||
uint32_t popUpCounter;
|
||||
T_MenuState lastMenuState;
|
||||
struct MenuPage menuArray[RM_NUMBER_OF_MENUS];
|
||||
MenuCoreFunctionCall _handleStateFunction;
|
||||
char errorMessage[MENUCORE_DISPLAY_ROW_LENGTH];
|
||||
char warningMessage[MENUCORE_DISPLAY_ROW_LENGTH];
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* MenuCore_construct
|
||||
* Description of function
|
||||
*
|
||||
* @param self Menu core object to construct
|
||||
* @param display Display device to use for output
|
||||
* @param keyboardDevice KeyboardDevice for menu input
|
||||
* @param taskPriority Priority for the menu task
|
||||
* @param stacksize Task stacksize
|
||||
* @param createMenu Functionpointer to a function that
|
||||
* creates the menu entries
|
||||
* must be provided in order to generate
|
||||
* the entries of the menu at the right
|
||||
* time.
|
||||
* @param stateHandle Functionpointer to a function that gets
|
||||
* called from the menu task everytime
|
||||
* PRIOR to the keyboard readout.
|
||||
* Handy for display printouts or other
|
||||
* functionality that is state-dependent
|
||||
*
|
||||
* @return ErrorStatus SUCCESS if construction was successful
|
||||
* ERROR otherwise
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus MenuCore_construct(struct MenuCore* self, struct Display* display, struct KeyboardDevice* keyboardDevice, int taskPriority, uint16_t stackSize, MenuCoreFunctionCall createMenu, MenuCoreFunctionCall stateHandle);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* MenuCore_destruct
|
||||
* Destructor for menu Core
|
||||
*
|
||||
* @param self Menu core object to destruct
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void MenuCore_destruct(struct MenuCore* self);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
* MenuCore_changeState
|
||||
* Requests the menu to change its state
|
||||
*
|
||||
* @param self Menu core object
|
||||
* @param newState New state of the menu
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern void MenuCore_changeState(struct MenuCore* self, T_MenuState newState);
|
||||
|
||||
|
||||
#endif /* MENUCORE_H_ */
|
||||
@@ -0,0 +1,76 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file MenuElements.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file MenuElements.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef MENUELEMENTS_H_
|
||||
#define MENUELEMENTS_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "MenuCore.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
extern ErrorStatus MenuElements_createMenuPage (struct MenuPage* self, bool hasCursor, int maxNumberOfRows);
|
||||
|
||||
|
||||
extern ErrorStatus MenuElements_addMenuPageRow (struct MenuPage* self, const char* text, int newState, MenuCoreFunctionCall actionCall);
|
||||
|
||||
|
||||
extern ErrorStatus MenuElements_addKeyAction_HOTKEYSELECT (struct MenuPage* self, char key, Keypad_KeyState keyState, int rowToSelect);
|
||||
|
||||
|
||||
extern ErrorStatus MenuElements_addKeyAction_SELECT (struct MenuPage* self, char key, Keypad_KeyState keyState);
|
||||
|
||||
|
||||
extern ErrorStatus MenuElements_addKeyAction_GOTOSTATE (struct MenuPage* self, char key, Keypad_KeyState keyState, T_MenuState state);
|
||||
|
||||
|
||||
extern ErrorStatus MenuElements_addKeyAction_EXECUTEFUNCTION (struct MenuPage* self, char key, Keypad_KeyState keyState, MenuCoreFunctionCall actionPointer);
|
||||
|
||||
|
||||
extern ErrorStatus MenuElements_addKeyAction_SCROLLUP (struct MenuPage* self, char key, Keypad_KeyState keyState);
|
||||
|
||||
|
||||
extern ErrorStatus MenuElements_addKeyAction_SCROLLDOWN (struct MenuPage* self, char key, Keypad_KeyState keyState);
|
||||
|
||||
#endif /* MENUELEMENTS_H_ */
|
||||
@@ -0,0 +1,149 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
/// @file MenuText.h
|
||||
/// @brief File description
|
||||
// -----------------------------------------------------------------------------
|
||||
// Micro-Key bv
|
||||
// Industrieweg 28, 9804 TG Noordhorn
|
||||
// Postbus 92, 9800 AB Zuidhorn
|
||||
// The Netherlands
|
||||
// Tel: +31 594 503020
|
||||
// Fax: +31 594 505825
|
||||
// Email: support@microkey.nl
|
||||
// Web: www.microkey.nl
|
||||
// -----------------------------------------------------------------------------
|
||||
/// $Revision$
|
||||
/// $Author$
|
||||
/// $Date$
|
||||
// (c) 2015 Micro-Key bv
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
/// @defgroup {group_name} {group_description}
|
||||
/// Description
|
||||
|
||||
/// @file MenuText.h
|
||||
/// @ingroup {group_name}
|
||||
|
||||
#ifndef MENUTEXT_H_
|
||||
#define MENUTEXT_H_
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Include files
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#include "MenuCore.h"
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define MENUTEXT_NUMBER_OF_LANGUAGES (2)
|
||||
#define MENUTEXT_ENGLISH (0)
|
||||
|
||||
// -----------------------
|
||||
// OPERATOR MENU
|
||||
// -----------------------
|
||||
static const char MenuText_MAINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
|
||||
{
|
||||
{
|
||||
"",
|
||||
" 1.Tube repair",
|
||||
" 2.Administrator",
|
||||
" 3.Calibration"
|
||||
},
|
||||
{
|
||||
//FRENCH TBW
|
||||
}
|
||||
};
|
||||
|
||||
static const char MenuText_CATHODEMCP_SELECT[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
|
||||
{
|
||||
{
|
||||
"Tube repair",
|
||||
" 1.Cathode repair",
|
||||
" 2.MCP repair",
|
||||
},
|
||||
{
|
||||
//FRENCH TBW
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static const char MenuText_REPAIRMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
|
||||
{
|
||||
{
|
||||
"Tube repair",
|
||||
" 1.Select preset",
|
||||
" 2.Start",
|
||||
},
|
||||
{
|
||||
//FRENCH TBW
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static const char MenuText_PRESETMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
|
||||
{
|
||||
{
|
||||
"Select preset",
|
||||
" 1.Preset 1",
|
||||
" 2.Preset 2",
|
||||
" 3.Preset 3",
|
||||
" 4.Preset 4",
|
||||
" 5.Preset 5",
|
||||
" 6.Preset 6",
|
||||
" 7.Preset 7",
|
||||
" 8.Preset 8",
|
||||
" 9.Preset 9",
|
||||
},
|
||||
{
|
||||
//FRENCH TBW
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// -----------------------
|
||||
// ADMINISTRATION MENU
|
||||
// -----------------------
|
||||
static const char MenuText_ADMINMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
|
||||
{
|
||||
{
|
||||
"Administration",
|
||||
" 1.Change Pin",
|
||||
" 2.I/O control",
|
||||
" 3.Info & Version"
|
||||
},
|
||||
{
|
||||
//FRENCH TBW
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// -----------------------
|
||||
// CALIBRATION MENU
|
||||
// -----------------------
|
||||
static const char MenuText_CALIBRATIONMENU[MENUTEXT_NUMBER_OF_LANGUAGES][MENUCORE_MAX_NUMBER_OF_ROWS][MENUCORE_DISPLAY_ROW_LENGTH] =
|
||||
{
|
||||
{
|
||||
"Calibration",
|
||||
" 1.NOTHING YET",
|
||||
|
||||
},
|
||||
{
|
||||
//FRENCH TBW
|
||||
}
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Function declarations
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
|
||||
#endif /* MENUTEXT_H_ */
|
||||
@@ -100,6 +100,9 @@ extern void SignalProfileGenerator_calculate(struct SignalProfileGenerator* self
|
||||
extern void SignalProfileGenerator_pause(struct SignalProfileGenerator* self);
|
||||
|
||||
|
||||
extern bool SignalProfileGenerator_isPaused(struct SignalProfileGenerator* self);
|
||||
|
||||
|
||||
extern void SignalProfileGenerator_continue(struct SignalProfileGenerator* self);
|
||||
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "semphr.h"
|
||||
|
||||
#include "stm32f10x.h"
|
||||
#include "MenuCore.h"
|
||||
#include "RepairPreset.h"
|
||||
#include "repairProcess.h"
|
||||
|
||||
@@ -51,8 +52,6 @@
|
||||
// Constant and macro definitions
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
#define REPAIRMENU_MAX_NUMBER_OF_ROWS (11)
|
||||
#define REPAIRMENU_MAX_NUMBER_OF_KEYS (16)
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// Type definitions.
|
||||
@@ -60,93 +59,16 @@
|
||||
|
||||
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MAINMENU = 0,
|
||||
RM_CATHODEMCP_SELECT,
|
||||
REPAIRMENU,
|
||||
ADMINMENU,
|
||||
CALIBRATIONMENU,
|
||||
PRESETMENU,
|
||||
RM_PRESET_PRINT,
|
||||
START_REPAIR,
|
||||
REPAIR_RUNNING,
|
||||
REPAIR_ASK_PAUSE,
|
||||
REPAIR_PAUSE,
|
||||
FINISH_CONTROL,
|
||||
FINISH,
|
||||
ERROR_STATE,
|
||||
WARNING_STATE,
|
||||
NO_MENU,
|
||||
NUMBER_OF_MENUS
|
||||
} T_MenuState;
|
||||
|
||||
struct RepairMenu;
|
||||
typedef void (*RepairMenuFunctionCall)(struct RepairMenu* self, int cursorIndex);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NO_ACTION = 0,
|
||||
HOTKEY_SELECT,
|
||||
SELECT,
|
||||
GOTO_STATE,
|
||||
EXECUTE_FUNCTION,
|
||||
SCROLL_UP,
|
||||
SCROLL_DOWN,
|
||||
DIGIT_INSERT
|
||||
} T_KeyAction;
|
||||
|
||||
struct MenuRow
|
||||
{
|
||||
char text[20];
|
||||
int newState;
|
||||
RepairMenuFunctionCall actionPointer;
|
||||
};
|
||||
|
||||
|
||||
struct KeyActionBinding
|
||||
{
|
||||
char key;
|
||||
Keypad_KeyState keyState;
|
||||
T_KeyAction action;
|
||||
int argument;
|
||||
RepairMenuFunctionCall actionPointer;
|
||||
};
|
||||
|
||||
|
||||
struct MenuPage
|
||||
{
|
||||
bool hasCursor;
|
||||
int numberOfRows;
|
||||
int maxNumberOfRows;
|
||||
int numberOfKeys;
|
||||
int maxNumberOfKeys;
|
||||
struct MenuRow row[REPAIRMENU_MAX_NUMBER_OF_ROWS];
|
||||
struct KeyActionBinding keyActionBinding[NUMBER_OF_KEY_EVENTS * REPAIRMENU_MAX_NUMBER_OF_KEYS];
|
||||
};
|
||||
|
||||
struct RepairMenu
|
||||
{
|
||||
TaskHandle_t taskHandle;
|
||||
int TaskPriority;
|
||||
uint16_t stackSize;
|
||||
bool runTask;
|
||||
bool initialized;
|
||||
struct Display* display;
|
||||
struct KeyboardDevice* keyboardDevice;
|
||||
struct MemoryDevice* memoryDevice;
|
||||
struct CachedStorage presetStorage;
|
||||
T_MenuState menuState;
|
||||
int cursorIndex;
|
||||
int scrollOffset;
|
||||
SemaphoreHandle_t repairScreenUpdateSemaphore;
|
||||
const struct RepairPreset* repairPreset;
|
||||
struct RepairProcessParameters rpParameters;
|
||||
struct MenuPage menuArray[NUMBER_OF_MENUS];
|
||||
char errorMessage[20];
|
||||
char warningMessage[20];
|
||||
Observer observer;
|
||||
struct MenuCore* menuCore;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -170,7 +92,7 @@ struct RepairMenu
|
||||
* @todo
|
||||
* -----------------------------------------------------------------------------
|
||||
*/
|
||||
extern ErrorStatus repairMenu_construct(struct RepairMenu* self, struct Display* display, struct KeyboardDevice* keyboardDevice, struct MemoryDevice* memoryDevice, int taskPriority, uint16_t stackSize, Observer repairScreenUpdateObserver);
|
||||
extern ErrorStatus repairMenu_construct(struct RepairMenu* self, struct MenuCore* menuCore, struct MemoryDevice* memoryDevice, Observer repairScreenUpdateObserver);
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------
|
||||
@@ -238,4 +160,10 @@ extern void repairMenu_interlockFailed(struct RepairMenu* self, T_INTERLOCK_ID i
|
||||
|
||||
extern void repairMenu_processFailed(struct RepairMenu* self);
|
||||
|
||||
|
||||
extern void repairMenu_menuStateHandle(struct MenuCore* menuCore);
|
||||
|
||||
|
||||
extern void repairMenu_createMenuEntries(struct MenuCore* menuCore);
|
||||
|
||||
#endif /* INC_REPAIRMENU_H_ */
|
||||
|
||||
Reference in New Issue
Block a user