Skip to content

Commit

Permalink
Merge pull request #25 from CodyTolene/ct/improvements
Browse files Browse the repository at this point in the history
New auto flasher. Improve camera I/O, code, comments, and draw. Resolve bugs.
  • Loading branch information
CodyTolene authored Oct 3, 2023
2 parents 880f4a5 + 5503a75 commit 3741c73
Show file tree
Hide file tree
Showing 65 changed files with 1,144 additions and 468 deletions.
Binary file modified .github/images/esp32-cam-pinout-guide.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .github/images/firmware-build-success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file removed .github/images/preview_02.png
Binary file not shown.
Binary file removed .github/images/v1-1.gif
Binary file not shown.
Binary file removed .github/images/v1-2.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
uses: flipperdevices/[email protected]
id: build-app
with:
app-dir: ./src-fap
app-dir: ./fap
sdk-channel: ${{ matrix.sdk-channel }}
- name: Upload app artifacts
uses: actions/upload-artifact@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on: pull_request
jobs:
ufbt-build-action:
runs-on: ubuntu-latest
name: 'ufbt: Build for Dev branch'
name: "ufbt: Build for Dev branch"
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -13,7 +13,7 @@ jobs:
uses: flipperdevices/[email protected]
id: build-app
with:
app-dir: ./src-fap
app-dir: ./fap
sdk-channel: dev
- name: Lint sources
uses: flipperdevices/[email protected]
Expand Down
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
*.clang-format
*.editorconfig
*.exe
*.flag
*.vscode
*.zip
.DS_Store
.clang-format
.editorconfig
.idea
.vscode
.submodules/*
/venv
__pycache__
dist/*
src-fap/.gitignore
.submodules/*
fap/dist/*
69 changes: 50 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,37 @@

## Table of Contents <a name="index"></a>

- [Previews](#previews)
- [Introduction](#intro)
- [Hardware Requirements](#hardware-requirements)
- [Hardware Installation](#hardware-installation)
- [Firmware Installation](#firmware-installation)
- [Software Installation](#software-installation)
- [Software Guide](#software-guide)
- [Attributions](#attributions)
- [Contributions](#contributions)
- [Changelog](src-fap/docs/CHANGELOG.md)
- [Changelog](fap/docs/CHANGELOG.md)

## Previews <a name="previews"></a>
## Introduction <a name="intro"></a>

Greetings!
<img align="center" src=".github/images/preview.png" />

- <img align="center" src=".github/images/preview_01.png" />
### Welcome to the ESP32-CAM Suite for Flipper Zero!

Preview with a camera module attached to the Flipper Zero.
Discover a new dimension of possibilities by connecting your ESP32-CAM module with your Flipper Zero device. The ESP32-CAM module, a compact ~~powerful~~ cheap camera module, enables you to capture images and stream a live video to your Flipper Zero. With this suite, your Flipper Zero becomes a hub of creativity and utility.

- <img align="center" src=".github/images/preview_02.png" />
**What You Can Do:**
- **Capture Moments:** This custom Flipper Zero application empowers you to take pictures effortlessly. View real-time image previews on your Flipper Zero screen while you capture high quality blocky and pixelated memories! Hey it's still a memory and we're at least having fun...
- **Personalize Your Experience:** Tailor your camera settings with ease. Adjust camera orientation, experiment with various dithering options, and toggle flash, haptic feedback, sound effects, and LED effects to match your preferences. Feel free to use this as a flashlight too, it's pretty bright and good at blinding yourself unexpectedly!

Version 1.1.0 and above now supports new dithering options and bug fixes!

- <img align="center" src=".github/images/v1-1.gif" />

Version 1.2.0 and above now supports taking pictures, configurable dithering, and LED flash!

- <img align="center" src=".github/images/v1-2.gif" />
There will be many more features added in the future! If you have any ideas or suggestions, please let me know by opening an issue [here][issues-link].

<p align="right">[ <a href="#index">Back to top</a> ]</p>

## Hardware Requirements <a name="hardware-requirements"></a>

Requires an ESP32-CAM module (I've personally used these: [Amazon Link 1][amazon-esp32-cam-link-1] | [Amazon Link 2][amazon-esp32-cam-link-2]).

<img src=".github/images/esp32-cam-front.png" />
<img src=".github/images/esp32-cam-back.png" />
<img src=".github/images/esp32-cam-front.png" /><img src=".github/images/esp32-cam-back.png" />

<p align="right">[ <a href="#index">Back to top</a> ]</p>

Expand All @@ -74,6 +69,30 @@ On the ESP32-CAM module itself you'll also need to connect the `IO0` pin to `GND

## Firmware Installation <a name="firmware-installation"></a>

The firmware is the software that runs on the ESP32-CAM module. It is required to use the camera module with your Flipper Zero. There are two ways to install the firmware, the new, easy way, and the old, hard way. The new way is a script that will do everything for you, the old way is a manual process that requires you to install the Arduino IDE and manually flash the firmware to the ESP32-CAM module. I recommend the new way, but if you have issues with it, try the old way.

Below are the instructions for both ways. Choose one and follow the instructions to continue.

<details>

<summary>Firmware Flashing Utility (easy way)</summary>

### Firmware Flashing Utility (Windows 10+ batch script)

1. Download/clone this repository to your computer.
2. Run the script found at the root of this directory: `firmware-flash.bat`.
3. Follow the on screen instructions to continue to flash the firmware to your ESP32-CAM module.

That's it, let me know if you have any issues!

</details>

<details>

<summary>Arduino IDE (hard way)</summary>

### Arduino IDE

1. Download and install the Arduino IDE from [here][arduino-ide].
2. Go to the [releases section][flipper-zero-camera-suite-releases] for this repo and download the `esp32_cam_uart_stream.zip` file.
3. Extract the contents of `esp32_cam_uart_stream.zip` to disk. Be sure to keep the `.ino` file nested in the folder with the same name.
Expand All @@ -96,6 +115,12 @@ On the ESP32-CAM module itself you'll also need to connect the `IO0` pin to `GND

Note the upload may fail a few times, this is normal, try again. If it still fails, try pressing the RST button on the back of the ESP32-CAM module again or checking your connections.

On success, your screen should look like this:

<img align="center" src=".github/images/firmware-build-success.png" />

</details>

<p align="right">[ <a href="#index">Back to top</a> ]</p>

## Software Installation <a name="software-installation"></a>
Expand Down Expand Up @@ -133,7 +158,7 @@ Note the upload may fail a few times, this is normal, try again. If it still fai

▶️ = Toggle dithering on/off.

⚪ = Take a picture and save 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"). If flash is on in the settings (enabled by default) the ESP32-CAM onboard LED will light up when the picture is taken.
⚪ = Take a picture and save 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"). If flash is on in the settings (enabled by default) the ESP32-CAM onboard LED will light up when the camera is opened.

↩️ = Go back.

Expand All @@ -143,7 +168,7 @@ Note the upload may fail a few times, this is normal, try again. If it still fai

**Dithering Type** Change between the Cycle Floyd–Steinberg, Jarvis-Judice-Ninke, and Stucki dithering types.

**Flash** Toggle the ESP32-CAM onboard LED on/off when taking a picture.
**Flash** Toggle the ESP32-CAM onboard LED on/off when using the camera.

**Haptic FX** = Toggle haptic feedback on/off.

Expand All @@ -159,6 +184,8 @@ This project is based on/forked from the [Flipper Zero Camera Application][flipp
by [Z4urce][github-profile-z4urce] combined with the [Flipper Zero Boilerplate Application][flipper-zero-fap-boilerplate]
by [Dave Lee][github-profile-leedave].

The firmware provided here also works with Z4urce's [Flipper Zero Camera Application][flipperzero-camera] so if you have their application installed it too should work fine.

<p align="right">[ <a href="#index">Back to top</a> ]</p>

## Contributions <a name="contributions"></a>
Expand All @@ -167,7 +194,9 @@ by [Dave Lee][github-profile-leedave].
2. Create a new branch: `<username>/[<issue-#>]-<feature-or-bug-fix-desc>`
3. Program. Commit changes, push.
4. Request PR [here][pull-request-link], introduce work via your branch.
5. Wait for review and merge. Thank you!
5. Wait for review and merge.

Thank you!

<p align="right">[ <a href="#index">Back to top</a> ]</p>

Expand All @@ -180,9 +209,11 @@ Cody
[amazon-esp32-cam-link-1]: https://amzn.to/44rBFrb
[amazon-esp32-cam-link-2]: https://amzn.to/45nDR45
[arduino-ide]: https://www.arduino.cc/en/software
[clang-format-tool]: https://releases.llvm.org/download.html
[flipper-zero-camera-suite-releases]: https://github.com/CodyTolene/Flipper-Zero-Camera-Suite/releases
[flipper-zero-fap-boilerplate]: https://github.com/leedave/flipper-zero-fap-boilerplate
[flipperzero-camera]: https://github.com/Z4urce/flipperzero-camera
[github-profile-leedave]: https://github.com/leedave
[github-profile-z4urce]: https://github.com/Z4urce
[issues-link]: https://github.com/CodyTolene/Flipper-Zero-Camera-Suite/issues
[pull-request-link]: https://github.com/CodyTolene/Flipper-Zero-Camera-Suite/pulls
27 changes: 27 additions & 0 deletions arduino-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
board_manager:
additional_urls:
- https://dl.espressif.com/dl/package_esp32_index.json
build_cache:
compilations_before_purge: 10
ttl: 720h0m0s
daemon:
port: "50051"
directories:
data: C:\temp\arduino-cli\data
downloads: C:\temp\arduino-cli\downloads
user: C:\temp\arduino-cli\user
library:
enable_unsafe_install: false
logging:
file: ""
format: text
level: info
metrics:
addr: :9090
enabled: true
output:
no_color: false
sketch:
always_export_binaries: false
updater:
enable_notification: true
2 changes: 1 addition & 1 deletion src-fap/application.fam → fap/application.fam
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ App(
fap_description="A camera suite application for the Flipper Zero ESP32-CAM module.",
fap_icon="icons/camera_suite.png",
fap_libs=["assets"],
fap_version="1.2",
fap_version="1.3",
fap_weburl="https://github.com/CodyTolene/Flipper-Zero-Cam",
name="[ESP32] Camera Suite",
order=1,
Expand Down
1 change: 1 addition & 0 deletions src-fap/camera_suite.c → fap/camera_suite.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ CameraSuite* camera_suite_app_alloc() {
app->dither = 0; // Dither algorithm is "Floyd Steinberg" by default.
app->flash = 1; // Flash is enabled by default.
app->haptic = 1; // Haptic is enabled by default
app->jpeg = 0; // Save JPEG to ESP32-CAM sd-card is disabled by default.
app->speaker = 1; // Speaker is enabled by default
app->led = 1; // LED is enabled by default

Expand Down
6 changes: 6 additions & 0 deletions src-fap/camera_suite.h → fap/camera_suite.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ typedef struct {
uint32_t dither;
uint32_t flash;
uint32_t haptic;
uint32_t jpeg;
uint32_t speaker;
uint32_t led;
ButtonMenu* button_menu;
Expand Down Expand Up @@ -64,6 +65,11 @@ typedef enum {
CameraSuiteFlashOn,
} CameraSuiteFlashState;

typedef enum {
CameraSuiteJpegOff,
CameraSuiteJpegOn,
} CameraSuiteJpegState;

typedef enum {
CameraSuiteHapticOff,
CameraSuiteHapticOn,
Expand Down
17 changes: 14 additions & 3 deletions src-fap/docs/CHANGELOG.md → fap/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
## Roadmap

- Full screen 90 degree and 270 degree fill.
- In-camera GUI.
- Store images to onboard ESP32-CAM SD card (currently in progress, #24).
- Camera preview GUI overlay (#21).
- Full screen 90 degree and 270 degree fill (#6).

## v1.2 (current)
## v1.3 (current)

- Important: Firmware Update Required! Ensure you update your firmware to fully utilize the new features. Backwards compatibility should be ok.
- New Feature: Introducing the Firmware Flash utility, simplifying the firmware flashing process. Refer to the project readme for detailed instructions. (Closes #26)
- Enhancement: Flash functionality now remains active during camera preview, making it easier to take pictures in areas of low light.
- 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.

## 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").
- Camera flash support. Flashes the ESP32-CAM onboard LED when a picture is taken if enabled in the settings.
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void camera_suite_save_settings(void* context) {
fff_file, BOILERPLATE_SETTINGS_KEY_ORIENTATION, &app->orientation, 1);
flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_DITHER, &app->dither, 1);
flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_FLASH, &app->flash, 1);
flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_JPEG, &app->jpeg, 1);
flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
flipper_format_write_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_LED, &app->led, 1);
Expand Down Expand Up @@ -107,6 +108,7 @@ void camera_suite_read_settings(void* context) {
fff_file, BOILERPLATE_SETTINGS_KEY_ORIENTATION, &app->orientation, 1);
flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_DITHER, &app->dither, 1);
flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_FLASH, &app->flash, 1);
flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_JPEG, &app->jpeg, 1);
flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_HAPTIC, &app->haptic, 1);
flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_SPEAKER, &app->speaker, 1);
flipper_format_read_uint32(fff_file, BOILERPLATE_SETTINGS_KEY_LED, &app->led, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define BOILERPLATE_SETTINGS_KEY_ORIENTATION "Orientation"
#define BOILERPLATE_SETTINGS_KEY_DITHER "Dither"
#define BOILERPLATE_SETTINGS_KEY_FLASH "Flash"
#define BOILERPLATE_SETTINGS_KEY_JPEG "SaveJPEG"
#define BOILERPLATE_SETTINGS_KEY_HAPTIC "Haptic"
#define BOILERPLATE_SETTINGS_KEY_LED "Led"
#define BOILERPLATE_SETTINGS_KEY_SPEAKER "Speaker"
Expand Down
File renamed without changes
2 changes: 1 addition & 1 deletion src-fap/manifest.yml → fap/manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ sourcecode:
location:
commit_sha: ...
origin: https://github.com/CodyTolene/Flipper-Zero-Camera-Suite.git
subdir: src-fap
subdir: fap
type: git
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ const uint32_t flash_value[2] = {
CameraSuiteFlashOn,
};

const char* const jpeg_text[2] = {
"OFF",
"ON",
};

const uint32_t jpeg_value[2] = {
CameraSuiteJpegOff,
CameraSuiteJpegOn,
};

const char* const haptic_text[2] = {
"OFF",
"ON",
Expand Down Expand Up @@ -93,6 +103,14 @@ static void camera_suite_scene_settings_set_flash(VariableItem* item) {
app->flash = flash_value[index];
}

static void camera_suite_scene_settings_set_jpeg(VariableItem* item) {
CameraSuite* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);

variable_item_set_current_value_text(item, jpeg_text[index]);
app->jpeg = jpeg_value[index];
}

static void camera_suite_scene_settings_set_haptic(VariableItem* item) {
CameraSuite* app = variable_item_get_context(item);
uint8_t index = variable_item_get_current_value_index(item);
Expand Down Expand Up @@ -154,6 +172,20 @@ void camera_suite_scene_settings_on_enter(void* context) {
variable_item_set_current_value_index(item, value_index);
variable_item_set_current_value_text(item, flash_text[value_index]);

// @todo - Save picture to ESP32-CAM sd-card instead of Flipper Zero
// sd-card. This hides the setting for it, for now.
// Save JPEG to ESP32-CAM sd-card instead of Flipper Zero sd-card ON/OFF
// item = variable_item_list_add(
// app->variable_item_list,
// "Save JPEG to ext sdcard:",
// 2,
// camera_suite_scene_settings_set_jpeg,
// app);
// value_index = value_index_uint32(app->jpeg, jpeg_value, 2);
// variable_item_set_current_value_index(item, value_index);
// variable_item_set_current_value_text(item, jpeg_text[value_index]);
UNUSED(camera_suite_scene_settings_set_jpeg);

// Haptic FX ON/OFF
item = variable_item_list_add(
app->variable_item_list, "Haptic FX:", 2, camera_suite_scene_settings_set_haptic, app);
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 3741c73

Please sign in to comment.