This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* USER CODE BEGIN WHILE */ | |
| bsp_accel_data_t current_motion; | |
| if (bsp_sensor_init() == BSP_STATUS_OK) { | |
| while (1) { | |
| if (bsp_sensor_read_accel(¤t_motion) == BSP_STATUS_OK) { | |
| // Application logic runs completely independent of hardware layout | |
| if (current_motion.z > 16000) { | |
| // Handle orientation event | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // bsp_sensor.c | |
| #include "bsp_sensor.h" | |
| #include "main.h" | |
| // The only place where the hardware handle is exposed | |
| extern I2C_HandleTypeDef hi2c1; | |
| #define ACCEL_DEVICE_ADDR (0x19 << 1) | |
| #define REG_OUT_X_L 0x28 | |
| #define REG_AUTO_INCREMENT 0x80 // OR'd into the sub-address to tell the | |
| // sensor to auto-increment across the | |
| // 6-byte X/Y/Z burst read instead of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // bsp_sensor.h | |
| #ifndef BSP_SENSOR_H_ | |
| #define BSP_SENSOR_H_ | |
| #include <stdint.h> | |
| typedef enum { | |
| BSP_STATUS_OK = 0, | |
| BSP_STATUS_ERROR | |
| } bsp_status_t; | |
| typedef struct { | |
| int16_t x; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // main.c | |
| #include "stm32f4xx_hal.h" | |
| extern I2C_HandleTypeDef hi2c1; // Hardcoded to I2C1 instance | |
| void process_sensor_data(void) { | |
| uint8_t raw_data[6]; | |
| // Hardcoding peripheral instances and hardware addresses directly in application logic | |
| if (HAL_I2C_Mem_Read(&hi2c1, (0x19 << 1), 0x28 | 0x80, I2C_MEMADD_SIZE_8BIT, raw_data, 6, 100) | |
| == HAL_OK) { | |
| int16_t x = (int16_t)((raw_data[1] << 8) | raw_data[0]); | |
| // If the hardware team switches the custom board to I2C2 or changes pins,this entire application function must be rewritten and re-tested. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <Adafruit_GFX.h> // Core graphics library | |
| #include <Adafruit_ST7735.h> // Hardware-specific library for ST7735 | |
| #define TFT_CS 10 | |
| #define TFT_RST 9 | |
| #define TFT_DC 8 | |
| #define A 5 | |
| #define B 6 | |
| #define C 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <ESP8266WiFi.h> | |
| void setup() { | |
| Serial.begin(115200); | |
| delay(500); | |
| Serial.println(); | |
| Serial.print("MAC address: "); | |
| Serial.println(WiFi.macAddress()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int tonePin = 2; | |
| int musicSelectA = 3; | |
| int musicSelectB = 4; | |
| void musicGame1() { | |
| tone(tonePin, 369, 135); | |
| delay(153); | |
| tone(tonePin, 554, 135); | |
| delay(153); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <SPI.h> | |
| #include <ESP8266WiFi.h> | |
| #include <espnow.h> | |
| #include <Wire.h> | |
| #include <TFT_eSPI.h> | |
| #include <SPI.h> | |
| #include "fighterSprites.h" | |
| #include "Wire.h" | |
| #include <MPU6050_light.h> |