A little confused
Soo I have been trying to a heading displayed on a 16x2 lcd through Arduino.
I have had it working for the CMSP panel but had to add the following into my code:
void onDcsBiosFrameSync() {
}
I notice you don't have that anywhere in your example code and have a hunch that is why I can't get my version to work.
#include <DcsBios.h>
#include <Servo.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd( 8, 13, 9, 4, 5, 6, 7);
unsigned int hdgDegValue;
/**** Make your changes after this line ****/
void onDcsBiosFrameSync() {
}
/**** In most cases, you do not have to change anything below this line ****/
/* Instantiate a ProtocolParser object to parse the DCS-BIOS export stream */
DcsBios::ProtocolParser parser;
void setup() {
Serial.begin(115200);
lcd.begin(16, 2);
lcd.clear();
}
/*
Your main loop needs to pass data from the DCS-BIOS export
stream to the parser object you instantiated above.
It also needs to call DcsBios::PollingInput::pollInputs()
to detect changes in the state of connected controls and
pass them on to DCS.
*/
void loop() {
// feed incoming data to the parser
int data = Serial.read();
while (data > -1) {
parser.processChar(data);
data = Serial.read();
}
// poll inputs
DcsBios::PollingInput::pollInputs();
}
/*
You need to define
void sendDcsBiosMessage(const char* msg, const char* arg)
so that the string msg, followed by a space, the string arg
and a newline gets sent to the DCS-BIOS import stream.
In this example we send it to the serial port, so you need to
run socat to read the data from the serial port and send it
over UDP to DCS-BIOS.
If you are using an Ethernet Shield, you would probably want
to send a UDP packet from this subroutine.
*/
void sendDcsBiosMessage(const char* msg, const char* arg) {
Serial.write(msg);
Serial.write(' ');
Serial.write(arg);
Serial.write('\n');
}
void onDcsBiosWrite(unsigned int address, unsigned int value) {
// show heading and altitude on line 3 of LCD
if (address == 0x040a ) {
hdgDegValue = (value & 0x01ff) >> 0;
}
if (address == 0xfffe ) { // end of DCS BIOS update marker (~every 30ms)
updateLCDDisplay();
}
}
void updateLCDDisplay()
{
String s(hdgDegValue);
lcd.setCursor(0,3);
lcd.print( "Hdg:" + s + " " );
}
Any ideas?
Cheers