Последние публикации Мастерская электронщика

@ee_craft
Последние публикации
Дата публикации: 03 Nov, 11:57
Подкаст по текущему статусу нейроинтерфейсов. На английском. Создан на основе репорта по последним решениям в области нейроинтерфейсов.
Сделал чтобы послушать в дороге
👁 148 👍 2 💬 0 🔁 0 Дата публикации: 26 Sep, 12:48
# 🔧 C/C++ Pointers & Functions Cheatsheet
## Basic Pointer Syntax
| Operation | Syntax | Description |
|---|---|---|
| Declare pointer | int* ptr; | Pointer to int |
| Get address of variable | ptr = &variable; | Store address |
| Dereference pointer | int value = *ptr; | Get value at address |
| Access struct member | ptr->member | Same as (*ptr).member |
## Function Parameter Types
### 📋 Declaration Examples
// Three different ways to pass data:
void funcByValue(measurement_data_t data); // Pass copy (slow for large structs)
void funcByPointer(measurement_data_t* data); // Pass address
void funcByReference(measurement_data_t& data); // Pass reference (C++ only)
### 📋 Implementation Examples
void funcByValue(measurement_data_t data) {
data.current_cycle_index = 5; // Modifies copy, not original
}
void funcByPointer(measurement_data_t* data) {
data->current_cycle_index = 5; // Modifies original (use ->)
}
void funcByReference(measurement_data_t& data) {
data.current_cycle_index = 5; // Modifies original (use .)
}
## How to Call Functions
### 🎯 If you HAVE a variable:
measurement_data_t myData;
funcByValue(myData); // Pass variable directly
funcByPointer(&myData); // Pass ADDRESS with &
funcByReference(myData); // Pass variable directly
### 🎯 If you HAVE a pointer:
measurement_data_t* myPtr = &myData;
funcByValue(*myPtr); // DEREFERENCE with *
funcByPointer(myPtr); // Pass pointer directly
funcByReference(*myPtr); // DEREFERENCE with *
---
## FreeRTOS Task Parameters
### 📋 Task Function Signature
void taskFunction(void* parameter) {
// parameter is ALWAYS a void pointer
// Must cast to your actual type
}
### 📋 Common Pattern
// 1. Create task with data address
measurement_data_t myData;
xTaskCreate(taskFunc, "Task", 2048, &myData, 1, NULL); // Pass &myData
// 2. In task function, cast back
void taskFunc(void* parameter) {
measurement_data_t* data = (measurement_data_t*)parameter; // Cast
// Now you have a pointer, so:
data->current_cycle_index++; // Use -> for struct members
funcByPointer(data); // Pass pointer directly
funcByReference(*data); // Dereference first
funcByValue(*data); // Dereference first
}
## Quick Reference Table
| You Have | Function Wants | How to Call |
|---|---|---|
| Variable myData | Value func(T data) | func(myData) |
| Variable myData | Pointer func(T* data) | func(&myData) |
| Variable myData | Reference func(T& data) | func(myData) |
| Pointer myPtr | Value func(T data) | func(*myPtr) |
| Pointer myPtr | Pointer func(T* data) | func(myPtr) |
| Pointer myPtr | Reference func(T& data) | func(*myPtr) |
---
## Common Mistakes & Fixes
### ❌ Wrong: Signature Mismatch
// Header declares pointer:
void send(measurement_data_t* data);
// Implementation uses reference:
void send(measurement_data_t& data) { } // LINKER ERROR!
### ✅ Fixed: Match Signatures
// Both use pointer:
void send(measurement_data_t* data); // Header
void send(measurement_data_t* data) { } // Implementation
### ❌ Wrong: Calling Mismatch
measurement_data_t* ptr = &myData;
send(ptr); // If send() expects reference, this fails!
### ✅ Fixed: Dereference When Needed
measurement_data_t* ptr = &myData;
send(*ptr); // Dereference pointer to get reference
---
## Memory Cheatsheet
| Syntax | What It Does |
|---|---|
| T variable; | Creates variable on stack |
| T* ptr = &variable; | Pointer to stack variable |
| T* ptr = malloc(sizeof(T)); | Allocate on heap (C) |
| T* ptr = new T; | Allocate on heap (C++) |
| free(ptr); | Free heap memory (C) |
| delete ptr; | Free heap memory (C++) |
---
## 🚨 Golden Rules
1. Match function signatures exactly between header and implementation
2. Use `&` to get address of a variable
3. Use `*` to get value from a pointer
4. Use `->` for struct members when you have a pointer
5. Use `.` for struct members when you have a variable or reference
6. In FreeRTOS tasks, parameter is always `void*` - cast it!
👁 303 👍 4 💬 0 🔁 2 Дата публикации: 25 Jun, 15:03
Прямо сейчас я стримлю PCB-разводку — подключайтесь и смотрите вживую:
▶️ https://youtube.com/live/9gm2GLOLdvw?feature=share
Буду объяснять свой процесс, отвечать на вопросы по KiCad, показывать приёмы и приёмы вдумчивого размещения, трассировки и хитростей в Pcbnew.
Заходите!
👁 562 💬 19 🔁 1 Дата публикации: 08 Nov, 11:44
Стримлю Factorio: https://www.youtube.com/live/ZKfQhFiq3yY?si=PrHqEwQNF9O5zu4u
👁 1139 👍 2 💬 1 🔁 1 Дата публикации: 03 Sep, 13:55

Сделал на выходных из аккумов вот такой power bank для ноутбука.
👁 2249 👍 13 💬 8 🔁 0 Дата публикации: 31 Aug, 08:58
👁 2005 💬 3 🔁 1
Дата публикации: 26 Aug, 13:11
Проблемы которые я думаю заботят владельцев apple.
{Insert here}
Проблемы которые их реально заботят:
https://youtube.com/shorts/n6y0ttXkxyk?si=RhOUyg0PKe_FDUdZ
👁 1968 👍 1 💬 0 🔁 0 Дата публикации: 12 Aug, 00:00
Беспилотные поезда в Австралии с 2019 года катаются!
👁 1736 👍 1 💬 5 🔁 1
