Skip to content

fix for clock.py display date-time overlapping#190

Merged
rm-hull merged 1 commit intorm-hull:mainfrom
Exaga:main
Mar 2, 2026
Merged

fix for clock.py display date-time overlapping#190
rm-hull merged 1 commit intorm-hull:mainfrom
Exaga:main

Conversation

@Exaga
Copy link
Contributor

@Exaga Exaga commented Mar 2, 2026

The date and time displayed on the SSD1306 OLED 128 x 64 pixel screen are colliding with each other - at the bottom of the date and the top of the time. In the clock.py code I added subtle spacing so that these two elements are separated. It now displays more cleanly and is not overlapping. No other changes. Everything else works perfectly.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 addresses a display issue on an SSD1306 OLED screen where the date and time text were overlapping. The changes involve subtle adjustments to spacing and vertical positioning of the text elements to ensure a cleaner and more readable display without any collision.

Highlights

  • Display Spacing Adjustment: The margin variable, used for horizontal spacing, was increased from 4 to 5 to provide more separation between displayed elements.
  • Vertical Positioning Refinement: The cy variable, which determines the vertical center for drawing, was adjusted from min(device.height, 64) / 2 to min(device.height, 60) / 2 to shift the overall display area slightly.
  • Date and Time Text Alignment: The vertical coordinates for drawing the date and time text were modified. The date was moved further up (from cy - 8 to cy - 10), and the time was moved slightly down (from cy to cy + 2) to prevent overlapping.
Changelog
  • examples/clock.py
    • Increased the margin value from 4 to 5 to enhance horizontal spacing.
    • Adjusted the cy calculation to min(device.height, 60) / 2 for refined vertical alignment.
    • Modified the draw.text coordinates for today_date and today_time to prevent text overlap, specifically moving the date up by 2 pixels and the time down by 2 pixels relative to their previous positions.
Activity
  • No activity has been recorded on this pull request since its creation.
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
Contributor

@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 successfully resolves a display issue where the date and time were overlapping by adjusting margins and coordinates. The changes are effective. My feedback focuses on improving the maintainability of the code by replacing the newly introduced hardcoded numerical values ('magic numbers') with named constants. This practice will make the code more readable and easier to manage for any future modifications.

Comment on lines +39 to +42
margin = 5

cx = 30
cy = min(device.height, 64) / 2
cy = min(device.height, 60) / 2
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While these changes fix the layout issue, they introduce 'magic numbers' (5, 60). To improve code readability and maintainability, it's a good practice to define these as named constants at a higher scope (e.g., at the top of the main function or module level). For example: MARGIN = 5, CLOCK_DIAMETER = 60. This would make the purpose of these values clearer and future adjustments easier.

Comment on lines +62 to +63
draw.text((text_x, cy - 10), today_date, fill="yellow")
draw.text((text_x, cy + 2), today_time, fill="yellow")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The vertical offsets -10 and 2 for positioning the date and time are 'magic numbers'. To make the code more understandable, consider defining them as named constants, like DATE_Y_OFFSET = -10 and TIME_Y_OFFSET = 2. This clarifies their purpose and makes future adjustments easier.

@rm-hull rm-hull merged commit 2a9ed1e into rm-hull:main Mar 2, 2026
3 checks passed
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.

2 participants