Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
BlackTie
Oct 23, 2008

Usagi-Sauce posted:

goddamn i think an attiny85 is 1 gpio line short for this job

1: connected to gate of a transistor to keep power going to vcc until the program says it's time to power off
2: brightness up
3: brightness down / off
4: measure supply voltage
5+6: charging/charged/low battery/off rgy indicator led
7: connected to led driver (or directly, people say the attiny can sink a decent amount of current?)

i can't just use the led driver for 1 because i'll be strobing it for brightness control

i guess one of 5+6 can actually be overloaded to serve the purpose of 1 - the indicator will only ever be red (voltage warning) or off (all ok) while the lights are on, and it's probably more trouble than it's worth to allow charging with the light on

or i could just go nuts and try something with more gpio pins i guess. attiny84? idk. the extra pins would give me breathing space if i wanted to add any more dumb poo poo.

maybe combine 2 and 3 with a pot? the tiny85 has enough adc channels, so you can have both the supply voltage and the brightness. maybe have the adc reading as less than x means off, and x-max for brightness

Adbot
ADBOT LOVES YOU

a cyberpunk goose
May 21, 2007

shift register? idk im bad at this tuff

Usagi-Sauce
Dec 2, 2005

YAMOxNINJA
~otp~

BlackTie posted:

maybe combine 2 and 3 with a pot? the tiny85 has enough adc channels, so you can have both the supply voltage and the brightness. maybe have the adc reading as less than x means off, and x-max for brightness

i don't much like pots in my digital electronics but that makes me think it'd be cool if i could fit a rotary encoder instead of the two buttons, it'd mean finer brightness steps & being able to select them more smoothly, and Base Emitter's suggestion means i've got enough pins

gotta do my reading though, it looks like i'd need to keep it powered when idling and i don't really want to invent a booklight that drains its battery in standby


peepsalot posted:

i did a really simple 3d random walk thing that looks kinda cool
http://jsfiddle.net/x84T7/1/embedded/result/
this DOES look cool, every time I see stuff like this I stare at it for a while because it's so unusual to see computer graphics with volumetric detail instead of just surface

Corla Plankun
May 8, 2007

improve the lives of everyone

peepsalot posted:

i did a really simple 3d random walk thing that looks kinda cool
http://jsfiddle.net/x84T7/1/embedded/result/

i just made it walk in a sphere instead for fun and jesus christ math is a nightmare in js

code:

if(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2) > Math.pow(size2,2)) {
  x = size2 * x / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
  y = size2 * y / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
  z = size2 * z / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
}

Dr. Honked
Jan 9, 2011

eat it you slaaaaaaag

Corla Plankun posted:

i just made it walk in a sphere instead for fun and jesus christ math is a nightmare in js

code:

if(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2) > Math.pow(size2,2)) {
  x = size2 * x / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
  y = size2 * y / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
  z = size2 * z / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
}


that's going to gently caress up really badly surely? why not precalc Math.pow(x,2), Math.sqrt(Math.pow(x,2)) etc and your calculations will then magically un-gently caress themselves? or am i missing something

Dr. Honked
Jan 9, 2011

eat it you slaaaaaaag
i mean your calculations are going to gently caress each other as they happen due to x, y, changing. why not do this?
code:

xsqr = Math.pow(x,2);
ysqr = Math.pow(y,2);
zsqr = Math.pow(z,2);

fart = xsqr + ysqr  + zsqr;

if(fart  > Math.pow(size2,2)) {
  fartroot = Math.sqrt(fart);
  x = size2 * x / fartroot;   
  y = size2 * y / fartroot; 
  z = size2 * z / fartroot;  
}

should be faster and not so fucky?

Corla Plankun
May 8, 2007

improve the lives of everyone
hahahaha yeah

i dont know anything about javascript and i just woke up and didnt want to scroll up to see how to initialize variables but thank you for pointing out how dumb i am in such a polite way

Dr. Honked
Jan 9, 2011

eat it you slaaaaaaag
you are most welcombe :wotwot:

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Corla Plankun posted:

i just made it walk in a sphere instead for fun and jesus christ math is a nightmare in js

code:

if(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2) > Math.pow(size2,2)) {
  x = size2 * x / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
  y = size2 * y / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
  z = size2 * z / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
}


why in gods name are you not using a vector maths library

code:
if (v.modulus > size2)
{
    v = size2 * v.normalized
}

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
btw have a play with unity3d if you get a chance. it's free, can be scripted in js, and idiotproofs whatever stuff you don't want to have to deal with

Corla Plankun
May 8, 2007

improve the lives of everyone

coffeetable posted:

why in gods name are you not using a vector maths library

code:
if (v.modulus > size2)
{
    v = size2 * v.normalized
}

nice!

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
have you not come across vector maths or linear algebra before? cause if you plan on doing a fair bit of work involvin well, objects in space, it's hella useful.

best self-teachin resource is stroud's Engineering Mathematics, on account of it also being the best all-round maths textbook ever written.

Base Emitter
Apr 1, 2012

?
linear algebra best algebra

Dr. Honked
Jan 9, 2011

eat it you slaaaaaaag

Base Emitter posted:

linear algebra best algebra

4 reals

Corla Plankun
May 8, 2007

improve the lives of everyone

coffeetable posted:

have you not come across vector maths or linear algebra before? cause if you plan on doing a fair bit of work involvin well, objects in space, it's hella useful.

best self-teachin resource is stroud's Engineering Mathematics, on account of it also being the best all-round maths textbook ever written.

i'm actually an engineer (which is why my code was so balls) so i use that stuff all the time, its real cool that there is a library for it though

edit: that book is loving amazing. that's like 36 credit hours of math in one tome!

Corla Plankun fucked around with this message at 19:31 on Dec 14, 2013

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Corla Plankun posted:

i'm actually an engineer (which is why my code was so balls) so i use that stuff all the time, its real cool that there is a library for it though

edit: that book is loving amazing. that's like 36 credit hours of math in one tome!
yeah whenever you find yourself manipulating the components of a conceptual object (ie, one that you treat of as a single object in your head. like a point in space), that's a sign you should encapsulate the components into an object in the code, and then apply operations to the object as a whole.

if you find yourself thinking this while working in a common problem domain, there will almost certainly be a library

Corla Plankun posted:

edit: that book is loving amazing. that's like 36 credit hours of math in one tome!
the scope is part of why it's so good, but the main reason is that it frames every.goddamn.step on the path from arithmetic through to laplace transforms as a Q/A. check a few random pages using Look Inside, it's all tiny sections with a simple new idea followed by a question to make sure you understand it properly. then the sections and chapters are bookended by more practice questions w/ answers at the back so you can get it down pat before moving forwards

there's also a sequel, Advanced Engineering Mathematics, which picks up where the first leaves off and takes you through to vector calculus + complex analysis. owns owns owns

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

i added color cycling :pcgaming:
http://jsfiddle.net/x84T7/11/embedded/result/

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

continuous walk: http://jsfiddle.net/x84T7/12/embedded/result/

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord
this is neat but man looking at it is making me sick

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

DEHUMANIZE YOURSELF AND FACE TO SWEET GFX

Sagebrush
Feb 26, 2012

v neat but pro tip about the color cycling, it's best to restrict your cycling to two components of the color. looks a lot better. eg keep the blue component at 0, randomize the r and g between 100 and 255, and you now just cycle in the red-orange-yellow segment of the wheel and it looks cleaner. or do red and blue for pink/purble/magenta stuff, etc.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Werthog 95 posted:

visit ur local library and find an electronics book i guess?? if u got a college nearby check out an old intro 2 EE textbook

what about "getting started in electronics" which everyone of a certain age got from radio shack and has smiley faces on the electrons?

Sagebrush
Feb 26, 2012

is that one of the forrest mims books? they're pretty good

dude is kind of like orson scott card in that he's an insane christian wacko, in this case believes stuff like ebola is a genetically engineerd virus created by the cia and global warming is a myth (he teaches these views at some unaccredited university) but as long as you stick to the areas he's not insane (electronics) he's alright

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

coffeetable posted:

have you not come across vector maths or linear algebra before? cause if you plan on doing a fair bit of work involvin well, objects in space, it's hella useful.

best self-teachin resource is stroud's Engineering Mathematics, on account of it also being the best all-round maths textbook ever written.

geometric algebra is better objectively but noone uses it ;_;

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Sagebrush posted:

is that one of the forrest mims books? they're pretty good

