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
105
106
|
#include <stdio.h>
#include <string.h>
#include "InovaLedDisplay.h"
#include "DisplayText.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#define BLACK 0x0000
#define RED 0xF800
#define GREEN 0x07E0
#define ORANGE 0xFFE0
#define PIN_NUM_R0 13 // MISO
#define PIN_NUM_G0 11 // MOSI
#define PIN_NUM_R1 14 // QUADWP
#define PIN_NUM_G1 9 // QUADHD
#define PIN_NUM_R2 36 // data4
#define PIN_NUM_G2 35 // data5
#define PIN_NUM_RD 37 // data6
#define PIN_NUM_GD 38 // data7
#define PIN_NUM_CLK 12
#define PIN_NUM_R_LATCH 16
#define PIN_NUM_R_CLK 17
#define PIN_NUM_R_ADDR_0 4
#define PIN_NUM_R_ADDR_1 5
#define PIN_NUM_R_ADDR_2 6
#define TAG "led_display"
#define STACK_SIZE 2000
extern "C" void runDisplayTask(void* taskParams) {
InovaLedDisplay* display = (InovaLedDisplay*) taskParams;
display->runDisplay();
}
extern "C" void app_main(void) {
InovaLedDisplay display = InovaLedDisplay(PIN_NUM_R0, PIN_NUM_G0, PIN_NUM_R1, PIN_NUM_G1, PIN_NUM_R2, PIN_NUM_G2, PIN_NUM_CLK, PIN_NUM_R_LATCH, PIN_NUM_R_CLK, PIN_NUM_R_ADDR_0, PIN_NUM_R_ADDR_1, PIN_NUM_R_ADDR_2);
TaskHandle_t taskHandle;
xTaskCreate(runDisplayTask, "updateDisplay", STACK_SIZE, &display, tskIDLE_PRIORITY + 1, &taskHandle);
display.fillScreen(0);
display.setTextWrap(false);
DisplayText scene[] = {
DisplayText("LEFT", 0, RED, -1),
DisplayText("RIGHT", 0, GREEN, 1),
DisplayText("CENTER", 0, ORANGE, 0),
DisplayText("This text is too long to fit on a single line (105 chars) so it has to scroll in order for you to read it.", 8, GREEN, 0),
DisplayText("Bottom text.", 16, ORANGE, 0)
};
uint8_t sceneLength = 5;
uint8_t i;
while(true) {
for(i = 0; i < sceneLength; i++) {
display.setTextColor(scene[i].getColor());
display.setCursor(scene[i].getX(), scene[i].getY());
display.print(scene[i].getText());
scene[i].step();
}
display.swapBuffer();
vTaskDelay(50 / portTICK_PERIOD_MS);
}
/* display.setTextColor(RED); */
/* display.setTextWrap(false); */
/* display.setCursor(0, 0); */
/* display.print("Line 0 0123456789"); */
/* display.setCursor(0, 8); */
/* display.print("Line 1 0123456789"); */
/* display.setCursor(0, 16); */
/* display.print("Line 2 0123456789"); */
/* display.swapBuffer(); */
/*
int j = display.width();
int color = 1;
String hello = "Hello World!! 0123456789";
int hello_length = hello.length();
int min_x = hello_length * -6;
while(true) {
display.fillScreen(0);
display.setCursor(j, 0);
display.print(hello);
display.swapBuffer();
if(--j == min_x) {
j = display.width();
if(++color > 3) {
color = 1;
}
}
vTaskDelay(50 / portTICK_PERIOD_MS);
}
*/
}
|