Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inkplate 10 #4582

Merged
merged 8 commits into from
Jan 14, 2025
Merged

Inkplate 10 #4582

merged 8 commits into from
Jan 14, 2025

Conversation

karlg100
Copy link
Contributor

Description:

added inkplate 10 example, with RTC, working battery voltage fix, and dual IO expanders

Related issue (if applicable): fixes

none

Pull request in esphome with YAML changes (if applicable): esphome/esphome#

none, docs only

Checklist:

  • I am merging into next because this is new documentation that has a matching pull-request in esphome as linked above.
    or

  • I am merging into current because this is a fix, change and/or adjustment in the current documentation and is not for a new component or feature.

  • Link added in /index.rst when creating new documents for new components or cookbook.

the soldered version of the inkplate 10 with rtc, dual epander and working battery level
Copy link
Contributor

coderabbitai bot commented Jan 14, 2025

Warning

Rate limit exceeded

@jesserockz has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 26 minutes and 35 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 9a22348 and af658fb.

📒 Files selected for processing (1)
  • components/display/inkplate6.rst (1 hunks)

Walkthrough

The pull request introduces documentation for the Inkplate 10 display configuration in the components/display/inkplate6.rst file. The new section provides comprehensive details about the Inkplate 10's specific hardware characteristics, including its two PCA6416A expanders, battery read MOSFET configuration, and potential embedded RTC. The documentation covers configuration examples for RTC synchronization, sensor setup, and display model specification, expanding the existing documentation to support this new display variant.

Changes

File Change Summary
components/display/inkplate6.rst Added Inkplate 10 configuration section with details on:
- RTC setup using PCF85063 platform
- Two PCA6416A expander configurations
- Battery voltage sensor template
- Display model specification as inkplate_10

Suggested labels

has-parent

Suggested reviewers

  • nagyrobi

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (3)
components/display/inkplate6.rst (3)

451-456: Document the purpose of dual PCA6416A expanders.

The configuration shows two PCA6416A expanders but doesn't explain their distinct roles.

Add documentation to clarify the purpose of each expander:

   pca6416a:
     - id: pca6416a_hub
+      # Primary expander for display control
       address: 0x20
     - id: pca6416a_hub2
+      # Secondary expander for additional I/O
       address: 0x21

474-486: Improve battery voltage sensor documentation.

The battery voltage sensor configuration could benefit from additional documentation about the voltage divider and sampling process.

Add comments to explain the battery voltage calculation:

     - platform: template
       name: "Inkplate Battery Voltage"
       unit_of_measurement: "V"
       accuracy_decimals: 3
       lambda: |-
+        // Enable MOSFET to connect battery voltage divider
         id(battery_read_mosfet).turn_on();
+        // Wait for voltage to stabilize
         delay(1);
+        // Sample ADC value
         float adc = id(battery_voltage).sample();
+        // Disable MOSFET to save power
         id(battery_read_mosfet).turn_off();
         return adc;
       filters:
-        - multiply: 2 # for voltage divider
+        - multiply: 2 # Compensate for voltage divider (1:2 ratio)

495-517: Document pin assignments for Inkplate 10.

The pin assignments lack documentation about their specific roles in the Inkplate 10 hardware.

Add comments to explain the pin assignments:

       ckv_pin: 32      # Clock vertical
       sph_pin: 33      # Sample and hold
       gmod_pin:        # Gate voltage controller
         pca6416a: pca6416a_hub
         number: 1
       gpio0_enable_pin: # GPIO0 enable control
         pca6416a: pca6416a_hub
         number: 8
       oe_pin:          # Output enable
         pca6416a: pca6416a_hub
         number: 0
       spv_pin:         # Source voltage controller
         pca6416a: pca6416a_hub
         number: 2
       powerup_pin:     # Power control
         pca6416a: pca6416a_hub
         number: 4
       wakeup_pin:      # Wake from sleep
         pca6416a: pca6416a_hub
         number: 3
       vcom_pin:        # Common voltage reference
         pca6416a: pca6416a_hub
         number: 5
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d65c41 and 73bd988.

