// ----------------------------------------------------------------------------- /// @file DisplayDevice.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 // ----------------------------------------------------------------------------- /** * %DisplayDevice implementation * \defgroup DisplayDevice Package DisplayDevice * \ingroup HAL * @{ */ #ifndef INC_DISPLAYDEVICE_H_ #define INC_DISPLAYDEVICE_H_ // ----------------------------------------------------------------------------- // Include files // ----------------------------------------------------------------------------- #include #include #include "stm32f10x.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Type definitions. // ----------------------------------------------------------------------------- typedef enum { OFF = 0, ON = !OFF } DisplayDevice_functionalState; struct DisplayDevice; typedef ErrorStatus (*DisplayResetFunction)(const struct DisplayDevice* self); typedef ErrorStatus (*DisplaySetStateFunction)(const struct DisplayDevice* self, DisplayDevice_functionalState state); typedef ErrorStatus (*DisplayBackspaceFunction)(const struct DisplayDevice* self); typedef ErrorStatus (*DisplayCursorPositionFunction)(const struct DisplayDevice* self, unsigned int row, unsigned int column); typedef ErrorStatus (*DisplayWriteFunction)(const struct DisplayDevice* self, const char* buffer, unsigned int length, unsigned int row, unsigned int column); typedef ErrorStatus (*DisplayWriteCharacterFunction)(const struct DisplayDevice* self, const char* buffer, unsigned int row, unsigned int column); typedef ErrorStatus (*DisplayClearFunction)(const struct DisplayDevice* self); typedef ErrorStatus (*DisplayClearLineFunction)(const struct DisplayDevice* self, unsigned int row); typedef ErrorStatus (*DisplaySetBrightnessFunction)(const struct DisplayDevice* self, unsigned int brightness); typedef ErrorStatus (*DisplaySetContrastFunction)(const struct DisplayDevice* self, unsigned int contrast); typedef ErrorStatus (*DisplayInvertFunction)(const struct DisplayDevice* self); typedef ErrorStatus (*DisplaySetBlinkingCursor)(const struct DisplayDevice* self, DisplayDevice_functionalState state); struct DisplayDeviceParameters { unsigned int numberOfRows; unsigned int numberOfColumns; unsigned int contrastMin; unsigned int contrastMax; unsigned int brightnessMin; unsigned int brightnessMax; }; struct DisplayDevice { DisplayResetFunction _reset; DisplaySetStateFunction _setState; DisplayBackspaceFunction _backspace; DisplayCursorPositionFunction _setCursorToPosition; DisplayWriteCharacterFunction _writeCharacter; DisplayWriteFunction _write; DisplayClearFunction _clear; DisplayClearLineFunction _clearLine; DisplaySetBrightnessFunction _setBrightness; DisplaySetContrastFunction _setContrast; DisplayInvertFunction _invert; DisplaySetBlinkingCursor _setBlinkingCursor; struct DisplayDeviceParameters parameters; bool initialized; }; // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- /** ---------------------------------------------------------------------------- * DisplayDevice_construct * Constructor for a new Display Device * If a specific function is not implemented at the display device it is valid * to use NULL pointer instead * * @param self The device instance * @param parameters Parameters for the display device * @param reset Pointer to DISPLAY RESET function * @param setState Pointer to DISPLAY SETSTATE function * @param backspace Pointer to DISPLAY BACKSPACE function * @param setCursorToPosition Pointer to DISPLAY SETCURSORTO POSITION * function * @param writeCharacter Pointer to DISPLAY WRITECHARACTER function * this function writes on single character * @param write Pointer to DIAPLAY WRITE function * @param clear Pointer to DISPLAY CLEARALL function * @param clearLine Pointer to DISPLAY CLEARLINE function * @param setBrightness Pointer to DISPLAY SETBRIGHTNESS function * @param setContrast Pointer to DISPLAY SETCONTRAST function * @param invert Pointer to DISPLAY INVERT function * @param setBlinkingCursor Pointer to DISPLAY SETBLINKINGCURSOR * function * * * @return ErrorStatus SUCCESS if constructor was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_construct (struct DisplayDevice* self, struct DisplayDeviceParameters* parameters, DisplayResetFunction reset, DisplaySetStateFunction setState, DisplayBackspaceFunction backspace, DisplayCursorPositionFunction setCursorToPosition, DisplayWriteCharacterFunction writeCharacter, DisplayWriteFunction write, DisplayClearFunction clear, DisplayClearLineFunction clearLine, DisplaySetBrightnessFunction setBrightness, DisplaySetContrastFunction setContrast, DisplayInvertFunction invert, DisplaySetBlinkingCursor setBlinkingCursor); /** ---------------------------------------------------------------------------- * DisplayDevice_destruct * Destructor for Display Device * * @param self The device instance to destruct * * @return void * * @todo * ----------------------------------------------------------------------------- */ extern void DisplayDevice_destruct (struct DisplayDevice* self); /** ---------------------------------------------------------------------------- * DisplayDevice_reset * RESET the complete display device * * @param self The device instance * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_reset(const struct DisplayDevice* self); /** ---------------------------------------------------------------------------- * DisplayDevice_setState * Sets the display to new state * * * @param self The device instance * @param state Can be either ON or OFF * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_setState(const struct DisplayDevice* self, DisplayDevice_functionalState state); /** ---------------------------------------------------------------------------- * DisplayDevice_backspace * Display backspace function. Set cursor one position back and delete character * * * @param self The device instance * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_backspace(const struct DisplayDevice* self); /** ---------------------------------------------------------------------------- * DisplayDevice_setCursorToPosition * Sets the cursor to the position given in arguments row/column * DisplayDevice function in behind verifies the position * * * @param self The device instance * @param row Row to use (starts with 1, not 0) * @param column Column to use (Starts with 1, not 0) * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * Especially when position was not valid * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_setCursorToPosition(const struct DisplayDevice* self, unsigned int row, unsigned int column); /** ---------------------------------------------------------------------------- * DisplayDevice_writeCharacter * Write a single character given in argument buffer to position given in * arguments row/column * * * @param self The device instance * @param buffer Pointer to the character to write * @param row Row to use (starts with 1, not 0) * @param column Column to use (Starts with 1, not 0) * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * Especially when position was not valid * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_writeCharacter(const struct DisplayDevice* self, const char* buffer, unsigned int row, unsigned int column); /** ---------------------------------------------------------------------------- * DisplayDevice_write * * * @param self The device instance * @param buffer Pointer to the string to write * @param length The length (number in characters) of the * message to write * @param row Row to use (starts with 1, not 0) * @param column Column to use (Starts with 1, not 0) * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * Especially when position or string length * are not valid * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_write(const struct DisplayDevice* self, const char* buffer, unsigned int length, unsigned int row, unsigned int column); /** ---------------------------------------------------------------------------- * DisplayDevice_clear * Function to clear the complete display * * * @param self The device instance * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_clear(const struct DisplayDevice* self); /** ---------------------------------------------------------------------------- * DisplayDevice_clearLine * Function to clear the line given in argument row * * * @param self The device instance * @param row Row to use (starts with 1, not 0) * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * Especially when position was not valid * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_clearLine(const struct DisplayDevice* self, unsigned int row); /** ---------------------------------------------------------------------------- * DisplayDevice_setBrightness * Sets the display brightness * Must be a value between the min and max brightness given in the display device * parameters in the constructor * * * @param self The device instance * @param brightness The brightness value * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * Especially when brightness value is * outside boundaries * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_setBrightness(const struct DisplayDevice* self, unsigned int brightness); /** ---------------------------------------------------------------------------- * DisplayDevice_setContrast * Sets the display contrast * Must be a value between the min and max contrast given in the display device * parameters in the constructor * * @param self The device instance * @param contrast The contrast value * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * Especially when contrast value is * outside boundaries * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_setContrast(const struct DisplayDevice* self, unsigned int contrast); /** ---------------------------------------------------------------------------- * DisplayDevice_invert * Function to invert the display representation * * * @param self The device instance * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_invert(const struct DisplayDevice* self); /** ---------------------------------------------------------------------------- * DisplayDevice_setBlinkingCursorState * Sets the state for a blinking cursor * * * @param self The device instance * @param state Can either be ON or OFF * * @return ErrorStatus SUCCESS if function was successful * ERROR otherwise * * @todo * ----------------------------------------------------------------------------- */ extern ErrorStatus DisplayDevice_setBlinkingCursorState(const struct DisplayDevice* self, DisplayDevice_functionalState state); #endif /* INC_DISPLAYDEVICE_H_ */ /** @} */