I admit I am stupid. Help with value settings.

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ElectronicOz
 
Posts: 74
Joined: Fri Jun 20, 2014 7:13 pm

I admit I am stupid. Help with value settings.

Post by ElectronicOz »

Folks,

This is a 95% working sketch.

That final 5% is killing me.

1 - the lines where I set the values for the "hours" "minutes" and "seconds".

Obviously INT doesn't work.
I need a "trick" to get things to work.

Hours is supposed to be RED. Minutes GREEN, and Seconds BLUE. (value 55 for now)

Doesn't work.


Next problem is the seconds LED isn't turned off.

I have a strip.show() line but I'm missing something obvious.
Attachments
Copy of LED_Clock2.txt
(2.92 KiB) Downloaded 149 times

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: I admit I am stupid. Help with value settings.

Post by Franklin97355 »

Doesn't work.
what does it do? Why do you have the strip.show() before you set the pixel color? If I were writing the code I wouldn't use a reserved word (loop) even if it were capitalized, it just doesn't feel right to me.

User avatar
ElectronicOz
 
Posts: 74
Joined: Fri Jun 20, 2014 7:13 pm

Re: I admit I am stupid. Help with value settings.

Post by ElectronicOz »

Well,

Say I want the hour to be "RED" (0x550000)
the line where I set the three colours is "accepted" but the hour LED isn't shown.

OBVIOUSLY (he says) is is something to do with the INT not supporting 0x550000 as a value.
I've seen these uint_32 things, but I have NFI what they mean or how to use them. I have NEVER really learned C/C++ or arduino. I just stick things together and they (mostly) work.

I've tidied up the second "hand" with a quick bit of code to turn off the LED at position second-1. And a bit of extra to do it when it gets to zero.

Then there is the minute hand.

As the second hand gets to "60" the minute hand increments. That isn't a big problem, as the second hand "clears" it on the next loop.

What would be nice to do is make the "second" minute LED a bit softer. That gets back to the colour "value" and how to make it a variable rather than a fixed number.

I've been watching it now for a few minutes and it looks ok, but the HOUR hand has problems.

Although it semi-steps as the minutes increase, at 10:00, the hour hand has GONE!

I thought strip.show() wipes the strip and only shows what is set.

