philsson 9302eadae7 Touch OSC and NodeMCU
1) A layout for the mobile phone
2) A sketch to receive the data on a NodeMCU over Wifi
3) A sketch to send a RC package to the stm32 from the NodeMCU

TODO: Merge these two sketches later
2020-06-13 15:45:43 +02:00

51 lines
815 B
C++

unsigned int ledState = LOW;
typedef struct Packet {
int16_t MagicWordLow;
int16_t MagicWordHigh;
int16_t Throttle;
int16_t Steering;
int16_t Kp;
int16_t Ki;
int16_t Kd;
bool Enabled;
};
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(57600);
Serial.println("Starting...");
}
void loop() {
// put your main code here, to run repeatedly:
delay(2000);
ledState = !ledState;
digitalWrite(BUILTIN_LED, ledState);
int bufferSize = 15;
uint8_t buffer[bufferSize];
Packet* pPacket = (Packet*)buffer;
pPacket->MagicWordLow = 0x0DED;
pPacket->MagicWordHigh = 0x0DEC;
pPacket->Throttle = 123;
pPacket->Steering = 456;
pPacket->Kp = 10;
pPacket->Ki = 20;
pPacket->Kd = 30;
pPacket->Enabled = true;
Serial.write(buffer, bufferSize);
}