speeduino/speeduino/cancomms.h

32 lines
1.1 KiB
C
Raw Normal View History

#ifndef CANCOMMS_H
#define CANCOMMS_H
Air Conditioning Control - Feature Implementation (#665) * 19.09.2021 * Final testing of AC Control, some idle features fixed AC control feature added, better than the existing idle-up feature (which can still be used for other things, e.g. electrical load detection). Air conditioning is locked out with coolant temp, RPM high/low, and high TPS. So the A/C automatically cuts out when driving hard. Idle step now works correctly with closed loop PWM, open loop PWM, and closed+open loop PWM. Untested with stepper motor, but no reason it shouldn't work. * Fixed mistakenly incremented page sizes * Initial changes as per HWright9 -Renamed engineRunSeconds to acAfterEngineStartDelay -Formatted large if statements better -Fixed acStartDelay overflow bug -Improved readability of logic * Final fixes as per HWright9's feedback -Add high/low RPM lockout delay, similar to the high TPM lockout delay -General tidy-up * Added stand-alone fan, moved config data in EEPROM -Added additional configurable stand-alone A/C fan output, for when there is dedicated cooling fan for the A/C compressor. This is independent of the engine cooling fan logic. -Moved config storage in EEPROM to configPage9, as noisymime's SD card logging has used the (previously unused) bytes I had used in configPage13. -Minor bug fix - rename Aux in 1-16 to Aux in 0-15 * Revert to current master branch - as of master commit 97f8ef795a514c9a5693e85be6cdb8bdee8ef2c5 * A/C Control Re-Integrated from AC-Control-Clean-3 (@Corey-Harding). Tested & ready to merge. Additionally, added @HazuTo25's lines into the update() routine to configure default A/C settings. * Changed updates.ino to just set A/C to disabled * Fix change reverted by mistake - master merge commit 73badbce8ca171faa8c58575947917829adfc1ba * Fix remaining mistakes from previous master merge * Remove test statements left in by mistake * define unusedBits * Remove test statements left in by mistake * Increase timing granularity to 0.1s * idleUpRPMAdder * Remove another line put in by mistake by auto merge * idleUpRPMFixes * Update speeduino.ino * Tweak A/C idle up descriptions * Tweak A/C TS descriptors again * Fixed alignment bug that turned page 15 config values into gobbledegook. This had the symptom of the A/C request never triggering, because when a pin was assigned in TS (e.g. I did 27), a completely different pin would be read from config15 (in my case 22 - connecting the button to pin 22 would work in this case, even though TS was set to 27). * Fix bit count - should be 6 to match ini file * Increase minimum RPM lockout granularity * Change granularity of A/C minimum RPM lockout to 10 RPM; Inline some functions for readability * Add static inline function prototypes to auxiliaries.h as per the style guide. * Fixed page 15 merge errors * Style changes to suit new pinIsUsed() checks in setPinMappings() * Add PWM Fan Control Minimum Clamp Value when A/C Compressor Engaged * Fix comment * Fix bug with stand-alone fan initialisation Pin was unable to be used in prog. I/O even if fan was disabled, because it was always initialised as an output even if it was disabled. Fixed in this commit. * Correction to Fahrenheit temperature scaling * Move A/C updates to correct next release Co-authored-by: shiznit304 <62686180+shiznit304@users.noreply.github.com> Co-authored-by: Josh Stewart <josh@noisymime.org>
2022-09-06 17:23:01 -07:00
#define NEW_CAN_PACKET_SIZE 123
2017-11-01 17:19:57 -07:00
#define CAN_PACKET_SIZE 75
#if ( defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) )
#define CANSerial_AVAILABLE
extern HardwareSerial &CANSerial;
#elif defined(CORE_STM32)
#define CANSerial_AVAILABLE
#ifndef HAVE_HWSERIAL2 //Hack to get the code to compile on BlackPills
#define Serial2 Serial1
#endif
#if defined(STM32GENERIC) // STM32GENERIC core
extern SerialUART &CANSerial;
#else //libmaple core aka STM32DUINO
extern HardwareSerial &CANSerial;
#endif
#elif defined(CORE_TEENSY)
#define CANSerial_AVAILABLE
extern HardwareSerial &CANSerial;
#endif
void secondserial_Command();//This is the heart of the Command Line Interpreter. All that needed to be done was to make it human readable.
void sendcanValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum);
void can_Command();
void sendCancommand(uint8_t cmdtype , uint16_t canadddress, uint8_t candata1, uint8_t candata2, uint16_t sourcecanAddress);
void obd_response(uint8_t therequestedPID , uint8_t therequestedPIDlow, uint8_t therequestedPIDhigh);
#endif // CANCOMMS_H