Заявка на ремонт Личный кабинет
Контактная информация

Россия

т.:

Казахстан

т.:

Москва

т.: /

Санкт-Петербург

т.: /
/

Челябинск

т.: /

Новосибирск

т.: /

Тольятти

т.: /

2m Flash - Use Fmuv3 Firmware Instant

// Find oldest log (simplified - would need blackbox log iterator) uint32_t oldest_log_address = 0; uint32_t oldest_log_size = 0;

// Rate calculation: 1kHz = ~2KB/sec (gyro+accel+debug) switch(adaptive_bb_config.resolution) { case 0: // Low (500Hz gyro, no accel) bytes_per_second = 800; break; case 1: // Normal (1kHz gyro, 1kHz accel) bytes_per_second = 2000; break; case 2: // High (2kHz gyro, 1kHz accel, debug) bytes_per_second = 4000; break; default: bytes_per_second = 2000; }

uint8_t percent = flash_status.percent_used;

// Implementation would scan flash for log headers // For brevity: erase first 512KB (oldest quarter) flash_erase_sector(0, 512 * 1024); 2m flash - use fmuv3 firmware

// Flash monitoring typedef struct flash_status_s { uint32_t total_bytes; uint32_t free_bytes; uint32_t used_bytes; uint8_t percent_used; uint16_t estimated_log_seconds; } flash_status_t;

// Configuration structure typedef struct adaptive_bb_s { uint8_t resolution; // 0=low, 1=normal, 2=high uint8_t auto_erase; // auto-erase oldest logs uint8_t priority_mode; // 0=quality, 1=duration uint16_t max_log_seconds; uint8_t dynamic_rate; // adjust rate based on flash remaining } adaptive_bb_t;

if(percent < 30) return 2; // High rate if(percent < 60) return 1; // Normal rate if(percent < 85) return 0; // Low rate return 0; // Minimal rate when almost full } // Find oldest log (simplified - would need

// Dynamic rate adjustment based on remaining space static uint8_t calculate_dynamic_rate(void) { if(!adaptive_bb_config.dynamic_rate) return 1;

static adaptive_bb_t adaptive_bb_config = { .resolution = 1, .auto_erase = 1, .priority_mode = 0, .max_log_seconds = 180, // 3 minutes max by default .dynamic_rate = 1 };

// Check if flash is 2MB (typical FMUV3 boards) if(flash_status.total_bytes == 2 * 1024 * 1024) { // Configure for 2M flash blackboxConfig()->rate_num = 1; blackboxConfig()->rate_denom = 1; // Auto-admit settings if(flash_status.percent_used > 90) { smart_erase_oldest(); } // Set max log size uint16_t max_seconds = adaptive_bb_config.max_log_seconds; if(max_seconds > 0) { uint32_t max_bytes = max_seconds * 2000; // 2KB/sec estimate if(max_bytes < flash_status.free_bytes) { blackboxConfig()->max_log_size_kb = max_bytes / 1024; } } // Apply dynamic rate uint8_t dyn_rate = calculate_dynamic_rate(); if(dyn_rate == 0) { blackboxConfig()->rate_num = 1; blackboxConfig()->rate_denom = 2; // 500Hz } else if(dyn_rate == 1) { blackboxConfig()->rate_num = 1; blackboxConfig()->rate_denom = 1; // 1kHz } else { blackboxConfig()->rate_num = 2; blackboxConfig()->rate_denom = 1; // 2kHz } } uint32_t oldest_log_size = 0

// Calculate remaining recording time based on current settings static uint16_t estimate_remaining_time(void) { uint32_t bytes_per_second;

// Smart erase: remove oldest 25% of logs when full static void smart_erase_oldest(void) { if (!adaptive_bb_config.auto_erase) return;

I'll help you create a feature for an using FMUV3 firmware (Betaflight target: MATEKF405 or similar F4 with 2MB flash). This feature will be a Blackbox logging manager with adaptive recording that optimizes flash storage. Feature: Adaptive Blackbox Manager for 2M Flash // File: src/main/drivers/adaptive_blackbox.c // Feature: Auto-manages 2MB flash with intelligent recording #include <stdbool.h> #include <stdint.h> #include "platform.h" #include "drivers/flash.h" #include "drivers/flash_m25p16.h" #include "drivers/time.h" #include "build/build_config.h"

return flash_status.free_bytes / bytes_per_second; }

2m flash - use fmuv3 firmware
2m flash - use fmuv3 firmware

У вас остались вопросы?

Пожалуйста, скорее задайте их нам!