-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlcd_driver.c
104 lines (86 loc) · 3.54 KB
/
lcd_driver.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/***************************************************************************//**
* @file
* @brief LCD driver implementation file
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
#include <stdio.h>
#include <string.h>
#include "graphics.h"
#include "lcd_driver.h"
#if (HAL_SPIDISPLAY_ENABLE == 1)
/***********************************************************************************************//**
* @addtogroup disp_interface
* @{
**************************************************************************************************/
/***********************************************************************************************//**
* @addtogroup lcd_driver
* @{
**************************************************************************************************/
/// 2D array for storing the LCD content
static char LCD_data[LCD_ROW_MAX][LCD_ROW_LEN];
/***************************************************************************//**
* Call a callback function at the given frequency.
*
* @param[in] pFunction Pointer to function that should be called at the
* given frequency.
* @param[in] argument Argument to be given to the function.
* @param[in] frequency Frequency at which to call function at.
*
* @return Status code of the operation.
*
* @note This is needed by the LCD driver
******************************************************************************/
int rtcIntCallbackRegister(void (*pFunction)(void*),
void* argument,
unsigned int frequency)
{
return 0;
}
/*******************************************************************************
* LCD initialization, called once at startup.
******************************************************************************/
void LCD_init(void)
{
memset(&LCD_data, 0, sizeof(LCD_data));
graphInit("SILICON LABORATORIES\nBluetooth Mesh Demo\n\n");
LCD_write("initializing", LCD_ROW_STATUS);
}
/*******************************************************************************
* This function is used to write one line in the LCD.
*
* @param[in] str Pointer to string which is displayed in the specified row.
* @param[in] row Selects which line of LCD display is written,
* possible values are defined as LCD_ROW_xxx.
******************************************************************************/
void LCD_write(char *str, uint8_t row)
{
char LCD_message[LCD_ROW_MAX * LCD_ROW_LEN];
char *pRow;
int i;
if (row > LCD_ROW_MAX) {
return;
}
pRow = &(LCD_data[row - 1][0]);
strcpy(pRow, str);
LCD_message[0] = 0;
for (i = 0; i < LCD_ROW_MAX; i++) {
pRow = &(LCD_data[i][0]);
strcat(LCD_message, pRow);
strcat(LCD_message, "\n"); // add newline at end of reach row
}
graphWriteString(LCD_message);
}
/** @} (end addtogroup lcd_driver) */
/** @} (end addtogroup disp_interface) */
#endif /* HAL_SPIDISPLAY_ENABLE */