Skip to content

Led flash work 2#87

Open
acutetech wants to merge 19 commits intodevfrom
led_flash_work_2
Open

Led flash work 2#87
acutetech wants to merge 19 commits intodevfrom
led_flash_work_2

Conversation

@acutetech
Copy link

The HM0360 default register settings in the list of all registers (file name below) has been updated to include values that produce acceptable STROBE behaviour.

HM0360_OSC_Bayer_640x480_setA_VGA_setB_QVGA_md_8b_ParallelOutput_R2.i

I have added some docs in /doc/Strobe_timings.md

@gemini-code-assist
Copy link

Summary of Changes

Hello @acutetech, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the LED flash functionality, particularly for the HM0360 camera sensor, by adjusting register settings to ensure correct STROBE timing during image capture. It also introduces a robust utility for managing CLI output, refines the image processing task's state transitions and timing, and integrates comprehensive Git version information into the build process. Additionally, new documentation has been added to clarify LED flash behavior and development workflows.

Highlights

  • LED Flash Control: Updated HM0360 camera register settings to achieve acceptable STROBE behavior for LED flashes, ensuring proper timing with image capture. The LED flash is now explicitly turned off after an image capture and before entering Deep Power Down (DPD).
  • CLI Output Refactoring: Introduced a new cli_append helper function to safely format and append text to FreeRTOS CLI output buffers, replacing numerous direct snprintf calls and improving buffer management.
  • Image Task Enhancements: Refined the image task's state machine logic, including improved timing measurements for image capture and NN processing, and better handling of camera initialization and DPD preparation for the HM0360 sensor.
  • Build Information & Documentation: Added Git branch, commit, and dirty status to the build output for better version tracking and included new markdown documentation detailing STROBE timing and Git workflow.
  • Codebase Cleanup: Removed redundant f_chdir calls in the FATFS task and eliminated a temporary image_hackInactive function, streamlining the codebase.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • .gitignore
    • Added ignore rules for secureboot_tool certificates, text, and log files.
  • EPII_CM55M_APP_S/app/ww_projects/ww130_cli/image_task.c
    • Reformatted curly brace placement for handleEventForInit function.
    • Reordered lines and added a comment in handleEventForInit for clarity.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/CLI-FATFS-commands.c
    • Replaced direct snprintf calls with the new cli_append helper function for safer buffer handling.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/CLI-commands.c
    • Removed an empty line for minor formatting cleanup.
    • Reformatted curly brace placement for prvTaskStateCmd function.
    • Replaced direct snprintf calls with the new cli_append helper function across various CLI commands.
    • Modified the prvDpd command to use inactivity_setPeriod instead of image_hackInactive.
    • Moved the inactivity_setPeriod call for CLI character reception to ensure extended inactivity period.
    • Added a new cli_append function for safe formatted string appending to CLI buffers.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/CLI-commands.h
    • Added the declaration for the new cli_append function.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/app_msg.h
    • Included FreeRTOS kernel headers for QueueHandle_t type definition.
    • Added a new APP_MSG_IMAGETASK_FLASH_OFF event to the image task message enumeration.
    • Updated comment for imageTaskEventString array.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/cis_sensor/cis_hm0360/HM0360_OSC_Bayer_640x480_setA_VGA_setB_QVGA_md_8b_ParallelOutput_R2.i
    • Updated the STROBE_CFG register (0x3080) value from 0x00 to 0x03.
    • Added descriptive comments for various STROBE control registers.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/cvapp.cpp
    • Added a comment clarifying the TFLM library definition.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/doc/STROBE_timing.md
    • Added a new markdown document detailing LED Flash timing for STROBE vs VSYNC, including register settings and timing diagrams.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/fatfs_task.c
    • Modified the op_parameter array to include a default STROBE mode setting (0x0b) for future use.
    • Removed commented-out f_chdir calls, simplifying directory management logic.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/hm0360_md.c
    • Added missing includes for stdbool.h.
    • Reformatted code with additional newlines for readability.
    • Updated the print statement in calculateSleepTime for better clarity.
    • Added a side effect comment for hm0360_md_isSensorPresent function.
    • Removed the old hm0360_md_prepare and hm0360_md_enableMD functions.
    • Updated the print statement in hm0360_md_setMode for better clarity.
    • Introduced a new hm0360_md_prepare function with an additional mdFrameInterval parameter, consolidating MD preparation logic.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/hm0360_md.h
    • Added HM0360_SENSOR_STROBE_MODE define with a default value of 0x03.
    • Updated the function signature for hm0360_md_prepare to include mdFrameInterval.
    • Commented out the hm0360_md_enableMD function, indicating it's replaced.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/hm0360_regs.h
    • Added a comment for PMU_CFG_5 indicating its purpose as 'pre-meter'.
    • Added STROBE_END_L define and corrected the register address for STROBE_LINE_H.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/if_task.c
    • Added a comment describing the purpose of xI2CTxSemaphore.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/image_task.c
    • Added a detailed file header comment for image_task.c.
    • Updated imageTaskEventString to include the new Image Event Flash Off.
    • Initialized cameraSystemEnabled to 0.
    • Removed unused presentTime, elapsedTime, and elapsedMs variables.
    • Reformatted curly brace placement for various functions.
    • Added a call to ledFlashDisable() after an image frame is ready.
    • Updated time measurement logic to use app_getElapsedMs and reset startTime more consistently.
    • Added configure_image_sensor(CAMERA_CONFIG_STOP) after a capture sequence is complete.
    • Initialized cameraInitialised to false and nnStatus to -1.
    • Improved initialisation print statements to show camera type, NN status, and flash LED details.
    • Updated MD and Timelapse interval print statements for clarity.
    • Added special handling for APP_MSG_IMAGETASK_FLASH_OFF event in the main task loop to disable the LED flash.
    • Removed the CAMERA_CONFIG_MD case from configure_image_sensor.
    • Removed the image_hackInactive function.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/image_task.h
    • Removed CAMERA_CONFIG_MD from the CAMERA_CONFIG_E enumeration.
    • Updated FLASHDURATION define to 50ms with a clarifying comment.
    • Removed the declaration for image_hackInactive.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/ledFlash.c
    • Included app_msg.h.
    • Added xImageTaskQueue as an external variable.
    • Modified FlashOffTimerCallback to send an APP_MSG_IMAGETASK_FLASH_OFF message to the image task queue.
    • Added checks for LEDFLASHDURATIONMIN and LEDFLASHDURATIONMAX in ledFlashEnable to prevent invalid flash durations.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/ledFlash.h
    • Added LEDFLASHDURATIONMIN and LEDFLASHDURATIONMAX defines for flash duration limits.
    • Corrected comment for ledFlashInit function.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/pca9574.c
    • Removed an empty line in saveMainCameraConfig.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/ww500_md.c
    • Added preprocessor defines (GIT_BRANCH, GIT_COMMIT, GIT_DIRTY) to include Git information in the build.
    • Added a new app_getElapsedMs function to calculate elapsed time in milliseconds.
    • Removed commented-out code related to HM0360 MD wake-up events.
    • Removed empty lines and unnecessary pinmux_init call.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/ww500_md.h
    • Added the declaration for the new app_getElapsedMs function.
  • EPII_CM55M_APP_S/app/ww_projects/ww500_md/ww500_md.mk
    • Added Makefile logic to extract Git branch, commit, and dirty status and define them as APPL_DEFINES.
    • Added a force_rebuild_main target to ensure the main C file is rebuilt on every build, updating __TIME__ and __DATE__.
    • Changed CIS_SUPPORT_INAPP_MODEL to cis_hm0360.
  • _Documentation/Git_Branch_and_PR_Workflow.md
    • Added a new markdown document outlining the team's Git branch and pull request workflow, including rebasing and stacked branches.
  • _Documentation/HM0360_on WW500_Summary.md
    • Updated the date in the document header.
    • Added new external resources and links related to HM0360 usage and drivers.
  • _Tools/hm0360_strobe_align_end.txt
    • Added a new text file containing HM0360 STROBE register settings for aligning to the end of the reset field.
  • _Tools/hm0360_strobe_dynamic1.txt
    • Added a new text file containing HM0360 STROBE register settings for Dynamic 1 mode.
  • _Tools/hm0360_strobe_dynamic1A.txt
    • Added a new text file containing HM0360 STROBE register settings for Dynamic 1 mode with VSYNC output enabled in Context B.
  • _Tools/hm0360_strobe_dynamic1B.txt
    • Added a new text file containing HM0360 STROBE register settings for Dynamic 1 mode with STROBE_FRAME_L set to 0x00.
  • _Tools/hm0360_strobe_dynamic1C.txt
    • Added a new text file containing HM0360 STROBE register settings for Dynamic 1 mode with STROBE_FRAME_L set to 0x01.
  • _Tools/hm0360_strobe_dynamic1D.txt
    • Added a new text file containing HM0360 STROBE register settings for Dynamic 1 mode with STROBE_FRAME_L set to 0x02.
  • _Tools/hm0360_strobe_dynamic1E.txt
    • Added a new text file containing HM0360 STROBE register settings for Dynamic 1 mode with STROBE_FRAME_L set to 0x03.
  • _Tools/hm0360_strobe_dynamic1F.txt
    • Added a new text file containing HM0360 STROBE register settings for Dynamic 1 mode with STROBE_FRAME_L restored to 0x04.
  • _Tools/hm0360_strobe_line200.txt
    • Added a new text file containing HM0360 STROBE register settings with STROBE_LINE_L set to 0xc8.
  • _Tools/scan_cis_settings.md
    • Updated the date in the document header.
    • Updated references to output binary file name from hm0360_extra.bin to HM0360EX.BIN and corresponding code snippets.
  • we2_image_gen_local_dpd/secureboot_tool/cert/ICVSBContent_Cert.txt
    • Removed the ICVSBContent_Cert.txt file.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant improvements related to the HM0360 sensor's LED flash (strobe) functionality. Key changes include updating the sensor's register settings for correct strobe behavior, adding documentation for the new timing, and a major refactoring of the CLI command handling to use a safer cli_append function. The codebase has also been cleaned up by removing dead or "hacky" code and improving logging. Overall, these changes enhance the correctness, maintainability, and robustness of the firmware. I've found a few minor issues in documentation and some dead code that could be cleaned up.

@acutetech
Copy link
Author

Added further commits on this branch. I am about to leave this branch to make another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant