display.c 1.18 KB
Newer Older
1
#include "LCD/LCD_Driver.h"
2
3
4
#include "framebuffer.h"
#include "gfx.h"
#include "textbuffer.h"
5
6

#include "gpio.h"
7
8
#include "portexpander.h"
#include "MAX77650-Arduino-Library.h"
9
10
11

#include <stdint.h>
#include <stdio.h>
12

13
/***** Globals *****/
schneider's avatar
schneider committed
14
const gpio_cfg_t DEV_DC_PIN = { PORT_1, PIN_6, GPIO_FUNC_OUT, GPIO_PAD_NONE };
15

16
17
18
struct gfx_region display_screen;
struct txt_buffer display_textb;

19
/***** Functions *****/
20
21
void display_set_reset_pin(uint8_t state)
{
schneider's avatar
schneider committed
22
23
24
	if (!portexpander_detected()) {
		MAX77650_setDO(state ? true : false);
	} else {
25
		portexpander_out_put(PIN_4, state);
schneider's avatar
schneider committed
26
	}
27
}
28
29
30

void display_init(void)
{
schneider's avatar
schneider committed
31
32
33
34
35
36
	if (!portexpander_detected()) {
		// Open-drain
		MAX77650_setDRV(false);
		// Output
		MAX77650_setDIR(false);
	}
37

schneider's avatar
schneider committed
38
	GPIO_Config(&DEV_DC_PIN);
39

40
	LCD_SetBacklight(20);
schneider's avatar
schneider committed
41
	LCD_Init();
42

43
44
45
	display_screen = gfx_screen(LCD_framebuffer());
	txt_init(&display_textb, &display_screen, &Font12);
	gfx_clear(&display_screen);
46
}
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

void display_init_slim(void)
{
	if (!portexpander_detected()) {
		// Open-drain
		MAX77650_setDRV(false);
		// Output
		MAX77650_setDIR(false);
	}

	GPIO_Config(&DEV_DC_PIN);

	display_screen = gfx_screen(LCD_framebuffer());
	txt_init(&display_textb, &display_screen, &Font12);
}