spectrum analyzer new mode

This commit is contained in:
Eng1n33r
2022-06-22 04:11:52 +03:00
parent c6a3b71db6
commit 881b6d2634
7 changed files with 46 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
### New Update ### New Update
* Spectrum Analyzer - ULTRA NARROW mode
* Merged latest ofw dev changes: * Merged latest ofw dev changes:
Infrared app C port, nfc: NTAG21x complete emulation, nfc: DESFire fixes Infrared app C port, nfc: NTAG21x complete emulation, nfc: DESFire fixes
SubGhz: frequency analyzer combined frequency detection method, etc... SubGhz: frequency analyzer combined frequency detection method, etc...

View File

@@ -176,7 +176,7 @@ Use **`flipper-z-{target}-full-{suffix}.dfu`** to flash your device.
- [UniversalRF Remix (By ESurge)(Original UniversalRF By jimilinuxguy)](https://github.com/ESurge/flipperzero-firmware-unirfremix) - [UniversalRF Remix (By ESurge)(Original UniversalRF By jimilinuxguy)](https://github.com/ESurge/flipperzero-firmware-unirfremix)
- [WAV Player (By DrZlo13)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/wav-player) With Fix From [Atmanos](https://github.com/at-manos) - [WAV Player (By DrZlo13)](https://github.com/flipperdevices/flipperzero-firmware/tree/zlo/wav-player) With Fix From [Atmanos](https://github.com/at-manos)
- [Tetris (By jeffplang)](https://github.com/jeffplang/flipperzero-firmware/tree/tetris_game/applications/tetris_game) - [Tetris (By jeffplang)](https://github.com/jeffplang/flipperzero-firmware/tree/tetris_game/applications/tetris_game)
- [Spectrum Analyzer (By jolcese)](https://github.com/jolcese/flipperzero-firmware/tree/spectrum/applications/spectrum_analyzer) - [Spectrum Analyzer (By jolcese)](https://github.com/jolcese/flipperzero-firmware/tree/spectrum/applications/spectrum_analyzer) - [ULTRA NARROW mode](https://github.com/theY4Kman/flipperzero-firmware)
- [Arkanoid (By gotnull)](https://github.com/gotnull/flipperzero-firmware-wPlugins) - [Arkanoid (By gotnull)](https://github.com/gotnull/flipperzero-firmware-wPlugins)
- [Tic Tac Toe (By gotnull)](https://github.com/gotnull/flipperzero-firmware-wPlugins) - [Tic Tac Toe (By gotnull)](https://github.com/gotnull/flipperzero-firmware-wPlugins)

View File

@@ -85,10 +85,11 @@ static void snake_game_render_callback(Canvas* const canvas, void* ctx) {
} }
// Show score on the game field // Show score on the game field
char buffer2[6]; if(snake_state->state != GameStateGameOver) {
snprintf(buffer2, sizeof(buffer2), "%u", snake_state->len - 7); char buffer2[6];
canvas_draw_str_aligned(canvas, 126, 8, AlignRight, AlignBottom, buffer2); snprintf(buffer2, sizeof(buffer2), "%u", snake_state->len - 7);
canvas_draw_str_aligned(canvas, 126, 8, AlignRight, AlignBottom, buffer2);
}
// Game Over banner // Game Over banner
if(snake_state->state == GameStateGameOver) { if(snake_state->state == GameStateGameOver) {
// Screen is 128x64 px // Screen is 128x64 px

View File

@@ -6,8 +6,6 @@
#include <stdlib.h> #include <stdlib.h>
#include "spectrum_analyzer.h" #include "spectrum_analyzer.h"
#include <gui/gui.h>
#include <lib/drivers/cc1101_regs.h> #include <lib/drivers/cc1101_regs.h>
#include "spectrum_analyzer_worker.h" #include "spectrum_analyzer_worker.h"
@@ -64,6 +62,10 @@ void spectrum_analyzer_draw_scale(Canvas* canvas, const SpectrumAnalyzerModel* m
tag_left = model->center_freq - 2; tag_left = model->center_freq - 2;
tag_right = model->center_freq + 2; tag_right = model->center_freq + 2;
break; break;
case ULTRANARROW:
tag_left = model->center_freq - 1;
tag_right = model->center_freq + 1;
break;
case ULTRAWIDE: case ULTRAWIDE:
tag_left = model->center_freq - 40; tag_left = model->center_freq - 40;
tag_right = model->center_freq + 40; tag_right = model->center_freq + 40;
@@ -194,6 +196,11 @@ void spectrum_analyzer_calculate_frequencies(SpectrumAnalyzerModel* model) {
step = NARROW_STEP; step = NARROW_STEP;
model->spacing = NARROW_SPACING; model->spacing = NARROW_SPACING;
break; break;
case ULTRANARROW:
margin = ULTRANARROW_MARGIN;
step = ULTRANARROW_STEP;
model->spacing = ULTRANARROW_SPACING;
break;
case ULTRAWIDE: case ULTRAWIDE:
margin = ULTRAWIDE_MARGIN; margin = ULTRAWIDE_MARGIN;
step = ULTRAWIDE_STEP; step = ULTRAWIDE_STEP;
@@ -392,6 +399,9 @@ int32_t spectrum_analyzer_app(void* p) {
case NARROW: case NARROW:
hstep = NARROW_STEP; hstep = NARROW_STEP;
break; break;
case ULTRANARROW:
hstep = ULTRANARROW_STEP;
break;
case ULTRAWIDE: case ULTRAWIDE:
hstep = ULTRAWIDE_STEP; hstep = ULTRAWIDE_STEP;
break; break;
@@ -429,13 +439,19 @@ int32_t spectrum_analyzer_app(void* p) {
model->width = NARROW; model->width = NARROW;
break; break;
case NARROW: case NARROW:
model->width = ULTRANARROW;
break;
case ULTRANARROW:
model->width = ULTRAWIDE; model->width = ULTRAWIDE;
break; break;
case ULTRAWIDE: case ULTRAWIDE:
model->width = WIDE;
break;
default: default:
model->width = WIDE; model->width = WIDE;
break;
} }
} }
spectrum_analyzer_calculate_frequencies(model); spectrum_analyzer_calculate_frequencies(model);
spectrum_analyzer_worker_set_frequencies( spectrum_analyzer_worker_set_frequencies(
spectrum_analyzer->worker, model->channel0_frequency, model->spacing, model->width); spectrum_analyzer->worker, model->channel0_frequency, model->spacing, model->width);

View File

@@ -1,4 +1,6 @@
#define NUM_CHANNELS 132 #define NUM_CHANNELS 132
#define NUM_CHUNKS 6
#define CHUNK_SIZE (NUM_CHANNELS / NUM_CHUNKS)
// Screen coordinates // Screen coordinates
#define FREQ_BOTTOM_Y 50 #define FREQ_BOTTOM_Y 50
@@ -12,15 +14,18 @@
* ultrawide mode: 80 MHz on screen, 784 kHz per channel * ultrawide mode: 80 MHz on screen, 784 kHz per channel
* wide mode (default): 20 MHz on screen, 196 kHz per channel * wide mode (default): 20 MHz on screen, 196 kHz per channel
* narrow mode: 4 MHz on screen, 39 kHz per channel * narrow mode: 4 MHz on screen, 39 kHz per channel
* ultranarrow mode: 2 MHz on screen, 19 kHz per channel
*/ */
#define WIDE 0 #define WIDE 0
#define NARROW 1 #define NARROW 1
#define ULTRAWIDE 2 #define ULTRAWIDE 2
#define ULTRANARROW 3
/* channel spacing in Hz */ /* channel spacing in Hz */
#define WIDE_SPACING 196078 #define WIDE_SPACING 196078
#define NARROW_SPACING 39215 #define NARROW_SPACING 39215
#define ULTRAWIDE_SPACING 784313 #define ULTRAWIDE_SPACING 784313
#define ULTRANARROW_SPACING 19607
/* vertical scrolling */ /* vertical scrolling */
#define VERTICAL_SHORT_STEP 16 #define VERTICAL_SHORT_STEP 16
@@ -33,9 +38,11 @@
#define WIDE_STEP 5 #define WIDE_STEP 5
#define NARROW_STEP 1 #define NARROW_STEP 1
#define ULTRAWIDE_STEP 20 #define ULTRAWIDE_STEP 20
#define ULTRANARROW_STEP 1
#define WIDE_MARGIN 13 #define WIDE_MARGIN 13
#define NARROW_MARGIN 3 #define NARROW_MARGIN 3
#define ULTRAWIDE_MARGIN 42 #define ULTRAWIDE_MARGIN 42
#define ULTRANARROW_MARGIN 1
/* frequency bands supported by device */ /* frequency bands supported by device */
#define BAND_300 0 #define BAND_300 0
@@ -63,4 +70,4 @@
#define MID_900 848000000 #define MID_900 848000000
#define UPPER(a, b, c) ((((a) - (b) + ((c) / 2)) / (c)) * (c)) #define UPPER(a, b, c) ((((a) - (b) + ((c) / 2)) / (c)) * (c))
#define LOWER(a, b, c) ((((a) + (b)) / (c)) * (c)) #define LOWER(a, b, c) ((((a) + (b)) / (c)) * (c))

View File

@@ -86,7 +86,13 @@ static int32_t spectrum_analyzer_worker_thread(void* context) {
instance->max_rssi_dec = 0; instance->max_rssi_dec = 0;
for(uint8_t ch = 0; ch < NUM_CHANNELS - 1; ch++) { // Visit each channel non-consecutively
for(
uint8_t ch_offset = 0, chunk = 0;
ch_offset < CHUNK_SIZE;
++chunk >= NUM_CHUNKS && ++ch_offset && (chunk = 0)
) {
uint8_t ch = chunk * CHUNK_SIZE + ch_offset;
furi_hal_subghz_set_frequency(instance->channel0_frequency + (ch * instance->spacing)); furi_hal_subghz_set_frequency(instance->channel0_frequency + (ch * instance->spacing));
furi_hal_subghz_rx(); furi_hal_subghz_rx();

View File

@@ -151,9 +151,11 @@ static void tetris_game_render_callback(Canvas* const canvas, void* ctx) {
tetris_game_draw_playfield(canvas, tetris_state); tetris_game_draw_playfield(canvas, tetris_state);
// Show score on the game field // Show score on the game field
char buffer2[6]; if(tetris_state->gameState == GameStatePlaying) {
snprintf(buffer2, sizeof(buffer2), "%u", tetris_state->numLines); char buffer2[6];
canvas_draw_str_aligned(canvas, 61, 8, AlignRight, AlignBottom, buffer2); snprintf(buffer2, sizeof(buffer2), "%u", tetris_state->numLines);
canvas_draw_str_aligned(canvas, 61, 8, AlignRight, AlignBottom, buffer2);
}
if(tetris_state->gameState == GameStateGameOver) { if(tetris_state->gameState == GameStateGameOver) {
// 128 x 64 // 128 x 64