Skip to content

Commit

Permalink
Squashed 'applications/external/' changes from 400bd29e100..0cbe0421ee4
Browse files Browse the repository at this point in the history
0cbe0421ee4 Format
e352a9e0b65 WAV Player: Reconfigure to use 8-bit memory buffer, halving memory usage
0f51370211e Merge jetpack_joyride from https://github.com/timstrasser/flipper-jetpack-game
985c4342fdc Merge camera_suite from https://github.com/CodyTolene/Flipper-Zero-Camera-Suite
847f0f0 Bump version
a9ecea40755 Update changelog
470c1f645bc Fix up horizontal flip when camera is rotated 180 degrees
dcefdf1c791 Update in-app pinout guide, readme, and version.
8669013 Merge pull request #4 from CookiePLMonster/master
ca74bc2 Updated to SDK 0.103
5fd43f8dbe7 Merge branch 'dev' into ct/v1.8.0
4ac83ef3814 Use new DateTime.

git-subtree-dir: applications/external
git-subtree-split: 0cbe0421ee4c09465dc9a265f202437cbf1967c5
  • Loading branch information
RogueMaster committed Jul 4, 2024
1 parent d72de6a commit f8d3779
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 50 deletions.
2 changes: 1 addition & 1 deletion camera_suite/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ App(
fap_category="GPIO/ESP",
fap_description="A camera suite application for the Flipper Zero ESP32-CAM module.",
fap_icon="icons/camera_suite.png",
fap_version="1.7",
fap_version="1.8",
fap_weburl="https://github.com/CodyTolene/Flipper-Zero-Cam",
name="[ESP32CAM] Camera Suite",
order=1,
Expand Down
13 changes: 10 additions & 3 deletions camera_suite/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
- Full screen 90 degree and 270 degree fill (#6).
- WiFi streaming/connection support (#35).

## v1.8

- Use new Flipper Zero "DateTime" type for image filenames as "YYYYMMDD-HHMMSS.bmp" (#52).
- Fix pinout guide image in-app for "GND-GND" pin reference (#59). Thanks PyroJoe313!
- Fix up horizontal flip when camera is rotated 180 degrees (#57). Thanks 4k3or3et!

## v1.7

- Add support for new Flipper Zero Firmware UART updates.
Expand All @@ -31,7 +37,7 @@
- Improve Firmware code (requires reflash).
- Improve Firmware flashing utility code.
- Improve GitHub actions code.
- Look to mitigate issue "Mirrored Image" #27.
- Look to mitigate issue "Mirrored Image" (#27).
- Addressed new linting issue with "ufbt" tools.

## v1.3
Expand All @@ -42,11 +48,12 @@
- Bug Fix: Addressed picture inversion issue reported by user leedave. Thanks for your contribution! (Closes #23)
- Code Refinement: Enhanced firmware code for readability and maintainability. Separated concerns into individual files for a more organized structure.
- Technical Improvements: Implemented general code enhancements and introduced syntactic sugar for cleaner, more efficient code.
- Work in Progress: Added a new test function for saving pictures to the onboard ESP32-CAM SD card. This feature is under development and will allow users to save pictures directly to the SD card in the future. Tracked under feature request #24.
- Work in Progress: Added a new test function for saving pictures to the onboard ESP32-CAM SD card (#24).

## v1.2

- Save image support. When the center button is pressed take a picture and save it to the "DCIM" folder at the root of your SD card. The image will be saved as a bitmap file with a timestamp as the filename ("YYYYMMDD-HHMMSS.bmp").
- Save image support. When the center button is pressed take a picture and save it to the "DCIM" folder at the root of your SD card.
- Image will be saved as a bitmap file with a timestamp as the filename ("YYYYMMDD-HHMMSS.bmp").
- Camera flash support. Flashes the ESP32-CAM onboard LED when a picture is taken if enabled in the settings.
- Move the camera dithering type to the settings scene as a new configurable option.
- Add "Flash" option to the settings scene as a new configurable option.
Expand Down
37 changes: 8 additions & 29 deletions camera_suite/views/camera_suite_view_camera.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static void draw_pixel_by_orientation(Canvas* canvas, uint8_t x, uint8_t y, uint
break;
}
case 2: { // Camera rotated 180 degrees (upside down)
canvas_draw_dot(canvas, FRAME_WIDTH - 1 - x, FRAME_HEIGHT - 1 - y);
canvas_draw_dot(canvas, x, FRAME_HEIGHT - 1 - y);
break;
}
case 3: { // Camera rotated 270 degrees
Expand Down Expand Up @@ -64,10 +64,11 @@ static void camera_suite_view_camera_draw(Canvas* canvas, void* model) {
// Clear the screen.
canvas_clear(canvas);

// Draw the ESP32-CAM module.
// Set the font to the secondary font.
canvas_set_font(canvas, FontSecondary);

// Draw the ESP32-CAM module.
canvas_draw_str(canvas, 47, 50, "ESP32");
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 52, 58, "CAM");
canvas_draw_dot(canvas, 84, 3);
canvas_draw_box(canvas, 50, 35, 23, 7);
Expand Down Expand Up @@ -114,7 +115,7 @@ static void camera_suite_view_camera_draw(Canvas* canvas, void* model) {
canvas_draw_frame(canvas, 78, 40, 5, 5);

// Draw the pinout lines.
canvas_draw_line(canvas, 39, 8, 21, 8);
canvas_draw_line(canvas, 39, 12, 21, 12);
canvas_draw_line(canvas, 87, 24, 83, 24);
canvas_draw_line(canvas, 87, 32, 83, 32);
canvas_draw_line(canvas, 88, 23, 88, 13);
Expand All @@ -124,27 +125,18 @@ static void camera_suite_view_camera_draw(Canvas* canvas, void* model) {
canvas_draw_line(canvas, 126, 44, 89, 44);

// Draw the pinout labels.
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 91, 11, "VCC-3V");
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 91, 27, "U0R-TX");
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 91, 43, "U0T-RX");
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 2, 12, "GND");
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 12, 21, "-GND");
canvas_draw_str(canvas, 2, 16, "GND");
canvas_draw_str(canvas, 12, 25, "-GND");

// Draw the "Please Connect Module!" text.
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 2, 40, "Please");
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 2, 49, "Connect");
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 2, 58, "Module!");

// Draw the "Back" text and button logo.
canvas_set_font(canvas, FontSecondary);
canvas_draw_str(canvas, 92, 57, "Back");
canvas_draw_line(canvas, 116, 49, 116, 53);
canvas_draw_line(canvas, 115, 50, 115, 52);
Expand Down Expand Up @@ -179,20 +171,11 @@ static void save_image_to_flipper_sd_card(void* model) {
FuriString* file_name = furi_string_alloc();

// Get the current date and time.

// Not supported in "Release" F0 build.
// TODO: Remove when DateTime is supported in "Release" F0 build.
// FuriHalRtcDateTime datetime = {0};

// Only supported in "RC" & "Dev" builds.
// TODO: Uncomment when DateTime is supported in "Release" F0 build.
DateTime datetime = {0};

// TODO: Uncomment when DateTime is supported in "Release" F0 build.
furi_hal_rtc_get_datetime(&datetime);

// Create the file name using DateTime.
// TODO: Uncomment when DateTime is supported in "Release" F0 build.
// Create the file name.
furi_string_printf(
file_name,
EXT_PATH("DCIM/%.4d%.2d%.2d-%.2d%.2d%.2d.bmp"),
Expand All @@ -203,10 +186,6 @@ static void save_image_to_flipper_sd_card(void* model) {
datetime.minute,
datetime.second);

// Just use a random number for now instead of DateTime.
// int random_number = rand();
// furi_string_printf(file_name, EXT_PATH("DCIM/%d.bmp"), random_number);

// Open the file for writing. If the file does not exist (it shouldn't),
// create it.
bool result =
Expand Down
1 change: 1 addition & 0 deletions jetpack_joyride/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ App(
fap_category="Games",
fap_icon_assets="assets",
fap_icon_assets_symbol="jetpack_game",
fap_version="1.1",
)
12 changes: 6 additions & 6 deletions jetpack_joyride/jetpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,18 +251,18 @@ static void jetpack_game_render_callback(Canvas* const canvas, void* ctx) {
furi_mutex_release(game_state->mutex);
}

static void jetpack_game_input_callback(InputEvent* input_event, void* ctx) {
furi_assert(ctx);
FuriMessageQueue* event_queue = ctx;
static void jetpack_game_input_callback(InputEvent* input_event, void* context) {
furi_assert(context);

FuriMessageQueue* event_queue = context;
GameEvent event = {.type = EventTypeKey, .input = *input_event};
furi_message_queue_put(event_queue, &event, FuriWaitForever);
}

static void jetpack_game_update_timer_callback(void* ctx) {
furi_assert(ctx);
FuriMessageQueue* event_queue = ctx;
static void jetpack_game_update_timer_callback(void* context) {
furi_assert(context);

FuriMessageQueue* event_queue = context;
GameEvent event = {.type = EventTypeTick};
furi_message_queue_put(event_queue, &event, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion wav_player/wav_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ typedef struct {
Storage* storage;
Stream* stream;
WavParser* parser;
uint16_t* sample_buffer;
uint8_t* sample_buffer;
uint8_t* tmp_buffer;

uint32_t sample_rate;
Expand Down
12 changes: 6 additions & 6 deletions wav_player/wav_player.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ static WavPlayerApp* app_alloc() {
app->storage = furi_record_open(RECORD_STORAGE);
app->stream = file_stream_alloc(app->storage);
app->parser = wav_parser_alloc();
app->sample_buffer = malloc(sizeof(uint16_t) * app->samples_count);
app->tmp_buffer = malloc(sizeof(uint8_t) * app->samples_count);
app->sample_buffer = malloc(sizeof(*app->sample_buffer) * app->samples_count);
app->tmp_buffer = malloc(sizeof(*app->tmp_buffer) * app->samples_count);
app->queue = furi_message_queue_alloc(10, sizeof(WavPlayerEvent));

app->volume = 10.0f;
Expand Down Expand Up @@ -137,7 +137,7 @@ static void app_free(WavPlayerApp* app) {
// TODO: that works only with 8-bit 2ch audio
static bool fill_data(WavPlayerApp* app, size_t index) {
if(app->num_channels == 1 && app->bits_per_sample == 8) {
uint16_t* sample_buffer_start = &app->sample_buffer[index];
uint8_t* sample_buffer_start = &app->sample_buffer[index];
size_t count = stream_read(app->stream, app->tmp_buffer, app->samples_count_half);

for(size_t i = count; i < app->samples_count_half; i++) {
Expand Down Expand Up @@ -176,7 +176,7 @@ static bool fill_data(WavPlayerApp* app, size_t index) {
}

if(app->num_channels == 1 && app->bits_per_sample == 16) {
uint16_t* sample_buffer_start = &app->sample_buffer[index];
uint8_t* sample_buffer_start = &app->sample_buffer[index];
size_t count = stream_read(app->stream, app->tmp_buffer, app->samples_count);

for(size_t i = count; i < app->samples_count; i++) {
Expand Down Expand Up @@ -214,7 +214,7 @@ static bool fill_data(WavPlayerApp* app, size_t index) {
}

if(app->num_channels == 2 && app->bits_per_sample == 16) {
uint16_t* sample_buffer_start = &app->sample_buffer[index];
uint8_t* sample_buffer_start = &app->sample_buffer[index];
size_t count = stream_read(app->stream, app->tmp_buffer, app->samples_count);

for(size_t i = 0; i < app->samples_count; i += 4) {
Expand Down Expand Up @@ -277,7 +277,7 @@ static bool fill_data(WavPlayerApp* app, size_t index) {
}

if(app->num_channels == 2 && app->bits_per_sample == 8) {
uint16_t* sample_buffer_start = &app->sample_buffer[index];
uint8_t* sample_buffer_start = &app->sample_buffer[index];
size_t count = stream_read(app->stream, app->tmp_buffer, app->samples_count);

for(size_t i = count; i < app->samples_count; i++) {
Expand Down
5 changes: 3 additions & 2 deletions wav_player/wav_player_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ void wav_player_speaker_init(uint32_t sample_rate) {
TIM_InitStruct.Prescaler = 0;
//TIM_InitStruct.Autoreload = 1451; //64 000 000 / 1451 ~= 44100 Hz

TIM_InitStruct.Autoreload = 64000000 / sample_rate - 1; //to support various sample rates
TIM_InitStruct.Autoreload =
SystemCoreClock / sample_rate - 1; //to support various sample rates

LL_TIM_Init(SAMPLE_RATE_TIMER, &TIM_InitStruct);

Expand Down Expand Up @@ -95,7 +96,7 @@ void wav_player_dma_init(uint32_t address, size_t size) {
LL_DMA_SetPeriphIncMode(DMA_INSTANCE, LL_DMA_PERIPH_NOINCREMENT);
LL_DMA_SetMemoryIncMode(DMA_INSTANCE, LL_DMA_MEMORY_INCREMENT);
LL_DMA_SetPeriphSize(DMA_INSTANCE, LL_DMA_PDATAALIGN_HALFWORD);
LL_DMA_SetMemorySize(DMA_INSTANCE, LL_DMA_MDATAALIGN_HALFWORD);
LL_DMA_SetMemorySize(DMA_INSTANCE, LL_DMA_MDATAALIGN_BYTE);

LL_DMA_EnableIT_TC(DMA_INSTANCE);
LL_DMA_EnableIT_HT(DMA_INSTANCE);
Expand Down
2 changes: 1 addition & 1 deletion wav_player/wav_player_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void wav_player_view_set_bits(WavPlayerView* wav_view, uint16_t bit) {
wav_view->view, WavPlayerViewModel * model, { model->bits_per_sample = bit; }, true);
}

void wav_player_view_set_data(WavPlayerView* wav_view, uint16_t* data, size_t data_count) {
void wav_player_view_set_data(WavPlayerView* wav_view, uint8_t* data, size_t data_count) {
furi_assert(wav_view);
with_view_model(
wav_view->view,
Expand Down
2 changes: 1 addition & 1 deletion wav_player/wav_player_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void wav_player_view_set_current(WavPlayerView* wav_view, size_t current);

void wav_player_view_set_play(WavPlayerView* wav_view, bool play);

void wav_player_view_set_data(WavPlayerView* wav_view, uint16_t* data, size_t data_count);
void wav_player_view_set_data(WavPlayerView* wav_view, uint8_t* data, size_t data_count);

void wav_player_view_set_bits(WavPlayerView* wav_view, uint16_t bit);
void wav_player_view_set_chans(WavPlayerView* wav_view, uint16_t chn);
Expand Down

0 comments on commit f8d3779

Please sign in to comment.