Obviously I am wrong. (Yeah, I'm the village idiot.)

Also: When the second hand is over the minute or hour hand, it would be better/nicer if the two colours "merged".

Again: back to the variable name.

Oh, update:
In the time I am writing this, the hour hand has come back.
I maybe need to INT the hours in case of rounding errors.

Dunno.

:(

User avatar
ElectronicOz
 
Posts: 74
Joined: Fri Jun 20, 2014 7:13 pm

Re: I admit I am stupid. Help with value settings.

Post by ElectronicOz »

Found the problem with the HOUR LED and why it wasn't working.

Stupid maths error.

Fixed.

Now I am working on TRYING to put all the 60 LED's in an array so I can spew that out to the ring.

I have cut apart the RGB values to just that. R, G and B. That seems to work.

Now I am thinking about how to get the values into the array.

I know it is a simple (cough) for 1 = 0 to Loop-cout-value.
Store values......

But for some reason I can't just get that into the right format to work.


It has been so long since I have done programming and tried to change codes and convert one idea to another.
I guess I am just out of practice.

Anyone mind giving me a bit of help?

User avatar
ElectronicOz
 
Posts: 74
Joined: Fri Jun 20, 2014 7:13 pm

Re: I admit I am stupid. Help with value settings.

Post by ElectronicOz »

Looking in the Neopixel.h file I find these lines:

uint32_t
getPixelColor(uint16_t n) const;


Not that they really mean much to me.

But reading it, I can GET the colour of an LED - right?
But I don't understand the syntax of the line/s.

I'm TRYING!


uint32_t
User Int 32 bits long?
Stuck on the 32 bit part......
8 R, 8 G, 8 B? That's 24.

32 is not divisible by 3.

_t?

Huh?

I give up?

Then there is the:
getPixelColor(uint16_t n) const;

Ok: getPixelColor. I get that.
uint16_t Ummmm..... 16 bits for the address? I'll accept that.
_t?

n - not sure why this is needed. If the uint_16 is the address, this is not needed.
const. Yup. Clear as mud.

Oh, this is the latest sketch. It works as in the LEDs go "round and round" and seem to track the time ok.
Attachments
LED_Clock2.txt
(3.66 KiB) Downloaded 138 times

User avatar
Franklin97355
 
Posts: 23912
Joined: Mon Apr 21, 2008 2:33 pm

Re: I admit I am stupid. Help with value settings.

Post by Franklin97355 »

I'm not much more c savy than you but here are some of the answers.
uint32_t
User Int 32 bits long?
uint32_t = unsigned integer 32 bits and I dont know what the _t is
getPixelColor(uint16_t n) const;
Ok: getPixelColor. I get that.
(unsigned integer 16 bits variable name is "n" so when you call getPixelColor you give it the pixel number you want the color of (n) and it returns the color as a 32 unsigned integer.

Take a look at the .cpp file for more info on how these work as the .h file is more of the declarations whereas the .cpp is where the work is done.

User avatar
ElectronicOz
 
Posts: 74
Joined: Fri Jun 20, 2014 7:13 pm

Re: I admit I am stupid. Help with value settings.

Post by ElectronicOz »

Thanks. Shall do. Just the head is getting a bit sore being bashed against the wall.

I am kicking myself for NOT downloading a sketch which nearly does what I want but with different hardware.
Granted that is a problem in itself, but would be food for thought.

Why is the value 16 bits?

If there are 8 R, G and B...... That's 24 bits. Obviously there are more elephants in the room than I can imagine.

User avatar
ElectronicOz
 
Posts: 74
Joined: Fri Jun 20, 2014 7:13 pm

Re: I admit I am stupid. Help with value settings.

Post by ElectronicOz »

It would be nicer if there was a "keywords.txt" file in the neopixel library to help with the words.

Anyway, I am (still) playing with the sketch.

long Blah;
Blah = getPixelColor(59);
Serial.print("Pixel colour data ");
Serial.println(Blah);

Yields:
LED_Clock3.ino: In function 'void loop()':
LED_Clock3:154: error: 'getPixelColor' was not declared in this scope

AARRGGHH!

Ok, oops.

Forgot the strip.getPixelColor.
Works ok now.
But still not really understanding what it going on or what is happening.

User avatar
ElectronicOz
 
Posts: 74
Joined: Fri Jun 20, 2014 7:13 pm

Re: I admit I am stupid. Help with value settings.

Post by ElectronicOz »

Right.

More blood on the bricks.

I have sort of got strip.getPixelColor working.

Thoughts:
That as the 3 "hands" are different colours, when they merge/overlap, instead of not seeing the hand/s that they two colours "merge".
R + G = (what ever)
The 4 "points" of the clock, 3, 6, 9 and 12, are set to 0x050505.

As the "RED" second hand moves around, you can see it become "pink" when it is on those numbers rather than the usual strong RED.
Well, sometimes.
But when it gets to the minute and hour hands: Forget it. It is "overwritten" by the GREEN or BLUE.

I checked that long can handle 0xffffff and it can. No errors for size.

So this is the code: (See attached as .txt file)
I even went as far as printing the values of the getpixelcolor and noticed them (multiple times on each LED get bigger.
This was put down to it was scanning the LED multiple times and was increasing the value because of looping.
I put in extra code to let it only ONCE read the brightness/colour but it still seemed to do that.

I don't mind playing and trying thing, but when it doesn't seem to do what it is told to do I find it frustrating.
Attachments
LED_Clock4.txt
(4.84 KiB) Downloaded 149 times

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”