sGUI  V1.0
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
log.c
Go to the documentation of this file.
1 
77 #ifdef __cplusplus
78 extern "C" {
79 #endif /* __cplusplus */
80 
81 /*----- Header-Files -------------------------------------------------------*/
82 #include <string.h> /* memory and string functions */
83 #include "lcd.h" /* Simple graphic library */
84 
85 /*----- Macros -------------------------------------------------------------*/
89 #define MAX_LINES (LCD_VER_RESOLUTION / FONT_MIN_HEIGHT)
90 
94 #define MAX_COLUMNS (LCD_HOR_RESOLUTION / FONT_MIN_WIDTH)
95 
96 /*----- Data types ---------------------------------------------------------*/
97 
98 /*----- Function prototypes ------------------------------------------------*/
99 
100 /*----- Data ---------------------------------------------------------------*/
106 
110 static uint8_t head = 0;
111 
115 static uint8_t count = 0;
116 
117 /*----- Implementation -----------------------------------------------------*/
122 void LCD_Log_AddMsg(char *ptr) {
123 
124  strncpy(LOG_Messages[head], ptr, (uint8_t) (MAX_COLUMNS));
125  LOG_Messages[head][MAX_COLUMNS - 1] = '\0';
126 
127  if (++head >= MAX_LINES) {
128  head = 0;
129  }
130  if (++count > MAX_LINES) {
131  count = MAX_LINES;
132  }
133 
134  LCD_Log_Update();
135 }
136 
141 void LCD_Log_Update(void) {
142 
143  uint8_t i;
144  uint8_t CurrentLine;
145  uint8_t LineCount = LCD_GetLineCount();
146  uint8_t MaxLines = (LineCount > count) ? count : LineCount;
147 
148  for (i = 1; i <= MaxLines; i++) {
149  CurrentLine = ((head - i) >= 0) ? head - i : MAX_LINES + head - i;
150  LCD_DisplayStringLine(MaxLines - i, LOG_Messages[CurrentLine]);
151  }
152 }
153 
154 /*----- EOF ----------------------------------------------------------------*/
155 
156 #ifdef __cplusplus
157 }
158 #endif /* __cplusplus */
159 
void LCD_Log_Update(void)
Update the log messages on the display. This is used, if the screen is overwritten by user...
Definition: log.c:141
#define MAX_COLUMNS
Maximal number of columns.
Definition: log.c:94
#define MAX_LINES
Maximal number of lines.
Definition: log.c:89
void LCD_DisplayStringLine(uint8_t Line, const char *ptr)
Displays a string on a line on the LCD. Position is set with a line number.
Definition: text.c:250
static uint8_t head
Index of the LOG_Messages of the last message.
Definition: log.c:110
uint8_t LCD_GetLineCount(void)
Gets the current count of possible lines.
Definition: text.c:176
static uint8_t count
Number of messages which are stored in LOG_Messages.
Definition: log.c:115
Simple graphic library main functionality.
void LCD_Log_AddMsg(char *ptr)
Add a log message to the screen.
Definition: log.c:122
static char LOG_Messages[MAX_LINES][MAX_COLUMNS]
Array of all log messages. The maximum line width and line count are the array dimension.
Definition: log.c:105