Giter VIP home page Giter VIP logo

Comments (3)

toblum avatar toblum commented on August 19, 2024

Hi @dimiHH,

thanks for the good feedback.

Regarding your idea: Wouldn't it work to check for button presses in the main loop() and change the mode according to your keypresses. So you could cycle through predefined modes.

Analog A0 should be used. Where did you see that? You're free to use the pins that are not covered be the LED strip.

Regards
Tobias

from mclighting.

dimiepp avatar dimiepp commented on August 19, 2024

thanks for the quick response @toblum , your approache also seems more elegant (it makes it possible to switch to to other predifined modes via the the browser without "unswitching" a physical button first)

So as see it, the following things need to be done for the changes I want:

  1. define a function "whitelight" somewhere in colormodes.h
void whitelight () {
         
	checkForRequests();
	if (exit_func) {
		exit_func = false;
		return;
	} 
         // is the upper part necessary?:

    strip.setColor(255, 255, 255);
    strip.setBrightness(analogRead (map(0, 1024, 0, 255) );
    strip.setMode(FX_MODE_STATIC);
}
  1. Add the whitelight-mode to the state machine in McLighting.ino (e.g. after the TV-Mode):
  if (mode == WHITELIGHT) {
    whitelight ();
  }
  1. Add a physical pushbutton and corresponding code, that sets the mode==WHITELIGHT if button is pushed. ( at the very beginning of the main loop() in McLighting.ino):
if (button.onPressed()) { //button.onPressed function is from RBDbutton library -Button will be at GPIO12
 mode = WHITELIGHT;
}

Would that already be it or did I miss something?

Thanks!
Dimi

PS:
About the A0 usage:
in this loop A0 is used - what is it for? --> It seems, that the analog input is/can be send to the webinterface aswell. Is this used to controll the brightness globaly (i.e. for all the modes)? If yes, that would make the code adjustments minmal (on button-push only the colors need to be set to white and the mode has to be changed to mode=ALL)

from mclighting.

toblum avatar toblum commented on August 19, 2024

From what I can see here, this should work.

Regarding A0: This is just some sample code I forgot. It has no real function. The line

json += ", \"analog\":" + String(analogRead(A0));
and the next can easily be omitted.

from mclighting.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.