Mandalorian Mercs Costume Club

Mandalorian Armor => Equipment & Accessories => Electronics => Topic started by: Fi-8015 on Mar 06, 2020, 12:18 PM

Title: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Mar 06, 2020, 12:18 PM
In this tutorial I want to present instructions how to recreate OLED displays like the ones I used to offer.
I try to be as detailed as possible to ensure you can follow this guide without any electronics or coding knowledge.

Update: May 9, 20
The instructions are now updated to reflect the changes in the updated library. It got a bit easier now. The codes are already updated as well. Thanks to runger, who pointed out the changes in the new library!

Update: September 7, 20
The instructions now state, that the Adafruit_BusIO library is required. Thanks for the hint LightningLion!

What is needed?

For the electronics:
components
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_153048.jpg)
1 arduino nano microcontroller or similar
1 OLED display module for arduino with a resolution of 128x64 pixels
some wire
1 9V battery clip (optional)
1 switch (optional)
some heat shrink tube (optional)

tools:
soldering iron
pliers


For programming:
Windows PC
USB cable matching your microcontroller (mini or micro USB)
Arduino IDE
Adafruit GFX library
Adafruit SSD1306 library


Instructions:

Choose the microcontroller
The sets are based on an arduino nano or a similar microcontroller. You can use a cheaper clone as well. They can be purchased in diffferent online shops.
I'm using ones with a micro-USB port to safe a bit of space, but mini-USB ports are totally fine.
They may either come with an ATmega 328P or ATmega 168P microcontroller. The ATmega 328P has more memory, which is required by some of the animations, so I would recommend to get one of them.
If possible try to get one without soldered pin rows.

Choose the OLED display
You'll need a module with an OLED screen. They come in a veriety of sizes, resolutions and colors. There are a few thing to pay attention to, if you want to use my code.
First: the code is written for a display with a resolution of 128x64 pixels, others will not work
Second: there are different interfaces for the communication between the module and the microcontroller. My code supports I2C and SPI.
You can tell the difference by looking at the number of pins on the module. 4 pins is I2C, 7 pins is SPI. Both will work fine.
Third: the OLED modules come with different driver chips. This instruction and the code is made for the SSD1306, which works also for modules with SSD1309. Others like the SH1106 need a different library and are not covered in this tutorial.
Fourth: the set is working with 5V logic, most times you won't find an info on this topic in the product description for the modules, but I just wanted to note that and that 3,3 V logic might not work.
The color and actual size of the module does not matter. A few sizes I used are 0.96", 1.3" (be careful, those came with the SH1106 drivers mostly), 1.54" and 2.42".
If possible, try to get one without soldered pin row.

Additional components
You'll need some isolated wire. Really not important which one. I use double stranded copper wires with 0,14 mm2 each, which is something between 25 and 26 AWG (I think). Those fit nicely inside the pads on the arduino and module.
You can run the set from the USB port on the arduino. Another option shown in this tutorial is to add a 9V clip. You'll need a loose 9V clip, which can be found online or in a electronics DIY store.
If you want, you can also add a power switch of your choice. In that case I recommend to have some shrink tube available as well.


Let's start soldering!
At the beginning you can put these aside, if they aren't already soldered to the boards:
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/70IMG_20200306_153153.jpg)
They are not needed. In case they are soldered, you can keep them in place, but they will take place, that's usually limited in a gauntlet.

1. Solder wires to the OLED modules pads. (I like to use different color cables to easily tell them apart.) If your module came with the pins soldered to the board, you may want to remove them first.
I2C
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_153520.jpg)

SPI
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_154812.jpg)

2. Solder the wires to the correct pads on the arduino (my code uses these pins, you can change them in the code, if you like).

I2C:
GND on the module goes to any GND on the arduino
VCC on the module goes to +5V on the arduino
SCL on the module goes to A5 on the arduino
SDA on the module goes to A4 on the arduino
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_153617.jpg)


SPI:
GND on the module goes to any GND on the arduino
VCC on the module goes to +5V on the arduino
SCL on the module goes to D8 on the arduino
SDA on the module goes to D9 on the arduino
RES on the module goes to D10 on the arduino
DC on the module goes to D11 on the arduino
CS on the module goes to D12 on the arduino
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_155019.jpg)

Be aware that the pads might be arranged in a different order than on these example modules. Especially check the GND and VCC pads! (My 1.3" OLED modules had them swapped.)

3. Add the 9V clip and switch (optional).
Either connect only the 9V clip to the arduino (red wire to VIN pad on the arduino and black to any GND pad) or place a switch inbetween.
First connect the wires to the switch (about 15cm or 6" should be fine to allow flexible placement in the gauntlet, measure your gauntlet, if unsure).
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_154119.jpg)

Connect one of the ends to the red wire of the 9V clip. Use the heat shrink tube to insulate the open wire.
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_154322.jpg)
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_154340.jpg)

Connect the second open end from the switch to the VIN pad on the arduino. Solder the black wire of the 9V clip to any GND pad on the arduino (I prefer the second option shown below).
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_154605.jpg)
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/80IMG_20200306_154620.jpg)

Finished!

Now to the programming:
The instructions given here are for a Windows PC, I can't provide any help for other OS. They start at the very beginning in case this is your first arduino project.

1. Get the arduino IDE: https://www.arduino.cc/en/Main/Software
(I use the classic installer, not the app)

2. Install the arduino IDE. I recommend to check the USB drivers and association with .ino files.

3. In case you use a cheap arduino clone, it's most likely that you'll need additional drivers, they use another USB interface: http://wch.cn/downloads/file/5.html
If you are using an original Arduino skip to step 7.

4. Extract the .zip archive (for example with 7zip).

5. Open the folder and run "setup.exe". Simply hit install and wait for it to finish.

6. Restart your computer.

7. Connect the arduino board to your PC (I had trouble using USB 3 ports, USB 2 ports work fine), windows should not say the device isn't recognised, otherwise the drivers were not installed correctly.

8. Open the arduino IDE.

