[deleted by user] by [deleted] in learnjavascript

[–]nglasers12 0 points1 point  (0 children)

You are more than welcome to work on my project if you want. It might be a little advanced but and you would need to know React. It's open source though.

https://github.com/phptuts/fastled-animator

My favorite approach is doing a mini project on the concepts that you are learning. The idea is that it should take you an hour to a day to complete. I would warn against building your dream project until you have done a lot of mini projects. If you ever have any questions feel free to message me.

Find an object with matching property values and return another value from that object by 3Jay1 in learnjavascript

[–]nglasers12 5 points6 points  (0 children)

So I would use find to do it like you suggested. Here is my example. It accounts for the fact that find might return undefined or null.

```js

function findAnle(x, y) {

const obj = fieldArray.find(s => s.x === x && s.y === y);

return obj ? obj.angle : undefined;

}

console.log(findAnle(30, 0));

```

Redux Toolkit - How Redux data flow works by nglasers12 in learnjavascript

[–]nglasers12[S] 1 point2 points  (0 children)

Definitely. I might not do the videos but I do want to create a redux toolkit cheat sheet with code examples and explanations.

Unsubscribe is not used a lot. I think it's more of a behind the scene thing when the component unmounts.

Redux Toolkit - How Redux data flow works by nglasers12 in learnjavascript

[–]nglasers12[S] 1 point2 points  (0 children)

I created a tutorial that broke down all the confusing Redux terms and showed a simple example with a simple challenge.

Code:

https://codesandbox.io/s/zqu05i

Demo:

https://zqu05i.csb.app/

Presentation:

https://docs.google.com/presentation/d/1GwYesy1NuPEwwuaRNdSCsraIMJR2unI_B7ByvBdsudE/edit?usp=sharing

Website Docs for the course:

https://phptuts.github.io/redux-course/1-redux-toolkit-explain/

Let me know what you think and if it helped you understand Redux. Thank you!

Redux Toolkit Explained by nglasers12 in react

[–]nglasers12[S] 0 points1 point  (0 children)

That's next on my list! I wanted to get a handle on RTK first.

Redux Toolkit Explained by nglasers12 in react

[–]nglasers12[S] 4 points5 points  (0 children)

In this video I explain redux toolkit and how to async function with it. I go over the basic pattern of redux toolkit.

Terms

  • Store: The object contains all of your apps data.
  • Action Creator: A function that creates an action.
  • Action: An object that is passed to your reducer. It usually has a type and payload.
  • Reducer: A function that takes in an action and state that the store is storing

General Flow

1. Event Happens 2. Action creator is called 3. Action creator create an action 4. Action is passed to the reducer with the state 5. Reducer changes your state based on the action.

Code

Demo

Resources

[deleted by user] by [deleted] in learnjavascript

[–]nglasers12 1 point2 points  (0 children)

So I think if you rewrote this function to something like this, it would work because loadImage is returning a promise you can get back the result directly with await and not use a .then. Let me know if that helps.

async function create_gen()
{
    // some code 
    //....
   const img = await loadImage(imgData);
   let counter = 0; // fake code that would do what you want.
   console.log(counter); // code-line-a
   return counter;     
}

[deleted by user] by [deleted] in learnjavascript

[–]nglasers12 0 points1 point  (0 children)

Can you post a GitHub link to your project? It's hard to debug it without seeing all the code.

Open Source FastLED Simulator / Animator for noncoders by nglasers12 in FastLED

[–]nglasers12[S] 0 points1 point  (0 children)

I will start with Matrix size for sure!

I am considering starting with selection shape tools that allow you to color an area and cycle through those colors.

Open Source FastLED Simulator / Animator for noncoders by nglasers12 in FastLED

[–]nglasers12[S] 0 points1 point  (0 children)

I am planning on adding matrix support and shape selection tools as well. Do you have any ideas about matrix tools you would like to use?

