Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

value of the neopixel.hsl() runs away when convert JavaScript or Python codes to block #59

Open
32ma-me opened this issue Dec 27, 2021 · 0 comments

Comments

@32ma-me
Copy link

32ma-me commented Dec 27, 2021

What's the problem?

I was writing program with MakeCode(JavaScript mode) and this package.
I finished coding and try to convert my program to block.
But when I look at block programs...i noticed. Value runs away!!!

What's it like?

like this image.
image

What kind of program were you writing?

There's JavaScript source code. (Sorry for comment written by Japanese)

//絶対これブロックに変換するなよ!!!絶対だからな!!!フリじゃないからね!!!!いやほんとに!!!!!
input.onButtonPressed(Button.A,function(){//ここはon/off切り替え処理です 基本いじらなくていいとおもふ
    if(!onflag){
        onflag++;
    }else{
        onflag=0;
    }
})
input.onButtonPressed(Button.B,function(){//明るさ調節 今は5段階にしてるけど調整したかったら調整してね
    if(brightness==20){//減らしていく値を変更したときにいくつで最大に戻すか
        brightness=100;//MAXは100です
    }else{
        brightness-=16;//16ずつ減らしていく
    }
})
let onflag=0,brightness=100,strip:neopixel.Strip=neopixel.create(DigitalPin.P1,9,NeoPixelMode.RGB);//初期化の翁
while(onflag){//onのときだけ実行されるやつら
    for(let l=0;l<=8;l++){//真ん中以外の制御
        if(l==4){continue;}//真ん中を飛ばす
        strip.setPixelColor(l,neopixel.hsl(randint(0,50),360,(input.soundLevel()/255*300+60)*brightness/-100+360));//大体赤~オレンジでランダムにしてる うるさいと暗くなります
    }
    strip.setPixelColor(4,neopixel.hsl(0,0,brightness*3.6));//真ん中の制御 白~黒にしてるけど文句あったら言ってね
    strip.show();//表示
    basic.pause(1);//1/1000秒のリアルタイム更新
}

Could you fix this? Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant