Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

arduino - Convert String or Integer into uint32_t with "x"

I'm working with a home automation project. With esp32 and Flutter. I'm using a infrared library to execute commands from the database. On my DB I receive a String value, for example "0x8800549", but in the IRremote library this command has to be in uint32_t.

I could read a Integer from the database, but then I have to find a way of adding the "x"
.
For example:

uint32_t sender = 0x8800549;

How can I convert a String into a uint32_t so I can send my commands.
this is the full code:

#include <IRremote.h>
#include "ATtinySerialOut.h"

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);

    Serial.begin(115200);

    IrSender.begin(true); // Enable feedback LED,
}

uint8_t sRepeats = 0;

void loop() {
  String convert = "0x8800549";
  uint32_t test;
  test = convert.toCharArray();

  Serial.println("Preparing to send...");
  delay(1000);
  
  Serial.println(F("Send LGRaw 0x88C0051 with "parity error" since C+0+0+5 != 1"));
    IrSender.sendLGRaw(test, sRepeats);
  delay(2000);

  delay(4000); // additional delay at the end of each loop
}
question from:https://stackoverflow.com/questions/66045869/convert-string-or-integer-into-uint32-t-with-x

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...