diff --git a/.ccls b/.ccls deleted file mode 100644 index 27ab492..0000000 --- a/.ccls +++ /dev/null @@ -1,125 +0,0 @@ -clang - -%c -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m7 -nostdlib -mfloat-abi=hard -mfpu=fpv5-d16 -O2 -%cpp -fno-exceptions -felide-constructors -fno-rtti -std=gnu++17 -Wno-error=narrowing -fpermissive -fno-threadsafe-statics -Wall -ffunction-sections -fdata-sections -mthumb -mcpu=cortex-m7 -nostdlib -mfloat-abi=hard -mfpu=fpv5-d16 -O2 - --I/home/ben/solar-car/TeensyBottomShellReborn/include --I/home/ben/solar-car/TeensyBottomShellReborn/src --I/home/ben/solar-car/TeensyBottomShellReborn/.pio/libdeps/teensy41/ChRt/src --I/home/ben/solar-car/TeensyBottomShellReborn/lib/function --I/home/ben/.platformio/packages/framework-arduinoteensy/cores/teensy4 --I/home/ben/solar-car/TeensyBottomShellReborn/.pio/libdeps/teensy41/Unity/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/ADC --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/AccelStepper/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Adafruit_NeoPixel --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Adafruit_STMPE610 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Adafruit_VS1053 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Adafruit_nRF8001 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Adafruit_nRF8001/utility --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/AltSoftSerial --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Artnet --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Audio --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Audio/utility --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Bounce --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Bounce2/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/CapacitiveSensor --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/CryptoAccel/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/DS1307RTC --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/DmxSimple --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/DogLcd --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/EEPROM --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/EasyTransfer/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/EasyTransferI2C/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Encoder --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Encoder/utility --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Entropy --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Ethernet/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FNET/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FastCRC --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FastLED/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FlexCAN --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FlexCAN_T4 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FlexIO_t4/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FlexiTimer2 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FreqCount --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FreqMeasure --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FreqMeasureMulti --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/FrequencyTimer2 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/ILI9341_t3 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/ILI9488_t3/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/IRremote/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Keypad/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/LedControl/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/LedDisplay --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/LiquidCrystal/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/LiquidCrystalFast --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/LittleFS/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/LowPower --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/MFRC522/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/MIDI/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Metro --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/MsTimer2 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/NXPMotionSense --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/NXPMotionSense/utility --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/NativeEthernet/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/OSC --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/OctoWS2811 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/OneWire --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/PS2Keyboard --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/PS2Keyboard/utility --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/PWMServo --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Ping --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/PulsePosition --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/QuadEncoder --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/RA8875/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/RadioHead --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/ResponsiveAnalogRead/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/SD/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/SPI --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/SPIFlash --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/ST7735_t3/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/SdFat/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/SerialFlash --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Servo --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/ShiftPWM --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Snooze/src --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/SoftPWM --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/SoftwareSerial --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/TFT_ILI9163C --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Talkie --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/TeensyThreads --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Time --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/TimeAlarms --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/TimerOne --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/TimerThree --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/TinyGPS --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Tlc5940 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/TouchScreen --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/USBHost_t36 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/USBHost_t36/utility --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/UTFT --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/VirtualWire --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/WS2812Serial --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Wire --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/Wire/utility --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/XBee --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/XPT2046_Touchscreen --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/i2c_t3 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/ks0108 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/ssd1351 --I/home/ben/.platformio/packages/framework-arduinoteensy/libraries/x10 --I/home/ben/.platformio/packages/toolchain-gccarmnoneeabi-teensy/arm-none-eabi/include/c++/11.3.1 --I/home/ben/.platformio/packages/toolchain-gccarmnoneeabi-teensy/arm-none-eabi/include/c++/11.3.1/arm-none-eabi --I/home/ben/.platformio/packages/toolchain-gccarmnoneeabi-teensy/lib/gcc/arm-none-eabi/11.3.1/include-fixed --I/home/ben/.platformio/packages/toolchain-gccarmnoneeabi-teensy/lib/gcc/arm-none-eabi/11.3.1/include --I/home/ben/.platformio/packages/toolchain-gccarmnoneeabi-teensy/arm-none-eabi/include - --DPLATFORMIO=60116 --D__IMXRT1062__ --DARDUINO_TEENSY41 --DUSB_SERIAL --DARDUINO=10805 --DTEENSYDUINO=159 --DCORE_TEENSY --DF_CPU=600000000 --DLAYOUT_US_ENGLISH diff --git a/.gitignore b/.gitignore index c22d7ea..89cc49c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,46 +1,5 @@ -# Prerequisites -*.d - -# Compiled Object files -*.slo -*.lo -*.o -*.obj - -# Precompiled Headers -*.gch -*.pch - -# Compiled Dynamic libraries -*.so -*.dylib -*.dll - -# Compiled Static libraries -*.lai -*.la -*.a -*.lib - -# Executables -*.exe -*.out -*.app -.pioenvs -.piolibdeps -.clang_complete -.gcc-flags.json - -# Custom -.pio/* -*.swp -.vscode/extensions.json -.vscode/ -.pio/ -hash.h - -## ccls/clangd files and compilation files -.ccls -.ccls-cache/ -compile_commands.json -.cache/ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 4f72a85..0000000 --- a/.gitmodules +++ /dev/null @@ -1,5 +0,0 @@ -[submodule "lib"] - path = lib - ; url = git@github.com:KentuckySolarCar/teensy_libs.git - url = ../teensy_libs.git - branch = bottom-shell-reborn diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 6adbeb9..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "files.associations": { - "cstdlib": "cpp", - "iostream": "cpp", - "iosfwd": "cpp", - "ostream": "cpp", - "*.tpp": "cpp", - "*.tcc": "cpp" - } -} \ No newline at end of file diff --git a/lib/README b/lib/README new file mode 100644 index 0000000..2593a33 --- /dev/null +++ b/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include +#include + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/platformio.ini b/platformio.ini index 886d452..a13d034 100644 --- a/platformio.ini +++ b/platformio.ini @@ -12,25 +12,3 @@ platform = teensy board = teensy41 framework = arduino -lib_deps = - greiman/ChRt@=1.3.0 - FlexCAN_T4 - can_msg_ids - UKSC_Alert -build_flags = - -Wall - ;-Isrc/battery - -Isrc/common - ;-Isrc/gps - ;-Isrc/heartbeat - ;-Isrc/inputs - ;-Isrc/logging - ;-Isrc/misc - ;-Isrc/motor - ;-Isrc/mppt - ;-Isrc/sensors - ;-Isrc/serial - ;-Isrc/settings - ;-Isrc/telemetry - ;-Isrc/light - ;-Isrc/light_router diff --git a/src/common/can_setup.h b/src/common/can_setup.h deleted file mode 100644 index 94efa0e..0000000 --- a/src/common/can_setup.h +++ /dev/null @@ -1,33 +0,0 @@ -/** - * @file can_setup.h - * @brief Declares the CAN ports used by the board - * @version 0.1 - * - * This header file must be included in any file that sends or receives data via CAN. - * Each port object must be instantiated only once, so we instantiate them in - * main.cpp and declare them here. - * - */ - -#ifndef CAN_SETUP_H -#define CAN_SETUP_H - -#include - -/** - * These typedefs aren't required, but they let us rename the ports. - * Note that we're calling CAN1 can0 and we're calling CAN2 can1. - * This is done to match the labels on the boards. - */ -typedef FlexCAN_T4 can0; -typedef FlexCAN_T4 can1; - - -/** - * This is where we specify which bus is connected to which port - * and what we want to call each bus. - */ -extern can0 MainCan; -extern can1 MotorCan; - -#endif diff --git a/src/common/common.h b/src/common/common.h deleted file mode 100644 index fc182ba..0000000 --- a/src/common/common.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef COMMON_H -#define COMMON_H - -#include -#include "can_setup.h" -#include "pin_definitions.h" -#include - -#define BAUD_RATE 500000 - -#define LIGHTS_PRIO (NORMALPRIO + 2) -#define LIGHTS_WA 4096 -#define LIGHTS_SLEEP 100 - -#define ROUTER_PRIO (NORMALPRIO + 3) -#define ROUTER_WA 2048 -#define ROUTER_SLEEP 40 - -#define HEARTBEAT_PRIO (LOWPRIO) -#define HEARTBEAT_WA 512 -#define HEARTBEAT_SLEEP 100 - -#endif \ No newline at end of file diff --git a/src/common/pin_definitions.h b/src/common/pin_definitions.h deleted file mode 100644 index 6ff2c82..0000000 --- a/src/common/pin_definitions.h +++ /dev/null @@ -1,70 +0,0 @@ -/** - * @file pin_definitions.h - * @brief Holds macros that serve as a hardware abstraction layer. Copied from TBS - * @version 0.01 - * - * - */ - -#ifndef BOTTOM_SHELL_H -#define BOTTOM_SHELL_H - -//TODO: Find pin for TRIGGER_MODE - -//Teensy 4.1 pin mappings, all names are referenced to the Eagle schematics - -//Left side of the board diagram -#define TWELVE_V_MEASURE A0 //14, on the Eagle schematic as "12V_MEASURE" - //15 is empty -#define THROT1_IN A2 //16 -#define THROT2_IN A3 //17 -#define BPT_FR_IN A4 //18 -#define BPT_RR_IN A5 //19 -#define BPT_FL_IN A6 //20 -#define BPT_RL_IN A7 //21 -#define CAN0_TX A8 //22 -#define CAN0_RX A9 //23 -#define BRAKE_SWITCH A10 //24 EX7 - //A11 25 is empty - //A12 26 is empty - //A13 27 is empty -#define RT_CTRL A14 //38 -#define LT_CTRL A15 //39 -#define BRAKE_CTRL A16 //40 -#define RUNNING_LIGHTS A17 //41 - //30 is empty - //31 is empty -#define BPS_STROBE 3 - //4 is empty -#define FORWARD_REVERSE_IN 5 // EX1 -#define V_BAT VBAT - -//Right side of the board diagram -#define V_USB VUSB -//#define USB0_D- D- -//#define USB0_D+ D+ -#define CAN1_RX 0 -#define CAN_TX 1 - -//pins that were added on the updated bottom shell board schematic -#define GPS_RX 7 -#define GPS_TX 8 - //28 is empty - //29 is empty - -#define CAN0_STB 34 -#define CAN1_STB 35 -#define EX4 10 // CHARGE_ENABLE/CHARGE_DISABLE -#define EX5 11 -#define EX6 12 -//heartbeat is on 13, DO NOT USE - //32 is empty -#define RECALIBRATION_MODE_PIN 9 // EX 3 -#define TRIGGER_MODE 6 // EX 2 -#define GPS_MISC 33 -#define GPS_TRIG 36 -#define GPS_PPS 37 - - - -#endif \ No newline at end of file diff --git a/src/light/light.cpp b/src/light/light.cpp deleted file mode 100644 index ace5c8d..0000000 --- a/src/light/light.cpp +++ /dev/null @@ -1,147 +0,0 @@ -#include "light.h" - -// VERY TEMPORARY STUFF FOR ERROR'S SAKE -#define CAN_BPS_STATUS 0 -#define CAN_BUTTON_LEFT_TURN 1 -#define CAN_BUTTON_RIGHT_TURN 2 -#define CAN_BUTTON_HEADLIGHTS 3 -#define CAN_BUTTON_Y 4 - -// the setup of this code is as follows: -// we define two threads, one for routing can messages, and the other for updating the blinking of the lights. -// the can router updates our internal state for the lights, while the blinker reflects this on the physical system. - -struct { - bool isLeftTurnOn = false; - bool isRightTurnOn = false; - bool isStrobeOn = false; - bool isHeadlightOn = false; - bool isBrakeOn = false; - bool isLightTestOn = false; -} lightState; - -// Explanation of THD_WORKING_AREA: -// the first parameter to this macro is the name of the data. -// the second parameter is the size of the data we're working with. In this case, 4096 bytes. -// we then define a function that operates in a thread called in the setup function. -static THD_WORKING_AREA(wa_light_route, LIGHTS_WA); -static THD_FUNCTION(light_route_thd, arg) { - (void) arg; - - CAN_message_t msg; - while (true) { - while (MainCan.read(msg)) { - switch (msg.id) { - case CAN_BPS_STATUS: updateBPSLight(msg); break; - case CAN_BUTTON_LEFT_TURN: updateLeftLight(msg); break; - case CAN_BUTTON_RIGHT_TURN: updateRightLight(msg); break; - case CAN_BUTTON_HEADLIGHTS: updateHeadlights(msg); break; - case CAN_BUTTON_Y: updateYButtonLong(msg); break; - default: { - // we'll figure out alert messages later - break; - } - } - } - - if (isBrakePressed) { - updateBrakeLights(isBrakePressed); - } - - handleBPSLight(); - chThdSleepMilliseconds(ROUTER_SLEEP); - } -} - -static THD_WORKING_AREA(wa_light_blink, LIGHTS_WA); -static THD_FUNCTION(light_blink_thd, arg) { - // prevent compiler for complaining about unused stuff - (void) arg; - - uint32_t blinkTimer = millis(); - bool isOn = false; - while (true) { - // change light status - if (!lightState.isLeftTurnOn && !lightState.isRightTurnOn) { - isOn = false; - digitalWrite(LT_CTRL, LOW); - digitalWrite(RT_CTRL, LOW); - } else if (millis() - blinkTimer > TURN_SIGNALS_SPEED) { - blinkTimer = millis(); - isOn = !isOn; - digitalWrite(LT_CTRL, isOn && lightState.isLeftTurnOn); - digitalWrite(RT_CTRL, isOn && lightState.isRightTurnOn); - } - - digitalWrite(RUNNING_LIGHTS, lightState.isHeadlightOn); - digitalWrite(BRAKE_CTRL, lightState.isBrakeOn); - - if (lightState.isLightTestOn && isThrottleUnlocked) { - if (millis() - blinkTimer > TURN_SIGNALS_BRIGHTNESS) { - blinkTimer = millis(); - isOn = !isOn; - digitalWrite(LT_CTRL, isOn); - digitalWrite(RT_CTRL, isOn); - digitalWrite(BRAKE_CTRL, isOn); - digitalWrite(RUNNING_LIGHTS, isOn); - digitalWrite(BPS_STROBE, isOn); - } - } - - chThdSleepMilliseconds(LIGHTS_SLEEP); - } -} - -void lightSetup() { - pinMode(BPS_STROBE,OUTPUT); - pinMode(LT_CTRL,OUTPUT); - pinMode(RT_CTRL,OUTPUT); - pinMode(RUNNING_LIGHTS,OUTPUT); - pinMode(BRAKE_CTRL,OUTPUT); - - digitalWrite(BPS_STROBE, LOW); - - chThdCreateStatic(wa_light_route, sizeof(wa_light_route), ROUTER_PRIO, light_route_thd, NULL); - chThdCreateStatic(wa_light_blink, sizeof(wa_light_blink), LIGHTS_PRIO, light_blink_thd, NULL); -} - -void updateLeftLight(CAN_message_t ltMsg){ - lightState.isLeftTurnOn = ltMsg.buf[0] % 2; -} - -void updateRightLight(CAN_message_t rtMsg){ - lightState.isRightTurnOn = rtMsg.buf[0] % 2; -} - -void updateHeadlights(CAN_message_t lightMsg){ - lightState.isHeadlightOn = lightMsg.buf[0] % 2; -} - -void updateBrakeLights(bool brakeMsg){ - lightState.isBrakeOn = brakeMsg; -} - -void updateBPSLight(CAN_message_t statusMsg){ - lightState.isStrobeOn = statusMsg.buf[1]; // This is 1(TRUE) if the battery pack is terminated by a fault, or 0(FALSE) if conditions are safe -} - -void updateYButtonLong(CAN_message_t lightTestMsg){ - lightState.isLightTestOn = lightTestMsg.buf[2] % 2; -} - - -void handleBPSLight(){ - static uint32_t timer = millis(); - static bool isOn = false; - - if (lightState.isStrobeOn){ - if ((millis() - timer) > TURN_SIGNALS_SPEED){ - timer = millis(); - isOn = !isOn; - digitalWrite(BPS_STROBE,isOn); - } - } else { - isOn = false; - digitalWrite(BPS_STROBE, isOn); - } -} diff --git a/src/light/light.h b/src/light/light.h deleted file mode 100644 index b436dcf..0000000 --- a/src/light/light.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef LIGHT_H -#define LIGHT_H - -#include "common.h" - -// the following was pulled from TeensyBottomShell -#define HEADLIGHTS_BRIGHTNESS 120 -#define BRAKES_BRIGHTNESS 80 -#define TURN_SIGNALS_BRIGHTNESS 80 -#define TURN_SIGNALS_SPEED 500 -#define TEST_LIGHT_SPEED 500 - -extern bool isThrottleUnlocked; -extern bool isBrakePressed; - -// Uncomment if we want to expose lightState publicly -/* -extern struct { - bool isLeftTurnOn = false; - bool isRightTurnOn = false; - bool isStrobeOn = false; - bool isHeadlightOn = false; - bool isBrakeOn = false; - bool isLightTestOn = false; - bool isThrottleUnlocked = false; - bool isBrakePressed = false; -} lightState; -*/ - -/** - * @brief Function called in the "setup" phase. Initializes light threads and establishes light state. - * Combination of `lightSetup` and `routerSetup` from TBS. - * @param msg Input CAN message. Assumes correct ID and layout. - */ -void lightSetup(); - -/** - * @brief Function to update left light state based on an inputted can message. Assumes correct ID. - * @param msg Input CAN message. Assumes correct ID and layout. - */ -void updateLeftLight(CAN_message_t msg); -/** - * @brief Function to update right light state based on an inputted can message. Assumes correct ID. - * @param msg Input CAN message. Assumes correct ID and layout. - */ -void updateRightLight(CAN_message_t msg); - -/** - * @brief Function to update headlight state based on an inputted can message. Assumes correct ID. - * @param msg Input CAN message. Assumes correct ID and layout. - */ -void updateHeadlights(CAN_message_t msg); -/** - * @brief Function to update brake lights based on an already parsed can message. Called in response to a change in the brakes. - * @param msg Input CAN message. Assumes correct ID and layout. - */ -void updateBrakeLights(bool msg); - -/** - * @brief Function to update the battery protection system light. If something goes VERY wrong with the batteries, we tigger a light indicating so. - * @param msg Input CAN message. Assumes correct ID and layout. - */ -void updateBPSLight(CAN_message_t msg); - -/** - * @brief - */ -void updateYButtonLong(CAN_message_t msg); - -/** - * @brief Function to blink BPS lights. Called if bad things happen to the battery. - */ -void handleBPSLight(void); - -#endif // LIGHT_H diff --git a/src/main.cpp b/src/main.cpp index e346b9e..cb9fbba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,10 +1,18 @@ -#include "common.h" +#include +// put function declarations here: +int myFunction(int, int); void setup() { - + // put your setup code here, to run once: + int result = myFunction(2, 3); } void loop() { - // Do nothing + // put your main code here, to run repeatedly: +} + +// put function definitions here: +int myFunction(int x, int y) { + return x + y; } \ No newline at end of file diff --git a/test/test_common/test_main.cpp b/test/test_common/test_main.cpp deleted file mode 100644 index fd8f313..0000000 --- a/test/test_common/test_main.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include -#include - - -void setUp(void) { - // Optional: Code to run before each test -} - -void tearDown(void) { - // Optional: Code to run after each test -} - -/* -void test_addition(void) { - TEST_ASSERT_EQUAL(3, addi.add(1, 2)); // Test if 1 + 2 equals 3 - TEST_ASSERT_EQUAL(0, addi.add(-1, 1)); // Test if -1 + 1 equals 0 - TEST_ASSERT_EQUAL(-2, addi.add(-1, -1)); // Test if -1 + -1 equals -2 -} -*/ - -void RUN_UNITY_TESTS() { - UNITY_BEGIN(); - //RUN_TEST(test_addition); - UNITY_END(); -} - -void setup() { - // NOTE!!! Wait for >2 secs - // if board doesn't support software reset via Serial.DTR/RTS - delay(2000); - - RUN_UNITY_TESTS(); -} - -void loop() { - digitalWrite(13, HIGH); - delay(100); - digitalWrite(13, LOW); - delay(500); -} diff --git a/test/test_embedded/test_main.cpp b/test/test_embedded/test_main.cpp deleted file mode 100644 index ed909d5..0000000 --- a/test/test_embedded/test_main.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include - -void setUp(void) { - // Optional: Code to run before each test -} - -void tearDown(void) { - // Optional: Code to run after each test -} - -/* -void test_addition(void) { - TEST_ASSERT_EQUAL(3, addi.add(1, 2)); // Test if 1 + 2 equals 3 - TEST_ASSERT_EQUAL(0, addi.add(-1, 1)); // Test if -1 + 1 equals 0 - TEST_ASSERT_EQUAL(-2, addi.add(-1, -1)); // Test if -1 + -1 equals -2 -} -*/ - -void setup() { - // NOTE!!! Wait for >2 secs - // if board doesn't support software reset via Serial.DTR/RTS - delay(2000); - - UNITY_BEGIN(); - //RUN_TEST(test_addition); - UNITY_END(); -} - -void loop() { - digitalWrite(13, HIGH); - delay(100); - digitalWrite(13, LOW); - delay(500); -} \ No newline at end of file