Skip to content

Instantly share code, notes, and snippets.

@dalewilson-eetech
dalewilson-eetech / Mahtani_Anoria_Using_BSPs_4.c
Created August 12, 2026 20:03
Mahtani_Anoria_Using_BSPs_4
/* USER CODE BEGIN WHILE */
bsp_accel_data_t current_motion;
if (bsp_sensor_init() == BSP_STATUS_OK) {
while (1) {
if (bsp_sensor_read_accel(&current_motion) == BSP_STATUS_OK) {
// Application logic runs completely independent of hardware layout
if (current_motion.z > 16000) {
// Handle orientation event
}
}
@dalewilson-eetech
dalewilson-eetech / Mahtani_Anoria_Using_BSPs_3.c
Created August 12, 2026 20:02
Mahtani_Anoria_Using_BSPs_3
// 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
@dalewilson-eetech
dalewilson-eetech / Mahtani_Anoria_Using_BSPs_2.c
Created August 12, 2026 20:01
Mahtani_Anoria_Using_BSPs_2
// 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;
@dalewilson-eetech
dalewilson-eetech / Mahtani_Anoria_Using_BSPs_1.c
Created August 12, 2026 20:00
Mahtani_Anoria_Using_BSPs_1
// 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.
@dalewilson-eetech
dalewilson-eetech / AAC-Project-Resistor-Color-Code-Calculator.ino
Created September 21, 2024 21:47
All About Circuits Project - Resistor Color Code Calculator and Ohmmeter Using Arduino Uno
#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
@dalewilson-eetech
dalewilson-eetech / AAC-Project-Motion-Color-Game-Console-MAC.ino
Created October 3, 2024 14:09
All About Circuits Project - Retro Handheld Gaming Console with Motion Control and an LCD - MAC Address Finder
#include <ESP8266WiFi.h>
void setup() {
Serial.begin(115200);
delay(500);
Serial.println();
Serial.print("MAC address: ");
Serial.println(WiFi.macAddress());
@dalewilson-eetech
dalewilson-eetech / AAC-Project-Motion-Color-Game-Console-Audio.ino
Created October 3, 2024 14:06
All About Circuits Project - Retro Handheld Gaming Console with Motion Control and an LCD - Audio
int tonePin = 2;
int musicSelectA = 3;
int musicSelectB = 4;
void musicGame1() {
tone(tonePin, 369, 135);
delay(153);
tone(tonePin, 554, 135);
delay(153);
@dalewilson-eetech
dalewilson-eetech / AAC-Project-Motion-Color-Game-Console.ino
Created October 3, 2024 14:04
All About Circuits Project - Retro Handheld Gaming Console with Motion Control and an LCD
#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>