-
Notifications
You must be signed in to change notification settings - Fork 0
/
display_interface.c
77 lines (67 loc) · 2.67 KB
/
display_interface.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
/***************************************************************************//**
* @file
* @brief Display interface implementation
*******************************************************************************
* # 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 "display_interface.h"
#ifdef ENABLE_LOGGING
#define log(...) printf(__VA_ARGS__)
#else
#define log(...)
#endif
/***********************************************************************************************//**
* @addtogroup disp_interface
* @{
**************************************************************************************************/
/// Display Interface
display_interface_t display_interface = DEFAULT_DISPLAY_INTERFACE;
/*******************************************************************************
* Configure Display Interface.
*
* @param[in] init Pointer to display initialization function.
* @param[in] print Pointer to display print function.
******************************************************************************/
void DI_Config(init_func_t init, print_func_t print)
{
display_interface.init = init;
display_interface.print = print;
}
/*******************************************************************************
* Initialize Display Interface.
******************************************************************************/
void DI_Init(void)
{
if (display_interface.init == NULL) {
log("DI_Init: Display interface is NULL.\r\n");
return;
}
display_interface.init();
}
/*******************************************************************************
* Print to Display Interface.
*
* @param[in] str Pointer to string which is displayed in the specified row.
* @param[in] row Selects which line of display is written,
* possible values are defined as DI_ROW_xxx.
******************************************************************************/
void DI_Print(char *str, uint8_t row)
{
if (display_interface.print == NULL) {
log("DI_Print: %s\r\n", str);
return;
}
display_interface.print(str, row);
}
/** @} (end addtogroup disp_interface) */