Answer the question
In order to leave comments, you need to log in
How to convert number c++?
Hello. I started to get interested in MK programming, but I still can't get into the language.
There is a WS2812FX library that implements getting some current data, in particular getting the current color:
uint32_t WS2812FX::getColor(void) {
return _segments[0].colors[0];
}
void WS2812FX::setColor(uint32_t c) {
RESET_RUNTIME;
_segments[0].colors[0] = c;
setBrightness(_brightness);
}
uint32_t tmp = (uint32_t) strtol(&server.arg(i)[0], NULL, 16);
if(tmp >= 0x000000 && tmp <= 0xFFFFFF) {
ws2812fx.setColor(tmp);
}
Answer the question
In order to leave comments, you need to log in
0xFFFFFF is the hexadecimal representation of the decimal number 16777215, just
like 0xFF00 is 65280 in decimal.
Even the Windows calculator in "programmer" mode has the feature of converting number systems
in C. You can print a number in HEX form using printf("%X", number)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question