9. In the IDE go to "tools" and search for a line starting with "Board:..." (most likely it will say "Board: Arduino/Genuino Uno". Select "Arduino Nano" instead.

10. Check if under "tools" -> "processor" the "ATmega 328P" is chosen. (If you have an arduino with ATmega 168P, choose this one instead.)

11. Go to "tools" -> "port" and select the port the arduino is connected to. (Even if "COM1" is available it is not the arduino, choose the other one.)

12. If everything went well and there is a second option in the list of ports you can now add the required libraries. Got to "Sketch" -> "include library" -> "manage libraries" a new window will open.

13. You'll need to install three libraries for this code. Enter "adafruit gfx library" in the search bar of the new window, click on the correct list entry (might be the second) and hit install. Do the same for "adafruit SSD1306" and "Adafruit_BusIO" library.

14. Now download the code of your desired animation for the OLED display here: https://drive.google.com/open?id=1cyMBIlov7y7PszwcFf2esufmCnR8Gyil
(please do not share this code anywhere else)

Available animations are:

1. Spinning mythosaur
https://youtu.be/UaMKQuJceV8 (https://youtu.be/UaMKQuJceV8)

2. Targetting computer
https://youtu.be/KZzqlTEB-fM (https://youtu.be/KZzqlTEB-fM)

3. Simple radar
https://youtu.be/Xk2jjG_vfNk (https://youtu.be/Xk2jjG_vfNk)

15. Open the code in the arduino IDE ("file" -> "open" or double klick the .ino file)

16. Now you may need to modify it for the communication mode of your module. Identify the correct communication for your display. In case it's I2C, you don't need to change anything, the code is already prepared correctly. For SPI remove any // infront the needed lines and add them to any I2C lines. Have a look at the pictures below, the example is the mythosaur animation, but is the same for all.
(https://mandalorianmercs.org/forum/images/members/19111/Oled_Tutorial/Code.jpg)

17. Click the round button with the check mark in the top row.

18. After a short time the IDE should show "compiling done" (or similar). That's the sign, that everything needed is working and you can now upload the code.

19. Click the button with the arrow pointing right, while your arduino is connected to your PC. Wait until the IDE returns a "done" and indeed you should be done now and have a working set.

In case you are now interested in creating your own animation I can recommend having a look at the adafruit sites for the GFX library, to learn how to do so: https://learn.adafruit.com/adafruit-gfx-graphics-library
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on Mar 06, 2020, 12:42 PM
Awesome! Can't wait to give this a shot
Title: Re: electriFi tutorial: build your own OLED display
Post by: Ori Dart on Mar 06, 2020, 02:07 PM
Wow! Thanks for posting this! Very generous of you. Really looking forward to putting some of these together.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Jyucik te adenn on Mar 08, 2020, 06:37 AM
thanks vod!
I'm definitely going to try this now!
 :like:
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Mar 08, 2020, 07:06 AM
I'm very happy about the positive feedback.
If you encounter any problems following the tutorial, just let me know how I can improve it.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Vorpal on Mar 08, 2020, 12:41 PM
You have made my day. Thank you so much. You have just saved me hours f tinkering to get some nowhere near as good as this
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Mar 08, 2020, 05:22 PM
For me it was a long period of trying and improving as well and I'm very happy that you like the result, but I can totally encourage you to look into writing your own animation too. The guide on the adafruit homepage is really helpful, even if you start at the very beginning with OLEDs.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on Mar 15, 2020, 07:10 AM
It's alive!

(https://i.imgur.com/DHYNIPW.jpg)

Although I'm not sure why the top is yellow lol
Title: Re: electriFi tutorial: build your own OLED display
Post by: Vorpal on Mar 15, 2020, 07:37 AM
there are some screen on the market that have a different colour top bar. It might be one of those
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on Mar 15, 2020, 07:48 AM
Ahh... apparently it is, yeah. Was only 6 bucks so no biggie... It actually looks kinda cool with the targeting one loaded though.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Vorpal on Mar 15, 2020, 08:03 AM
Put some red clear plastic over it like from a sweet wrapper. You might loose the top bar as will as making it look even cooler
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Mar 15, 2020, 09:31 AM
Awesome!
I ordered some off those too, but I'm not sure if I like the seperated top bar. I guess the effect could be better if the animation is designed to better incorporate this separation.
Anyway, I'm happy it was possible to get the display working, following the instructions. Any tips how I could improve the instructions?
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on Mar 15, 2020, 10:35 AM
No they were actually pretty clear. I just spent the better part of a couple hours converting the Mandalorian font file into a .h file for Adafruit_GFX and figuring out how to get it to work. I might now take advantage of that and see if I can't try to keep it so the text displays on the top bar and the animation displays below but that's gonna be a long process I think lol.

If anyone else wants said font file:
https://drive.google.com/file/d/1yH46GG2-18EHLyOXxc4Toka4F0t0iTZg/view?usp=sharing

(https://i.imgur.com/bTs1Hne.jpg)


Update: Head is spinning but I finally have a text line and static object lol
(https://i.imgur.com/yOWKjWZ.jpg)
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on Mar 17, 2020, 05:11 AM
I am inordinately proud of myself.

https://www.youtube.com/watch?v=_SmyYrxTUVc

The only reason it's so long is because I wanted to capture the dots resetting.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Mar 18, 2020, 03:53 AM
Awesome!
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on Mar 19, 2020, 10:13 AM
https://drive.google.com/drive/folders/1ol6_ZAaqYAafNVQJpz9sWnbrf-samIKP?usp=sharing

Added an aurebesh font as well so this link should take anyone interested to the folder containing both.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kurshi BeJahaal on Mar 29, 2020, 03:37 PM
Thank you for posting all these steps! I'm gonna give it a go when I get everything in!

(https://i.imgur.com/l2sqQfZ.png)
(https://i.imgur.com/IQ5IrgY.jpg)

My goal is to incorporate the LED button on the gauntlet to give it a bit more character. How long does a 9v usually run the screen?
Title: Re: electriFi tutorial: build your own OLED display
Post by: jc27 on Apr 09, 2020, 12:42 PM
Thank you for posting this. I have been wanting to try this out for a long time and had no idea where to start. I do a bit of Arduino coding for my wireless servo kit and jetpack beacon light kit, so hopefully I will be able to figure it out fairly quickly.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Apr 11, 2020, 03:12 AM
My goal is to incorporate the LED button on the gauntlet to give it a bit more character. How long does a 9v usually run the screen?

Sorry for the late reply. The screen will draw very low current. A small 0.96 inch display together with the arduino will need around 30 mA. Typically the batteries don't have their capacity written on them, but I assume Alkaline batteries to have about 600 mAh and Lithium batteries about 1200 mAh which would lead to 20 or 40 h of constant use.
I don't have the chance to measure the bigger ones but I guess the 1.54" is around 70 mA and the 2.54" at 140 mA. Those would lead to ~8h/~16h or ~4h/~8h.
I guess your switches will draw around 20 mA as well, when connected in series to the battery. That will shorten the lifespan of the battery a bit.

Thank you for posting this. I have been wanting to try this out for a long time and had no idea where to start. I do a bit of Arduino coding for my wireless servo kit and jetpack beacon light kit, so hopefully I will be able to figure it out fairly quickly.

I hope you're successfull trying it. Regarding your knowledge from the other projects, you should have the perfect base.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on Apr 19, 2020, 11:54 AM
Looking a tip or two here... Went to wire everything up this morning, did a final check while it was on the breadboard to make sure everything was kosher and it was. Uploaded the code to my nano, wired and soldered everything up according to instructions. (double checked instructions). Only burned myself once! lol. But when I flip the switch on I'm getting power to the board but not to the screen? Or I guess it might be possible that there's a translation issue between running the code on my Uno for testing and the Nano for the actual unit? I'm lost.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Apr 20, 2020, 03:51 AM
Both of the following possible issues should result in a error while uploading the code, but I'll note them anyway:
Did you change the arduino model in the IDE from Uno to Nano before uploading the code?
It's also possible, that your nano has the ATmega168p microcontroller instead of ATmega328p, you would need to change that in the settings too.

If you're using my code and the same wiring, the only thing I can advise is to re-upload the code.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on Apr 26, 2020, 01:30 PM
So after more troubleshooting... everything works fine when I have it hooked up via usb to either my computer or a power bank. Board lights up but screen doesn't do anything when it's connected to a 9V. So... not enough power?
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Apr 27, 2020, 08:05 AM
These setups need very low power. If your battery isn't completely empty it should work. Have  you tried another battery?
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on Apr 27, 2020, 08:15 AM
I've tried two, same results on both... I'm gonna try a different connector after work today to see if I had a bad one
Title: Re: electriFi tutorial: build your own OLED display
Post by: runger on May 05, 2020, 04:38 PM
Hey - thanks for this, just did a build of this and it worked a charm.

Just wanted to point out a possible improvement - if you update the code to initialize the display like this:

#define OLED_RESET 4
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

then you can skip steps 13-20 in your instructions, just install the GFX and 1306 libraries with the library manager, and there is no need to modify them.

Defining the size via #define is obsolete, and the constructors now take the size as arguments.

Anyway, thanks a lot and regards from Vienna,

Richard
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on May 06, 2020, 03:40 PM
(https://i.imgur.com/Iz09i5q.jpg)

Finally got it! Apparently my little light-up switch was pulling too much power away from the board.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Ori Dart on May 07, 2020, 09:05 PM
(https://i.imgur.com/Iz09i5q.jpg)

Finally got it! Apparently my little light-up switch was pulling too much power away from the board.

Very cool display!
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on May 09, 2020, 09:20 AM
Just wanted to point out a possible improvement - if you update the code to initialize the display like this:

#define OLED_RESET 4
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);

then you can skip steps 13-20 in your instructions, just install the GFX and 1306 libraries with the library manager, and there is no need to modify them.

Thanks for the hint!

Instructions and code are now updated to reflect the changes in the library.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kurz on May 13, 2020, 07:26 AM
Hi, I bought a 2.42 screen. Saw that 9v battery will have a 4/8 h lifespan. Any suggestion to make it last longer? Maybe a powerbank?
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on May 13, 2020, 08:01 AM
Yes, you can use a powerbank too. That will increase the time accordingly. You can even use the USB-port on the Arduino itself for this setup, since the display doesn't draw too much current.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kurz on May 13, 2020, 11:10 AM
How manu mAh would you recommend? Because I'd have to make everything fit in a gauntlet
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on May 13, 2020, 11:15 AM
You're prolly not gonna find anything bigger than maybe 1200 or 1500 that's gonna fit easily in a gauntlet... I have some the size of a credit card and about a quarter inch thick that I use in my welding helmet for my fans that MIGHT fit, depending on your gauntlet. I searched high and low for something the size of a 9v or a little bigger and didn't come up with a whole lot... Considered running a cable up my sleeve before deciding to just use a 9v, but I'm using a smaller screen too.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kurz on May 13, 2020, 11:34 AM
You're prolly not gonna find anything bigger than maybe 1200 or 1500 that's gonna fit easily in a gauntlet... I have some the size of a credit card and about a quarter inch thick that I use in my welding helmet for my fans that MIGHT fit, depending on your gauntlet. I searched high and low for something the size of a 9v or a little bigger and didn't come up with a whole lot... Considered running a cable up my sleeve before deciding to just use a 9v, but I'm using a smaller screen too.
Gauntlet will be scratch built. I'm waiting to see how much space i'll need, so thats not a big problem.

Was thinking about one of these two.

(https://i.imgur.com/ZDj3rZH.jpg)
(https://i.imgur.com/9CHC8de.jpg)

10000 or 5000 mAh. They dont seem too bulky to fit in a gauntlet... thoughts? Would I be able to throw in a 2 or 3 led in addition?
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on May 13, 2020, 12:44 PM
Seems a bit overkill in my oppinion, but if you have the space, there is no issue using them. I always use the smallest ones with about 2500 mAh. Adding LEDs will be no issue as well (asuming we are not talking about high power LEDs, but LEDs with a current of about 20 mA).

Some further words on the maximum current issue:
I found several current limiting factors, but none of them should apply in this case, so in theory you can feed all your needed current through the micro-USB port of the nano. Lots of older entries say, that 500 mA is the maximum, but that's because USB was once specified that way. Every USB wall charger or powerbank supplys more than that.
I still am a bit uncertain to feed high currents (> 0,5A) through the nano, but in theory it should be possible.
But be careful when using the VIN pin for power supply afterwards agin! The voltage regulator connected to that pin has strict limitations and even though you may power a lot of things via USB it may fry the nano, if you try to power them via VIN.
You won't get much trouble, but a small cloud of funny smelling fumes will tell you, that the regulator quit it's job.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kazya Rembrea on May 17, 2020, 09:09 AM
Thank you for posting all these steps! I'm gonna give it a go when I get everything in!

(https://i.imgur.com/l2sqQfZ.png)
(https://i.imgur.com/IQ5IrgY.jpg)

My goal is to incorporate the LED button on the gauntlet to give it a bit more character. How long does a 9v usually run the screen?

Hey did you ever get around to trying out those switches? The light-up toggles that I bought were drawing too much power off the 9v and not letting enough to the board to run the screen.

Also with a regular switch I ran my screen for 6 hours yesterday and battery isn't dead yet.
Title: Re: electriFi tutorial: build your own OLED display
Post by: BearCubsTeacher on May 21, 2020, 10:57 PM
I'm using an Adafruit ST7789, Adafruit Feather Express M4 and a Lipo 820mAH battery by EEMB. The board is a 240x240 TFT display. All of it should easily fit into my gauntlet and I'm in the process of creative the cavities for the parts now, but have yet to actually assemble or test any of the electronics. I'm still awaiting the battery, which I just ordered today.

I'm not sure about getting a breadboard or if I should just get some wire and go for it first. I'm just following directions that are very clear and available online so I'll probably just continue shaping my vambrace for the parts once the battery gets here and then just jump right into the soldering once I know my parts all fit into their enclosures. At any rate, here's a bit of what I have:
(https://i.imgur.com/CjsCltN.jpg)
(https://i.imgur.com/XfaUAKE.jpg)
(https://i.imgur.com/hURPbgy.jpg)
(https://i.imgur.com/MKv7DNO.jpg)
(https://i.imgur.com/wlgyNhb.jpg)
(https://i.imgur.com/6Pc1PEG.jpg)
(https://i.imgur.com/Ai0uKK7.jpg)

Any idea how long this battery, https://www.amazon.com/gp/product/B082152887/ref=ppx_yo_dt_b_asin_title_o00_s00?ie=UTF8&psc=1 , would run that display for?
Title: Re: electriFi tutorial: build your own OLED display
Post by: Kurz on Jun 02, 2020, 01:25 PM
Thanks for your tutorial!
I know, soldering isn't fancy but it gets the job done.

(https://i.imgur.com/x5SQkK5.jpg)
Title: Re: electriFi tutorial: build your own OLED display
Post by: BearCubsTeacher on Jun 06, 2020, 05:08 PM
My Mandoputer works!
https://i.imgur.com/21uHSjl.mp4

(https://i.imgur.com/QQOFUZj.jpg)
(https://i.imgur.com/BHOf63S.jpg)
Title: Re: electriFi tutorial: build your own OLED display
Post by: BearCubsTeacher on Jun 18, 2020, 04:03 PM
https://i.imgur.com/VKWBvqF.mp4

(https://i.imgur.com/uXRJk1c.jpg)
Title: Re: electriFi tutorial: build your own OLED display
Post by: WarlockHCP on Sep 01, 2020, 06:32 PM
So I'm jumping into this head first ;) I have a set of April Storms Rav gauntlets on the way, one has a spot that fits a 1.5" digital photo frame as she suggests to use to get these effects. 

I'm wanting to use this set up instead for obvious reasons. 

Found these FTCBlock Mini Nano V3.0 ATmega328P Microcontroller on amazon: https://www.amazon.com/gp/product/B07H346KVG/ref=ox_sc_act_title_1?smid=A278BT9THV444Y&psc=1 

Any suggestions on a screen that will work in 1.5".....or can I make a 128x128 work? 


Thanks!
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Sep 02, 2020, 06:19 AM
There are rectangular (1:2) OLEDs with 1.54" diagonal. The question is, which aspect ratio the spot on the gauntlet has.
Maybe the 0.96" display would fit better, with an added frame.
The animations I supplied, are only for 128x64 displays. You can modify them to show on bigger screens, but it will only use the same space, the rest of the display would remain unused.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Roundtop_98 on Sep 02, 2020, 06:51 AM
I decided I wanted to incorporate electronics into the chest box for my pilot.  I like the EKG and Readout animations that Kazya Rembrea offers, but a 1"x.5" screen seems a bit small for the application though, no offence to Kazya, I am considering your sale thread even though.  What's the biggest screen you would recommend with these instructions and coding?
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Sep 02, 2020, 07:59 AM
The largest I found and used was 2.42"
Title: Re: electriFi tutorial: build your own OLED display
Post by: WarlockHCP on Sep 02, 2020, 06:40 PM
Ended up just getting the .96" screen for now to see how well I can do all this ;) $12 with a spare board with worth a test  :laugh:
Title: Re: electriFi tutorial: build your own OLED display
Post by: Matchstick1021 on Sep 03, 2020, 10:23 PM
Hello vod! First off thank you for this amazing tutorial it’s super easy to follow even for a complete newbie like myself.  :laugh:

However since I know nothing about this kind of stuff I have a question. When I try to compile your code it throws me this error (please forgive the bad picture I just snapped a quick picture to show the issue I am having)
(https://i.imgur.com/V6j64bK.jpg)
Has anyone else had this issue? Is it something on my end?
Any help is greatly appreciated!
Title: Re: electriFi tutorial: build your own OLED display
Post by: LightningLion on Sep 04, 2020, 08:00 AM
You can expand the lower square (or scroll through it) to read what's causing the problem during compilation.
Maybe the required libraries are not downloaded? I think Adafruit changed recently (last months) how their library works and now you need to download the Adafruit BusIO for the Adafruit GFX/SSD1306 to work. Check that first, and if it doesn't work paste here the message you got.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Matchstick1021 on Sep 04, 2020, 08:44 AM
I have the other two libraries that are required downloaded but I don’t know about that third one, I’ll give it a try and see what I get! Thank you!

I also now see what you mean about scrolling through the lower box *facepalm*

Edit:
it turns out that’s exactly what I needed to do! Thank you! Just install that extra library (Adafruit  BusIO)
(https://i.imgur.com/8e9bFaM.jpg)
Works like a charm thank you for the great tutorial!
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Sep 07, 2020, 11:46 AM
Great that you figured it out already, thanks Lion!

I'll add that point to the tutorial.
Title: Re: electriFi tutorial: build your own OLED display
Post by: mikehall419 on Sep 26, 2020, 03:22 AM
Hey everyone. So I'm attempting to make one of these, and I have a SH1106 module, because the 1.3in size fits my gauntlet well.
I don't think the 1306 version comes in this size, so I'm trying to make what I have work. Here's the link to what I have
https://www.amazon.com/gp/product/B073VD6W1H/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1

Does anyone know how to get this to work? So far no library has made any difference, it just sits there with a blank screen.
I've been trying to troubleshoot but so far I cannot get anything to print to the screen.

I'm also using these knock off arduinos, but I have updated the drivers on them.
https://www.amazon.com/gp/product/B0713XK923/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1

Any help would be fantastic!
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Oct 01, 2020, 09:49 AM
You'll need to use the 1306 driver library and replace all commands specific to the 1106 lib.
Title: Re: electriFi tutorial: build your own OLED display
Post by: mikehall419 on Oct 01, 2020, 08:26 PM
I did try that, but the screen remains blank.
It may have something to do with the display command I had to change. I changed it from :
Adafruit_SSD1306 display(8,9);
To
Adafruit_SH1106 display(OLED_RESET);

The example from the 1106 library I found uses that as its display, if I use the (8,9) one, it throws this error.
Arduino: 1.8.13 (Windows 10), Board: "Arduino Nano, ATmega328P"


Targeting___Target:13:28: error: no matching function for call to 'Adafruit_SH1106::Adafruit_SH1106(int, int)'

 Adafruit_SH1106 display(8,9);

                            ^

In file included from D:\Code\Mando OLED\Targeting___Target\Targeting___Target.ino:1:0:

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:145:3: note: candidate: Adafruit_SH1106::Adafruit_SH1106(int8_t)

   Adafruit_SH1106(int8_t RST);

   ^~~~~~~~~~~~~~~

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:145:3: note:   candidate expects 1 argument, 2 provided

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:144:3: note: candidate: Adafruit_SH1106::Adafruit_SH1106(int8_t, int8_t, int8_t)

   Adafruit_SH1106(int8_t DC, int8_t RST, int8_t CS);

   ^~~~~~~~~~~~~~~

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:144:3: note:   candidate expects 3 arguments, 2 provided

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:143:3: note: candidate: Adafruit_SH1106::Adafruit_SH1106(int8_t, int8_t, int8_t, int8_t, int8_t)

   Adafruit_SH1106(int8_t SID, int8_t SCLK, int8_t DC, int8_t RST, int8_t CS);

   ^~~~~~~~~~~~~~~

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:143:3: note:   candidate expects 5 arguments, 2 provided

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:141:7: note: candidate: constexpr Adafruit_SH1106::Adafruit_SH1106(const Adafruit_SH1106&)

 class Adafruit_SH1106 : public Adafruit_GFX {

       ^~~~~~~~~~~~~~~

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:141:7: note:   candidate expects 1 argument, 2 provided

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:141:7: note: candidate: constexpr Adafruit_SH1106::Adafruit_SH1106(Adafruit_SH1106&&)

D:\New folder (4)\Arduino\libraries\Adafruit_SH1106-master/Adafruit_SH1106.h:141:7: note:   candidate expects 1 argument, 2 provided

Multiple libraries were found for "Adafruit_GFX.h"

 Used: D:\New folder (4)\Arduino\libraries\Adafruit_GFX_Library

 Not used: D:\New folder (4)\Arduino\libraries\ssd1306

exit status 1

no matching function for call to 'Adafruit_SH1106::Adafruit_SH1106(int, int)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.


I am using this library btw. https://github.com/wonho-maker/Adafruit_SH1106
Title: Re: electriFi tutorial: build your own OLED display
Post by: LightningLion on Oct 01, 2020, 08:31 PM
Past the code (at least until the setup) here. And remember to use the
{code}{ /code} tags (with [] instead of {}) in the forum to make it look better.
Title: Re: electriFi tutorial: build your own OLED display
Post by: mikehall419 on Oct 01, 2020, 08:46 PM
I'm a bit confused on how to paste it, but this is the code. I can fix the format if its wrong.
{code}
#include <Adafruit_SH1106.h>
#include <splash.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>


#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

//I2C
#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);
{/code}
Title: Re: electriFi tutorial: build your own OLED display
Post by: LightningLion on Oct 02, 2020, 08:21 PM
{code}
---Your code goes in here.
{/code}


Which library are you using? And why would you code that has (8. 9)?
Is it with (oled_reset) that you have your screen blank? Do you have anything wired to the pin 4?

As mentioned before, Adafruit changed a bit how their libraries work for these displays. If you're using wonho-maker library, maybe it's no longer compatible with Adafruit GFX.

But first things first! Maybe you don't know the address of the display. Use this sketch to find your display's address:
https://playground.arduino.cc/Main/I2cScanner/
Title: Re: electriFi tutorial: build your own OLED display
Post by: mikehall419 on Oct 04, 2020, 03:33 PM
Thanks!
So I uploaded the sketch, and the serial monitor reports
{code}
I2C Scanner
Scanning...
{/code}
But that is all it seems to do on mine. Unless it takes a long time?

Also, as a side note, I did find ONE 1306 OLED in 1.3in over on Adafruit.
https://www.adafruit.com/product/938
So in case anyone wants to avoid this hassle.

I bought one, but I still want to figure out how to make this one work.
Title: Re: electriFi tutorial: build your own OLED display
Post by: LightningLion on Oct 04, 2020, 03:57 PM
It shouldn't take long. Are you sure you have wired it correctly?
Title: Re: electriFi tutorial: build your own OLED display
Post by: mikehall419 on Oct 04, 2020, 04:09 PM
Okay so my breadboard is a bit wonky, so I rewired it. But now it says-
{code}
Scanning...
No I2C devices found
{/code}
-over and over again.
This means its connected right, right? Or should I solder it together to be sure?
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Oct 05, 2020, 03:12 AM
I'm sorry for what I wrote earlier, of course you need to use the sh1106 library and replace all commands from the ssd1306 library. But it seems you already figured out that I was confused.
I don't know what the other libraries are for, but I guess you'll need the BusIO lib too.
As far as I can tell for now the rest seems fine besides that.
The errors seem to origin from the fact that the function expects to get one value but you supply two (8,9). The code including the "OLED_RESET" should be fine, what happens if you use that one?
I can't help with the I2C Scan, I never had to use it. You should be completely sure that the pins are connected, in cases like that I use a multimeter to check if the connection is the problem.
Title: Re: electriFi tutorial: build your own OLED display
Post by: mikehall419 on Oct 05, 2020, 03:22 AM
Hey! So I just tried adding the BusIO lib, but that didn't do anything. The screen remains off, and dark.
On the back of the OLED, the address does say you can use 0x7A, or 0x78, but neither of those work either.
I'm quite stumped here!
Title: Re: electriFi tutorial: build your own OLED display
Post by: LightningLion on Oct 05, 2020, 03:36 AM
The selectable address works this way: You solder the resistor between the center pad and the lef or right pad. That would define the address.
In the picture of the Amazon link you posted the resistor is in the right address (Can't tell if 0x7B or 0x78). In any case, I always use the I2C Scanner to make sure the address in the display is the one it says. it should find devices very quickly.

Wiring is the same it was for the 0.96" display, but double check it.

Post your full code here. And if everything else fails, just try a different library.
Title: Re: electriFi tutorial: build your own OLED display
Post by: Fi-8015 on Oct 05, 2020, 07:56 AM
And do also please add a photo of your wiring.
Title: Re: electriFi tutorial: build your own OLED display
Post by: mikehall419 on Oct 05, 2020, 11:27 PM
Okay so I ran the address finder on a screen I know works, so I ran it on the smaller 1306 and it found this address.
(https://i.imgur.com/J8tO0zp.png)
Then I tried with the same setup on the 1106 one and got this.
(https://i.imgur.com/z8G4v4A.png)
Then, I was  moving the board around and the wires a bit and it actually found an address briefly, but I could not get it to do it again. And I did try using that 0x01 as the address, and still nothing.
(https://i.imgur.com/0pQ5dUi.png)

I'm thinking to solder the wires on, what do you guys think?
Also, here's my current code.

{code}
#include <Adafruit_BusIO_Register.h>
#include <Adafruit_I2CDevice.h>
#include <Adafruit_I2CRegister.h>
#include <Adafruit_SPIDevice.h>

#include <Adafruit_SH1106.h>
#include <splash.h>

#include <Adafruit_GFX.h>




#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>


#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

//I2C
#define OLED_RESET 4
Adafruit_SH1106 display(OLED_RESET);


//software SPI:
//#define OLED_CLK    8       //SCL
//#define OLED_MOSI  9        //SDA
//#define OLED_RESET 10       //RES
//#define OLED_DC    11       //DC
//#define OLED_CS    12       //CS
//Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT,OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS);


int xs = 64;  //x für Start
int ys = 32;  //y für Start
int xe = 64;  //x für Ende
int ye = 31;  //y für Ende

int xs1 = 64;  //x für Start
int ys1 = 32;  //y für Start
int xe1 = 64;  //x für Ende
int ye1 = 31;  //y für Ende

int xs2 = 64;  //x für Start
int ys2 = 32;  //y für Start
int xe2 = 64;  //x für Ende
int ye2 = 31;  //y für Ende

int xs3 = 64;  //x für Start
int ys3 = 32;  //y für Start
int xe3 = 64;  //x für Ende
int ye3 = 31;  //y für Ende

int i = 0;

int counter = 0;
int counter1 = 0;
int counter2 = 0;

int targetCounter = 0;
int flickerCounter= 0;

void setup() {
  Serial.begin(9600);
  display.begin(SH1106_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x64)
  display.clearDisplay();

  display.drawRoundRect(0, 0, 128, 64, 6, WHITE);
  display.drawPixel(64,32, WHITE);
  display.drawPixel(63,32, WHITE);
  display.drawPixel(64,31, WHITE);
  display.drawPixel(63,31, WHITE);

  //4 Pixel in der Mitte: x=63, 64  und y = 31, 32

  display.display();

  delay(500);
 
  display.drawLine(33, 1, 94, 62, WHITE);
  display.drawLine(94, 1, 33, 62, WHITE);
 
  display.display();
  delay(500);

  display.drawLine(17, 1, 110, 62, WHITE);
  display.drawLine(110, 1, 17, 62, WHITE);
 
  display.display();
  delay(500);

  display.drawLine(1, 15, 126, 48, WHITE);
  display.drawLine(1, 48, 126, 15, WHITE);
 

  display.display();

  delay(1000);

}

void loop() {

if (targetCounter < 4)
{
while(i<64)
{
  if(i == 16)
  {
    counter = 1;
  }

  if(i == 15)
  {
    counter = 0;
  }

  if(i == 32)
  {
    counter1 = 1;
  }

  if(i == 31)
  {
    counter1 = 0;
  }
 
  if(i == 48)
  {
    counter2 = 1;
  }

  if(i == 47)
  {
    counter2 = 0;
  }
  display.drawLine(xs-1, ys-1, xs-1, ye+1, BLACK);
  display.drawLine(127-xs+1, ys-1, 127-xs+1, ye+1, BLACK);
  display.drawLine(xs-1, ys-1, 127-xs+1, ys-1, BLACK);

  display.drawLine(xs1-1, ys1-1, xs1-1, ye1+1, BLACK);
  display.drawLine(127-xs1+1, ys1-1, 127-xs1+1, ye1+1, BLACK);
  display.drawLine(xs1-1, ys1-1, 127-xs1+1, ys1-1, BLACK);

  display.drawLine(xs2-1, ys2-1, xs2-1, ye2+1, BLACK);
  display.drawLine(127-xs2+1, ys2-1, 127-xs2+1, ye2+1, BLACK);
  display.drawLine(xs2-1, ys2-1, 127-xs2+1, ys2-1, BLACK);

  display.drawLine(xs3-1, ys3-1, xs3-1, ye3+1, BLACK);
  display.drawLine(127-xs3+1, ys3-1, 127-xs3+1, ye3+1, BLACK);
  display.drawLine(xs3-1, ys3-1, 127-xs3+1, ys3-1, BLACK);
 
  if(counter == 1)
  {
    display.drawLine(xs1, ys1, xs1, ye1, WHITE);
    display.drawLine(127-xs1, ys1, 127-xs1, ye1, WHITE);
    display.drawLine(xs1, ys1, 127-xs1, ys1, WHITE);
  }

  if(counter1 == 1)
  {
    display.drawLine(xs2, ys2, xs2, ye2, WHITE);
    display.drawLine(127-xs2, ys2, 127-xs2, ye2, WHITE);
    display.drawLine(xs2, ys2, 127-xs2, ys2, WHITE);
  }

  if(counter2 == 1)
  {
    display.drawLine(xs3, ys3, xs3, ye3, WHITE);
    display.drawLine(127-xs3, ys3, 127-xs3, ye3, WHITE);
    display.drawLine(xs3, ys3, 127-xs3, ys3, WHITE);
  }
 
  if(counter == 0)
  {
    ye1 = 31;
    xe1 = 64;
    ys1 = 32;
    xs1 = 64;
  }

  if(counter1 == 0)
  {
    ye2 = 31;
    xe2 = 64;
    ys2 = 32;
    xs2 = 64;
  }

  if(counter2 == 0)
  {
    ye3 = 31;
    xe3 = 64;
    ys3 = 32;
    xs3 = 64;
  }

  display.drawRoundRect(0, 0, 128, 64, 6, WHITE);
  display.drawLine(33, 1, 94, 62, WHITE);
  display.drawLine(94, 1, 33, 62, WHITE);
 
 
  display.drawLine(17, 1, 110, 62, WHITE);
  display.drawLine(110, 1, 17, 62, WHITE);
 
  display.drawLine(1, 15, 126, 48, WHITE);
  display.drawLine(1, 48, 126, 15, WHITE);


  display.drawLine(xs, ys, xs, ye, WHITE);
  display.drawLine(127-xs, ys, 127-xs, ye, WHITE);
  display.drawLine(xs, ys, 127-xs, ys, WHITE);

  display.fillTriangle(0, 0, 0, 3, 3, 0, BLACK); //Ecken übermalen
  display.fillTriangle(0, 63, 0, 60, 3, 63, BLACK);
  display.fillTriangle(127, 0, 124, 0, 127, 3, BLACK);
  display.fillTriangle(127, 63, 127, 60, 124, 63, BLACK);
 
  display.display();

 
   

   xs ++;
   xe --;
   ys ++;
   ye --;
   i ++;

   if(counter == 1)
   {
   xs1 ++;
   xe1 --;
   ys1 ++;
   ye1 --;
   }

   if(counter1 == 1)
   {
   xs2 ++;
   xe2 --;
   ys2 ++;
   ye2 --;
   }

   if(counter2 == 1)
   {
   xs3 ++;
   xe3 --;
   ys3 ++;
   ye3 --;
   }
}
i = 0;
ye = 31;
xe = 64;
ys = 32;
xs = 64;

targetCounter ++;
}

if (targetCounter == 4)
{
  if(flickerCounter < 24)
  {
display.fillRect(49,17, 30, 30, BLACK);
display.drawLine(48,15, 80, 15, WHITE);
display.drawRoundRect(53, 21, 22,22, 11, WHITE);

display.drawLine(49, 31, 78, 31, WHITE);
display.drawLine(49, 32, 78, 32, WHITE);

display.drawLine(63, 16, 63, 46, WHITE);
display.drawLine(64, 16, 64, 46, WHITE);

display.display();
delay(100);

display.drawLine(49, 31, 78, 31, BLACK);
display.drawLine(49, 32, 78, 32, BLACK);

display.drawLine(63, 16, 63, 46, BLACK);
display.drawLine(64, 16, 64, 46, BLACK);
display.drawRoundRect(53, 21, 22,22, 11, WHITE);
display.display();
delay(100);
flickerCounter ++;
  }

  if(flickerCounter == 24)
  {
    targetCounter = 0;
    flickerCounter = 0;

    display.drawRoundRect(53, 21, 22,22, 11, BLACK);
    display.drawLine(48,15, 80, 15, BLACK);     
  }
}
}
{/code}

EDIT: 10/8/2020
I received in a new display with the 1306 drivers, but I'm confused on where to wire it to the OLED.
https://www.adafruit.com/product/938
I got the example code to work, but the targeting computer does not work. Here is code that works.
Does anyone know what is going on? Btw the pins that work are A4 to DATA, and A5 to C1k.
{code}
/**************************************************************************
 This is an example for our Monochrome OLEDs based on SSD1306 drivers
 Pick one up today in the adafruit shop!
 ------> http://www.adafruit.com/category/63_98
 This example is for a 128x64 pixel display using I2C to communicate
 3 pins are required to interface (two I2C and one reset).
 Adafruit invests time and resources providing this open
 source code, please support Adafruit and open-source
 hardware by purchasing products from Adafruit!
 Written by Limor Fried/Ladyada for Adafruit Industries,
 with contributions from the open source community.
 BSD license, check license.txt for more information
 All text above, and the splash screen below must be
 included in any redistribution.
 **************************************************************************/

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

// Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
#define OLED_RESET     4 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define NUMFLAKES     10 // Number of snowflakes in the animation example

#define LOGO_HEIGHT   16
#define LOGO_WIDTH    16
static const unsigned char PROGMEM logo_bmp[] =
{ B00000000, B11000000,
  B00000001, B11000000,
  B00000001, B11000000,
  B00000011, B11100000,
  B11110011, B11100000,
  B11111110, B11111000,
  B01111110, B11111111,
  B00110011, B10011111,
  B00011111, B11111100,
  B00001101, B01110000,
  B00011011, B10100000,
  B00111111, B11100000,
  B00111111, B11110000,
  B01111100, B11110000,
  B01110000, B01110000,
  B00000000, B00110000 };

void setup() {
  Serial.begin(9600);

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3D)) { // Address 0x3D for 128x64
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  // Show initial display buffer contents on the screen --
  // the library initializes this with an Adafruit splash screen.
  display.display();
  delay(2000); // Pause for 2 seconds

  // Clear the buffer
  display.clearDisplay();

  // Draw a single pixel in white
  display.drawPixel(10, 10, SSD1306_WHITE);

  // Show the display buffer on the screen. You MUST call display() after
  // drawing commands to make them visible on screen!
  display.display();
  delay(2000);
  // display.display() is NOT necessary after every single drawing command,
  // unless that's what you want...rather, you can batch up a bunch of
  // drawing operations and then update the screen all at once by calling
  // display.display(). These examples demonstrate both approaches...

  testdrawline();      // Draw many lines

  testdrawrect();      // Draw rectangles (outlines)

  testfillrect();      // Draw rectangles (filled)

  testdrawcircle();    // Draw circles (outlines)

  testfillcircle();    // Draw circles (filled)

  testdrawroundrect(); // Draw rounded rectangles (outlines)

  testfillroundrect(); // Draw rounded rectangles (filled)

  testdrawtriangle();  // Draw triangles (outlines)

  testfilltriangle();  // Draw triangles (filled)

  testdrawchar();      // Draw characters of the default font

  testdrawstyles();    // Draw 'stylized' characters

  testscrolltext();    // Draw scrolling text

  testdrawbitmap();    // Draw a small bitmap image

  // Invert and restore display, pausing in-between
  display.invertDisplay(true);
  delay(1000);
  display.invertDisplay(false);
  delay(1000);

  testanimate(logo_bmp, LOGO_WIDTH, LOGO_HEIGHT); // Animate bitmaps
}

void loop() {
}

void testdrawline() {
  int16_t i;

  display.clearDisplay(); // Clear display buffer

  for(i=0; i<display.width(); i+=4) {
    display.drawLine(0, 0, i, display.height()-1, SSD1306_WHITE);
    display.display(); // Update screen with each newly-drawn line
    delay(1);
  }
  for(i=0; i<display.height(); i+=4) {
    display.drawLine(0, 0, display.width()-1, i, SSD1306_WHITE);
    display.display();
    delay(1);
  }
  delay(250);

  display.clearDisplay();

  for(i=0; i<display.width(); i+=4) {
    display.drawLine(0, display.height()-1, i, 0, SSD1306_WHITE);
    display.display();
    delay(1);
  }
  for(i=display.height()-1; i>=0; i-=4) {
    display.drawLine(0, display.height()-1, display.width()-1, i, SSD1306_WHITE);
    display.display();
    delay(1);
  }
  delay(250);

  display.clearDisplay();

  for(i=display.width()-1; i>=0; i-=4) {
    display.drawLine(display.width()-1, display.height()-1, i, 0, SSD1306_WHITE);
    display.display();
    delay(1);
  }
  for(i=display.height()-1; i>=0; i-=4) {
    display.drawLine(display.width()-1, display.height()-1, 0, i, SSD1306_WHITE);
    display.display();
    delay(1);
  }
  delay(250);

  display.clearDisplay();

  for(i=0; i<display.height(); i+=4) {
    display.drawLine(display.width()-1, 0, 0, i, SSD1306_WHITE);
    display.display();
    delay(1);
  }
  for(i=0; i<display.width(); i+=4) {
    display.drawLine(display.width()-1, 0, i, display.height()-1, SSD1306_WHITE);
    display.display();
    delay(1);
  }

  delay(2000); // Pause for 2 seconds
}

void testdrawrect(void) {
  display.clearDisplay();

  for(int16_t i=0; i<display.height()/2; i+=2) {
    display.drawRect(i, i, display.width()-2*i, display.height()-2*i, SSD1306_WHITE);
    display.display(); // Update screen with each newly-drawn rectangle
    delay(1);
  }

  delay(2000);
}

void testfillrect(void) {
  display.clearDisplay();

  for(int16_t i=0; i<display.height()/2; i+=3) {
    // The INVERSE color is used so rectangles alternate white/black
    display.fillRect(i, i, display.width()-i*2, display.height()-i*2, SSD1306_INVERSE);
    display.display(); // Update screen with each newly-drawn rectangle
    delay(1);
  }

  delay(2000);
}

void testdrawcircle(void) {
  display.clearDisplay();

  for(int16_t i=0; i<max(display.width(),display.height())/2; i+=2) {
    display.drawCircle(display.width()/2, display.height()/2, i, SSD1306_WHITE);
    display.display();
    delay(1);
  }

  delay(2000);
}

void testfillcircle(void) {
  display.clearDisplay();

  for(int16_t i=max(display.width(),display.height())/2; i>0; i-=3) {
    // The INVERSE color is used so circles alternate white/black
    display.fillCircle(display.width() / 2, display.height() / 2, i, SSD1306_INVERSE);
    display.display(); // Update screen with each newly-drawn circle
    delay(1);
  }

  delay(2000);
}

void testdrawroundrect(void) {
  display.clearDisplay();

  for(int16_t i=0; i<display.height()/2-2; i+=2) {
    display.drawRoundRect(i, i, display.width()-2*i, display.height()-2*i,
      display.height()/4, SSD1306_WHITE);
    display.display();
    delay(1);
  }

  delay(2000);
}

void testfillroundrect(void) {
  display.clearDisplay();

  for(int16_t i=0; i<display.height()/2-2; i+=2) {
    // The INVERSE color is used so round-rects alternate white/black
    display.fillRoundRect(i, i, display.width()-2*i, display.height()-2*i,
      display.height()/4, SSD1306_INVERSE);
    display.display();
    delay(1);
  }

  delay(2000);
}

void testdrawtriangle(void) {
  display.clearDisplay();

  for(int16_t i=0; i<max(display.width(),display.height())/2; i+=5) {
    display.drawTriangle(
      display.width()/2  , display.height()/2-i,
      display.width()/2-i, display.height()/2+i,
      display.width()/2+i, display.height()/2+i, SSD1306_WHITE);
    display.display();
    delay(1);
  }

  delay(2000);
}

void testfilltriangle(void) {
  display.clearDisplay();

  for(int16_t i=max(display.width(),display.height())/2; i>0; i-=5) {
    // The INVERSE color is used so triangles alternate white/black
    display.fillTriangle(
      display.width()/2  , display.height()/2-i,
      display.width()/2-i, display.height()/2+i,
      display.width()/2+i, display.height()/2+i, SSD1306_INVERSE);
    display.display();
    delay(1);
  }

  delay(2000);
}

void testdrawchar(void) {
  display.clearDisplay();

  display.setTextSize(1);      // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE); // Draw white text
  display.setCursor(0, 0);     // Start at top-left corner
  display.cp437(true);         // Use full 256 char 'Code Page 437' font

  // Not all the characters will fit on the display. This is normal.
  // Library will draw what it can and the rest will be clipped.
  for(int16_t i=0; i<256; i++) {
    if(i == '\n') display.write(' ');
    else          display.write(i);
  }

  display.display();
  delay(2000);
}

void testdrawstyles(void) {
  display.clearDisplay();

  display.setTextSize(1);             // Normal 1:1 pixel scale
  display.setTextColor(SSD1306_WHITE);        // Draw white text
  display.setCursor(0,0);             // Start at top-left corner
  display.println(F("Hello, world!"));

  display.setTextColor(SSD1306_BLACK, SSD1306_WHITE); // Draw 'inverse' text
  display.println(3.141592);

  display.setTextSize(2);             // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE);
  display.print(F("0x")); display.println(0xDEADBEEF, HEX);

  display.display();
  delay(2000);
}

void testscrolltext(void) {
  display.clearDisplay();

  display.setTextSize(2); // Draw 2X-scale text
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(10, 0);
  display.println(F("scroll"));
  display.display();      // Show initial text
  delay(100);

  // Scroll in various directions, pausing in-between:
  display.startscrollright(0x00, 0x0F);
  delay(2000);
  display.stopscroll();
  delay(1000);
  display.startscrollleft(0x00, 0x0F);
  delay(2000);
  display.stopscroll();
  delay(1000);
  display.startscrolldiagright(0x00, 0x07);
  delay(2000);
  display.startscrolldiagleft(0x00, 0x07);
  delay(2000);
  display.stopscroll();
  delay(1000);
}

void testdrawbitmap(void) {
  display.clearDisplay();

  display.drawBitmap(
    (display.width()  - LOGO_WIDTH ) / 2,
    (display.height() - LOGO_HEIGHT) / 2,
    logo_bmp, LOGO_WIDTH, LOGO_HEIGHT, 1);
  display.display();
  delay(1000);
}

#define XPOS   0 // Indexes into the 'icons' array in function below
#define YPOS   1
#define DELTAY 2

void testanimate(const uint8_t *bitmap, uint8_t w, uint8_t h) {
  int8_t f, icons[NUMFLAKES][3];

  // Initialize 'snowflake' positions
  for(f=0; f< NUMFLAKES; f++) {
    icons[f][XPOS]   = random(1 - LOGO_WIDTH, display.width());
    icons[f][YPOS]   = -LOGO_HEIGHT;
    icons[f][DELTAY] = random(1, 6);
    Serial.print(F("x: "));
    Serial.print(icons[f][XPOS], DEC);
    Serial.print(F(" y: "));
    Serial.print(icons[f][YPOS], DEC);
    Serial.print(F(" dy: "));
    Serial.println(icons[f][DELTAY], DEC);
  }

  for(;;) { // Loop forever...
    display.clearDisplay(); // Clear the display buffer

    // Draw each snowflake:
    for(f=0; f< NUMFLAKES; f++) {
      display.drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, SSD1306_WHITE);
    }

    display.display(); // Show the display buffer on the screen
    delay(200);        // Pause for 1/10 second

    // Then update coordinates of each flake...
    for(f=0; f< NUMFLAKES; f++) {
      icons[f][YPOS] += icons[f][DELTAY];
      // If snowflake is off the bottom of the screen...
      if (icons[f][YPOS] >= display.height()) {
        // Reinitialize to a random position, just off the top
        icons[f][XPOS]   = random(1 - LOGO_WIDTH, display.width());
        icons[f][YPOS]   = -LOGO_HEIGHT;
        icons[f][DELTAY] = random(1, 6);
      }
    }
  }
}
{/code}

EDIT: 10/09/2020
I GOT IT!
Let me just say thank you guys so much for your help, I couldn't have done it without both of you.
So the address on this Adafruit 1.3in SSD1306 OLED is 0x3D. So that address finder did the trick! Now it works with the standard I2C code!
Thank you guys so much.  :like: ;D
Title: Re: electriFi tutorial: build your own OLED display
Post by: LightningLion on Oct 13, 2020, 01:29 PM
But did you get the 1106 to work?
Title: Re: electriFi tutorial: build your own OLED display
Post by: mikehall419 on Oct 13, 2020, 03:25 PM
Still no, it is possible the screen is broken. The address finder can’t really seem to find it.
Title: Re: electriFi tutorial: build your own OLED display
Post by: FinPerlak on Nov 27, 2020, 10:37 AM
Hello...I needed to feature the text style tone to understand it.

I understand that little OLED shows are utilized in some PDAs, PDAs, camcorders, and so on, however I comprehend that lifetime for the blue organics is pretty short (~1000 hrs). I think OLED presentations would create a definitive TV or screen on the off chance that they can beat that issue and the significant expense of production.