Skip to content

Commit b3b3996

Browse files
Merge branch 'LedController' into main
2 parents 89b11e6 + 22e8e16 commit b3b3996

File tree

7 files changed

+270
-24
lines changed

7 files changed

+270
-24
lines changed

Code PlatformIO/Led-Controller/src/main.c

+30-24
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,20 @@ int led_columns[led_matrix_width][2] = {
6464
int posx = 0;
6565
int posy = 0;
6666

67-
enum commands
68-
{
69-
DIM = 0x25,
70-
RL = 0x22,
71-
LR = 0x21,
72-
UD = 0x23,
73-
DU = 0x24,
74-
NONE = 0x10
75-
};
67+
enum commands
68+
{
69+
DIM = 0x25,
70+
RL = 0x22,
71+
LR = 0x21,
72+
UD = 0x23,
73+
DU = 0x24,
74+
NONE = 0x10
75+
};
7676

77-
typedef enum commands command_t;
77+
typedef enum commands command_t;
7878

79-
command_t commando = NONE;
79+
command_t commando = NONE;
80+
command_t prevCommando = NONE;
8081

8182
/* Private function prototypes -----------------------------------------------*/
8283
void SystemClock_Config(void);
@@ -201,18 +202,20 @@ int main()
201202
// I2C stuff
202203
status = HAL_I2C_Master_Transmit(&hi2c1, addrs, &counter, 1, 500);
203204

204-
if(status == HAL_OK){
205-
status = HAL_I2C_Master_Receive(&hi2c1, addrs, &commando, 1, 500);
205+
if (status == HAL_OK)
206+
{
207+
status = HAL_I2C_Master_Receive(&hi2c1, addrs, &buf, 1, 500);
206208
}
207209

208210
HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
209211
printf("buf: %3d \r\n", buf);
212+
commando = (command_t)buf;
210213
int x = 0;
211214
while (x < 50)
212215
{
213216
for (uint8_t col = 0; col < led_matrix_width; col++)
214217
{
215-
//Reset de rijen
218+
// Reset de rijen
216219
for (uint8_t col1 = 0; col1 < led_matrix_height; col1++)
217220
{
218221
HAL_GPIO_WritePin(led_columns[col1][0], led_columns[col1][1], 0);
@@ -231,33 +234,36 @@ int main()
231234
x++;
232235
}
233236

234-
//HAL_Delay(500);
237+
// HAL_Delay(500);
235238

236239
led_matrix[posy][posx] = 0;
237240

238241
// Ontvang data
239-
if(commando == RL)
240-
posx--;
242+
if (commando == RL && prevCommando == NONE)
243+
posx--;
244+
245+
if (commando == LR && prevCommando == NONE)
246+
posx++;
241247

242-
if(commando == LR)
243-
posx++;
244-
245-
246248
if (posx >= led_matrix_width)
247249
posx = 0;
250+
if (posx < 0)
251+
posx = led_matrix_width-1;
248252

249-
if (commando == UD)
253+
if (commando == UD && prevCommando == NONE )
250254
posy++;
251255

252-
if (commando == DU)
256+
if (commando == DU && prevCommando == NONE)
253257
posy--;
254258

255259
if (posy >= led_matrix_height)
256260
posy = 0;
261+
if (posy < 0)
262+
posy = led_matrix_height-1;
257263

258264
led_matrix[posy][posx] = 1;
259265

260-
commando = NONE;
266+
prevCommando = commando;
261267
}
262268
}
263269

Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"env_name": "nucleo_f401re", "libsource_dirs": ["c:\\Users\\robel\\GitHub\\GestureControl\\Code PlatformIO\\Testing Interrupt\\lib", "c:\\Users\\robel\\GitHub\\GestureControl\\Code PlatformIO\\Testing Interrupt\\.pio\\libdeps\\nucleo_f401re", "C:\\Users\\robel\\.platformio\\lib"], "defines": ["PLATFORMIO=50205", "STM32F4", "STM32F401xE", "STM32F40_41xxx", "USE_HAL_DRIVER", "F_CPU=84000000L"], "includes": {"build": ["c:\\Users\\robel\\GitHub\\GestureControl\\Code PlatformIO\\Testing Interrupt\\include", "c:\\Users\\robel\\GitHub\\GestureControl\\Code PlatformIO\\Testing Interrupt\\src", "c:\\Users\\robel\\GitHub\\GestureControl\\Code PlatformIO\\Testing Interrupt\\include", "c:\\Users\\robel\\GitHub\\GestureControl\\Code PlatformIO\\Testing Interrupt\\src", "c:\\Users\\robel\\GitHub\\GestureControl\\Code PlatformIO\\Testing Interrupt\\src", "c:\\Users\\robel\\GitHub\\GestureControl\\Code PlatformIO\\Testing Interrupt\\include", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\CMSIS\\Include", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\CMSIS\\Device\\ST\\STM32F4xx\\Include", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\STM32F4xx_HAL_Driver\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\STM32F4xx_HAL_Driver\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\CMSIS\\DSP\\Include"], "compatlib": ["C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\ampire480272", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\ampire640480", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\Common", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\cs43l22", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\exc7200", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\ft6x06", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\i3g4250d", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\ili9325", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\ili9341", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\l3gd20", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\lis302dl", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\lis3dsh", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\ls016b8uy", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\lsm303agr", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\lsm303dlhc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\mfxstm32l152", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\n25q128a", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\n25q256a", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\n25q512a", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\nt35510", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\otm8009a", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\ov2640", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\ov5640", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\s25fl512s", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\s5k5cag", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\st7735", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\st7789h2", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\stmpe1600", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\stmpe811", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\ts3510", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Components\\wm8994", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Drivers\\BSP\\Adafruit_Shield", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Utilities\\CPU", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Utilities\\Fonts", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Utilities\\Log", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Core\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Core\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\AUDIO\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\AUDIO\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\BillBoard\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\BillBoard\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CDC\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CDC\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CDC_ECM\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CDC_ECM\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CDC_RNDIS\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CDC_RNDIS\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CustomHID\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\CustomHID\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\DFU\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\DFU\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\HID\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\HID\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\MSC\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\MSC\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\VIDEO\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Device_Library\\Class\\VIDEO\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Core\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Core\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\AUDIO\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\AUDIO\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\CDC\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\CDC\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\HID\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\HID\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\MSC\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\MSC\\Src", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\MTP\\Inc", "C:\\Users\\robel\\.platformio\\packages\\framework-stm32cubef4\\Middlewares\\ST\\STM32_USB_Host_Library\\Class\\MTP\\Src"], "toolchain": ["C:\\Users\\robel\\.platformio\\packages\\[email protected]\\arm-none-eabi\\include\\c++\\7.2.1", "C:\\Users\\robel\\.platformio\\packages\\[email protected]\\arm-none-eabi\\include\\c++\\7.2.1\\arm-none-eabi", "C:\\Users\\robel\\.platformio\\packages\\[email protected]\\lib\\gcc\\arm-none-eabi\\7.2.1\\include", "C:\\Users\\robel\\.platformio\\packages\\[email protected]\\lib\\gcc\\arm-none-eabi\\7.2.1\\include-fixed", "C:\\Users\\robel\\.platformio\\packages\\[email protected]\\arm-none-eabi\\include"], "unity": ["C:\\Users\\robel\\.platformio\\packages\\tool-unity"]}, "cc_path": "C:\\Users\\robel\\.platformio\\packages\\[email protected]\\bin\\arm-none-eabi-gcc.exe", "cxx_path": "C:\\Users\\robel\\.platformio\\packages\\[email protected]\\bin\\arm-none-eabi-g++.exe", "gdb_path": "C:\\Users\\robel\\.platformio\\packages\\[email protected]\\bin\\arm-none-eabi-gdb.exe", "prog_path": "c:\\Users\\robel\\GitHub\\GestureControl\\Code PlatformIO\\Testing Interrupt\\.pio\\build\\nucleo_f401re\\firmware.elf", "svd_path": "C:\\Users\\robel\\.platformio\\platforms\\ststm32\\misc\\svd\\STM32F401xE.svd", "compiler_type": "gcc", "targets": [{"name": "upload", "group": "Platform", "title": "Upload"}, {"name": "compiledb", "title": "Compilation Database", "description": "Generate compilation database `compile_commands.json`", "group": "Advanced"}, {"name": "clean", "title": "Clean", "group": "General"}, {"name": "cleanall", "title": "Clean All", "group": "General", "description": "Clean a build environment and installed library dependencies"}], "extra": {"flash_images": []}, "cc_flags": "-Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib", "cxx_flags": "-fno-rtti -fno-exceptions -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m4 -nostdlib"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
9fa2330192c6656b25e30605699eb7ec29c4e2ed

0 commit comments

Comments
 (0)