I just uploaded the new code to the Nano. Later tonight i will replace the Nano and test it. Again, you’re the best.
I tested it. Works great but only the screensaver is not working. Is it possible that as soon as the module gets a clock input, the screensaver gets postponed by each trigger input? I do i need to change something in the code? I assume We dont have identical setups. Im using i2c btw.
That’s strange. The screensaver time is only reset by encoder operations (rotation or button), not by the input clock. It’s working fine on my UNO / I2C test rig. So if it’s not kicking in about 30s after the last encoder operation I’m puzzled as to what can be going on. Just to be absolutely sure, does the version you downloaded have ‘#define SS_TIMEOUT 30’ at the top (line 11)?
Hi. Yes i have. I see the timeout option. Compiling is also good. No missing libraries, but i do remember a library seen in the code of clock module from @analogoutput
Maybe the Nano needs this in order to use the screensaver. Let me check real quick……….
This screensaver is working on my Nano but i do not know which lines of code i can use without messing things up
No other library is needed. The screensaver just runs a simple millis() timer; if there haven’t been any inputs from the encoder during the timeout period (SS_TIMEOUT * 1000 milliseconds) it blanks the OLED and doesn’t call the screen update subroutine until the encoder is used again.
I’ve just downloaded the code from GitHub (to be sure I’ve got exactly the same version as you), loaded it on to my test system and the screensaver still works fine.
The only thing I can suggest at the moment is to look at the source code at line 280. This should be a comment line - // Screen Saver. Try removing the next line -
#ifdef SS_TIMEOUT
and the #endif a few lines later. This will force the screensaver code to be compiled, just in case there’s something odd going on with the preprocessor directives.
There’s another block with preprocessor directives at line 57. Remove the #ifdef SS_TIMEOUT, #else and #endif lines plus one of the declarations of ssTimeout. Change the other to
const unsigned long ssTimeout = 30000;
That removes all the conditional stuff and should force the compiler to give a 30s timeout.
Will test it tomorrow mate. Thanks for looking into it. Have a nice evening
.
I adapted your code and its still not working. Its a nice to have, not a must mate. Im still happy that the module is functioning.
How does that work anyways? Via the SDA and SDL?
I really don’t understand what can be going on here.
What the code does is check how long it is since the last operation using the encoder (which sets the screenMillis variable equal to the current value of millis() ). When that time difference exceeds the timeout period, the code sets a flag (variable screenSave) to indicate that screensave is active, and blanks the display (lines 282 - 286)
if (!screenSave && (millis() - screenMillis > ssTimeout)) {
screenSave = 1;
display.clearDisplay();
display.display();
}
While the screenSave flag is set the OLED_display subroutine is not called
if (!screenSave) OLED_display();
and the screen should stay blank (or at the very least, not update any more) until the encoder is used again. I don’t see how this would fail.
All the communication with the OLED is via SDA (the data line) and SCL (the clock). The screensaver doesn’t send a special ‘screensave’ instruction, it just (attempts to) send a blank screen and then not update the screen any more until the encoder is used.
Since I can’t replicate the problem it’s hard to debug it! If I could replicate it I’d start by adding a ‘Serial.println(screenSave);’ statement in the code block (above) which sets the screenSave variable to 1. This should tell you if the screenSave variable is ever set. If it is, then it appears your OLED needs a more thorough way of blanking it (which seems unlikely, especially if the display keeps on updating). Otherwise, something appears to be causing the screenMillis variable to be continuously updated so the screenSave variable never gets set to 1. That would need some debugging code around the ‘Rotary encoder reading’ and ‘BUTTON reading’ code blocks to see what’s happening to the value of screenMillis when there’s no encoder activity.
Hope this may help a bit…
To my great embarrasment, I found that I introduced a bug in the code for setting user defined patterns. It’s now fixed, so please download the code from Github again.
Sorry about that!
Hahahahaha. Thanks mate. I know that mistakes in code can be easily made. Especially when coding after midnight when my eyes start to go from round to square..
It works!!! I just powered it up without any connections, but then when i turned the rotary knob, the oled didn’t came back on, so i connected a clock signal and boom!! Oled came back on. Then i waited for 30 seconds and the screensaver kicked in. Super! So basically only power will get the oled black after 30sec, but you need the clock signal to get out of the hibernation mode. Just turning the rotary without the clock signal won’t do much. When there is a clock signal, turning the rotary will get the oled out of hibernation. Now since i have also an quantizer (alicedb2), i like to try to add the screensaver code too.![]()
![]()
![]()
![]()
![]()
![]()
Yay - I’m really pleased to hear that! I was beginning to wonder what was going on…
Yes, you need the clock running to get out of screensaver in the same way that the module doesn’t update the display at all without the clock. I looked into ways of avoiding that so you’d see changes to the settings without a clock input, but the code to create each frame (regardless of the upload time) is so long that it’s not really possible. I may revisit that for the SPI version but it would be tricky for I2C.
I’ve just sent an order to JLCPCB so I can build an SPI version on a PCB. I really don’t like using stripboard like I did for my Euclidean Rhythms module.
Good luck adding a screensaver to your quantizer!
Thanks a lot. Really appreciate the time and effort you’ve put in to this. If i can help you in any way just let me know. Also ask me if you need to test something.
Phew, thats not easy. I opened up your code with screensaver in a text editor and the quantizer in the arduino IDE and put it next to each other. So i logically start from the top and copy pasted in each line of code into the correct places (header, void setup, void loop etc etc) and after each line i compiled it. So far so good, but when i copy paste lines with the ‘enc’ in it and ‘oldposition’ it throws errors that it isn’t declared. Oled.display i need to change to adafruit oled ssd1306 display. Then i get a little freaked out because i simply dont know enough how to trouble shoot. So maybe when you have some spare time left, would you help me with this too? Thanks in advance
The only new variables you should need to add to your quantiser code are (equivalents of) screenMillis and screenSaver. The others (e.g. enc and oldposition) are specific to the sequencer’s code. You’ll need to find the places in your quantiser code which read its encoder and fit the new screensaver code in there.
I’d be happy to look at the code if I can download it from somewhere, but I probably won’t have time to look at it before the weekend.
Thats no problem. I will try again and learn something from it.
Here is the code of the quantizer if you might interested in it
So I had a few minutes to look at the tinyQuan code this morning and it struck me that its structure is quite different from the 6ch sequencer code. This might give some challenges trying to adapt the screensave code from one to the other. So I’ve quickly hacked together some test code based on the orkginal tinyQuan sketch. It works at least partially, but I can’t test it fully on my test rig. It should be a reasonable starting point for your experiments - I hope!
It works!! The screensaver.![]()
![]()
But it doesn’t quantize notes from my sequencer. I had this before and tried every hardware address for the DAC (default is 0x60 when A0 is tied to ground) and ended up with 0x63. So that worked, but now using a new Arduino Nano and the modified code with screensaver, it does not work anymore hahaha. So i tried uploading the original code without the screensaver, having the correct hw addresses for the mcp4725 and ads1115 set and it still does not work (??) I think i need to do a little more investigation. Anyways many thanks. Have a great day
Have you tried I2Cdetect? It shows the addresses of the I2C devices connected to your Arduino.