dude is kind of like orson scott card in that he's an insane christian wacko, in this case believes stuff like ebola is a genetically engineerd virus created by the cia and global warming is a myth (he teaches these views at some unaccredited university) but as long as you stick to the areas he's not insane (electronics) he's alright

yeah its mims and yeah hes a nut, he got fired from sciam for it (i think it was sciam anyway)

but smiley face electrons

peepsalot
Apr 24, 2007

        PEEP THIS...
           BITCH!

Sagebrush posted:

v neat but pro tip about the color cycling, it's best to restrict your cycling to two components of the color. looks a lot better. eg keep the blue component at 0, randomize the r and g between 100 and 255, and you now just cycle in the red-orange-yellow segment of the wheel and it looks cleaner. or do red and blue for pink/purble/magenta stuff, etc.
i tried like you suggested but stil didn't realy like the look.

heres one with just cycling through 1d of spectrum with colors locked in 3phase relative to eachother.
http://jsfiddle.net/x84T7/13/

Sapozhnik
Jan 2, 2005

Nap Ghost

heh

There Will Be Penalty
May 18, 2002

Makes a great pet!

Corla Plankun posted:

i just made it walk in a sphere instead for fun and jesus christ math is a nightmare in js

code:

if(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2) > Math.pow(size2,2)) {
  x = size2 * x / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
  y = size2 * y / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
  z = size2 * z / Math.sqrt(Math.pow(x,2) + Math.pow(y,2) + Math.pow(z,2))  
}


var pow = Math.pow, sqrt = Math.sqrt;

Dr. Honked
Jan 9, 2011

eat it you slaaaaaaag

heeeeh

GameCube
Nov 21, 2006

Sagebrush posted:

is that one of the forrest mims books? they're pretty good

dude is kind of like orson scott card in that he's an insane christian wacko, in this case believes stuff like ebola is a genetically engineerd virus created by the cia and global warming is a myth (he teaches these views at some unaccredited university) but as long as you stick to the areas he's not insane (electronics) he's alright

oh drat i did not know that poo poo. should have assumed, now that i think about it

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Malcolm XML posted:

geometric algebra is better objectively but noone uses it ;_;

not gonna disagree. i found diff geo a right pain until i ran into forms via mtw and oh my god its full of stars

but yeah if wishes were fishes. right now i just want the roll-your-own approach to be stomped out, and seein as linear algebra is what 98% of physics-related libraries use, that's the recommendation

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY
see also: $functional_lang is objectively better than $lang but noone uses it ;_;

01011001
Dec 26, 2012

Base Emitter posted:

linear algebra best algebra

HAL 219000
Nov 27, 2013

number 219
is alive
kill you'reself op

duck pond
Sep 13, 2007

There Will Be Penalty posted:

var pow = Math.pow, sqrt = Math.sqrt;

with (Math) {
var y = sqrt(x)
}

don't take my word for it though, i'm on me phone and can't test it (who ever uses the with statement anyway?)

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

Malcolm XML posted:

geometric algebra is better objectively but noone uses it ;_;

I studied a bit of Clifford algebras years ago and I had no idea there were people using it in computer graphics. besides quaternions I mean

unless what you're saying is that there are not :saddowns:

enotnert
Jun 10, 2005

Only women bleed
Just got that book trig mentioned.

It's fuckin awesome, already gave me some more ideas about what to do with all these piezos i bought when i decided i wanted to sample a dying hard disk.

Corla Plankun
May 8, 2007

improve the lives of everyone

enotnert posted:

Just got that book trig mentioned.

It's fuckin awesome, already gave me some more ideas about what to do with all these piezos i bought when i decided i wanted to sample a dying hard disk.

thats a real cool idea

coffeetable
Feb 5, 2006

TELL ME AGAIN HOW GREAT BRITAIN WOULD BE IF IT WAS RULED BY THE MERCILESS JACKBOOT OF PRINCE CHARLES

YES I DO TALK TO PLANTS ACTUALLY

Symbolic Butt posted:

there are not :saddowns:

afaik, at least.

Adbot
ADBOT LOVES YOU

enotnert
Jun 10, 2005

Only women bleed

Corla Plankun posted:

thats a real cool idea

https://vine.co/v/h2AuPjel3qQ

I have this one in my office right now that I've had plugged up for days waiting for the rhythm to change.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply