ferm10n / morpheus

Emulate an arduino neopixel setup right from your browser
10 stars 0 forks source link

Install documentation is unclear on several points #5

Open marcmerlin opened 4 years ago

marcmerlin commented 4 years ago

Hi, I looked at your project, and there are a few things that aren't clear for people who have 0 experience with npm

1) does it allow emulating an X/Y FastLED Matrix, or just a 2D strand? I'm looking for/needing this: https://github.com/marcmerlin/FastLEDonPc/ Note that I obviously have it already, but would be interested in seeing it work in a browser instead of only linux with SDL. Also, I'm very interested in an emulation that allows serial input as I do need this extensively

2) getting started it not clear on those steps a) I arn 'npm init -y' on linux, and got a few warnings that don't look safe to ignore

Love nodemon? You can now support the project via the open collective:
 > https://opencollective.com/nodemon/donate

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN ws@7.2.1 requires a peer of bufferutil@^4.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN ws@7.2.1 requires a peer of utf-8-validate@^5.0.2 but none is installed. You must install peer dependencies yourself.
npm WARN emulation@1.0.0 No description
npm WARN emulation@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.11 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.11: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ morpheus-neopixel@1.0.0
added 408 packages from 238 contributors

b) your code then ends up kind of half hidden inside node_modules/morpheus-neopixel 'add "start": "morpheus" to the "scripts" part of your package.json' is that the top level one or the one in that directory?

c) create morpheus-config.js. Where? Top level? node_modules/morpheus-neopixel? Looks like I need to use this as a template: morpheus-neopixel/examples/strandtest/morpheus-config.js ?

Thanks for more details :)

ferm10n commented 4 years ago

Hello!

I apologize the documentation is lacking. The project is a work in progress and I found myself changing how things get setup a lot and stopped updating the documentation because it was hard to keep up on.

does it allow emulating an X/Y FastLED Matrix, or just a 2D strand?

The plan is to allow it to support emulation of any individually addressable RGB strip, provided that it is controlled with the Adafruit Neopixel or the FastLED library. At the moment, I only have support for neopixel library, and I was learning fastled but had issues when trying to compile for PC. I might be able to get some ideas by studying a couple of your projects! I'd be open to collaborating.

I believe the FastLed matrix simply abstracts the single data output away so you can use X/Y control, so it is not limited to a "2D strip" (even though it might very well be a 2d strip arranged in a grid). So it should work in theory. Here's a demo I made with a LED matrix that shows what morpheus generates in the browser: (see the stacey-matrix branch) morpheus_matrix

(frame rate sacrificed for gif size)

I'm very interested in an emulation that allows serial input

This would have to be mocked so that stdin provides the "serial input" when compiling on PC, but yes this is possible.

got a few warnings that don't look safe to ignore

These are just warnings from npm, mostly for optional dependencies. I don't make use of those deps, so it's fine. You are safe to ignore.

_your code then ends up kind of half hidden inside nodemodules/morpheus-neopixel

This is correct. npm is a package manager, and node_modules is where it installs application dependencies. That is why when installing morpheus as a dependency, it ends up in that folder.

is that the top level one or the one in that directory?

The top level one. After running npm init -y it should create a package.json at the top level, and after adding the "start": "morpheus" it should look like this:

{
  "name": "your-project-name",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "morpheus"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "morpheus-neopixel": "git+https://github.com/ferm10n/morpheus.git"
  }
}

regarding adding the morpheus-config.js

I haven't updated the documentation yet for this, but as long as you have a .ino file, morpheus will find it automatically and you won't need the config file. but if you needed to, you would place it in the top level directory.


It seems like you have more experience with FastLED than I do, I think it'd be beneficial to us both if we worked together to add support for it and polish up this project! If so, let me know how you'd like to go about coordinating this and keeping the discussion going :)

marcmerlin commented 4 years ago

Thanks for the quick reply. Not to worry about documentation, it takes a crapload of time ot write and no matter how much I write, it seems that it could always be more :) Right now, I will likely lean on the FastLEDonPC project as I need to run arduino code on an rPi that will run a higher res SmartMatrix (max resolution on arduino chips is around 128x64 and I want 192x128 for my next version of http://marc.merlins.org/perso/arduino/post_2019-04-08_Clubbing_-EDM-Festival-and-Burning-Man-LED-Pants-and-Shirt-v4-on-ESP32-with-RGBPanels-and-SmartMatrix_GFX.html )

So, I do indeed need FastLED support over Adafruit::Neopixel because FastLED::NeoMatrix is what my code supports (FastLED supports more pixels and better than Adafruit does). FastLED indeed only has the concept of a 1D strip (CRGB array). NeoMatrix adds 2D support on top and my every lib, every backend combined library set uses https://github.com/marcmerlin/Framebuffer_GFX as the base class that supports GFX, FastLED and LEDMatrix APIs running on top of 5 different hardware backends. If you can add 1D FastLED support or write your own simple subclass, then morpheus will be the 6th hardware backend :)

Thanks for clearing up the rest of my NPM newbie questions, it sounds like for now I won't be able to use your code directly until it gets FastLED support or its own hardware backend, but I'd be happy to support it when it does and answer general FastLED questions if you have anything you feel I might be able to help with. Note however, that you don't actually have to support any FastLED pixel hardware, you could write a trivial https://github.com/marcmerlin/Framebuffer_GFX hardware frontend with minimal code and not have to emulate any FastLED hardware. See https://github.com/marcmerlin/FastLED_SPITFT_GFX https://github.com/marcmerlin/FastLED_SPITFT_GFX/blob/master/FastLED_SPITFT_GFX.cpp and https://github.com/marcmerlin/FastLED_SPITFT_GFX/blob/master/FastLED_SPITFT_GFX.h are pretty short. then look at https://github.com/marcmerlin/FastLED_NeoMatrix_SmartMatrix_LEDMatrix_GFX_Demos/blob/master/neomatrix_config.h and read the code for ST7735_128b128 this sets up FastLED_SPITFT_GFX in a way that matrix does the rest.

I realize there are 2 layers but hopefully it should be reasonably easy to read and understand, but feel free to ping me with questions: marcmerlins.org

One thing to keep in mind is that I still use FastLED for its CRGB definition and methods, but that can do so without actually defining any FastLED hardware (which is what I do for SmartMatrix, or TFT hardware).

marcmerlin commented 4 years ago

one last thought, you may be able to write a NeoPixel frontend for https://github.com/marcmerlin/Framebuffer_GFX . It would still have to be backed by the FastLED CRGB array that's in there, but then you can probably shadow the show() method to render the CRGB array into an adafruit neopixel method you've already hijacked to render in your renderer. Not sure what's easiest, I haven't had time to look at the code.

marcmerlin commented 4 years ago

Actually one last option, you may be able to simply take this https://github.com/marcmerlin/FastLED_NeoMatrix/blob/master/FastLED_NeoMatrix.cpp and replace show() with a version that sends the CRGB array to adafruit Neopixel. It's actually possible that ultimately they are both RGB888 arrays that are compatible and that adafruit can display them directly.