Jack Worthington
Member
Can someone please help me, when i run this script or other programs which work with xplane:
#include <Bounce.h>
#include <Encoder.h>
#include <DogLcd.h>
// hardware objects, for accessing the buttons, rotary encoder and LCD
//
Bounce buttonUp = Bounce(3, 5); // Pushbutton on pin 3, 5ms debounce
Bounce buttonDown = Bounce(4, 5); // Pushbutton on pin 4, 5ms debounce
Encoder wheel = Encoder(5, 6); // Rotary Encoder on pin 5 and 6
DogLcd lcd = DogLcd(10, 9, 7, 8); // DogM LCD on pins 7, 8, 9, 10
// X-Plane objects, 3 command refs and 1 data ref
FlightSimCommand NavCoarseUp;
FlightSimCommand NavCoarseDown;
FlightSimCommand NavFineUp;
FlightSimInteger NavFrequencyHz;
// variables
long encoder_prev=0; // for detecting rotary position change
elapsedMillis inactivityTimeout;// an inactivity timeout
// setup runs once, when Teensy boots.
//
void setup() {
// initialize all hardware
pinMode(3, INPUT_PULLUP); // input pullup mode allows connecting
pinMode(4, INPUT_PULLUP); // buttons and switches from the pins
pinMode(5, INPUT_PULLUP); // to ground, and the chip provide the
pinMode(6, INPUT_PULLUP); // required pullup resistor
lcd.begin(DOG_LCD_M162);
lcd.print("nav1:");
// configure the X-Plane variables
NavCoarseUp = XPlaneRef("sim/radios/actv_nav1_coarse_up");
NavCoarseDown = XPlaneRef("sim/radios/actv_nav1_coarse_down");
NavFineUp = XPlaneRef("sim/radios/actv_nav1_fine_up");
NavFrequencyHz = XPlaneRef("sim/cockpit2/radios/actuators/nav1_frequency_hz");
NavFrequencyHz.onChange(update_lcd); // update the LCD when X-Plane changes
}
// loop runs repetitively, as long as Teensy is powered up
//
void loop() {
// normally the first step in loop() should update from X-Plane
FlightSim.update();
// read the rotary encoder, if it's changed, write to NavFrequencyHz
long enc = wheel.read();
if (enc != encoder_prev) {
NavFrequencyHz = NavFrequencyHz + (enc - encoder_prev);
encoder_prev = enc;
update_lcd(NavFrequencyHz);
inactivityTimeout = 0; // reset the inactivity timeout
}
// read the pushbuttons, and send X-Plane commands when they're pressed
buttonUp.update();
buttonDown.update();
if (buttonUp.fallingEdge()) {
NavCoarseUp = 1;
inactivityTimeout = 0;
}
if (buttonUp.risingEdge()) {
NavCoarseUp = 0;
}
if (buttonDown.fallingEdge()) {
NavCoarseDown = 1;
inactivityTimeout = 0;
}
if (buttonDown.risingEdge()) {
NavCoarseDown = 0;
}
// if there's no user activity for 2 seconds, send the NavFineUp.
// admittedly this is not very useful, but it's meant to demonstrate
// possibility of automated actions in addition to driving everything
// directly from physical user inputs.
if (inactivityTimeout > 2000) {
NavFineUp.once();
inactivityTimeout = 0;
}
}
// write a number onto the LCD, first row, starting at 6th column
void update_lcd(long val)
{
lcd.setCursor(6, 0);
lcd.print(val);
lcd.print(" ");
}
i get a similar error saying:
Arduino: 1.8.1 (Mac OS X), TD: 1.35, Board: "Teensy++ 2.0, Serial, 16 MHz, US English"
NavFrequency:13: error: 'FlightSimCommand' does not name a type
FlightSimCommand NavCoarseUp;
^
NavFrequency:14: error: 'FlightSimCommand' does not name a type
FlightSimCommand NavCoarseDown;
^
NavFrequency:15: error: 'FlightSimCommand' does not name a type
FlightSimCommand NavFineUp;
^
NavFrequency:16: error: 'FlightSimInteger' does not name a type
FlightSimInteger NavFrequencyHz;
^
NavFrequency: In function 'void setup()':
NavFrequency:35: error: 'NavCoarseUp' was not declared in this scope
NavCoarseUp = XPlaneRef("sim/radios/actv_nav1_coarse_up");
^
NavFrequency:35: error: 'XPlaneRef' was not declared in this scope
NavCoarseUp = XPlaneRef("sim/radios/actv_nav1_coarse_up");
^
NavFrequency:36: error: 'NavCoarseDown' was not declared in this scope
NavCoarseDown = XPlaneRef("sim/radios/actv_nav1_coarse_down");
^
NavFrequency:37: error: 'NavFineUp' was not declared in this scope
NavFineUp = XPlaneRef("sim/radios/actv_nav1_fine_up");
^
NavFrequency:38: error: 'NavFrequencyHz' was not declared in this scope
NavFrequencyHz = XPlaneRef("sim/cockpit2/radios/actuators/nav1_frequency_hz");
^
NavFrequency: In function 'void loop()':
NavFrequency:46: error: 'FlightSim' was not declared in this scope
To make a Flight Simulator device, use the Tools > USB Type menu
FlightSim.update();
^
NavFrequency:51: error: 'NavFrequencyHz' was not declared in this scope
NavFrequencyHz = NavFrequencyHz + (enc - encoder_prev);
^
NavFrequency:61: error: 'NavCoarseUp' was not declared in this scope
NavCoarseUp = 1;
^
NavFrequency:65: error: 'NavCoarseUp' was not declared in this scope
NavCoarseUp = 0;
^
NavFrequency:68: error: 'NavCoarseDown' was not declared in this scope
NavCoarseDown = 1;
^
NavFrequency:72: error: 'NavCoarseDown' was not declared in this scope
NavCoarseDown = 0;
^
NavFrequency:80: error: 'NavFineUp' was not declared in this scope
NavFineUp.once();
^
'FlightSimCommand' does not name a type
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Can someone please help me fix this.
#include <Bounce.h>
#include <Encoder.h>
#include <DogLcd.h>
// hardware objects, for accessing the buttons, rotary encoder and LCD
//
Bounce buttonUp = Bounce(3, 5); // Pushbutton on pin 3, 5ms debounce
Bounce buttonDown = Bounce(4, 5); // Pushbutton on pin 4, 5ms debounce
Encoder wheel = Encoder(5, 6); // Rotary Encoder on pin 5 and 6
DogLcd lcd = DogLcd(10, 9, 7, 8); // DogM LCD on pins 7, 8, 9, 10
// X-Plane objects, 3 command refs and 1 data ref
FlightSimCommand NavCoarseUp;
FlightSimCommand NavCoarseDown;
FlightSimCommand NavFineUp;
FlightSimInteger NavFrequencyHz;
// variables
long encoder_prev=0; // for detecting rotary position change
elapsedMillis inactivityTimeout;// an inactivity timeout
// setup runs once, when Teensy boots.
//
void setup() {
// initialize all hardware
pinMode(3, INPUT_PULLUP); // input pullup mode allows connecting
pinMode(4, INPUT_PULLUP); // buttons and switches from the pins
pinMode(5, INPUT_PULLUP); // to ground, and the chip provide the
pinMode(6, INPUT_PULLUP); // required pullup resistor
lcd.begin(DOG_LCD_M162);
lcd.print("nav1:");
// configure the X-Plane variables
NavCoarseUp = XPlaneRef("sim/radios/actv_nav1_coarse_up");
NavCoarseDown = XPlaneRef("sim/radios/actv_nav1_coarse_down");
NavFineUp = XPlaneRef("sim/radios/actv_nav1_fine_up");
NavFrequencyHz = XPlaneRef("sim/cockpit2/radios/actuators/nav1_frequency_hz");
NavFrequencyHz.onChange(update_lcd); // update the LCD when X-Plane changes
}
// loop runs repetitively, as long as Teensy is powered up
//
void loop() {
// normally the first step in loop() should update from X-Plane
FlightSim.update();
// read the rotary encoder, if it's changed, write to NavFrequencyHz
long enc = wheel.read();
if (enc != encoder_prev) {
NavFrequencyHz = NavFrequencyHz + (enc - encoder_prev);
encoder_prev = enc;
update_lcd(NavFrequencyHz);
inactivityTimeout = 0; // reset the inactivity timeout
}
// read the pushbuttons, and send X-Plane commands when they're pressed
buttonUp.update();
buttonDown.update();
if (buttonUp.fallingEdge()) {
NavCoarseUp = 1;
inactivityTimeout = 0;
}
if (buttonUp.risingEdge()) {
NavCoarseUp = 0;
}
if (buttonDown.fallingEdge()) {
NavCoarseDown = 1;
inactivityTimeout = 0;
}
if (buttonDown.risingEdge()) {
NavCoarseDown = 0;
}
// if there's no user activity for 2 seconds, send the NavFineUp.
// admittedly this is not very useful, but it's meant to demonstrate
// possibility of automated actions in addition to driving everything
// directly from physical user inputs.
if (inactivityTimeout > 2000) {
NavFineUp.once();
inactivityTimeout = 0;
}
}
// write a number onto the LCD, first row, starting at 6th column
void update_lcd(long val)
{
lcd.setCursor(6, 0);
lcd.print(val);
lcd.print(" ");
}
i get a similar error saying:
Arduino: 1.8.1 (Mac OS X), TD: 1.35, Board: "Teensy++ 2.0, Serial, 16 MHz, US English"
NavFrequency:13: error: 'FlightSimCommand' does not name a type
FlightSimCommand NavCoarseUp;
^
NavFrequency:14: error: 'FlightSimCommand' does not name a type
FlightSimCommand NavCoarseDown;
^
NavFrequency:15: error: 'FlightSimCommand' does not name a type
FlightSimCommand NavFineUp;
^
NavFrequency:16: error: 'FlightSimInteger' does not name a type
FlightSimInteger NavFrequencyHz;
^
NavFrequency: In function 'void setup()':
NavFrequency:35: error: 'NavCoarseUp' was not declared in this scope
NavCoarseUp = XPlaneRef("sim/radios/actv_nav1_coarse_up");
^
NavFrequency:35: error: 'XPlaneRef' was not declared in this scope
NavCoarseUp = XPlaneRef("sim/radios/actv_nav1_coarse_up");
^
NavFrequency:36: error: 'NavCoarseDown' was not declared in this scope
NavCoarseDown = XPlaneRef("sim/radios/actv_nav1_coarse_down");
^
NavFrequency:37: error: 'NavFineUp' was not declared in this scope
NavFineUp = XPlaneRef("sim/radios/actv_nav1_fine_up");
^
NavFrequency:38: error: 'NavFrequencyHz' was not declared in this scope
NavFrequencyHz = XPlaneRef("sim/cockpit2/radios/actuators/nav1_frequency_hz");
^
NavFrequency: In function 'void loop()':
NavFrequency:46: error: 'FlightSim' was not declared in this scope
To make a Flight Simulator device, use the Tools > USB Type menu
FlightSim.update();
^
NavFrequency:51: error: 'NavFrequencyHz' was not declared in this scope
NavFrequencyHz = NavFrequencyHz + (enc - encoder_prev);
^
NavFrequency:61: error: 'NavCoarseUp' was not declared in this scope
NavCoarseUp = 1;
^
NavFrequency:65: error: 'NavCoarseUp' was not declared in this scope
NavCoarseUp = 0;
^
NavFrequency:68: error: 'NavCoarseDown' was not declared in this scope
NavCoarseDown = 1;
^
NavFrequency:72: error: 'NavCoarseDown' was not declared in this scope
NavCoarseDown = 0;
^
NavFrequency:80: error: 'NavFineUp' was not declared in this scope
NavFineUp.once();
^
'FlightSimCommand' does not name a type
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
Can someone please help me fix this.