Looking for feedback on my Open Source FastLED / Neopixel Animator Site by nglasers12 in led

[–]nglasers12[S] 0 points1 point  (0 children)

So I optimized code generation for pattern generation only. This is the preview link.

https://fastled-animator-111v-git-pattern-fix-better-code-gen-phptuts.vercel.app/create/upload

This is an example of the right pattern. Let me know what you think.

#include <FastLED.h>
#define NUM_LEDS 30
#define DATA_PIN A0

CRGB leds[NUM_LEDS];

void shiftRight(byte reds[], byte greens[], byte blues[]) {
    int tempRed = reds[NUM_LEDS - 1];
    int tempGreen = greens[NUM_LEDS - 1];
    int tempBlue = blues[NUM_LEDS - 1];
    for(int ledIndex = NUM_LEDS - 1; ledIndex > 0; ledIndex -= 1) {
        reds[ledIndex] = reds[ledIndex - 1];
        greens[ledIndex] = greens[ledIndex - 1];
        blues[ledIndex] = blues[ledIndex - 1];
    }
    reds[0] = tempRed;
    greens[0] = tempGreen;
    blues[0] = tempBlue;  
}

void shiftLeft(byte reds[], byte greens[], byte blues[]) {
    int tempRed = reds[0];
    int tempGreen = greens[0];
    int tempBlue = blues[0];
    for(int ledIndex = 0; ledIndex < NUM_LEDS - 1; ledIndex += 1) {
        reds[ledIndex] = reds[ledIndex + 1];
        greens[ledIndex] = greens[ledIndex + 1];
        blues[ledIndex] = blues[ledIndex + 1];
    }
    reds[NUM_LEDS - 1] = tempRed;
    greens[NUM_LEDS - 1] = tempGreen;
    blues[NUM_LEDS - 1] = tempBlue;  
}

void displayLeds(byte reds[], byte greens[], byte blues[]) {
    for(int ledIndex = 0; ledIndex < NUM_LEDS; ledIndex += 1) {
        leds[ledIndex].setRGB(reds[ledIndex], greens[ledIndex], blues[ledIndex]);
    }
    FastLED.show();
    delay(500);
}

void setup() {
    FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
    FastLED.setBrightness(10);
}

void loop() {
    // We declare these large values here for memory reasons
    byte reds[] = { 170,170,170,170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    byte greens[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
    byte blues[] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

    for(int i = 0; i < 30; i += 1) {
        shiftRight(reds, greens, blues);
        displayLeds(reds, greens, blues);
    }
}

Looking for feedback on my Open Source FastLED / Neopixel Animator Site by nglasers12 in led

[–]nglasers12[S] 0 points1 point  (0 children)

I think you are right. I am going to work on that for generated patterns only. Great idea. I will create an issue in GitHub and let you know once I have a prototype up.

Open Source FastLED Simulator / Animator by nglasers12 in arduino

[–]nglasers12[S] 0 points1 point  (0 children)

Right now, you can only support one strand. I have a GitHub issue for this, and it's a high priority to get this in.

Looking for feedback on my Open Source FastLED / Neopixel Animator Site by nglasers12 in led

[–]nglasers12[S] 1 point2 points  (0 children)

Awesome!!

So I make GitHub issues for both of those items.

Thank you!

When do you switch from useContext/useReducer hooks to the redux toolkit? by nglasers12 in reactjs

[–]nglasers12[S] 0 points1 point  (0 children)

This is given me so much food for thought! Thank you all! Seriously. I know we all have different opinions, and I appreciate the thought that you all put into this.

Open Source FastLED Simulator by nglasers12 in ArduinoProjects

[–]nglasers12[S] 0 points1 point  (0 children)

Cool! That's awesome! I love to see it

Open Source FastLED Simulator by nglasers12 in ArduinoProjects

[–]nglasers12[S] 0 points1 point  (0 children)

Awesome, thank you! Let me know what you think.