From 649e8559fd8cd1077ebf422acf3bb24705a399d9 Mon Sep 17 00:00:00 2001 From: Christoffer Martinsson Date: Sun, 21 May 2023 05:57:17 +0000 Subject: [PATCH] Code cleanup --- firmware/compile_commands.json | 422 ++++++++++++ firmware/src/cmdr_joystick.cpp | 1150 +++++++++++++------------------- firmware/src/erls.cpp | 180 +++++ firmware/src/erls.h | 63 ++ 4 files changed, 1129 insertions(+), 686 deletions(-) create mode 100644 firmware/compile_commands.json create mode 100644 firmware/src/erls.cpp create mode 100644 firmware/src/erls.h diff --git a/firmware/compile_commands.json b/firmware/compile_commands.json new file mode 100644 index 0000000..3257583 --- /dev/null +++ b/firmware/compile_commands.json @@ -0,0 +1,422 @@ +[ + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/AudioStream.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/AudioStream.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/AudioStream.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/AudioStream.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/CrashReport.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/CrashReport.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/CrashReport.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/CrashReport.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/DMAChannel.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/DMAChannel.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/DMAChannel.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/DMAChannel.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/EventResponder.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/EventResponder.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/EventResponder.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/EventResponder.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/HardwareSerial.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/HardwareSerial.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/HardwareSerial1.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial1.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial1.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/HardwareSerial1.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/HardwareSerial2.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial2.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial2.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/HardwareSerial2.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/HardwareSerial3.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial3.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial3.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/HardwareSerial3.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/HardwareSerial4.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial4.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial4.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/HardwareSerial4.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/HardwareSerial5.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial5.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial5.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/HardwareSerial5.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/HardwareSerial6.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial6.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/HardwareSerial6.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/HardwareSerial6.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/IPAddress.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/IPAddress.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/IPAddress.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/IPAddress.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/IntervalTimer.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/IntervalTimer.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/IntervalTimer.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/IntervalTimer.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/Print.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/Print.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/Print.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/Print.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/Stream.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/Stream.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/Stream.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/Stream.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/Time.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/Time.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/Time.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/Time.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/Tone.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/Tone.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/Tone.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/Tone.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/WMath.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/WMath.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/WMath.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/WMath.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/WString.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/WString.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/WString.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/WString.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/analog.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/analog.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/analog.c", + "output": ".pio/build/teensylc/FrameworkArduino/analog.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/avr_emulation.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/avr_emulation.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/avr_emulation.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/avr_emulation.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/eeprom.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/eeprom.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/eeprom.c", + "output": ".pio/build/teensylc/FrameworkArduino/eeprom.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/keylayouts.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/keylayouts.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/keylayouts.c", + "output": ".pio/build/teensylc/FrameworkArduino/keylayouts.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/main.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/main.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/main.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/main.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/math_helper.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/math_helper.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/math_helper.c", + "output": ".pio/build/teensylc/FrameworkArduino/math_helper.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m0plus -mno-unaligned-access -x assembler-with-cpp -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 -c -o .pio/build/teensylc/FrameworkArduino/memcpy-armv7m.S.o /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/memcpy-armv7m.S", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/memcpy-armv7m.S", + "output": ".pio/build/teensylc/FrameworkArduino/memcpy-armv7m.S.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -mthumb -mcpu=cortex-m0plus -mno-unaligned-access -x assembler-with-cpp -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 -c -o .pio/build/teensylc/FrameworkArduino/memset.S.o /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/memset.S", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/memset.S", + "output": ".pio/build/teensylc/FrameworkArduino/memset.S.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/mk20dx128.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/mk20dx128.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/mk20dx128.c", + "output": ".pio/build/teensylc/FrameworkArduino/mk20dx128.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/new.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/new.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/new.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/new.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/nonstd.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/nonstd.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/nonstd.c", + "output": ".pio/build/teensylc/FrameworkArduino/nonstd.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/pins_teensy.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/pins_teensy.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/pins_teensy.c", + "output": ".pio/build/teensylc/FrameworkArduino/pins_teensy.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/ser_print.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/ser_print.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/ser_print.c", + "output": ".pio/build/teensylc/FrameworkArduino/ser_print.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/serial1.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial1.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial1.c", + "output": ".pio/build/teensylc/FrameworkArduino/serial1.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/serial2.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial2.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial2.c", + "output": ".pio/build/teensylc/FrameworkArduino/serial2.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/serial3.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial3.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial3.c", + "output": ".pio/build/teensylc/FrameworkArduino/serial3.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/serial4.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial4.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial4.c", + "output": ".pio/build/teensylc/FrameworkArduino/serial4.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/serial5.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial5.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial5.c", + "output": ".pio/build/teensylc/FrameworkArduino/serial5.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/serial6.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial6.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial6.c", + "output": ".pio/build/teensylc/FrameworkArduino/serial6.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/serial6_lpuart.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial6_lpuart.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serial6_lpuart.c", + "output": ".pio/build/teensylc/FrameworkArduino/serial6_lpuart.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/serialEvent.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/serialEvent.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/serialEvent1.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent1.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent1.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/serialEvent1.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/serialEvent2.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent2.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent2.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/serialEvent2.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/serialEvent3.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent3.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent3.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/serialEvent3.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/serialEvent4.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent4.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent4.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/serialEvent4.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/serialEvent5.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent5.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent5.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/serialEvent5.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/serialEvent6.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent6.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEvent6.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/serialEvent6.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/serialEventUSB1.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEventUSB1.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEventUSB1.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/serialEventUSB1.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/serialEventUSB2.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEventUSB2.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/serialEventUSB2.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/serialEventUSB2.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/touch.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/touch.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/touch.c", + "output": ".pio/build/teensylc/FrameworkArduino/touch.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/usb_audio.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_audio.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_audio.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/usb_audio.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_desc.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_desc.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_desc.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_desc.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_dev.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_dev.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_dev.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_dev.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/usb_flightsim.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_flightsim.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_flightsim.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/usb_flightsim.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/usb_inst.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_inst.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_inst.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/usb_inst.cpp.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_joystick.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_joystick.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_joystick.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_joystick.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_keyboard.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_keyboard.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_keyboard.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_keyboard.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_mem.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_mem.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_mem.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_mem.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_midi.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_midi.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_midi.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_midi.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_mouse.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_mouse.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_mouse.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_mouse.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_mtp.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_mtp.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_mtp.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_mtp.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_rawhid.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_rawhid.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_rawhid.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_rawhid.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_seremu.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_seremu.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_seremu.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_seremu.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_serial.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_serial.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_serial.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_serial.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_serial2.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_serial2.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_serial2.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_serial2.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_serial3.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_serial3.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_serial3.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_serial3.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-gcc -o .pio/build/teensylc/FrameworkArduino/usb_touch.c.o -c -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_touch.c", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/usb_touch.c", + "output": ".pio/build/teensylc/FrameworkArduino/usb_touch.c.o" + }, + { + "command": "/home/cm/.platformio/packages/toolchain-gccarmnoneeabi/bin/arm-none-eabi-g++ -o .pio/build/teensylc/FrameworkArduino/yield.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/yield.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3/yield.cpp", + "output": ".pio/build/teensylc/FrameworkArduino/yield.cpp.o" + }, + { + "command": "arm-none-eabi-g++ -o .pio/build/teensylc/lib155/ResponsiveAnalogRead/ResponsiveAnalogRead.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/libraries/ResponsiveAnalogRead/src -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/libraries/ResponsiveAnalogRead/src/ResponsiveAnalogRead.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/libraries/ResponsiveAnalogRead/src/ResponsiveAnalogRead.cpp", + "output": ".pio/build/teensylc/lib155/ResponsiveAnalogRead/ResponsiveAnalogRead.cpp.o" + }, + { + "command": "arm-none-eabi-g++ -o .pio/build/teensylc/libab5/EEPROM/EEPROM.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -I/home/cm/.platformio/packages/framework-arduinoteensy/libraries/EEPROM -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 /home/cm/.platformio/packages/framework-arduinoteensy/libraries/EEPROM/EEPROM.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "/home/cm/.platformio/packages/framework-arduinoteensy/libraries/EEPROM/EEPROM.cpp", + "output": ".pio/build/teensylc/libab5/EEPROM/EEPROM.cpp.o" + }, + { + "command": "arm-none-eabi-g++ -o .pio/build/teensylc/src/cmdr_joystick.cpp.o -c -fno-exceptions -felide-constructors -fno-rtti -std=gnu++14 -Wno-error=narrowing -fpermissive -w -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m0plus -nostdlib -fsingle-precision-constant -Os --specs=nano.specs -mno-unaligned-access -fsingle-precision-constant -DPLATFORMIO=60107 -D__MKL26Z64__ -DARDUINO_TEENSYLC -DUSB_HID -DLAYOUT_SWEDISH -DARDUINO=10805 -DTEENSYDUINO=157 -DCORE_TEENSY -DF_CPU=48000000L -DLAYOUT_US_ENGLISH -Iinclude -Isrc -I/home/cm/.platformio/packages/framework-arduinoteensy/libraries/EEPROM -I/home/cm/.platformio/packages/framework-arduinoteensy/libraries/ResponsiveAnalogRead/src -I/home/cm/.platformio/packages/framework-arduinoteensy/cores/teensy3 src/cmdr_joystick.cpp", + "directory": "/home/cm/projects/cmdr-joystick/firmware", + "file": "src/cmdr_joystick.cpp", + "output": ".pio/build/teensylc/src/cmdr_joystick.cpp.o" + } +] diff --git a/firmware/src/cmdr_joystick.cpp b/firmware/src/cmdr_joystick.cpp index 17d3089..233941f 100644 --- a/firmware/src/cmdr_joystick.cpp +++ b/firmware/src/cmdr_joystick.cpp @@ -1,4 +1,4 @@ - /* +/* * ======================================================================================================= * ------------------------------------------------------------------------------------------------------- * ---####################-----###########-------###########-----############--############-############-- @@ -27,160 +27,69 @@ * A PARTICULAR PURPOSE. See the GNU General Public License for more details. * * Joystick based on standard teensy "usb_joystick" library for HID joystick usb data communication. - * - * USB Joystick Layer 0 - * - * | B1 | | B3 | - * | B2 | | B4 | - * -------------------------------------------- - * | | Fn1 | | B5 | | - * | | - * | X1,Y1 X2,Y2 | - * | | B6 | | B7 | | - * -------------------------------------------- - * - * USB Joystick Layer 1 (Fn1) - * - * | B1 | | B3 | - * | B8 | | B9 | - * -------------------------------------------- - * | | Fn1 | | Fn2 | | - * | | - * | X1,Y1 Fn1 toggle Fn1 toggle X3,Y2 | - * | | B10 | | B11 | | - * -------------------------------------------- - * - * USB Joystick Layer 2 (Fn2) - * - * | B1 | | B3 | - * | B12 | | B13 | - * -------------------------------------------- - * | | Fn1 | | Fn2 | | - * | | - * | X1,Y1 X3,Y3 | - * | | B14 | | B15 | | - * -------------------------------------------- - * - * ELRS Layer - * - * | CH7 | | CH9 | - * | HC8 | | CH10 | - * -------------------------------------------- - * | | Fn | | CH11 | | - * | | - * | X,Y Fn toggle Fn toggle X,Y | - * | CH1,CH2 | CH5 | | CH6 | CH3,CH4 | - * -------------------------------------------- - * - * Features: - * - * * USB HID Joystick. - * * ERLS protocol (CRSF) support. - * * 4 physical axis. - * * 6 joystick axis using layers (USB Joystick). - * * 8 physical buttons. - * * 15 joystick buttons using three layers (Fn1 and Fn2). */ #include #include +#include "erls.h" #include "ResponsiveAnalogRead.h" -// CRSF -#define CRSF_MAX_CHANNEL 16 -#define CRSF_TYPE_CHANNELS 0x16 -#define CRSF_DIGITAL_CHANNEL_MIN 172 -#define CRSF_DIGITAL_CHANNEL_CENTER 992 -#define CRSF_DIGITAL_CHANNEL_MAX 1811 -#define CRSF_TIME_BETWEEN_FRAMES_US 1666 // 1.6 ms 500Hz -#define CRSF_PACKET_SIZE 26 -#define CRSF_CMD_PACKET_SIZE 8 - -// ELRS command -#define ELRS_ADDRESS 0xEE -#define ELRS_BIND_COMMAND 0xFF -#define ELRS_WIFI_COMMAND 0xFE -#define ELRS_PKT_RATE_COMMAND 0x01 -#define ELRS_TLM_RATIO_COMMAND 0x02 -#define ELRS_SWITCH_MODE_COMMAND 0x03 -#define ELRS_MODEL_MATCH_COMMAND 0x04 -#define ELRS_POWER_COMMAND 0x06 -#define ELRS_BLE_JOYSTIC_COMMAND 17 -#define ELRS_TYPE_SETTINGS_WRITE 0x2D -#define ELRS_ADDR_RADIO 0xEA -#define ELRS_SERIAL_PORT Serial1 -#define ELRS_SERIAL_BAUDRATE 400000 -#define ELRS_PKT_RATE 3 // 0 = 50Hz, 1 = 100Hz, 2 = 200Hz, 3 = 500Hz, 4 = 1000Hz -#define ELRS_POWER 2 // 0 = 10mW, 1 = 25mW, 2 = 100mW, 3 = 250mW, 4 = 500mW, 5 = 1000mW - -// crc implementation from CRSF protocol document rev7 -static uint8_t crsf_crc8tab[256] = { - 0x00, 0xD5, 0x7F, 0xAA, 0xFE, 0x2B, 0x81, 0x54, 0x29, 0xFC, 0x56, 0x83, 0xD7, 0x02, 0xA8, 0x7D, - 0x52, 0x87, 0x2D, 0xF8, 0xAC, 0x79, 0xD3, 0x06, 0x7B, 0xAE, 0x04, 0xD1, 0x85, 0x50, 0xFA, 0x2F, - 0xA4, 0x71, 0xDB, 0x0E, 0x5A, 0x8F, 0x25, 0xF0, 0x8D, 0x58, 0xF2, 0x27, 0x73, 0xA6, 0x0C, 0xD9, - 0xF6, 0x23, 0x89, 0x5C, 0x08, 0xDD, 0x77, 0xA2, 0xDF, 0x0A, 0xA0, 0x75, 0x21, 0xF4, 0x5E, 0x8B, - 0x9D, 0x48, 0xE2, 0x37, 0x63, 0xB6, 0x1C, 0xC9, 0xB4, 0x61, 0xCB, 0x1E, 0x4A, 0x9F, 0x35, 0xE0, - 0xCF, 0x1A, 0xB0, 0x65, 0x31, 0xE4, 0x4E, 0x9B, 0xE6, 0x33, 0x99, 0x4C, 0x18, 0xCD, 0x67, 0xB2, - 0x39, 0xEC, 0x46, 0x93, 0xC7, 0x12, 0xB8, 0x6D, 0x10, 0xC5, 0x6F, 0xBA, 0xEE, 0x3B, 0x91, 0x44, - 0x6B, 0xBE, 0x14, 0xC1, 0x95, 0x40, 0xEA, 0x3F, 0x42, 0x97, 0x3D, 0xE8, 0xBC, 0x69, 0xC3, 0x16, - 0xEF, 0x3A, 0x90, 0x45, 0x11, 0xC4, 0x6E, 0xBB, 0xC6, 0x13, 0xB9, 0x6C, 0x38, 0xED, 0x47, 0x92, - 0xBD, 0x68, 0xC2, 0x17, 0x43, 0x96, 0x3C, 0xE9, 0x94, 0x41, 0xEB, 0x3E, 0x6A, 0xBF, 0x15, 0xC0, - 0x4B, 0x9E, 0x34, 0xE1, 0xB5, 0x60, 0xCA, 0x1F, 0x62, 0xB7, 0x1D, 0xC8, 0x9C, 0x49, 0xE3, 0x36, - 0x19, 0xCC, 0x66, 0xB3, 0xE7, 0x32, 0x98, 0x4D, 0x30, 0xE5, 0x4F, 0x9A, 0xCE, 0x1B, 0xB1, 0x64, - 0x72, 0xA7, 0x0D, 0xD8, 0x8C, 0x59, 0xF3, 0x26, 0x5B, 0x8E, 0x24, 0xF1, 0xA5, 0x70, 0xDA, 0x0F, - 0x20, 0xF5, 0x5F, 0x8A, 0xDE, 0x0B, 0xA1, 0x74, 0x09, 0xDC, 0x76, 0xA3, 0xF7, 0x22, 0x88, 0x5D, - 0xD6, 0x03, 0xA9, 0x7C, 0x28, 0xFD, 0x57, 0x82, 0xFF, 0x2A, 0x80, 0x55, 0x01, 0xD4, 0x7E, 0xAB, - 0x84, 0x51, 0xFB, 0x2E, 0x7A, 0xAF, 0x05, 0xD0, 0xAD, 0x78, 0xD2, 0x07, 0x53, 0x86, 0x2C, 0xF9}; - -uint8_t crsf_packet[CRSF_PACKET_SIZE]; -uint8_t crsf_cmd_packet[CRSF_CMD_PACKET_SIZE]; -int16_t elrs_channels[CRSF_MAX_CHANNEL]; -bool elrs_init_done = false; -int elrs_init_counter = 0; +#define LED_MODE_OFF 0 +#define LED_MODE_ON 1 +#define LED_MODE_BLINK 2 +#define LED_ON HIGH +#define LED_OFF LOW const int STATUS_LED_PIN = 13; bool status_led_on = false; -int status_led_mode = 2; +int status_led_mode = LED_MODE_BLINK; const int BUTTON_LED_1_PIN = 22; bool button_led_1_on = false; -int button_led_1_mode = 0; +int button_led_1_mode = LED_MODE_OFF; const int BUTTON_LED_2_PIN = 23; bool button_led_2_on = false; -int button_led_2_mode = 0; - -unsigned long current_timestamp = 0; -unsigned long process_data_timestamp = 0; -unsigned long indicator_timestamp = 0; -unsigned long send_usb_timestamp = 0; +int button_led_2_mode = LED_MODE_OFF; +#define TIME_US_1ms 1000 +#define TIME_US_5ms 5000 +#define TIME_US_200ms 200000 unsigned long current_timestamp_micros = 0; +unsigned long process_data_timestamp_micros = 0; +unsigned long indicator_timestamp_micros = 0; +unsigned long send_usb_timestamp_micros = 0; unsigned long send_elrs_timestamp_micros = 0; -const int BUTTON_FLU_PIN = 4; // Front left upper button -const int BUTTON_FLD_PIN = 5; // Front left lower button -const int BUTTON_FRU_PIN = 6; // Front right upper button -const int BUTTON_FRD_PIN = 7; // Front right lower button -const int BUTTON_TLU_PIN = 9; // top upper left button -const int BUTTON_TRU_PIN = 10; // Top upper right button -const int BUTTON_TLD_PIN = 8; // Top left lower button -const int BUTTON_TRD_PIN = 11; // Top right lower button +#define BUTTON_PRESSED LOW +#define BUTTON_NOT_PRESSED HIGH +const int BUTTON_FRONT_LEFT_UPPER_PIN = 4; +const int BUTTON_FRONT_LEFT_LOWER_PIN = 5; +const int BUTTON_FRONT_RIGHT_UPPER_PIN = 6; +const int BUTTON_FRONT_RIGHT_LOWER_PIN = 7; +const int BUTTON_TOP_LEFT_UPPER_PIN = 9; +const int BUTTON_TOP_RIGHT_UPPER_PIN = 10; +const int BUTTON_TOP_LEFT_LOWER_PIN = 8; +const int BUTTON_TOP_RIGHT_LOWER_PIN = 11; -const int GIMBAL_MODE_PIN = 21; // Open = M7, Closed (GND) = M10 +#define GIMBAL_MODE_FRSKY_M7 0 +#define GIMBAL_MODE_FRSKY_M10 1 +const int GIMBAL_MODE_PIN = 21; +int gimbal_mode = GIMBAL_MODE_FRSKY_M7; bool toggle_button_arm = false; bool toggle_button_mode = false; int toggle_button_arm_previous_value = HIGH; -#define HID_AXIS_MAX 1023 -#define HID_AXIS_MIN 0 -#define HID_AXIS_CENTER 512 -#define AXIS_MAX 4096 -#define AXIS_MIN 0 -#define AXIS_CENTER 2048 +#define AXIS_10BIT_MAX 1023 +#define AXIS_10BIT_MIN 0 +#define AXIS_10BIT_CENTER 512 +#define AXIS_12BIT_MAX 4096 +#define AXIS_12BIT_MIN 0 +#define AXIS_12BIT_CENTER 2048 #define DEADZONE_X 50 #define DEADZONE_Y 50 +#define JOYSTICK_HAT_CENTER -1 enum EEPROM_ADR { @@ -212,33 +121,26 @@ enum EEPROM_ADR }; int joystick_counter = 0; -int joystick_x1 = 0; -int joystick_x1_hid = 0; -int joystick_x1_max = 4096; -int joystick_x1_min = 0; -int joystick_x1_center = joystick_x1_max/2; -int joystick_y1 = 0; -int joystick_y1_hid = 0; -int joystick_y1_hid_rev = 0; -int joystick_y1_hid_rev_mode = 0; -int joystick_y1_max = 4096; -int joystick_y1_min = 0; -int joystick_y1_center = joystick_y1_max/2; -int joystick_x2 = 0; -int joystick_x2_hid = 0; -int joystick_x2_max = 4096; -int joystick_x2_min = 0; -int joystick_x2_center = joystick_x2_max/2; -int joystick_y2 = 0; -int joystick_y2_hid = 0; -int joystick_y2_max = 4096; -int joystick_y2_min = 0; -int joystick_y2_center = joystick_y2_max/2; +int joystick_x1_12bit = 0; +int joystick_x1_12bit_max = 4096; +int joystick_x1_12bit_min = 0; +int joystick_x1_12bit_center = joystick_x1_12bit_max / 2; +int joystick_y1_12bit = 0; +int joystick_y1_12bit_max = 4096; +int joystick_y1_12bit_min = 0; +int joystick_y1_12bit_center = joystick_y1_12bit_max / 2; +int joystick_x2_12bit = 0; +int joystick_x2_12bit_max = 4096; +int joystick_x2_12bit_min = 0; +int joystick_x2_12bit_center = joystick_x2_12bit_max / 2; +int joystick_y2_12bit = 0; +int joystick_y2_12bit_max = 4096; +int joystick_y2_12bit_min = 0; +int joystick_y2_12bit_center = joystick_y2_12bit_max / 2; float exp_constant = 0.2; int fn_mode = 0; -int gimbal_mode = 0; ResponsiveAnalogRead analog_x1(A0, true); ResponsiveAnalogRead analog_y1(A1, true); @@ -251,502 +153,379 @@ ResponsiveAnalogRead analog_y2(A2, true); #define CALIBRATION_MINMAX 3 int joystick_calibration_mode = CALIBRATION_OFF; -// ----------------------------------------------- +/** + * @brief Save calibration data to EEPROM + */ +void save_to_eeprom() +{ + EEPROM.write(MAX_X1_ADR_LOW, joystick_x1_12bit_max); + EEPROM.write(MAX_X1_ADR_HIGH, joystick_x1_12bit_max >> 8); + EEPROM.write(MIN_X1_ADR_LOW, joystick_x1_12bit_min); + EEPROM.write(MIN_X1_ADR_HIGH, joystick_x1_12bit_min >> 8); + EEPROM.write(CNT_X1_ADR_LOW, joystick_x1_12bit_center); + EEPROM.write(CNT_X1_ADR_HIGH, joystick_x1_12bit_center >> 8); -void save_to_eeprom(){ - EEPROM.write(MAX_X1_ADR_LOW, joystick_x1_max); - EEPROM.write(MAX_X1_ADR_HIGH, joystick_x1_max >> 8); - EEPROM.write(MIN_X1_ADR_LOW, joystick_x1_min); - EEPROM.write(MIN_X1_ADR_HIGH, joystick_x1_min >> 8); - EEPROM.write(CNT_X1_ADR_LOW, joystick_x1_center); - EEPROM.write(CNT_X1_ADR_HIGH, joystick_x1_center >> 8); - - EEPROM.write(MAX_Y1_ADR_LOW, joystick_y1_max); - EEPROM.write(MAX_Y1_ADR_HIGH, joystick_y1_max >> 8); - EEPROM.write(MIN_Y1_ADR_LOW, joystick_y1_min); - EEPROM.write(MIN_Y1_ADR_HIGH, joystick_y1_min >> 8); - EEPROM.write(CNT_Y1_ADR_LOW, joystick_y1_center); - EEPROM.write(CNT_Y1_ADR_HIGH, joystick_y1_center >> 8); - - EEPROM.write(MAX_X2_ADR_LOW, joystick_x2_max); - EEPROM.write(MAX_X2_ADR_HIGH, joystick_x2_max >> 8); - EEPROM.write(MIN_X2_ADR_LOW, joystick_x2_min); - EEPROM.write(MIN_X2_ADR_HIGH, joystick_x2_min >> 8); - EEPROM.write(CNT_X2_ADR_LOW, joystick_x2_center); - EEPROM.write(CNT_X2_ADR_HIGH, joystick_x2_center >> 8); - - EEPROM.write(MAX_Y2_ADR_LOW, joystick_y2_max); - EEPROM.write(MAX_Y2_ADR_HIGH, joystick_y2_max >> 8); - EEPROM.write(MIN_Y2_ADR_LOW, joystick_y2_min); - EEPROM.write(MIN_Y2_ADR_HIGH, joystick_y2_min >> 8); - EEPROM.write(CNT_Y2_ADR_LOW, joystick_y2_center); - EEPROM.write(CNT_Y2_ADR_HIGH, joystick_y2_center >> 8); + EEPROM.write(MAX_Y1_ADR_LOW, joystick_y1_12bit_max); + EEPROM.write(MAX_Y1_ADR_HIGH, joystick_y1_12bit_max >> 8); + EEPROM.write(MIN_Y1_ADR_LOW, joystick_y1_12bit_min); + EEPROM.write(MIN_Y1_ADR_HIGH, joystick_y1_12bit_min >> 8); + EEPROM.write(CNT_Y1_ADR_LOW, joystick_y1_12bit_center); + EEPROM.write(CNT_Y1_ADR_HIGH, joystick_y1_12bit_center >> 8); + + EEPROM.write(MAX_X2_ADR_LOW, joystick_x2_12bit_max); + EEPROM.write(MAX_X2_ADR_HIGH, joystick_x2_12bit_max >> 8); + EEPROM.write(MIN_X2_ADR_LOW, joystick_x2_12bit_min); + EEPROM.write(MIN_X2_ADR_HIGH, joystick_x2_12bit_min >> 8); + EEPROM.write(CNT_X2_ADR_LOW, joystick_x2_12bit_center); + EEPROM.write(CNT_X2_ADR_HIGH, joystick_x2_12bit_center >> 8); + + EEPROM.write(MAX_Y2_ADR_LOW, joystick_y2_12bit_max); + EEPROM.write(MAX_Y2_ADR_HIGH, joystick_y2_12bit_max >> 8); + EEPROM.write(MIN_Y2_ADR_LOW, joystick_y2_12bit_min); + EEPROM.write(MIN_Y2_ADR_HIGH, joystick_y2_12bit_min >> 8); + EEPROM.write(CNT_Y2_ADR_LOW, joystick_y2_12bit_center); + EEPROM.write(CNT_Y2_ADR_HIGH, joystick_y2_12bit_center >> 8); } -void load_from_eeprom(){ - joystick_x1_max = (EEPROM.read(MAX_X1_ADR_HIGH) << 8); - joystick_x1_max |= EEPROM.read(MAX_X1_ADR_LOW); - joystick_x1_min = (EEPROM.read(MIN_X1_ADR_HIGH) << 8); - joystick_x1_min |= EEPROM.read(MIN_X1_ADR_LOW); - joystick_x1_center = (EEPROM.read(CNT_X1_ADR_HIGH) << 8); - joystick_x1_center |= EEPROM.read(CNT_X1_ADR_LOW); +/** + * @brief Load calibration data from EEPROM + */ +void load_from_eeprom() +{ + joystick_x1_12bit_max = (EEPROM.read(MAX_X1_ADR_HIGH) << 8); + joystick_x1_12bit_max |= EEPROM.read(MAX_X1_ADR_LOW); + joystick_x1_12bit_min = (EEPROM.read(MIN_X1_ADR_HIGH) << 8); + joystick_x1_12bit_min |= EEPROM.read(MIN_X1_ADR_LOW); + joystick_x1_12bit_center = (EEPROM.read(CNT_X1_ADR_HIGH) << 8); + joystick_x1_12bit_center |= EEPROM.read(CNT_X1_ADR_LOW); - joystick_y1_max = (EEPROM.read(MAX_Y1_ADR_HIGH) << 8); - joystick_y1_max |= EEPROM.read(MAX_Y1_ADR_LOW); - joystick_y1_min = (EEPROM.read(MIN_Y1_ADR_HIGH) << 8); - joystick_y1_min |= EEPROM.read(MIN_Y1_ADR_LOW); - joystick_y1_center = (EEPROM.read(CNT_Y1_ADR_HIGH) << 8); - joystick_y1_center |= EEPROM.read(CNT_Y1_ADR_LOW); - - joystick_x2_max = (EEPROM.read(MAX_X2_ADR_HIGH) << 8); - joystick_x2_max |= EEPROM.read(MAX_X2_ADR_LOW); - joystick_x2_min = (EEPROM.read(MIN_X2_ADR_HIGH) << 8); - joystick_x2_min |= EEPROM.read(MIN_X2_ADR_LOW); - joystick_x2_center = (EEPROM.read(CNT_X2_ADR_HIGH) << 8); - joystick_x2_center |= EEPROM.read(CNT_X2_ADR_LOW); + joystick_y1_12bit_max = (EEPROM.read(MAX_Y1_ADR_HIGH) << 8); + joystick_y1_12bit_max |= EEPROM.read(MAX_Y1_ADR_LOW); + joystick_y1_12bit_min = (EEPROM.read(MIN_Y1_ADR_HIGH) << 8); + joystick_y1_12bit_min |= EEPROM.read(MIN_Y1_ADR_LOW); + joystick_y1_12bit_center = (EEPROM.read(CNT_Y1_ADR_HIGH) << 8); + joystick_y1_12bit_center |= EEPROM.read(CNT_Y1_ADR_LOW); - joystick_y2_max = (EEPROM.read(MAX_Y2_ADR_HIGH) << 8); - joystick_y2_max |= EEPROM.read(MAX_Y2_ADR_LOW); - joystick_y2_min = (EEPROM.read(MIN_Y2_ADR_HIGH) << 8); - joystick_y2_min |= EEPROM.read(MIN_Y2_ADR_LOW); - joystick_y2_center = (EEPROM.read(CNT_Y2_ADR_HIGH) << 8); - joystick_y2_center |= EEPROM.read(CNT_Y2_ADR_LOW); + joystick_x2_12bit_max = (EEPROM.read(MAX_X2_ADR_HIGH) << 8); + joystick_x2_12bit_max |= EEPROM.read(MAX_X2_ADR_LOW); + joystick_x2_12bit_min = (EEPROM.read(MIN_X2_ADR_HIGH) << 8); + joystick_x2_12bit_min |= EEPROM.read(MIN_X2_ADR_LOW); + joystick_x2_12bit_center = (EEPROM.read(CNT_X2_ADR_HIGH) << 8); + joystick_x2_12bit_center |= EEPROM.read(CNT_X2_ADR_LOW); + + joystick_y2_12bit_max = (EEPROM.read(MAX_Y2_ADR_HIGH) << 8); + joystick_y2_12bit_max |= EEPROM.read(MAX_Y2_ADR_LOW); + joystick_y2_12bit_min = (EEPROM.read(MIN_Y2_ADR_HIGH) << 8); + joystick_y2_12bit_min |= EEPROM.read(MIN_Y2_ADR_LOW); + joystick_y2_12bit_center = (EEPROM.read(CNT_Y2_ADR_HIGH) << 8); + joystick_y2_12bit_center |= EEPROM.read(CNT_Y2_ADR_LOW); } -// CRSF CRC calculation via lookup table -uint8_t calculate_crsf_crc8(const uint8_t *ptr, uint8_t len) { - uint8_t crc = 0; - for (uint8_t i = 0; i < len; i++){ - crc = crsf_crc8tab[crc ^ *ptr++]; +/** + * @brief Calibrate all joystick axis + * + * @param analog_x1 + * @param analog_y1 + * @param analog_x2 + * @param analog_y2 + */ +void calibrate_axis(int analog_x1, int analog_y1, int analog_x2, int analog_y2) +{ + + joystick_x1_12bit = AXIS_12BIT_CENTER; + joystick_y1_12bit = AXIS_12BIT_CENTER; + joystick_x2_12bit = AXIS_12BIT_CENTER; + joystick_y2_12bit = AXIS_12BIT_CENTER; + + // Check for calibration mode + if (joystick_calibration_mode == CALIBRATION_INIT) + { + if (digitalRead(BUTTON_TOP_LEFT_LOWER_PIN) == BUTTON_NOT_PRESSED) + { + joystick_calibration_mode = CALIBRATION_CENTER; + } + } + + // Calibrate joystick center values + else if (joystick_calibration_mode == CALIBRATION_CENTER) + { + joystick_x1_12bit_center = analog_x1; + joystick_y1_12bit_center = analog_y1; + joystick_x1_12bit_max = joystick_x1_12bit_center; + joystick_x1_12bit_min = joystick_x1_12bit_center; + joystick_y1_12bit_max = joystick_y1_12bit_center; + joystick_y1_12bit_min = joystick_y1_12bit_center; + + joystick_x2_12bit_center = analog_x2; + joystick_y2_12bit_center = analog_y2; + joystick_x2_12bit_max = joystick_x2_12bit_center; + joystick_x2_12bit_min = joystick_x2_12bit_center; + joystick_y2_12bit_max = joystick_y2_12bit_center; + joystick_y2_12bit_min = joystick_y2_12bit_center; + + if (digitalRead(BUTTON_TOP_LEFT_LOWER_PIN) == BUTTON_PRESSED) + { + joystick_calibration_mode = CALIBRATION_MINMAX; + } + } + + // Calibrate joystick min/max values + else if (joystick_calibration_mode == CALIBRATION_MINMAX) + { + if (analog_x1 > joystick_x1_12bit_max) joystick_x1_12bit_max = analog_x1; + if (analog_x1 < joystick_x1_12bit_min) joystick_x1_12bit_min = analog_x1; + if (analog_y1 > joystick_y1_12bit_max) joystick_y1_12bit_max = analog_y1; + if (analog_y1 < joystick_y1_12bit_min) joystick_y1_12bit_min = analog_y1; + if (analog_x2 > joystick_x2_12bit_max) joystick_x2_12bit_max = analog_x2; + if (analog_x2 < joystick_x2_12bit_min) joystick_x2_12bit_min = analog_x2; + if (analog_y2 > joystick_y2_12bit_max) joystick_y2_12bit_max = analog_y2; + if (analog_y2 < joystick_y2_12bit_min) joystick_y2_12bit_min = analog_y2; + + if (digitalRead(BUTTON_TOP_RIGHT_LOWER_PIN) == BUTTON_PRESSED) + { + joystick_calibration_mode = CALIBRATION_OFF; + save_to_eeprom(); + } } - return crc; } -// Prepare CRSF data packet -void prepare_crsf_data_packet(uint8_t packet[], int16_t channels[]) { - packet[0] = ELRS_ADDRESS; // Header - packet[1] = 24; // length - packet[2] = CRSF_TYPE_CHANNELS; - packet[3] = (uint8_t)(channels[0] & 0x07FF); - packet[4] = (uint8_t)((channels[0] & 0x07FF) >> 8 | (channels[1] & 0x07FF) << 3); - packet[5] = (uint8_t)((channels[1] & 0x07FF) >> 5 | (channels[2] & 0x07FF) << 6); - packet[6] = (uint8_t)((channels[2] & 0x07FF) >> 2); - packet[7] = (uint8_t)((channels[2] & 0x07FF) >> 10 | (channels[3] & 0x07FF) << 1); - packet[8] = (uint8_t)((channels[3] & 0x07FF) >> 7 | (channels[4] & 0x07FF) << 4); - packet[9] = (uint8_t)((channels[4] & 0x07FF) >> 4 | (channels[5] & 0x07FF) << 7); - packet[10] = (uint8_t)((channels[5] & 0x07FF) >> 1); - packet[11] = (uint8_t)((channels[5] & 0x07FF) >> 9 | (channels[6] & 0x07FF) << 2); - packet[12] = (uint8_t)((channels[6] & 0x07FF) >> 6 | (channels[7] & 0x07FF) << 5); - packet[13] = (uint8_t)((channels[7] & 0x07FF) >> 3); - packet[14] = (uint8_t)((channels[8] & 0x07FF)); - packet[15] = (uint8_t)((channels[8] & 0x07FF) >> 8 | (channels[9] & 0x07FF) << 3); - packet[16] = (uint8_t)((channels[9] & 0x07FF) >> 5 | (channels[10] & 0x07FF) << 6); - packet[17] = (uint8_t)((channels[10] & 0x07FF) >> 2); - packet[18] = (uint8_t)((channels[10] & 0x07FF) >> 10 | (channels[11] & 0x07FF) << 1); - packet[19] = (uint8_t)((channels[11] & 0x07FF) >> 7 | (channels[12] & 0x07FF) << 4); - packet[20] = (uint8_t)((channels[12] & 0x07FF) >> 4 | (channels[13] & 0x07FF) << 7); // Channel not used by ELRS - packet[21] = (uint8_t)((channels[13] & 0x07FF) >> 1); // Channel not used by ELRS - packet[22] = (uint8_t)((channels[13] & 0x07FF) >> 9 | (channels[14] & 0x07FF) << 2); // Channel not used by ELRS - packet[23] = (uint8_t)((channels[14] & 0x07FF) >> 6 | (channels[15] & 0x07FF) << 5); // Channel not used by ELRS - packet[24] = (uint8_t)((channels[15] & 0x07FF) >> 3); // Channel not used by ELRS - packet[25] = calculate_crsf_crc8(&packet[2], packet[1] - 1); -} - -// Prepare CRSF setup packet -void prepare_crsf_cmd_packet(uint8_t packet_cmd[], uint8_t command, uint8_t value) { - packet_cmd[0] = ELRS_ADDRESS; // Header - packet_cmd[1] = 6; // length - packet_cmd[2] = ELRS_TYPE_SETTINGS_WRITE; - packet_cmd[3] = ELRS_ADDRESS; - packet_cmd[4] = ELRS_ADDR_RADIO; - packet_cmd[5] = command; - packet_cmd[6] = value; - packet_cmd[7] = calculate_crsf_crc8(&packet_cmd[2], packet_cmd[1] - 1); -} - -void send_elrs_data(){ +/** + * @brief Save joystick calibration values to EEPROM + */ +void send_erls_data() +{ // Set ELRS analog channels - elrs_channels[0] = map(joystick_x1, AXIS_MIN, AXIS_MAX, CRSF_DIGITAL_CHANNEL_MIN, CRSF_DIGITAL_CHANNEL_MAX); - elrs_channels[1] = map(joystick_y1, AXIS_MIN, AXIS_MAX, CRSF_DIGITAL_CHANNEL_MIN, CRSF_DIGITAL_CHANNEL_MAX); - elrs_channels[2] = map(joystick_x2, AXIS_MIN, AXIS_MAX, CRSF_DIGITAL_CHANNEL_MIN, CRSF_DIGITAL_CHANNEL_MAX); - elrs_channels[3] = map(joystick_y2, AXIS_MIN, AXIS_MAX, CRSF_DIGITAL_CHANNEL_MIN, CRSF_DIGITAL_CHANNEL_MAX); + erls_set_data(map(joystick_x1_12bit, AXIS_12BIT_MIN, AXIS_12BIT_MAX, CRSF_DIGITAL_CHANNEL_MIN, CRSF_DIGITAL_CHANNEL_MAX), 0); + erls_set_data(map(joystick_y1_12bit, AXIS_12BIT_MIN, AXIS_12BIT_MAX, CRSF_DIGITAL_CHANNEL_MIN, CRSF_DIGITAL_CHANNEL_MAX), 1); + erls_set_data(map(joystick_x2_12bit, AXIS_12BIT_MIN, AXIS_12BIT_MAX, CRSF_DIGITAL_CHANNEL_MIN, CRSF_DIGITAL_CHANNEL_MAX), 2); + erls_set_data(map(joystick_y2_12bit, AXIS_12BIT_MIN, AXIS_12BIT_MAX, CRSF_DIGITAL_CHANNEL_MIN, CRSF_DIGITAL_CHANNEL_MAX), 3); // Set ELRS digital channels - for (int i = 4; i < CRSF_MAX_CHANNEL; i++){ - elrs_channels[i] = CRSF_DIGITAL_CHANNEL_MIN; - } - if (toggle_button_arm){ - elrs_channels[4] = CRSF_DIGITAL_CHANNEL_MAX; - } - if (toggle_button_mode){ - elrs_channels[5] = CRSF_DIGITAL_CHANNEL_MAX; - } - if (digitalRead(BUTTON_FRU_PIN) == LOW){ - elrs_channels[6] = CRSF_DIGITAL_CHANNEL_MAX; - } - if (digitalRead(BUTTON_FRD_PIN) == LOW){ - elrs_channels[7] = CRSF_DIGITAL_CHANNEL_MAX; - } - if (digitalRead(BUTTON_TRU_PIN) == LOW){ - elrs_channels[8] = CRSF_DIGITAL_CHANNEL_MAX; + for (int i = 4; i < CRSF_MAX_CHANNEL; i++) + { + erls_set_data(CRSF_DIGITAL_CHANNEL_MIN, i); } - // Send ELRS data - if (elrs_init_done == true){ - prepare_crsf_data_packet(crsf_packet, elrs_channels); - ELRS_SERIAL_PORT.write(crsf_packet, CRSF_PACKET_SIZE); - } - else{ - // Setting up initial communication link between ERLS TX and Teensy (give ERLS TX time to auto detect Teensy) - if (elrs_init_counter < 500){ - prepare_crsf_data_packet(crsf_packet, elrs_channels); - ELRS_SERIAL_PORT.write(crsf_packet, CRSF_PACKET_SIZE); - elrs_init_counter++; - } - // Send command to update TX packet rate to 500Hz - else if (elrs_init_counter < 505){ - prepare_crsf_cmd_packet(crsf_cmd_packet, ELRS_PKT_RATE_COMMAND, ELRS_PKT_RATE); - ELRS_SERIAL_PORT.write(crsf_cmd_packet, CRSF_CMD_PACKET_SIZE); - elrs_init_counter++; - } - // Send command to update TX power to 100mW - else if (elrs_init_counter < 510){ - prepare_crsf_cmd_packet(crsf_cmd_packet, ELRS_POWER_COMMAND, ELRS_POWER); - ELRS_SERIAL_PORT.write(crsf_cmd_packet, CRSF_CMD_PACKET_SIZE); - elrs_init_counter++; - } - else{ - elrs_init_done = true; - } - } + if (toggle_button_arm) erls_set_data(CRSF_DIGITAL_CHANNEL_MAX, 4); + if (toggle_button_mode) erls_set_data(CRSF_DIGITAL_CHANNEL_MAX, 5); + if (digitalRead(BUTTON_FRONT_RIGHT_UPPER_PIN) == BUTTON_PRESSED) erls_set_data(CRSF_DIGITAL_CHANNEL_MAX, 6); + if (digitalRead(BUTTON_FRONT_RIGHT_LOWER_PIN) == BUTTON_PRESSED) erls_set_data(CRSF_DIGITAL_CHANNEL_MAX, 7); + if (digitalRead(BUTTON_TOP_RIGHT_UPPER_PIN) == BUTTON_PRESSED) erls_set_data(CRSF_DIGITAL_CHANNEL_MAX, 8); + + // Send ELRS data + erls_send_data(); } -void send_usb_data(){ +/** + * Send USB data to PC + */ +void send_usb_data() +{ + // Set USB analog channels + int joystick_x1_10bit = map(joystick_x1_12bit, AXIS_12BIT_MIN, AXIS_12BIT_MAX, AXIS_10BIT_MIN, AXIS_10BIT_MAX); + int joystick_y1_10bit = map(joystick_y1_12bit, AXIS_12BIT_MIN, AXIS_12BIT_MAX, AXIS_10BIT_MIN, AXIS_10BIT_MAX); + int joystick_x2_10bit = map(joystick_x2_12bit, AXIS_12BIT_MIN, AXIS_12BIT_MAX, AXIS_10BIT_MIN, AXIS_10BIT_MAX); + int joystick_y2_10bit = map(joystick_y2_12bit, AXIS_12BIT_MIN, AXIS_12BIT_MAX, AXIS_10BIT_MIN, AXIS_10BIT_MAX); - // Set joystick buttons to released - for (int i = 1; i < 32; i++){ - Joystick.button(i, 0); - } + Joystick.Zrotate(joystick_x1_10bit); + Joystick.Z(joystick_y1_10bit); - // Set joystick hat to center position - Joystick.hat(-1); - - // Set joystick buttons to pressed - if (fn_mode == 2){ - - if (digitalRead(BUTTON_FLD_PIN) == LOW){ - Joystick.button(12, 1); - } - if (digitalRead(BUTTON_FRD_PIN) == LOW){ - Joystick.button(13, 1); - } - if (digitalRead(BUTTON_TLD_PIN) == LOW){ - Joystick.button(14, 1); - } - if (digitalRead(BUTTON_TRD_PIN) == LOW){ - Joystick.button(15, 1); - } - } - else if (fn_mode == 1){ - - if (digitalRead(BUTTON_FLD_PIN) == LOW){ - Joystick.button(8, 1); - } - if (digitalRead(BUTTON_FRD_PIN) == LOW){ - Joystick.button(9, 1); - } - if (digitalRead(BUTTON_TLD_PIN) == LOW){ - Joystick.button(10, 1); - } - if (digitalRead(BUTTON_TRD_PIN) == LOW){ - Joystick.button(11, 1); - } - } - else{ - - if (digitalRead(BUTTON_FLD_PIN) == LOW){ - Joystick.button(2, 1); - } - if (digitalRead(BUTTON_FRD_PIN) == LOW){ - Joystick.button(4, 1); - } - if (digitalRead(BUTTON_TRU_PIN) == LOW){ - Joystick.button(5, 1); - } - if (digitalRead(BUTTON_TLD_PIN) == LOW){ - Joystick.button(6, 1); - } - if (digitalRead(BUTTON_TRD_PIN) == LOW){ - Joystick.button(7, 1); - } - } - - if (digitalRead(BUTTON_FLU_PIN) == LOW){ - Joystick.button(1, 1); - } - if (digitalRead(BUTTON_FRU_PIN) == LOW){ - Joystick.button(3, 1); - } - - // Set axis values - Joystick.Zrotate(joystick_x1_hid); - Joystick.Z(joystick_y1_hid); - - if (fn_mode == 2){ - Joystick.X(HID_AXIS_CENTER); - Joystick.Y(HID_AXIS_CENTER); - Joystick.sliderRight(joystick_x2_hid); - Joystick.sliderLeft(joystick_y2_hid); - } - else if (fn_mode == 1){ - Joystick.X(joystick_x2_hid); - Joystick.Y(HID_AXIS_CENTER); - Joystick.sliderRight(HID_AXIS_CENTER); - Joystick.sliderLeft(joystick_y2_hid); - } - else{ - Joystick.X(joystick_x2_hid); - Joystick.Y(joystick_y2_hid); - Joystick.sliderRight(HID_AXIS_CENTER); - Joystick.sliderLeft(HID_AXIS_CENTER); - } - - // Send USB Joystick data - Joystick.send_now(); -} - -void process_input_data(){ - - int analog_x1_inv = 0; - int analog_y1_inv = 0; - int analog_x2_inv = 0; - int analog_y2_inv = 0; - - if (gimbal_mode == 1){ - // FrSky M10 Gimbal - analog_x1_inv = constrain(AXIS_MAX - analog_x1.getValue(), AXIS_MIN, AXIS_MAX); - analog_y1_inv = constrain(analog_y1.getValue(), AXIS_MIN, AXIS_MAX); - analog_x2_inv = constrain(analog_x2.getValue(), AXIS_MIN, AXIS_MAX); - analog_y2_inv = constrain(AXIS_MAX - analog_y2.getValue(), AXIS_MIN, AXIS_MAX); - } - else{ - // FrSky M7 Gimbal - analog_x1_inv = constrain(analog_x1.getValue(), AXIS_MIN, AXIS_MAX); - analog_y1_inv = constrain(AXIS_MAX - analog_y1.getValue(), AXIS_MIN, AXIS_MAX); - analog_x2_inv = constrain(AXIS_MAX - analog_x2.getValue(), AXIS_MIN, AXIS_MAX); - analog_y2_inv = constrain(analog_y2.getValue(), AXIS_MIN, AXIS_MAX); - } - - if (joystick_calibration_mode == CALIBRATION_OFF){ - - // Calculate X1 joystick values - if(analog_x1_inv > (joystick_x1_center + DEADZONE_X)){ - joystick_x1 = constrain(map(analog_x1_inv, (joystick_x1_center + DEADZONE_X), joystick_x1_max, AXIS_CENTER, AXIS_MAX), AXIS_CENTER, AXIS_MAX); - } - else if(analog_x1_inv < (joystick_x1_center - DEADZONE_X)){ - joystick_x1 = constrain(map(analog_x1_inv, joystick_x1_min, (joystick_x1_center - DEADZONE_X), AXIS_MIN, AXIS_CENTER), AXIS_MIN, AXIS_CENTER); - } - else{ - joystick_x1 = AXIS_CENTER; - } - - // Calculate Y1 joystick values - if(analog_y1_inv > (joystick_y1_min + DEADZONE_Y)){ - joystick_y1 = constrain(map(analog_y1_inv, (joystick_y1_min + DEADZONE_Y), joystick_y1_max, AXIS_MIN, AXIS_MAX), AXIS_MIN, AXIS_MAX); - } - else{ - joystick_y1 = AXIS_MIN; - } - - // Calculate X2 joystick values - if(analog_x2_inv > (joystick_x2_center + DEADZONE_X)){ - joystick_x2 = constrain(map(analog_x2_inv, (joystick_x2_center + DEADZONE_X), joystick_x2_max, AXIS_CENTER, AXIS_MAX), AXIS_CENTER, AXIS_MAX); - } - else if(analog_x2_inv < (joystick_x2_center - DEADZONE_X)){ - joystick_x2 = constrain(map(analog_x2_inv, joystick_x2_min, (joystick_x2_center - DEADZONE_X), AXIS_MIN, AXIS_CENTER), AXIS_MIN, AXIS_CENTER); - } - else{ - joystick_x2 = AXIS_CENTER; - } - - // Calculate Y2 joystick values - if(analog_y2_inv > (joystick_y2_center + DEADZONE_Y)){ - joystick_y2 = constrain(map(analog_y2_inv, (joystick_y2_center + DEADZONE_Y), joystick_y2_max, AXIS_CENTER, AXIS_MAX), AXIS_CENTER, AXIS_MAX); - } - else if(analog_y2_inv < (joystick_y2_center - DEADZONE_Y)){ - joystick_y2 = constrain(map(analog_y2_inv, joystick_y2_min, (joystick_y2_center - DEADZONE_Y), AXIS_MIN, AXIS_CENTER), AXIS_MIN, AXIS_CENTER); - } - else{ - joystick_y2 = AXIS_CENTER; - } - - // Calculate new X1 values after applying exp curve - if (joystick_x1 != AXIS_CENTER){ - float joystick_x_float = joystick_x1 / float(AXIS_MAX); - float joystick_x_exp = exp_constant * (0.5 + 256 * pow((joystick_x_float - 0.5),9)) + (1 - exp_constant) * joystick_x_float; - joystick_x1_hid = int(joystick_x_exp * float(HID_AXIS_MAX)); - joystick_x1_hid = constrain(joystick_x1_hid, HID_AXIS_MIN, HID_AXIS_MAX); - } - else{ - joystick_x1_hid = HID_AXIS_CENTER; - } - - // Calculate new Y1 values - joystick_y1_hid = map(joystick_y1, AXIS_MIN, AXIS_MAX, HID_AXIS_MIN, HID_AXIS_MAX); - - // Calculate new X2 values after applying exp curve - if (joystick_x2 != AXIS_CENTER){ - float joystick_x_float = joystick_x2 / float(AXIS_MAX); - float joystick_x_exp = exp_constant * (0.5 + 256 * pow((joystick_x_float - 0.5),9)) + (1 - exp_constant) * joystick_x_float; - joystick_x2_hid = int(joystick_x_exp * float(HID_AXIS_MAX)); - joystick_x2_hid = constrain(joystick_x2_hid, HID_AXIS_MIN, HID_AXIS_MAX); - } - else{ - joystick_x2_hid = HID_AXIS_CENTER; - } - - // Calculate new Y2 values after applying exp curve - if (joystick_y2 != AXIS_CENTER){ - float joystick_y_float = joystick_y2 / float(AXIS_MAX); - float joystick_y_exp = exp_constant * (0.5 + 256 * pow((joystick_y_float - 0.5),9)) + (1 - exp_constant) * joystick_y_float; - joystick_y2_hid = int(joystick_y_exp * float(HID_AXIS_MAX)); - joystick_y2_hid = constrain(joystick_y2_hid, HID_AXIS_MIN, HID_AXIS_MAX); - } - else{ - joystick_y2_hid = HID_AXIS_CENTER; - } - - // Check fn mode - fn_mode = 0; - if (digitalRead(BUTTON_TLU_PIN) == LOW){ - fn_mode = 1; - if (digitalRead(BUTTON_TRU_PIN) == LOW){ - fn_mode = 2; - } - } - - // Check toggle mode buttons - if (digitalRead(BUTTON_FLU_PIN) == LOW){ - toggle_button_mode = true; - } - else if (digitalRead(BUTTON_FLD_PIN) == LOW){ - toggle_button_mode = false; - } - - // Check toggle arm button - if (fn_mode == 1){ - if (digitalRead(BUTTON_TRD_PIN) != toggle_button_arm_previous_value){ - toggle_button_arm_previous_value = digitalRead(BUTTON_TRD_PIN); - if (digitalRead(BUTTON_TRD_PIN) == LOW){ - if (toggle_button_arm == false){ - toggle_button_arm = true; - } - else{ - toggle_button_arm = false; - } - } - } - } - } - else{ - - // Calibration mode. - joystick_x1 = AXIS_CENTER; - joystick_y1 = AXIS_CENTER; - joystick_x2 = AXIS_CENTER; - joystick_y2 = AXIS_CENTER; - joystick_x1_hid = HID_AXIS_CENTER; - joystick_y1_hid = HID_AXIS_CENTER; - joystick_x2_hid = HID_AXIS_CENTER; - joystick_y2_hid = HID_AXIS_CENTER; - - // Check for calibration mode - if (joystick_calibration_mode == CALIBRATION_INIT){ - if (digitalRead(BUTTON_TLD_PIN) == HIGH){ - joystick_calibration_mode = CALIBRATION_CENTER; - } - } - - // Calibrate joystick center values - else if (joystick_calibration_mode == CALIBRATION_CENTER){ - joystick_x1_center = analog_x1_inv; - joystick_y1_center = analog_y1_inv; - joystick_x1_max = joystick_x1_center; - joystick_x1_min = joystick_x1_center; - joystick_y1_max = joystick_y1_center; - joystick_y1_min = joystick_y1_center; - - joystick_x2_center = analog_x2_inv; - joystick_y2_center = analog_y2_inv; - joystick_x2_max = joystick_x2_center; - joystick_x2_min = joystick_x2_center; - joystick_y2_max = joystick_y2_center; - joystick_y2_min = joystick_y2_center; - - if (digitalRead(BUTTON_TLD_PIN) == LOW){ - joystick_calibration_mode = CALIBRATION_MINMAX; - } - } - - // Calibrate joystick min/max values - else if (joystick_calibration_mode == CALIBRATION_MINMAX){ - if(analog_x1_inv > joystick_x1_max){ - joystick_x1_max = analog_x1_inv; - } - if(analog_x1_inv < joystick_x1_min){ - joystick_x1_min = analog_x1_inv; - } - if(analog_y1_inv > joystick_y1_max){ - joystick_y1_max = analog_y1_inv; - } - if(analog_y1_inv < joystick_y1_min){ - joystick_y1_min = analog_y1_inv; - } - - if(analog_x2_inv > joystick_x2_max){ - joystick_x2_max = analog_x2_inv; - } - if(analog_x2_inv < joystick_x2_min){ - joystick_x2_min = analog_x2_inv; - } - if(analog_y2_inv > joystick_y2_max){ - joystick_y2_max = analog_y2_inv; - } - if(analog_y2_inv < joystick_y2_min){ - joystick_y2_min = analog_y2_inv; - } - - if (digitalRead(BUTTON_TRD_PIN) == LOW){ - joystick_calibration_mode = CALIBRATION_OFF; - save_to_eeprom(); - } - } - } -} - -/* Update indicator 0=Off, 1=On, 2=Blink */ -void update_indicator(int mode, bool ¤t_state, int pin){ - - if (mode == 2 && current_state == false) + if (fn_mode == 2) { - digitalWrite(pin, HIGH); - current_state = true; + Joystick.X(AXIS_10BIT_CENTER); + Joystick.Y(AXIS_10BIT_CENTER); + Joystick.sliderRight(joystick_x2_10bit); + Joystick.sliderLeft(joystick_y2_10bit); } - else if (mode == 2 && current_state == true) + else if (fn_mode == 1) { - digitalWrite(pin, LOW); - current_state = false; - } - else if (mode == 1) - { - digitalWrite(pin, HIGH); - current_state = true; + Joystick.X(AXIS_10BIT_CENTER); + Joystick.Y(joystick_y2_10bit); + Joystick.sliderRight(joystick_x2_10bit); + Joystick.sliderLeft(AXIS_10BIT_CENTER); } else { - digitalWrite(pin, LOW); - current_state = false; + Joystick.X(joystick_x2_10bit); + Joystick.Y(joystick_y2_10bit); + Joystick.sliderRight(AXIS_10BIT_CENTER); + Joystick.sliderLeft(AXIS_10BIT_CENTER); + } + + // Set USB digital channels + for (int i = 1; i < 32; i++) + { + Joystick.button(i, 0); + } + + Joystick.hat(JOYSTICK_HAT_CENTER); + + if (fn_mode == 2) + { + if (digitalRead(BUTTON_TOP_LEFT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(12, 1); + if (digitalRead(BUTTON_TOP_RIGHT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(13, 1); + if (digitalRead(BUTTON_TOP_LEFT_LOWER_PIN) == BUTTON_PRESSED) Joystick.button(14, 1); + if (digitalRead(BUTTON_TOP_RIGHT_LOWER_PIN) == BUTTON_PRESSED) Joystick.button(15, 1); + if (digitalRead(BUTTON_FRONT_RIGHT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(16, 1); + if (digitalRead(BUTTON_FRONT_RIGHT_LOWER_PIN) == BUTTON_PRESSED) Joystick.button(17, 1); + } + else if (fn_mode == 1) + { + if (digitalRead(BUTTON_TOP_LEFT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(8, 1); + if (digitalRead(BUTTON_TOP_RIGHT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(9, 1); + if (digitalRead(BUTTON_TOP_LEFT_LOWER_PIN) == BUTTON_PRESSED) Joystick.button(10, 1); + if (digitalRead(BUTTON_TOP_RIGHT_LOWER_PIN) == BUTTON_PRESSED) Joystick.button(11, 1); + if (digitalRead(BUTTON_FRONT_RIGHT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(1, 1); + if (digitalRead(BUTTON_FRONT_RIGHT_LOWER_PIN) == BUTTON_PRESSED) Joystick.button(2, 1); + } + else + { + if (digitalRead(BUTTON_FRONT_LEFT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(3, 1); + if (digitalRead(BUTTON_TOP_LEFT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(4, 1); + if (digitalRead(BUTTON_TOP_RIGHT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(5, 1); + if (digitalRead(BUTTON_TOP_LEFT_LOWER_PIN) == BUTTON_PRESSED) Joystick.button(6, 1); + if (digitalRead(BUTTON_TOP_RIGHT_LOWER_PIN) == BUTTON_PRESSED) Joystick.button(7, 1); + if (digitalRead(BUTTON_FRONT_RIGHT_UPPER_PIN) == BUTTON_PRESSED) Joystick.button(1, 1); + if (digitalRead(BUTTON_FRONT_RIGHT_LOWER_PIN) == BUTTON_PRESSED) Joystick.button(2, 1); + } + + Joystick.send_now(); +} + +/** + * @brief Apply calibration to 12-bit gimbal value + * + * @param gimbal_value + * @param min_value + * @param max_value + * @param center_value + * @param deadband_value + * @param expo_value + */ +int apply_calibration_12bit(int gimbal_value, int min_value, int max_value, int center_value, int deadband_value, int expo_value) +{ + + int calibrated_value = AXIS_12BIT_CENTER; + + if (gimbal_value > (center_value + deadband_value)) + { + calibrated_value = constrain(map(gimbal_value, (center_value + deadband_value), max_value, AXIS_12BIT_CENTER, AXIS_12BIT_MAX), AXIS_12BIT_CENTER, AXIS_12BIT_MAX); + } + else if (gimbal_value < (center_value - deadband_value)) + { + calibrated_value = constrain(map(gimbal_value, min_value, (center_value - deadband_value), AXIS_12BIT_MIN, AXIS_12BIT_CENTER), AXIS_12BIT_MIN, AXIS_12BIT_CENTER); + } + + if (expo_value != 0) + { + float joystick_x_float = calibrated_value / float(AXIS_12BIT_MAX); + /* Calculate expo using 9th order polynomial function with 0.5 as center point */ + float joystick_x_exp = expo_value * (0.5 + 256 * pow((joystick_x_float - 0.5), 9)) + (1 - expo_value) * joystick_x_float; + calibrated_value = constrain(int(joystick_x_exp * float(AXIS_12BIT_MAX)), AXIS_12BIT_MIN, AXIS_12BIT_MAX); + } + + return calibrated_value; +} + +/** + * @brief Process input data from gimbal and buttons + */ +void process_input_data() +{ + + int analog_x1_gimbal_value = 0; + int analog_y1_gimbal_value = 0; + int analog_x2_gimbal_value = 0; + int analog_y2_gimbal_value = 0; + + if (gimbal_mode == GIMBAL_MODE_FRSKY_M10) + { + analog_x1_gimbal_value = constrain(AXIS_12BIT_MAX - analog_x1.getValue(), AXIS_12BIT_MIN, AXIS_12BIT_MAX); + analog_y1_gimbal_value = constrain(analog_y1.getValue(), AXIS_12BIT_MIN, AXIS_12BIT_MAX); + analog_x2_gimbal_value = constrain(analog_x2.getValue(), AXIS_12BIT_MIN, AXIS_12BIT_MAX); + analog_y2_gimbal_value = constrain(AXIS_12BIT_MAX - analog_y2.getValue(), AXIS_12BIT_MIN, AXIS_12BIT_MAX); + } + else if (gimbal_mode == GIMBAL_MODE_FRSKY_M7) + { + analog_x1_gimbal_value = constrain(analog_x1.getValue(), AXIS_12BIT_MIN, AXIS_12BIT_MAX); + analog_y1_gimbal_value = constrain(AXIS_12BIT_MAX - analog_y1.getValue(), AXIS_12BIT_MIN, AXIS_12BIT_MAX); + analog_x2_gimbal_value = constrain(AXIS_12BIT_MAX - analog_x2.getValue(), AXIS_12BIT_MIN, AXIS_12BIT_MAX); + analog_y2_gimbal_value = constrain(analog_y2.getValue(), AXIS_12BIT_MIN, AXIS_12BIT_MAX); + } + + if (joystick_calibration_mode != CALIBRATION_OFF) + { + calibrate_axis(analog_x1_gimbal_value, analog_y1_gimbal_value, analog_x2_gimbal_value, analog_y2_gimbal_value); + return; + } + + joystick_x1_12bit = apply_calibration_12bit(analog_x1_gimbal_value, joystick_x1_12bit_min, joystick_x1_12bit_max, joystick_x1_12bit_center, DEADZONE_X, exp_constant); + joystick_y1_12bit = apply_calibration_12bit(analog_y1_gimbal_value, joystick_y1_12bit_min, joystick_y1_12bit_max, joystick_y1_12bit_center, DEADZONE_Y, 0); + joystick_x2_12bit = apply_calibration_12bit(analog_x2_gimbal_value, joystick_x2_12bit_min, joystick_x2_12bit_max, joystick_x2_12bit_center, DEADZONE_X, exp_constant); + joystick_y2_12bit = apply_calibration_12bit(analog_y2_gimbal_value, joystick_y2_12bit_min, joystick_y2_12bit_max, joystick_y2_12bit_center, DEADZONE_Y, exp_constant); + + // Check fn mode + fn_mode = 0; + if (digitalRead(BUTTON_FRONT_LEFT_LOWER_PIN) == BUTTON_PRESSED) + { + fn_mode = 1; + if (digitalRead(BUTTON_FRONT_LEFT_UPPER_PIN) == BUTTON_PRESSED) + { + fn_mode = 2; + } + } + + // Check toggle mode buttons + if (digitalRead(BUTTON_FRONT_LEFT_UPPER_PIN) == BUTTON_PRESSED) + { + toggle_button_mode = true; + } + else if (digitalRead(BUTTON_FRONT_LEFT_LOWER_PIN) == BUTTON_PRESSED) + { + toggle_button_mode = false; + } + + // Check toggle arm button + if ((fn_mode == 1) && (digitalRead(BUTTON_TOP_RIGHT_LOWER_PIN) != toggle_button_arm_previous_value)) + { + if ((digitalRead(BUTTON_TOP_RIGHT_LOWER_PIN) == BUTTON_PRESSED) && (toggle_button_arm == false)) + { + toggle_button_arm = true; + } + else if ((digitalRead(BUTTON_TOP_RIGHT_LOWER_PIN) == BUTTON_PRESSED) && (toggle_button_arm == true)) + { + toggle_button_arm = false; + } + toggle_button_arm_previous_value = digitalRead(BUTTON_TOP_RIGHT_LOWER_PIN); + } +} + +/** + * @brief Update indicator LED + */ +void update_indicator(int led_mode, bool ¤t_led_state, int led_pin) +{ + + if (led_mode == LED_MODE_BLINK && current_led_state == false) + { + digitalWrite(led_pin, LED_ON); + current_led_state = true; + } + else if (led_mode == LED_MODE_BLINK && current_led_state == true) + { + digitalWrite(led_pin, LED_OFF); + current_led_state = false; + } + else if (led_mode == LED_MODE_ON) + { + digitalWrite(led_pin, LED_ON); + current_led_state = true; + } + else + { + digitalWrite(led_pin, LED_OFF); + current_led_state = false; } } @@ -754,29 +533,29 @@ void setup() { /* Init HW */ pinMode(STATUS_LED_PIN, OUTPUT); - digitalWrite(STATUS_LED_PIN, LOW); - - pinMode(BUTTON_LED_1_PIN, OUTPUT); - digitalWrite(BUTTON_LED_1_PIN, LOW); - - pinMode(BUTTON_LED_2_PIN, OUTPUT); - digitalWrite(BUTTON_LED_2_PIN, LOW); + digitalWrite(STATUS_LED_PIN, LED_OFF); + + pinMode(BUTTON_LED_1_PIN, OUTPUT); + digitalWrite(BUTTON_LED_1_PIN, LED_OFF); + + pinMode(BUTTON_LED_2_PIN, OUTPUT); + digitalWrite(BUTTON_LED_2_PIN, LED_OFF); + + pinMode(BUTTON_FRONT_LEFT_LOWER_PIN, INPUT_PULLUP); + pinMode(BUTTON_FRONT_LEFT_UPPER_PIN, INPUT_PULLUP); + pinMode(BUTTON_FRONT_RIGHT_LOWER_PIN, INPUT_PULLUP); + pinMode(BUTTON_FRONT_RIGHT_UPPER_PIN, INPUT_PULLUP); + pinMode(BUTTON_TOP_LEFT_LOWER_PIN, INPUT_PULLUP); + pinMode(BUTTON_TOP_RIGHT_LOWER_PIN, INPUT_PULLUP); + pinMode(BUTTON_TOP_LEFT_UPPER_PIN, INPUT_PULLUP); + pinMode(BUTTON_TOP_RIGHT_UPPER_PIN, INPUT_PULLUP); - pinMode(BUTTON_FLD_PIN, INPUT_PULLUP); - pinMode(BUTTON_FLU_PIN, INPUT_PULLUP); - pinMode(BUTTON_FRD_PIN, INPUT_PULLUP); - pinMode(BUTTON_FRU_PIN, INPUT_PULLUP); - pinMode(BUTTON_TLD_PIN, INPUT_PULLUP); - pinMode(BUTTON_TRD_PIN, INPUT_PULLUP); - pinMode(BUTTON_TLU_PIN, INPUT_PULLUP); - pinMode(BUTTON_TRU_PIN, INPUT_PULLUP); - pinMode(GIMBAL_MODE_PIN, INPUT_PULLUP); // Set ADC resolution to 12bit - analogReadResolution(12); + analogReadResolution(12); analogReadAveraging(32); - delay(500); + delay(500); // Set analog (lib) resolution to 12bit analog_x1.setAnalogResolution(4096); @@ -784,27 +563,30 @@ void setup() analog_x2.setAnalogResolution(4096); analog_y2.setAnalogResolution(4096); - // Init EEPROM + // Init EEPROM load_from_eeprom(); // Init Joystick Joystick.useManualSend(true); - - // Check if calibration mode is enabled - if (digitalRead(BUTTON_TLD_PIN) == LOW){ + + // Check if calibration mode is enabled + if (digitalRead(BUTTON_TOP_LEFT_LOWER_PIN) == BUTTON_PRESSED) + { joystick_calibration_mode = CALIBRATION_INIT; } - // Check if bootloader mode is enabled - if (digitalRead(BUTTON_TRD_PIN) == LOW){ + // Check if bootloader mode is enabled + if (digitalRead(BUTTON_TOP_RIGHT_LOWER_PIN) == BUTTON_PRESSED) + { digitalWrite(BUTTON_LED_2_PIN, HIGH); delay(200); - _reboot_Teensyduino_(); + _reboot_Teensyduino_(); } - // Check what gimbal mode is selected - if (digitalRead(GIMBAL_MODE_PIN) == LOW){ - gimbal_mode = 1; + // Check what gimbal mode is selected + if (digitalRead(GIMBAL_MODE_PIN) == LOW) + { + gimbal_mode = GIMBAL_MODE_FRSKY_M10; } // Init ELRS @@ -813,70 +595,66 @@ void setup() void loop() { - /* Update current time (ms) */ - current_timestamp = millis(); - /* Update current time (us) */ current_timestamp_micros = micros(); - /* Read io value as fast as possible */ analog_x1.update(); analog_y1.update(); analog_x2.update(); analog_y2.update(); - + /* Process data with 1ms interval*/ - if (current_timestamp >= process_data_timestamp) + if (current_timestamp_micros >= process_data_timestamp_micros) { process_input_data(); - process_data_timestamp = current_timestamp + 1; + process_data_timestamp_micros = current_timestamp_micros + TIME_US_1ms; } /* Update/Send USB data with 5ms interval*/ - if (current_timestamp >= send_usb_timestamp) + if (current_timestamp_micros >= send_usb_timestamp_micros) { send_usb_data(); - send_usb_timestamp = current_timestamp + 5; + send_usb_timestamp_micros = current_timestamp_micros + TIME_US_5ms; } - - /* Update/Send ERLS data with 1,6ms interval */ + + /* Update/Send ERLS data with about 1,6ms interval */ if (current_timestamp_micros >= send_elrs_timestamp_micros) { - send_elrs_data(); + send_erls_data(); send_elrs_timestamp_micros = current_timestamp_micros + CRSF_TIME_BETWEEN_FRAMES_US; } - - /* Update indicator 200ms */ - if (current_timestamp >= indicator_timestamp) + + /* Update indicator with 200ms interval */ + if (current_timestamp_micros >= indicator_timestamp_micros) { - // Set led mode - button_led_1_mode = 0; - button_led_2_mode = 0; - - if (joystick_calibration_mode == CALIBRATION_INIT){ - button_led_1_mode = 2; - button_led_2_mode = 2; + button_led_1_mode = LED_MODE_OFF; + button_led_2_mode = LED_MODE_OFF; + + if (joystick_calibration_mode == CALIBRATION_INIT) + { + button_led_1_mode = LED_MODE_BLINK; + button_led_2_mode = LED_MODE_BLINK; } - else if (joystick_calibration_mode == CALIBRATION_CENTER){ - button_led_1_mode = 2; - button_led_2_mode = 0; + else if (joystick_calibration_mode == CALIBRATION_CENTER) + { + button_led_1_mode = LED_MODE_BLINK; + button_led_2_mode = LED_MODE_OFF; } - else if (joystick_calibration_mode == CALIBRATION_MINMAX){ - button_led_1_mode = 0; - button_led_2_mode = 2; + else if (joystick_calibration_mode == CALIBRATION_MINMAX) + { + button_led_1_mode = LED_MODE_OFF; + button_led_2_mode = LED_MODE_BLINK; } - else if ((joystick_x1 != AXIS_CENTER) || (joystick_y1 != AXIS_MIN) || - (joystick_x2 != AXIS_CENTER) || (joystick_y2 != AXIS_CENTER)){ - button_led_1_mode = 1; - button_led_2_mode = 1; + else if ((joystick_x1_12bit != AXIS_12BIT_CENTER) || (joystick_y1_12bit != AXIS_12BIT_MIN) || + (joystick_x2_12bit != AXIS_12BIT_CENTER) || (joystick_y2_12bit != AXIS_12BIT_CENTER)) + { + button_led_1_mode = LED_MODE_ON; + button_led_2_mode = LED_MODE_ON; } - /* Updated button led 1 */ update_indicator(button_led_1_mode, button_led_1_on, BUTTON_LED_1_PIN); - /* Updated button led 2 */ update_indicator(button_led_2_mode, button_led_2_on, BUTTON_LED_2_PIN); - /* Update status led */ update_indicator(status_led_mode, status_led_on, STATUS_LED_PIN); - - indicator_timestamp = current_timestamp + 200; + + indicator_timestamp_micros = current_timestamp_micros + TIME_US_200ms; } } diff --git a/firmware/src/erls.cpp b/firmware/src/erls.cpp new file mode 100644 index 0000000..85217c3 --- /dev/null +++ b/firmware/src/erls.cpp @@ -0,0 +1,180 @@ +/* + * ======================================================================================================= + * ------------------------------------------------------------------------------------------------------- + * ---####################-----###########-------###########-----############--############-############-- + * --######################---#############-----#############---- -- - --- + * --###### ##---##### ###-----### #####---------##-------#######------#------------- + * -- -------------- --- ----- --- ----- ---------##-------#------------#------------- + * --#####--------------------#####------####-####------#####---------##-------###########--############-- + * -- -------------------- ------ ------ --------- ------- -- -- + * --#####--------------------#####--------#####--------#####--------------------------------------------- + * -- -------------------- -------- -------- --------------------------------------------- + * --######--------------##---#####---------------------#####---------------- ERLS ----------------------- + * --##################### ---#####---------------------#####--------------------------------------------- + * ---################### ----#####---------------------#####--------------------------------------------- + * --- ----- --------------------- --------------------------------------------- + * ------------------------------------------------------------------------------------------------------- + * ======================================================================================================= + * + * Copyright 2023 Christoffer Martinsson + * + * CMtec ERLS can be redistributed and/or modified under the terms of the GNU General + * Public License (Version 2), as published by the Free Software Foundation. + * A copy of the license can be found online at www.gnu.o urg/licenses. + * + * CMtec ERLS is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + */ + +#include "erls.h" + +uint8_t crsf_packet[CRSF_PACKET_SIZE]; +uint8_t crsf_cmd_packet[CRSF_CMD_PACKET_SIZE]; +int16_t elrs_channels[CRSF_MAX_CHANNEL]; + +bool elrs_init_done = false; +int elrs_init_counter = 0; + +// crc implementation from CRSF protocol document rev7 +static uint8_t crsf_crc8tab[256] = { + 0x00, 0xD5, 0x7F, 0xAA, 0xFE, 0x2B, 0x81, 0x54, 0x29, 0xFC, 0x56, 0x83, 0xD7, 0x02, 0xA8, 0x7D, + 0x52, 0x87, 0x2D, 0xF8, 0xAC, 0x79, 0xD3, 0x06, 0x7B, 0xAE, 0x04, 0xD1, 0x85, 0x50, 0xFA, 0x2F, + 0xA4, 0x71, 0xDB, 0x0E, 0x5A, 0x8F, 0x25, 0xF0, 0x8D, 0x58, 0xF2, 0x27, 0x73, 0xA6, 0x0C, 0xD9, + 0xF6, 0x23, 0x89, 0x5C, 0x08, 0xDD, 0x77, 0xA2, 0xDF, 0x0A, 0xA0, 0x75, 0x21, 0xF4, 0x5E, 0x8B, + 0x9D, 0x48, 0xE2, 0x37, 0x63, 0xB6, 0x1C, 0xC9, 0xB4, 0x61, 0xCB, 0x1E, 0x4A, 0x9F, 0x35, 0xE0, + 0xCF, 0x1A, 0xB0, 0x65, 0x31, 0xE4, 0x4E, 0x9B, 0xE6, 0x33, 0x99, 0x4C, 0x18, 0xCD, 0x67, 0xB2, + 0x39, 0xEC, 0x46, 0x93, 0xC7, 0x12, 0xB8, 0x6D, 0x10, 0xC5, 0x6F, 0xBA, 0xEE, 0x3B, 0x91, 0x44, + 0x6B, 0xBE, 0x14, 0xC1, 0x95, 0x40, 0xEA, 0x3F, 0x42, 0x97, 0x3D, 0xE8, 0xBC, 0x69, 0xC3, 0x16, + 0xEF, 0x3A, 0x90, 0x45, 0x11, 0xC4, 0x6E, 0xBB, 0xC6, 0x13, 0xB9, 0x6C, 0x38, 0xED, 0x47, 0x92, + 0xBD, 0x68, 0xC2, 0x17, 0x43, 0x96, 0x3C, 0xE9, 0x94, 0x41, 0xEB, 0x3E, 0x6A, 0xBF, 0x15, 0xC0, + 0x4B, 0x9E, 0x34, 0xE1, 0xB5, 0x60, 0xCA, 0x1F, 0x62, 0xB7, 0x1D, 0xC8, 0x9C, 0x49, 0xE3, 0x36, + 0x19, 0xCC, 0x66, 0xB3, 0xE7, 0x32, 0x98, 0x4D, 0x30, 0xE5, 0x4F, 0x9A, 0xCE, 0x1B, 0xB1, 0x64, + 0x72, 0xA7, 0x0D, 0xD8, 0x8C, 0x59, 0xF3, 0x26, 0x5B, 0x8E, 0x24, 0xF1, 0xA5, 0x70, 0xDA, 0x0F, + 0x20, 0xF5, 0x5F, 0x8A, 0xDE, 0x0B, 0xA1, 0x74, 0x09, 0xDC, 0x76, 0xA3, 0xF7, 0x22, 0x88, 0x5D, + 0xD6, 0x03, 0xA9, 0x7C, 0x28, 0xFD, 0x57, 0x82, 0xFF, 0x2A, 0x80, 0x55, 0x01, 0xD4, 0x7E, 0xAB, + 0x84, 0x51, 0xFB, 0x2E, 0x7A, 0xAF, 0x05, 0xD0, 0xAD, 0x78, 0xD2, 0x07, 0x53, 0x86, 0x2C, 0xF9}; + +/** + * @brief Calculate the CRC8 of a CRSF packet + * + * @param ptr The packet to be calculated + * @param len The length of the packet + */ +uint8_t calculate_crsf_crc8(const uint8_t *ptr, uint8_t len) +{ + uint8_t crc = 0; + for (uint8_t i = 0; i < len; i++) + { + crc = crsf_crc8tab[crc ^ *ptr++]; + } + return crc; +} + +/** + * @brief Prepare a CRSF data packet + * + * @param packet The packet to be prepared + * @param channels The channels to be sent + */ +void prepare_crsf_data_packet(uint8_t packet[], int16_t channels[]) +{ + packet[0] = ELRS_ADDRESS; // Header + packet[1] = 24; // length + packet[2] = CRSF_TYPE_CHANNELS; + packet[3] = (uint8_t)(channels[0] & 0x07FF); + packet[4] = (uint8_t)((channels[0] & 0x07FF) >> 8 | (channels[1] & 0x07FF) << 3); + packet[5] = (uint8_t)((channels[1] & 0x07FF) >> 5 | (channels[2] & 0x07FF) << 6); + packet[6] = (uint8_t)((channels[2] & 0x07FF) >> 2); + packet[7] = (uint8_t)((channels[2] & 0x07FF) >> 10 | (channels[3] & 0x07FF) << 1); + packet[8] = (uint8_t)((channels[3] & 0x07FF) >> 7 | (channels[4] & 0x07FF) << 4); + packet[9] = (uint8_t)((channels[4] & 0x07FF) >> 4 | (channels[5] & 0x07FF) << 7); + packet[10] = (uint8_t)((channels[5] & 0x07FF) >> 1); + packet[11] = (uint8_t)((channels[5] & 0x07FF) >> 9 | (channels[6] & 0x07FF) << 2); + packet[12] = (uint8_t)((channels[6] & 0x07FF) >> 6 | (channels[7] & 0x07FF) << 5); + packet[13] = (uint8_t)((channels[7] & 0x07FF) >> 3); + packet[14] = (uint8_t)((channels[8] & 0x07FF)); + packet[15] = (uint8_t)((channels[8] & 0x07FF) >> 8 | (channels[9] & 0x07FF) << 3); + packet[16] = (uint8_t)((channels[9] & 0x07FF) >> 5 | (channels[10] & 0x07FF) << 6); + packet[17] = (uint8_t)((channels[10] & 0x07FF) >> 2); + packet[18] = (uint8_t)((channels[10] & 0x07FF) >> 10 | (channels[11] & 0x07FF) << 1); + packet[19] = (uint8_t)((channels[11] & 0x07FF) >> 7 | (channels[12] & 0x07FF) << 4); + packet[20] = (uint8_t)((channels[12] & 0x07FF) >> 4 | (channels[13] & 0x07FF) << 7); // Channel not used by ELRS + packet[21] = (uint8_t)((channels[13] & 0x07FF) >> 1); // Channel not used by ELRS + packet[22] = (uint8_t)((channels[13] & 0x07FF) >> 9 | (channels[14] & 0x07FF) << 2); // Channel not used by ELRS + packet[23] = (uint8_t)((channels[14] & 0x07FF) >> 6 | (channels[15] & 0x07FF) << 5); // Channel not used by ELRS + packet[24] = (uint8_t)((channels[15] & 0x07FF) >> 3); // Channel not used by ELRS + packet[25] = calculate_crsf_crc8(&packet[2], packet[1] - 1); +} + +/** + * @brief Prepare CRSF command packet + * + * @param packet_cmd + * @param command + * @param value + */ +void prepare_crsf_cmd_packet(uint8_t packet_cmd[], uint8_t command, uint8_t value) +{ + packet_cmd[0] = ELRS_ADDRESS; // Header + packet_cmd[1] = 6; // length + packet_cmd[2] = ELRS_TYPE_SETTINGS_WRITE; + packet_cmd[3] = ELRS_ADDRESS; + packet_cmd[4] = ELRS_ADDR_RADIO; + packet_cmd[5] = command; + packet_cmd[6] = value; + packet_cmd[7] = calculate_crsf_crc8(&packet_cmd[2], packet_cmd[1] - 1); +} + +/** + * @brief Set data to be sent to ERLS TX + * + * @param value + * @param channel + */ +void erls_set_data(int16_t value, uint8_t channel) +{ + elrs_channels[channel] = value; +} + +/** + * @brief Send data to ERLS TX + * + */ +void erls_send_data() +{ + + if (elrs_init_done == true) + { + prepare_crsf_data_packet(crsf_packet, elrs_channels); + ELRS_SERIAL_PORT.write(crsf_packet, CRSF_PACKET_SIZE); + } + else + { + // Setting up initial communication link between ERLS TX and Teensy (give ERLS TX time to auto detect Teensy) + if (elrs_init_counter < 500) + { + prepare_crsf_data_packet(crsf_packet, elrs_channels); + ELRS_SERIAL_PORT.write(crsf_packet, CRSF_PACKET_SIZE); + elrs_init_counter++; + } + // Send command to update TX packet rate to 500Hz + else if (elrs_init_counter < 505) + { + prepare_crsf_cmd_packet(crsf_cmd_packet, ELRS_PKT_RATE_COMMAND, ELRS_PKT_RATE); + ELRS_SERIAL_PORT.write(crsf_cmd_packet, CRSF_CMD_PACKET_SIZE); + elrs_init_counter++; + } + // Send command to update TX power to 100mW + else if (elrs_init_counter < 510) + { + prepare_crsf_cmd_packet(crsf_cmd_packet, ELRS_POWER_COMMAND, ELRS_POWER); + ELRS_SERIAL_PORT.write(crsf_cmd_packet, CRSF_CMD_PACKET_SIZE); + elrs_init_counter++; + } + else + { + elrs_init_done = true; + } + } +} \ No newline at end of file diff --git a/firmware/src/erls.h b/firmware/src/erls.h new file mode 100644 index 0000000..e09c85f --- /dev/null +++ b/firmware/src/erls.h @@ -0,0 +1,63 @@ + /* + * ======================================================================================================= + * ------------------------------------------------------------------------------------------------------- + * ---####################-----###########-------###########-----############--############-############-- + * --######################---#############-----#############---- -- - --- + * --###### ##---##### ###-----### #####---------##-------#######------#------------- + * -- -------------- --- ----- --- ----- ---------##-------#------------#------------- + * --#####--------------------#####------####-####------#####---------##-------###########--############-- + * -- -------------------- ------ ------ --------- ------- -- -- + * --#####--------------------#####--------#####--------#####--------------------------------------------- + * -- -------------------- -------- -------- --------------------------------------------- + * --######--------------##---#####---------------------#####---------------- ERLS ----------------------- + * --##################### ---#####---------------------#####--------------------------------------------- + * ---################### ----#####---------------------#####--------------------------------------------- + * --- ----- --------------------- --------------------------------------------- + * ------------------------------------------------------------------------------------------------------- + * ======================================================================================================= + * + * Copyright 2023 Christoffer Martinsson + * + * CMtec ERLS can be redistributed and/or modified under the terms of the GNU General + * Public License (Version 2), as published by the Free Software Foundation. + * A copy of the license can be found online at www.gnu.o urg/licenses. + * + * CMtec ERLS is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU General Public License for more details. + */ + +#include + +// CRSF +#define CRSF_MAX_CHANNEL 16 +#define CRSF_TYPE_CHANNELS 0x16 +#define CRSF_DIGITAL_CHANNEL_MIN 172 +#define CRSF_DIGITAL_CHANNEL_CENTER 992 +#define CRSF_DIGITAL_CHANNEL_MAX 1811 +#define CRSF_TIME_BETWEEN_FRAMES_US 1666 // 1.6 ms 500Hz +#define CRSF_PACKET_SIZE 26 +#define CRSF_CMD_PACKET_SIZE 8 + +// ELRS command +#define ELRS_ADDRESS 0xEE +#define ELRS_BIND_COMMAND 0xFF +#define ELRS_WIFI_COMMAND 0xFE +#define ELRS_PKT_RATE_COMMAND 0x01 +#define ELRS_TLM_RATIO_COMMAND 0x02 +#define ELRS_SWITCH_MODE_COMMAND 0x03 +#define ELRS_MODEL_MATCH_COMMAND 0x04 +#define ELRS_POWER_COMMAND 0x06 +#define ELRS_BLE_JOYSTIC_COMMAND 17 +#define ELRS_TYPE_SETTINGS_WRITE 0x2D +#define ELRS_ADDR_RADIO 0xEA +#define ELRS_SERIAL_PORT Serial1 +#define ELRS_SERIAL_BAUDRATE 400000 +#define ELRS_PKT_RATE 3 // 0 = 50Hz, 1 = 100Hz, 2 = 200Hz, 3 = 500Hz, 4 = 1000Hz +#define ELRS_POWER 2 // 0 = 10mW, 1 = 25mW, 2 = 100mW, 3 = 250mW, 4 = 500mW, 5 = 1000mW + + +void prepare_crsf_data_packet(uint8_t packet[], int16_t channels[]); +void prepare_crsf_cmd_packet(uint8_t packet_cmd[], uint8_t command, uint8_t value); +void erls_set_data(int16_t value, uint8_t channel); +void erls_send_data(); \ No newline at end of file