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

Attempt to fix compat_mode_pigpio #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

TojikCZ
Copy link

@TojikCZ TojikCZ commented May 5, 2020

Hi, after discovering the pull request that was supposed to add the compat mode to the pigpio side i included my changes to make the sleep amount tune-able and to make it stop busy waiting. The wait gets less precise but I don't think that's a big deal, sleep overshoots by 0.15 nano seconds on my pi. There is a lot of sleep requests shorter than that and the code works regardless.

I have another thing ready for a pull request. I made the caching optional as my setup produces too many errors for me to trust it with displaying the text right on the first try.

This is my first time trying to contribute to an open-source project, so criticize everything i do, so I'll learn something new :)

@TojikCZ
Copy link
Author

TojikCZ commented May 5, 2020

Interested in what the Travis CI will output. I don't have it setup (yet)

-implement for pigpio
@TojikCZ
Copy link
Author

TojikCZ commented May 7, 2020

rebased on master, squashed ugly fix commits

@TojikCZ
Copy link
Author

TojikCZ commented Sep 29, 2021

Feeling pretty ignored over here. Guess I'm deploying with my fork stuck in the time I made it.
What could have I done differently to not get stood up?

@dbrgn
Copy link
Owner

dbrgn commented Oct 3, 2021

This is my first time trying to contribute to an open-source project, so criticize everything i do, so I'll learn something new :)

@TojikCZ sorry for the late response (especially since this was your first contribution). I have lots of open source projects (plus other obligations and interests as well), and sometimes a GitHub notification e-mail gets overlooked.

What could have I done differently to not get stood up?

A friendly ping after a few weeks of inactivity usually helps to bring the issue to my attention.

Your patch looks pretty simple, so I'll take a look right now.

Copy link
Owner

@dbrgn dbrgn left a comment

Choose a reason for hiding this comment

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

This looks like a potentially useful improvement, thanks! I left a few comments.

I realize that the first commit is not your own code, but maybe you want to implement those improvements nevertheless?

if sys.version_info.major < 3:
from time import clock as now
else:
from time import perf_counter as now
Copy link
Owner

Choose a reason for hiding this comment

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

Looking at this Python 2 compat code, I think it's time to drop Python 2 support in the next release. However, for now, let's keep it since it still works.

Default: False
compat_mode_wait_time: Minimum time to pass between sends.
if zero, turns off compat_mode
Default: ``0.001`` seconds.
Copy link
Owner

Choose a reason for hiding this comment

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

Since compat_mode=False and compat_mode_wait_time=0 are essentially the same, can we merge the two parameters?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, I'd like to. But there are two problems with having just the wait amount.
We'll lose backwards compatibility. That's ok. I can do an assert that tells would be users what to do instead.
There would be no default for compat_mode "on". The default amount would have to be sourced from something like DEFAULT_COMPAT_WAIT_TIME constant or the docs.
It's undoubtedly cleaner and gets rid of invalid configs like compat_mode=False with a high compat_mode_wait_time value. Your pick 😉

RPLCD/lcd.py Outdated
@@ -117,6 +135,8 @@ def __init__(self, cols=20, rows=4, dotsize=8, charmap='A02', auto_linebreaks=Tr
else:
raise ValueError('Invalid data bus mode: {}'.format(self.data_bus_mode))



Copy link
Owner

Choose a reason for hiding this comment

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

Two stray empty lines that can be removed.

Copy link
Author

Choose a reason for hiding this comment

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

*poof*

RPLCD/pigpio.py Outdated
@@ -316,6 +332,10 @@ def _send(self, value, mode):
# Switch on pigpio's exceptions
pigpio.exceptions = True

# Record the time for the tail-end of the last send event
if self.compat_mode:
self.last_send_event = now()
Copy link
Owner

Choose a reason for hiding this comment

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

It's a bit weird that the compat mode is something that is supported in the base class, but that implementation details need to be handled in the subclass. How about this?

  • Add two functions in the base class called _compat_mode_wait() and _compat_mode_record_send_event().
  • In the two subclasses, never explicitly check for self.compat_mode, instead simply call those two functions (which are a no-op if compat mode is not enabled).

Another benefit of this is that the Python 2 compat importing of now is only needed once (in the base class).

Copy link
Author

Choose a reason for hiding this comment

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

Yup, done

@dbrgn dbrgn mentioned this pull request Oct 3, 2021
@TojikCZ
Copy link
Author

TojikCZ commented Oct 4, 2021

Sorry, I got a taste of how missable github notifications can be shortly after posting this 😅

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.

3 participants