RGB Led Project - Help #675
Replies: 31 comments
-
Posted at 2016-12-14 by GarrettL I keep getting this error, the first part will send 100+ times. and the actual program is this, any ideas? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by @allObjects I cannot see anything wrong in the logic of your code. From what I get is that you fill an array with functions that do different lights. Such a light pattern function is then called every 50ms and you start with pattern with index 0. When you press the button, you increment the index (with modulo, currently commented) and run the new pattern - which you get by invoking next pattern. ...never mind next paragraph (came across your other conversation about A HY Mini-STM32 VCT6 3.2" board... and there LCD is probably defined... the LCD that is part of the board... but you errors with it and that could be the reason all is failing...)... What is not clear to me is the LCD... I don't see any initialization or so... and do not understand what you want to achieve with it... (btw, you set the color first, before you draw,... drawing the rectangle border first, and then draw a filled rectangle, is that what you want?) (And btw, cycle is an undeclared global). To get to the bottom of the story, check each of your pattern function at once... It is a good practice to put your initiating / starting code into After upload, you then enter in the console |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-14 by @gfwilliams
I'm not sure I understand what you're doing - for each LED you're completely wiping the screen with fillRect for most patterns - so it's going to be insanely slow and almost certainly not what you want. If you want to see the lights on the screen, remove all the LCD calls you have, and change
Your actual problem is For some reason you've actually commented out the code that made it work - so unsurprisingly it's now broken.
should be:
The percent is a 'modulo' - basically if patternNumber gets bigger than the number of patterns then it rolls over back to 0. Without it, patternNumber gets bigger, and you try and access something in the patterns array that doesn't exist, which gives you undefined. Finally, you probably also want to debounce the switch, so use:
instead of just |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-15 by GarrettL
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-15 by GarrettL So this is the new code correct? Shouldn't the screen show what the leds are showing and then the screen isn't showing anything? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-16 by @gfwilliams You seem to have commented out the line I guess it was failing because you moved the definition of If you get an error and comment stuff out, can say in the future? It can save a lot of time. Also, if you want code to show up in the forum properly, you need to highlight it and click the |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-17 by GarrettL Now it won't send it, it either gets a 1/4 of the way on the progress bar or 90 and then it becomes un responsive. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-20 by GarrettL any ideas? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-20 by @gfwilliams Did you change anything else? Did you plug in via the other USB connector this time by mistake? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-21 by GarrettL I think i fixed it, thank you so very much! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-21 by GarrettL If i want to make the size of the box on the lcd what numbers would i need to adjust? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-22 by GarrettL I know how to fix the y2 and that made it taller, any way to make it wider? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-23 by @allObjects Check the references for fillRect(...) and drawRect(...). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-23 by GarrettL But the code has i, I'm not sure how i can change that. Its not that simple of a rect allObjects |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-23 by @allObjects @GarrettL, line 143 The current setup / code takes advantage of the stepping of 3 and makes it 3 wide... depending on the pixels you have in x-axis, you can make it wider... I assume you have a 240x320 display... I though do not know how you orient it: is x-axis (A) 240 pixels, or (b) 320 pixels... It matters, but not really, because you can calculate it... I suggest you explore your options with these 3 steps: 1st, replace line 143 with these two lines:
2nd, insert between line 140 and 141 this line:
3rd, to make everything work, you do some prep work between line 10 and 11 with these lines:
The Constant Enjoy! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-24 by GarrettL Or it just has a delay of the showing |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-24 by @allObjects @GarrettL, what I prepared for you are 2 emulations in html5 and movie clips of them running: your initial code and then the code with my suggestion changes to display the LEDs on the display in maximal size - in either vertical or horizontal orientation . Click RGBLightsEmulation2.html link, play with it, view the source (in the browser). To run it on Espruino, copy the portion from line 29 through 223 to the Espruino Web IDE, upload it to your board, and run it by entering in the console I used emulation to verify the code because I do not have the LED string and didn't want to wire up my SPI connected LCD to Original/Pico/Wifi/Puck Espruino boards (using the LCD over SPI is so slow that it does not allow to have 50ms redraw cycles... :(... ). Furthermore, emulation shows that cross development is easily and quickly to achieve, is very useful, and is fun. Note that I use your Espruino code as is (with a minor fix that has nothing to do with the emulation0)... You can run the emulations yourself by clicking on the html attachments. You start and stop the lights by clicking on lightsOn() and lightsOff() buttons. These buttons are for convenience and work as if you entered the commands into the Espruino console (or browser debug console). Cycling through your light patterns is done by clicking repeatedly on the BTN button. The code in html5 with my suggested modifications for displaying the LED string in maximal size - either vertical or horizontal - looks like below and includes the code for Espruino from line 83 thru 223:
There are some small change/fix to your code of which commenting the LCD.clear() statement is noteworthy.Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-24 by GarrettL You made this so much more than it needed to be, I have no idea on any of this stuff you're talking about and wanting me to do now. I just wanted the simple fix to enlarge my screen thats it. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-24 by GarrettL The emulators are great but it still doesn't help me with what i need to edit, I'm on here for help because I'm not sure what i need to change that doesn't tell me what i need to change or anything, I understand how the first guy helped me but you completely changed what he did. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-25 by @allObjects ...I'm not so sure... I understand more or less what you want to do: show a larger rectangle for each of the LEDs on your display. In post #16 of this conversation, I gave you some help to modify the code so it shows wider bars for each of the LED. You mentioned then no positive feedback in posts #17 and #18, since I could not test the code as per the instruction, I decided to to that verification,... and it was successful. Just follow the instructions and copy the lines 89 through 223 - your code with the added lines as instructed in post #16 - and paste them into the editor pane of your Espruino Web IDE, upload them, and enter That's it! PS: Study the |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-26 by GarrettL In post #16 it didn't widen the bars though it, it moved them over the the left or only showed one bar! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-26 by @allObjects Can you take a pic of what you see with the unchanged code and share it in the forum? Your code creates something looking like on the right in the screen shot I attached... assuming the display you have is configured 240 pixels horizontal in the x-axis and 320 pixels vertical in the y-axis with x=0 and y=0 being left-top corner. You have 50 lights and the code creates a bar of 3 pixels wide for each of the LEDs, which makes 150 pixels... just by co-using the fact that every third byte in the Uint8Array is the begin of a new LED. My suggested changes take the full width into account - 240 pixels - which makes it possible to have a 4 pixels wide vertical bar for each LED building a large horizontal bar. Furthermore, the suggested changes allow to use the vertical - 320 pixels - which makes it possible to have a 6 pixels high horizontal bar for each LED building a large vertical bar. The changes in the begin use the If this is not what you get, then we are not talking the same language, or may be not the same hardware... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-26 by GarrettL
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-26 by GarrettL This is what this code is doing, it isn't with the modifications you have showed me, i will send that later on. I want these bars wider but i want to make it cover the full screen. I can change the var rgb = new Uint8Array(50*3); 3 to 9 and it make full screen but i dont know if that will change my leds.Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-27 by @allObjects @GarretL, your pic helps a lot. You may easily achieve using 300 of the 320 horizontal pixels with the following changes to your original code: Make line 12 of code in post #25 look like this:
...and line 204 like this:
...and line 204 like this:
Using all of the 320 pixels is a bit a mess and may slow down the execution to the point where you cannot achieve 20 cycles per second anymore. But you may give it a try: Make line 12 of code in post #25 look like this:
...and line 204 like this:
...and line 204 like this:
Just for my curiosity - and help you with the generic code that maximizes dynamically the display size of the LEDs. A) Do you know the number pixels your display has horizontally? ...I assume it is 320. The answer for C) is easy to find out. It should be sufficient to enter in the console pane of the Espruino Web IDE (left hand pane) the following line:
This draws and filled rectangle that is double as wide as high in the corner where 0,0 is. Looking forward to hear from you about - hopefully - success! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-27 by GarrettL
The first set of changes showed nothing on the screen. Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-27 by GarrettL
The second shows the same thing without the white thing in the corner. Yes you have the correct dimensions and i believe 0,0 is top left corner! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-12-27 by @allObjects @GarrettL, thanks for showing the coded... because you inserted lines, it got a bit mangled because the line numbers changed... The reason that you do not see effects is that both 3rd changes ended up outside the loop and before the color is set instead of replacing your fillRect() in the loop after the color is set. Furthermore, because your code comes after the changes, it just overwrites what was before... and in the second example you commented oh¥-so-required the loop that's why you get just a white dot in the top left corner... ;-) Return to your code in post #25, and apply literally proposed changes.... and you will see it work. There is nothing wrong with your code in post #25, because it produced a big tall, fat horizontal bar from top to bottom - 240 pixels - consisting of 50 slim vertical bars - 3 pixels wide - for each LED. The proposed changes will just double that... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-02 by GarrettL in post #27 you have two codes of line that you want me to sub for the same line and also i tried it and causes some errors! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2017-01-02 by GarrettL If you could just copy the code and change them yourself it might be easier than explaining! Thank you |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-12-09 by GarrettL
Beta Was this translation helpful? Give feedback.
All reactions