donkeycar icon indicating copy to clipboard operation
donkeycar copied to clipboard

Improved OLED display part with larger hardware support

Open deltaflyer opened this issue 4 years ago • 14 comments

Dear contributors,

we kindly ask for review of the extension of the OLED part. Following features have been added to the existing OLED-part

  • improved performance upper bound in run time behavior to allow smooth actuator movements, while rendering information on the display
  • more display types: support for 128x32 and 128x64 displays
  • reduced depencies: support of Adafruit legacy SSD1306 pythen package removed
  • support for monochrome graphic rendering: of base64-encoded png pictures
  • smooth integration into i2c-based peripherals: (e.g. actuators) using fair share bus usage policies
  • compact footprint: all graphics and resources embedded into the source code as a single file
  • graphics are hand drawn and thus also open source

It has been tested with the latest dev branch using a Raspberry PI 3 and an Adafruit 16-Channel 12-bit PWM/Servo HAT. Attached are some pictures. After merging of this PR, I can also contribute documentation for the hardware integration. However, integrating the OLED display as another i2c device is complicated

NOTE: the display update rate is slow by purpose to give actuators on i2c priority. if actuators are controlled differently, the update rate can be incremented in the config.

2

3

4

1

Kudos to Rahul Ravikumar for his initial implementation and the input into the discussion

Thank you for comments and the review, Oliver

deltaflyer avatar Dec 18 '19 21:12 deltaflyer

Codecov Report

Merging #512 into dev will increase coverage by 0.06%. The diff coverage is 72.72%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #512      +/-   ##
==========================================
+ Coverage   37.11%   37.17%   +0.06%     
==========================================
  Files          30       30              
  Lines        5510     5517       +7     
  Branches      635      634       -1     
==========================================
+ Hits         2045     2051       +6     
- Misses       3317     3318       +1     
  Partials      148      148
Impacted Files Coverage Δ
setup.py 0% <ø> (ø) :arrow_up:
donkeycar/templates/complete.py 20.44% <0%> (ø) :arrow_up:
donkeycar/templates/cfg_complete.py 100% <100%> (ø) :arrow_up:
donkeycar/management/base.py 32% <0%> (-0.09%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 3bd8541...80e7bda. Read the comment docs.

codecov-io avatar Dec 18 '19 21:12 codecov-io

I already wrote an OLED part some time ago, and have been using it for a while.

https://github.com/tikurahul/donkey/blob/donkey-v3-dev/donkeycar/parts/oled.py

For reference.

tikurahul avatar Dec 19 '19 07:12 tikurahul

Hello @tikurahul

glad, to get feedback from you. I studied your design. The functionality of your OLED part is very nice and showing the IP is a helpful feature. Since the Adafruit libraries use the Linux-Kernel function i2c_smbus_xfer(..) that uses mutex-based protection for concurrent i2c access, your multi-threaded design works without locking up the I2C bus. The idea of my implementation is that it provides an upper run time bound for display updates to meet the soft real-time requirements of Donkey car even for bulky display updates. As a result, complex graphic rendering will not slow down I2c-based actuator controllers. What do you think is a good way to progress? Should I integrate your functionality into your existing OLED driver? Or should the upper bound runtime behaviour added to your OLED-driver implemenation?

Thank you for sharing your thoughts, Oliver

deltaflyer avatar Dec 19 '19 13:12 deltaflyer

Thanks for looking at the part. Yes, in general I was trying to minimize the damage caused by a slow part.

My version does not try to maintain any real-time guarantees but having used it for a couple of months, that has never been an issue.

I can contribute my part to the main donkeycar repo. You can maybe subsequently make changes you want to, to improve upon the part ?

tikurahul avatar Dec 19 '19 14:12 tikurahul

Hello @tikurahul

I can contribute my part to the main donkeycar repo. You can maybe subsequently make changes you want to, to improve upon the part ?

I fully agree. Please do it like this. After that I will propose an extension to your OLED part with my real-time preserving i2c backend and the graphics functions. By this, we should get powerful and safe OLED support with a straight-forward design.

deltaflyer avatar Dec 19 '19 19:12 deltaflyer

Thanks guys! Excited to try this.

On Thu, Dec 19, 2019 at 11:44 AM Oliver Wannenwetsch < [email protected]> wrote:

Hello @tikurahul https://github.com/tikurahul

I can contribute my part to the main donkeycar repo. You can maybe subsequently make changes you want to, to improve upon the part ?

I fully agree. Please do it like this. After that I will propose an extension to your OLED part with my real-time preserving i2c backend and the graphics functions. By this, we should powerful and safe OLED support with a straight-forward design.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/autorope/donkeycar/pull/512?email_source=notifications&email_token=AABKJZ56RKWA2OSF6QTULT3QZPFLFA5CNFSM4J4SCEJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEHKWZXY#issuecomment-567635167, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABKJZ6BYM5V7TSIVQJ7OXTQZPFLFANCNFSM4J4SCEJA .

tawnkramer avatar Dec 19 '19 21:12 tawnkramer

Sorry, will send out the PR today.

tikurahul avatar Dec 20 '19 15:12 tikurahul

Hello @tikurahul thank you for creating the PR. I am looking forward to code on the OLED part on the Christmas break. Best, Oliver

deltaflyer avatar Dec 20 '19 21:12 deltaflyer

@tikurahul thank you for merging your PR, I will continue to work on it now.

deltaflyer avatar Dec 25 '19 20:12 deltaflyer

Hello @tikurahul ok, I have the first prototype running on my hardware that uses your front end and my back end code. While doing this, I recognized that our OLED parts are assuming different display dimensions (128x64 vs. 128x32) :desktop_computer: . Now, I am extending the code base to support both resolutions. For owners of the larger 64 pixel height display, I plan to display an icon of the user mode in the lower part. To get proper testing, I ordered a second smaller display, which should arrive by tomorrow evening. It would be very nice to have all major display sizes in donkey car. I'll keep you in the loop. Best, Oliver

deltaflyer avatar Dec 26 '19 21:12 deltaflyer

Ah. I just realized that too. Let me know if you need help when testing things.

tikurahul avatar Dec 27 '19 17:12 tikurahul

Hello @tikurahul I just pushed my changes and updated the PR description. Can you test the code with your display, if you don't mind? My 128x32 display also arrived, so I will test the code also with both displays.

deltaflyer avatar Dec 28 '19 22:12 deltaflyer

Hey @deltaflyer. Thank you for your PR. You have re-ordered changes, and I can no longer rebase as a result.

Can you please squash and reorder your commits so I can rebase them ? (Use git pull --rebase from dev and apply your changes on top. Ideally there should be 1 commit on top, with all your changes to make it easier to review).

tikurahul avatar Dec 29 '19 05:12 tikurahul

Hello @tikurahul I just rebased the commits. Now everything should be fine for review.

deltaflyer avatar Dec 30 '19 13:12 deltaflyer