I am looking for a little guidance. I am an armature at programming. I am working on making an arduino powered box mod for vaping. I am using an Uno and an I2C oled display and have the display library and ButtonClick library included. The problem I am experiencing is that when the various regions of the display are all enabled and updating, the code is running too slowly (it appears) to capture the button presses. As I disable one section at a time, the serial output speeds up and starts catching some of the button presses, and when the majority are disabled it works fine. Ive tried this code on a mega to rule out memory issues and I experience the same problems. What could be causing this?
Usually best way to speed up things is to not display something if it has not changed. Are you testing for this or always displaying everything in the loop?
Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?
Every time you refresh the display, you have to push over 1KiB of data over the I²C connection. This takes a lot of time. You can reduce the time by increasing the I²C clock speed:
Usually best way to speed up things is to not display something if it has not changed. Are you testing for this or always displaying everything in the loop?
Could you please show me an example of how to implement this?
PieterP:
Every time you refresh the display, you have to push over 1KiB of data over the I²C connection. This takes a lot of time. You can reduce the time by increasing the I²C clock speed: Wire - Arduino Reference
Pieter
Thank you, I will be reading up on this later tonight.
Here is a snippet of the code displaying. the function is in loop and i can see how its constantly updating.
Hi,
We need to see your complete code.
If it is too big fr code tags, please attach it as an .ino file.
Can I suggest you forget trying use a graphics program, and get pen and paper out and draw your circuit, label all components and connections. Keep your wires as straight lines and do not use diagonal wires.
This may take time, but worth it.
My code is largely incomplete as its still in its infancy stage. I started out making the basic functions and have yet to put them together for the most part. I am also still waiting for parts for testing and am still trying out button libraries and I2C libraries. That is when I hit this "dead end" I am working on.
I will attach it. Maybe you can provide me some insight.
Basically the code monitors battery voltage through a voltage divider and will check the amps of the coil (this part is not written yet) and calculate the ohms of the coil. The user will select a preferred wattage which i am hoping to store in eeprom. For input there will be three buttons. an up button, a down button, and a fire button. The Fire button will "fire" if held, store wattage, wake the display, and poll the amps on single clicks, three clicks will lock the wattage from being adjusted accidentally, and 5 clicks will sleep the device. the up and down buttons are for selecting the wattage and will increase the rate that numbers increment the longer its held.
upon firing the code will calculate the correct voltage to pwm to make the output the desired watts. A number of safety checks will be implement as well. For instance it will not fire if the coil is shorted or open, it will shutdown if the battery becomes critically low, and it will not allow it to fire for longer than 10 seconds as that usually happens in the users pockets.