📒 Files selected for processing (1)
  • components/display/inkplate6.rst (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
components/display/inkplate6.rst (1)

Pattern **: - Do not generate or add any sequence diagrams

🪛 GitHub Check: build
components/display/inkplate6.rst

[failure] 438-438:
Directive 'code-block' must be indented with 4 spaces, not 2. See components/display/inkplate6.rst:438

🪛 GitHub Actions: Lint
components/display/inkplate6.rst

[error] 438-438: Directive 'code-block' must be indented with 4 spaces, not 2

🔇 Additional comments (1)
components/display/inkplate6.rst (1)

487-494: Verify display platform compatibility.

The configuration uses platform: inkplate6 for an Inkplate 10 display. Let's verify if this is the correct platform.

✅ Verification successful

The platform configuration is correct.

The platform: inkplate6 is the correct platform for Inkplate 10 displays. According to the documentation, this platform supports multiple Inkplate models including Inkplate 10 through the model parameter, which is correctly set to inkplate_10 in your configuration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for Inkplate display platform definitions
rg -A 5 "platform:\s+inkplate" --type yaml

Length of output: 44


Script:

#!/bin/bash
# Search for any Inkplate-related files
fd -t f inkplate

# Search for Inkplate mentions in all files
rg -i "inkplate.*?(6|10)" -A 5

# Search specifically in documentation and component files
fd -e rst -e md -e yaml . | xargs rg -i "inkplate" -A 5

Length of output: 46721

Comment on lines 438 to 450
time:
- platform: pcf85063
id: esptime
# repeated synchronization is not necessary unless the external RTC
# is much more accurate than the internal clock
update_interval: never
- platform: homeassistant
# instead try to synchronize via network repeatedly ...
on_time_sync:
then:
# ... and update the RTC when the synchronization was successful
pcf85063.write_time:

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix indentation and improve RTC configuration documentation.

The code block indentation needs to be fixed to comply with reStructuredText standards. Also, the RTC configuration could benefit from clearer documentation.

Apply this diff to fix the indentation and improve documentation:

-  time:
-    - platform: pcf85063
+    time:
+      - platform: pcf85063
+        # Configure the PCF85063 Real-Time Clock
         id: esptime
-      # repeated synchronization is not necessary unless the external RTC
-      # is much more accurate than the internal clock
+        # Only sync once on boot as the RTC is typically accurate enough
         update_interval: never
-    - platform: homeassistant
-      # instead try to synchronize via network repeatedly ...
+      - platform: homeassistant
+        # Use Home Assistant as the primary time source
         on_time_sync:
           then:
-          # ... and update the RTC when the synchronization was successful
+            # Update the RTC when network time sync succeeds
             pcf85063.write_time:
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
time:
- platform: pcf85063
id: esptime
# repeated synchronization is not necessary unless the external RTC
# is much more accurate than the internal clock
update_interval: never
- platform: homeassistant
# instead try to synchronize via network repeatedly ...
on_time_sync:
then:
# ... and update the RTC when the synchronization was successful
pcf85063.write_time:
time:
- platform: pcf85063
# Configure the PCF85063 Real-Time Clock
id: esptime
# Only sync once on boot as the RTC is typically accurate enough
update_interval: never
- platform: homeassistant
# Use Home Assistant as the primary time source
on_time_sync:
then:
# Update the RTC when network time sync succeeds
pcf85063.write_time:
🧰 Tools
🪛 GitHub Check: build

[failure] 438-438:
Directive 'code-block' must be indented with 4 spaces, not 2. See components/display/inkplate6.rst:438

🪛 GitHub Actions: Lint

[error] 438-438: Directive 'code-block' must be indented with 4 spaces, not 2

components/display/inkplate6.rst Outdated Show resolved Hide resolved
fix for failed lint check
Copy link

netlify bot commented Jan 14, 2025

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit 73bd988
🔍 Latest deploy log https://app.netlify.com/sites/esphome/deploys/67861ab3125852000868d720
😎 Deploy Preview https://deploy-preview-4582--esphome.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
components/display/inkplate6.rst (3)

451-456: Add comments to document IO expander purposes.

Consider adding comments to clarify the role of each PCA6416A expander for better maintainability.

 pca6416a:
   - id: pca6416a_hub
     address: 0x20
+    # Primary expander for display control signals
   - id: pca6416a_hub2
     address: 0x21
+    # Secondary expander for additional GPIO functionality

468-486: Improve ADC reading stability.

The current 1ms delay might be insufficient for the ADC to stabilize after enabling the MOSFET.

       lambda: |-
         id(battery_read_mosfet).turn_on();
-        delay(1);
+        delay(5);  # Allow more time for voltage to stabilize
         float adc = id(battery_voltage).sample();
+        # Take multiple samples for better accuracy
+        for (int i = 0; i < 4; i++) {
+          adc += id(battery_voltage).sample();
+        }
+        adc = adc / 5.0;  # Average the samples
         id(battery_read_mosfet).turn_off();
         return adc;

487-517: Add documentation about Inkplate 10 specific features.

Consider adding comments to highlight the key differences between Inkplate 10 and other models, such as:

  • Display resolution and dimensions
  • Power consumption characteristics
  • Any model-specific limitations or features
     - platform: inkplate6
       id: inkplate_display
+      # Inkplate 10 specific configuration
+      # Resolution: 1200 x 825 pixels
+      # Display size: 9.7 inches
       greyscale: true
       partial_updating: false
       update_interval: never
       model: inkplate_10  
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73bd988 and 55c035c.

📒 Files selected for processing (1)
  • components/display/inkplate6.rst (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
components/display/inkplate6.rst (1)

Pattern **: - Do not generate or add any sequence diagrams

🔇 Additional comments (2)
components/display/inkplate6.rst (2)

430-433: Fix typo in section title and description.

The section title needs proper capitalization, and there's a typo referring to "Inkplate 20" instead of "Inkplate 10".


438-449: Fix indentation and improve RTC configuration documentation.

The code block needs proper indentation, and the RTC configuration comments could be more descriptive.

Additional suggestions for improving the RTC configuration:

  1. Add error handling for RTC write failures
  2. Consider adding a status sensor to monitor RTC synchronization state
 time:
   - platform: pcf85063
     id: esptime
-    # repeated synchronization is not necessary unless the external RTC
-    # is much more accurate than the internal clock
+    # The PCF85063 RTC maintains time when main power is lost
+    # Only sync once on boot as the RTC drift is typically < 1 second per day
     update_interval: never
   - platform: homeassistant
-    # instead try to synchronize via network repeatedly ...
+    # Use Home Assistant as the primary time source
     on_time_sync:
       then:
-        # ... and update the RTC when the synchronization was successful
+        # Update the RTC when network time sync succeeds
+        # Add error handling for RTC write failures
         pcf85063.write_time:
+          id: esptime
+        logger.log:
+          format: "RTC synchronized with network time"
+          level: INFO

Copy link

netlify bot commented Jan 14, 2025

Deploy Preview for esphome ready!

Name Link
🔨 Latest commit af658fb
🔍 Latest deploy log https://app.netlify.com/sites/esphome/deploys/6786ec7b5b54b7000861924b
😎 Deploy Preview https://deploy-preview-4582--esphome.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

karlg100 and others added 2 commits January 14, 2025 03:16
updated based on AI suggestions
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@jesserockz jesserockz merged commit a8948df into esphome:current Jan 14, 2025
3 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants