1 | int main(void)
|
2 | {
|
3 | /* USER CODE BEGIN 1 */
|
4 |
|
5 | uint8_t Ringpuffer[] = {" Dies ist ein Scrolltext. Er wandert von selbst das Display entlang "};
|
6 | uint8_t Lesekopf = 0;
|
7 | uint8_t Schreibkopf = 0;
|
8 | uint8_t i = 0;
|
9 | uint8_t j = 0;
|
10 |
|
11 | uint8_t Farbflags = 0b00001100; //bit7,6 = X, bit5 = Rot(not running/running), bit4 = Rot(down/up), bit3 = Gruen(nr/r), bit2 = Gruen (d/u), bit1 = Blau(nr/r), bit0 = Blau(d/u)
|
12 | uint8_t Rot = 255;
|
13 | uint8_t Gruen = 0;
|
14 | uint8_t Blau = 0;
|
15 | uint32_t Farbe = 0;
|
16 |
|
17 | uint8_t Textpuffer[sizeof(Ringpuffer)] = {0};
|
18 |
|
19 | uint16_t k = 100;
|
20 |
|
21 | /* USER CODE END 1 */
|
22 |
|
23 | /* Enable I-Cache-------------------------------------------------------------*/
|
24 | SCB_EnableICache();
|
25 |
|
26 | /* Enable D-Cache-------------------------------------------------------------*/
|
27 | SCB_EnableDCache();
|
28 |
|
29 | /* MCU Configuration----------------------------------------------------------*/
|
30 |
|
31 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
32 | HAL_Init();
|
33 |
|
34 | /* USER CODE BEGIN Init */
|
35 |
|
36 | /* USER CODE END Init */
|
37 |
|
38 | /* Configure the system clock */
|
39 | SystemClock_Config();
|
40 |
|
41 | /* USER CODE BEGIN SysInit */
|
42 |
|
43 | /* USER CODE END SysInit */
|
44 |
|
45 | /* Initialize all configured peripherals */
|
46 | MX_GPIO_Init();
|
47 | MX_USART6_UART_Init();
|
48 | MX_SPI2_Init();
|
49 | MX_RNG_Init();
|
50 | MX_QUADSPI_Init();
|
51 | MX_LTDC_Init();
|
52 | MX_FMC_Init();
|
53 | MX_DMA2D_Init();
|
54 | MX_CRC_Init();
|
55 | MX_ADC3_Init();
|
56 | /* USER CODE BEGIN 2 */
|
57 |
|
58 | BSP_LCD_Init();
|
59 | BSP_LCD_Init();
|
60 | BSP_LCD_LayerDefaultInit(0, LCD_FB_START_ADDRESS);
|
61 | BSP_LCD_LayerDefaultInit( 1, ( LCD_FB_START_ADDRESS + (4*1024*1024) ) );
|
62 | BSP_LCD_SelectLayer(0);
|
63 | BSP_LCD_SetTextColor(0xFFFFFFFF);
|
64 | BSP_LCD_SetBackColor(0x00000000);
|
65 | BSP_LCD_Clear(0x00000000);
|
66 | BSP_LCD_SelectLayer(1);
|
67 | BSP_LCD_SetBackColor(0x00000000);
|
68 | BSP_LCD_Clear(0x00000000);
|
69 | BSP_LCD_SetTextColor(0xFFFF0000);
|
70 | BSP_LCD_DisplayStringAtLine(0, "Line0");
|
71 | BSP_LCD_SetTextColor(0xFFFF8800);
|
72 | BSP_LCD_DisplayStringAtLine(1, "Line1");
|
73 | BSP_LCD_SetTextColor(0xFFFFFF00);
|
74 | BSP_LCD_DisplayStringAtLine(2, "Line2");
|
75 | BSP_LCD_SetTextColor(0xFF88FF00);
|
76 | BSP_LCD_DisplayStringAtLine(3, "Line3");
|
77 | BSP_LCD_SetTextColor(0xFF00FF00);
|
78 | BSP_LCD_DisplayStringAtLine(4, "Line4");
|
79 | BSP_LCD_SetTextColor(0xFF00FF88);
|
80 | BSP_LCD_DisplayStringAtLine(5, "Line5");
|
81 | BSP_LCD_SetTextColor(0xFF00FFFF);
|
82 | BSP_LCD_DisplayStringAtLine(6, "Line6");
|
83 | BSP_LCD_SetTextColor(0xFF0088FF);
|
84 | BSP_LCD_DisplayStringAtLine(7, "Line7");
|
85 | BSP_LCD_SetTextColor(0xFF0000FF);
|
86 | BSP_LCD_DisplayStringAtLine(8, "Line8");
|
87 | BSP_LCD_SetTextColor(0xFF8800FF);
|
88 | BSP_LCD_DisplayStringAtLine(9, "Line9");
|
89 | BSP_LCD_SetTextColor(0xFFFF00FF);
|
90 | BSP_LCD_DisplayStringAtLine(10, "Line10");
|
91 |
|
92 | HAL_ADC_Init(&hadc3);
|
93 | HAL_ADC_Start(&hadc3);
|
94 |
|
95 | HAL_RNG_Init(&hrng);
|
96 |
|
97 | BSP_LCD_SetTextColor(0xFFFF0088);
|
98 | /* USER CODE END 2 */
|
99 |
|
100 | /* Infinite loop */
|
101 | /* USER CODE BEGIN WHILE */
|
102 | while (1)
|
103 | {
|
104 | Lesekopf = j;
|
105 | j++;
|
106 | j %= sizeof(Ringpuffer);
|
107 | i = 0;
|
108 |
|
109 | while( i < sizeof(Ringpuffer) )
|
110 | {
|
111 | if( (Farbflags & (1 << Rot_run)) != 0)
|
112 | {
|
113 | if ( (Farbflags & (1 << Rot_dir)) == 0)
|
114 | {
|
115 | Rot--;
|
116 | if(Rot == 0)
|
117 | {
|
118 | Farbflags &= ~(1 << Rot_run);
|
119 | Farbflags |= (1 << Rot_dir);
|
120 | Farbflags |= (1 << Gruen_run);
|
121 | }
|
122 | }
|
123 | else
|
124 | {
|
125 | Rot++;
|
126 | if(Rot == 255)
|
127 | {
|
128 | Farbflags &= ~(1 << Rot_run);
|
129 | Farbflags |= (1 << Rot_dir);
|
130 | Farbflags |= (1 << Gruen_run);
|
131 | }
|
132 | }
|
133 |
|
134 | if( (Farbflags & (1 << Gruen_run)) != 0)
|
135 | {
|
136 | if ( (Farbflags & (1 << Gruen_run)) == 0)
|
137 | {
|
138 | Gruen--;
|
139 | if(Gruen == 0)
|
140 | {
|
141 | Farbflags &= ~(1 << Gruen_run);
|
142 | Farbflags |= (1 << Gruen_dir);
|
143 | Farbflags |= (1 << Blau_run);
|
144 | }
|
145 | }
|
146 | else
|
147 | {
|
148 | Gruen++;
|
149 | if(Gruen == 255)
|
150 | {
|
151 | Farbflags &= ~(1 << Gruen_run);
|
152 | Farbflags |= (1 << Gruen_dir);
|
153 | Farbflags |= (1 << Blau_run);
|
154 | }
|
155 | }
|
156 | }
|
157 |
|
158 | if( (Farbflags & (1 << Blau_run)) != 0)
|
159 | {
|
160 | if ( (Farbflags & (1 << Blau_run)) == 0)
|
161 | {
|
162 | Blau--;
|
163 | if(Blau == 0)
|
164 | {
|
165 | Farbflags &= ~(1 << Blau_run);
|
166 | Farbflags |= (1 << Blau_dir);
|
167 | Farbflags |= (1 << Rot_run);
|
168 | }
|
169 | }
|
170 | else
|
171 | {
|
172 | Blau++;
|
173 | if(Blau == 255)
|
174 | {
|
175 | Farbflags &= ~(1 << Blau_run);
|
176 | Farbflags |= (1 << Blau_dir);
|
177 | Farbflags |= (1 << Rot_run);
|
178 | }
|
179 | }
|
180 | }
|
181 |
|
182 |
|
183 | Textpuffer[i] = Ringpuffer[Lesekopf];
|
184 | i++;
|
185 | Lesekopf++;
|
186 | Lesekopf %= sizeof(Ringpuffer);
|
187 | }
|
188 |
|
189 | BSP_LCD_DisplayStringAtLine(0, &Textpuffer[0]);
|
190 | HAL_Delay(k);
|
191 |
|
192 | /* USER CODE END WHILE */
|
193 |
|
194 | /* USER CODE BEGIN 3 */
|
195 |
|
196 | }
|
197 | /* USER CODE END 3 */
|
198 |
|
199 | }
|