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

Extended hardware support #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Extended hardware support #2

wants to merge 1 commit into from

Conversation

tic226n
Copy link
Contributor

@tic226n tic226n commented Dec 30, 2021

  • Added #ifdef-based support for OLED displays with SH1106 controller since they are often sold as 'SSD1306 compatible' but would render with an offset on the x-axis and garbage on the right edge when used as a drop-in replacement, although physically/electrically they are identical.
  • Added #ifdef-based support for Adafruit's MCP4725 ADC module which uses a custom address scheme (source: https://learn.adafruit.com/mcp4725-12-bit-dac-tutorial/wiring)
  • Added an additional disp.clear(); instruction on line 1255 because during testing the main screen (displayscreen1) showed characters from the calibration screen texts between the longitude/latitude numbers and the voltages displayed behind them. Note: This might be caused by the display type (SH1106-based) since the problem is not visible on the documentation's photos. I don't have a spare SSD1306 display to test this theory but so far this additional disp.clear instruction hasn't caused any issues during testing (i.e. screen flicker or similar)

I've got a few small additions i'm using in my copy of the code which i turned into #ifdef style config options to support two hardware variants, namely a SH1106-based OLED display and the Adafruit version of the MCP4725 ADC board.
The SH1106 is compatible with the SSD1306 but when used without modifications the display will render the characters with a negative offset on the x-axis. As i bought my OLED displays from AliExpress and the sellers described them as 'the same as SSD1306' it took some troubleshooting to find out that the display itself was not at fault but needed just a different library call. This might help others running into the same problem and widens display type support.
The Adafruit MCP4725 ADC module was bugging me as well; the MCP4725 datasheet lists the default I2C address as '1100000' but customers can specify the second and third address bit to be hardwired during production which apparently Adafruit did, so their default address is '1100010' or 0x62 if pin A0 is left floating and 0x63 if pulled high (info source in comment above).
The additional disp.clear on line 1255 was necessary for me to get rid of leftover characters from the calibration screen which would sit between longitude/latitude values and the Vdd/Vcc readings. Kind of a headscratcher, this might be due to the different display type but hasn't shown any negative effect during testing so far. Uncommenting the disp.clearLine has led to flickering.
Some of the #ifdef statements had to be rewritten to include a boolean OR operand in case they're valid for both hardware variants. (source: https://stackoverflow.com/questions/2998864/how-to-add-a-or-condition-in-ifdef)

I thought the additions might be helpful for others in the future and save them some unnecessary troubleshooting but i understand that they might not be helpful with refactoring and reducing codebase size so i understand if you don't want to merge this. After all, it's just 2 small changes in 2 lines of code which can be done manually if needed.

PS: Fantastic project and very nice, clean code. Thank you for open-sourcing it! Have a happy new year!

- Added #ifdef-based support for OLED displays with SH1106 controller since they are often sold as 'SSD1306 compatible' but would render with an offset on the x-axis and garbage on the right edge when used as a drop-in replacement, although physically/electrically they are identical.
- Added #ifdef-based support for Adafruit's MCP4725 ADC module which uses a custom address scheme (source: https://learn.adafruit.com/mcp4725-12-bit-dac-tutorial/wiring)
- Added an additional disp.clear(); instruction on line 1255 because during testing the main screen (displayscreen1) showed characters from the calibration screen texts between the longitude/latitude numbers and the voltages displayed behind them. Note: This might be caused by the display type (SH1106-based) since the problem is not visible on the documentation's photos. I don't have a spare SSD1306 display to test this theory but so far this additional disp.clear instruction hasn't caused any issues during testing (i.e. screen flicker or similar)
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