Commit Graph

363 Commits

Author SHA1 Message Date
tx_haggis f95b4978cd
Refactor comms: save 130+ bytes RAM (#906)
* Remove serialCRC - only used within parseSerial()
Also hoist the CRC read into a function.

* Minimize global variable visibility

* Encapsulate write of multi-byte primitives

* Factor out sendBufferAndCrc()

* Push safety test into TS_CommandButtonsHandler()

* Extract writePage()

* Simpler parsing

* Remove some functions from public interface

* Store constant arrays in progmem

* Centralize high speed logger start/stop code

* Factor out loadO2Calibration()

* Factor out temperature calibration table update functions

* Remove dead code

* Fix sendToothLog()

* Fix sendCompositeLog()

* Replace tooth log send booleans with an enum
Saves a byte

* Remove sendBufferAndCrcProgMem()
Use serialPayload to send

* Whitespace clean up

* Optimize comms.cpp for size

* Replace global unsigned long with bool
Saves 2 bytes

* Replace 2 global bools with an enum
Saves a byte, reads better.

* Remove global FastCRC instance

* Make sendSerialReturnCode blocking.
It was using non-blocking functions but was never
re-entered.
Rename to make blocking & non-blocking calls
more obvious.

* Use one uint16_t to track RX/TX byte count

* Simplify new comms log tx API

* Extract loadPageToBuffer function

* All endianess changes use the same code

* Doxygen comments and code organization

* Remove serialWriteUpdateCrc() & updateTmpCalibration()

* Combine SerialStatus & logSendStatus enums.
Makes sense since we can only be doing one thing at a time.

* Remove global inProgressCompositeTime
Only used when sending composite log

* Replace 3 global bools with expanded SerialStatus enum

* Remove unused global tsCanId

* Limit scope of some comms globals.

* Remove isMap global - replace witth function

* Reduce the serial API to only 2 calls
transmit & receive

* Tidy up #define visibility

* Fix Black* build errors

* Workaround Teensy code race condition
availableForWrite() is not reliable.

* Prevent race condition
Was pematurely setting the serialStatusFlag to
SERIAL_INACTIVE before final CRC ws read from
serial.

* Use post write buffer availability checks
Remove buffer size check prior to writing.

* Write multi-byte values as single bytes.
(attempt to fix Teensy 3.5 issue)

* Only use Serial.available() as a boolean test
(Teensy fix)

* writeNonBlocking checks Serial.write() return value

* Non-blocking CRC write
In sendBufferAndCrcNonBlocking().

* Fix compile warning

* Set serial status flag prior to transmitting!

* Reliable blocking byte writes.

* Fix timeout code: not firing under some conditions

* MISRA fixes
2023-02-21 12:55:54 +11:00
DeionSi 2312102d4b
Replace 8 channelXInjEnabled variables with 1 (#1001) 2023-02-06 11:48:11 +11:00
Pasi Kemppainen f59d013714
Add deceleration enleanment feature (#939)
* Add decel enleanment feature

* Fix tps and map DOT scaling in TS.

* updates.ino

* Small bug fix.

* One more small bug fix.

* Update cancomms.ino

Cast tps/mapDOT as uint8 to cancomms to retain backwards compatibility

* Fix programmable outputs list.

* Fix programmable outputs in updates.ino

* Add abs around currentStatus.mapDOT
2022-12-14 11:17:47 +11:00
Josh Stewart 22d2b4e38e Add delay to oil pressure engine protection 2022-11-23 16:15:01 +11:00
Vitor Moreno B. Sales 8e2fb0b36e
Added possibility to configure Steper bounds (#930)
Previous bounding worked only for PWM
2022-11-07 13:52:04 +11:00
Afroboltski 75d6c2ff61
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 97f8ef795a

* 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 73badbce8c

* 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-07 10:23:01 +10:00
Josh Stewart 739dc06f24 Add option to specify min absolute delta values for AE 2022-08-30 11:23:25 +10:00
Josh Stewart c129fa3326 Add option for SD logging with external switch 2022-07-08 14:31:48 +10:00
Vitor Moreno B. Sales adaa6a227e
Enable use of disabled functions pins (#549)
* Enable use pins of disabled functions or unused ign channels

* Added new pins and functions to check
2022-06-29 16:37:50 +10:00
Daniel Tobias 540b3a4fa2
Correct typos found by codespell (#880) 2022-06-27 10:39:14 +10:00
larmicfre ae3347f571
Fixed value mode for AFR protection (#877) 2022-06-27 09:21:11 +10:00
larmicfre 298d994ba1
AFR protection function (#861)
* Implementing AFR protection

* Update globals.h

* Bug fixes and code refactoring

* Moved variables to prevent ODR

* Dialog for AFR protection

* Data size and math corrections

* Possibility to use either AFR or lambda

* Updated default AFR protection values

* No need to do multiplications due to existing RPMdiv100 variable

* The X100 multiplier was wrongfully removed

* Add defaults in updates.ino, minor formatting cleanups

Co-authored-by: Josh Stewart <josh@noisymime.org>
2022-06-20 09:52:07 +10:00
Tjeerd 20c5e17756
Improve closedloop boost control (#736)
* First try on updating closedloop boost control

* added eeprom updates for backward comp[atibility

* fix merge conflict

* Change updates to next release EEPROM version.

* Fix some issues after merging master

* some cleanup to minimize changes and speedup review

* cleanup updates

* chances on updates to alaign with new table format

* move LUT to new config page in eeprom

* little cleanup

* Update storage.h comments

* fix some ini warnings

Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
2022-06-03 15:44:09 +10:00
Josh Stewart 3bd945f546 Add unit test for basic TAE 2022-05-25 11:02:55 +10:00
Pasi Kemppainen d7ccf4945b
Added option to fix tacho signal to coil dwell (#825)
* Add dwell fixed tacho option

* Better implentation

Added description to TS. Removed code duplication and unnecessary if's.

* Resolve conflicts and minor changes to wording on this option

Co-authored-by: Josh Stewart <josh@noisymime.org>
2022-05-24 14:29:38 +10:00
Pasi Kemppainen af5272b74c
[WIP] CAN broadcasting menu (#639)
* Add CAN broadcasting menu

* Fix updates.ino

* Remove use of floats and few other fixes.

* Fix building.

* Change updates.ino up to date.
2022-04-21 16:33:10 +10:00
Pasi Kemppainen 5dee6135b7
PWM and on/off idle fixes/cleanup (#806)
* Idle fixes #1

* Idle fixes #2

Co-authored-by: Josh Stewart <josh@noisymime.org>
2022-04-12 10:23:18 +10:00
tx_haggis 7933bb68c4
Remove previousLoopTime - never used (#706) 2022-04-11 14:16:26 +10:00
Daniel Tobias 7020705dbe
fix typos in code documentation (#816)
* fix typos in code documentation

* minor reverts

* fix typos in ini

Co-authored-by: Josh Stewart <josh@noisymime.org>
2022-04-11 10:49:58 +10:00
Josh Stewart f55789e5a3 Reorganise Engine Protection UI 2022-04-10 09:07:21 +10:00
Vitor Moreno B. Sales 9c3f745c16
All tapers use byte counters (#746)
Fixes

Update idle.ino
2022-04-05 07:27:54 +10:00
Josh Stewart beedfb44e4 Add 4cyl semi-seq injector pairing option 2022-03-18 09:45:07 +11:00
Josh Stewart 738ae2ed93 Add indicator showing when an EEPROM burn is in progress 2022-02-24 10:22:28 +11:00
tx_haggis fc9967e31d
Performance: optimize fuel trim PW calcs (#756)
* Consistent set of div100 functions

* Add typedef for trimTable3d

* Performance: use div100() function
when applying fuel trim corrections

* Silly ARM compiler!

* Unit test fixes

* Fix tests: expected & actual parameters were swapped

* div100(): add 8-bit overloads for completeness

* Fix unit tests
1. Force call to correct div100() overload
2. Use appropriately typed assertion

* Restore use of USE_LIBDIVIDE preprocessor symbol

* Add div360() - encapsulate libdivide use

* Fix copy/paste issue.
2022-02-18 14:55:43 +11:00
Benas Brazdziunas 07a4d1ea79
Coolant/RPM Protection (#785)
* Coolant/RPM Protection

* removed test  clear flash option

* Add new update section for coolantProtEnbl rather than using old area

Co-authored-by: Benas <bbrazdziunas@gavea.co.uk>
Co-authored-by: Josh Stewart <josh@noisymime.org>
2022-02-14 10:41:58 +11:00
Josh Stewart c6a37f7347 Implement tableCrcCommand command. Fixes #786 until TS 3.1.07.1 is released
The tableCrcCommand is used by TS to determine what calibrations (IAT, CLT and O2) are currently on the board. This is an optional command, however v3.1.07 unintentionally assumed it was implemented on all boards and gave a 'null' error if the command was not present.
This adds the command for all future versions, but previous releases will need to wait for theTS fix release
2022-02-07 11:05:41 +11:00
Josh Stewart e2dd7a388e Fix for O2 calibration not working on mega2560 2022-01-09 17:05:05 +11:00
Josh Stewart 4e00f12415 Fix for boost PWM output not working correctly at 100% DC 2022-01-04 22:58:44 +11:00
Josh Stewart bd9d59a145 Fixes to 202201 update routine 2022-01-04 12:19:58 +11:00
tx_haggis be0f2c69c7
Add table2d tests (#748)
* Improve native debug experience

* Add unit tests for table2d
2021-12-23 15:07:38 +11:00
Vitor Moreno B. Sales d9bde09f5e
Enabled softRevLimit time limit (#602)
Co-authored-by: Josh Stewart <josh@noisymime.org>
2021-12-22 13:29:13 +11:00
Josh Stewart 30e566068c Remove extra tooth log buffer definition. Slight RAM free up 2021-12-21 12:54:38 +11:00
Josh Stewart 809fd9d55b New Comms Tooth and Composite loggers 2021-12-20 16:22:23 +11:00
Corey Harding b419f15a32
Add Radiator Cooling Fan indicator (#719). Fixes #716
* Update auxiliaries.ino

Add Radiator Fan Status Indicator Changes

* Update globals.h

Add Radiator Fan Status Indicator Changes

* Update cancomms.ino

Add Radiator Fan Status Indicator Changes

* Update speeduino.ini

Add Radiator Fan Status Indicator Changes

* Update speeduino.ini

Simplify Naming

* Update auxiliaries.ino

Simplify Naming

* Update cancomms.ino

Simplify Naming

* Update globals.h

Simplify Naming

* Update speeduino.ini

Enable Datalogging of Radiator Cooling Fan Status

* Update auxiliaries.ino

Remove old instances of fanOn

* Update globals.h

Remove old instances of fanOn

* Update auxiliaries.ino

Correct formatting

* Update auxiliaries.ino

formatting

* Update auxiliaries.ino

formatting

* Update auxiliaries.ino

formatting

* Update auxiliaries.ino

formatting

* Update auxiliaries.ino

formatting

Co-authored-by: github-account-0 <91717711+github-account-0@users.noreply.github.com>
2021-11-26 10:28:53 +11:00
Pasi Kemppainen e213f2534e
PWM Fan addition (#637)
* Added PWM Fan functionality

PWM Fan output for Teensy and STM32

* Teensy3.5 timer fix for PWM Fan.

* Fix the conflicts with incorporate AFR

* Possibility to use PWM fan on mega too

Not tested at this stage!! Do not merge yet.

* Fix log entry size

* Remove duplicate stuff and use same way off toggling fan

* Fix typo errors

* Move fan pin definitions to globals.h

* Fix problems related to PWM fan.

* Revert previous change.

* Fix problems with idle things

* fix idle duty getting stuck at 100%

* Revert "fix idle duty getting stuck at 100%"

This reverts commit 7e9779483b.

* Revert "Fix problems with idle things"

This reverts commit 8bccb56d9a.

* Revert "Revert previous change."

This reverts commit fcb962864a.

* Remove mega support

* fixes

* more fixes

* moar fixes

* Should be working now

* Update speeduino.ini

* Lots of tweaking

* Update to work better with current FW

* Fix compiler warnings and include update things.

* Minor fixes

* Update logger.ino

* Fan duty working on mega too and fan output will be on/off

Co-authored-by: Pasi Kemppainen <pazi88@users.noreply.github.com>
2021-11-24 12:18:41 +11:00
Josh Stewart 4e15c77c00 Fix broken Teensy 4.1 build 2021-11-20 08:39:38 +11:00
Josh Stewart db2e667abb Initial work on new serial comms (Disabled in ini) 2021-11-19 11:07:38 +11:00
tx_haggis 5ed9ec3ca9
Reduce 3d table memory usage (>500 bytes) (#662)
* Use table_row_iterator_t to adjust ignitionTable

* Separate 2d & 3d table code, abstract page to table iterator conversion.

This is just moving code around in preparation for future changes.

* Reduce table RAM (.bss) usage

Generate a separate type for each possible
3d axis & size combination.

This turns what was runtime information into
compile time data.

* Save 1 byte per table.

Use a flag value (INT16_MAX) instead of a separate boolean
flag

* File renaming

table_iterator -> table3d_iterator.h
table3d.h -> table3d_interpolate.h
table3d.cpp -> table3d_interpolate.cpp
table3d_types.h -> table3d.h

* Optimize page.cpp: reduce code clutter, maintain performance

* Reduce flash usage

* Encapsulate table metadata

* Performance - hoist if statement

* Replace function with macro

* Use a packed enum as a type identifier

Use a packed enum as a type identifier

Slimmer data types

* Use table iterators for random access to table
values and axis.

* Centralize write buffer check

* Encapsulate 16-bit reference concept

* Performance: make table iterators proper classes

This allows us to chain calls on temporaries - not possible
with regular function calls.

* Performance: encapsulate EEPROM update
& address increment

* Save flash - don't duplicate function

* Performance: directly invalidate table cache

* Separate out iterator reversal

* Separate out entity mapping & per-byte access

Much faster, smaller code footprint & easier to understand

* Code quality fixes

* Separate out axis metadata

* Doxygen comments

* Separate int16_ref into separate file

* Separate out table axies & values into separate types

No need for metadata types & more localised code.
E.g. creating iterators is now alongside the data over
which they iterate.

* Doxygen
2021-11-18 11:30:29 +11:00
DeionSi 366f720455
Ignition advance range changes (#701)
* Signed int8 for fixed crank angle (range -10to80)

* Limit ignition advance in tables to 70 and use different range for multiplied

* Limit WMI and Nitrous ign adv to reasonable values

* Fix IAT timing retard table

* Don't let IAT retard correction set a fixed advance. No other correction does this and this fixed correction can be changed by other corrections. Also the current code is not working as ignition offset is not used for IAT retard.
2021-11-09 07:57:15 +11:00
Daniel Tobias 03650d80eb
Doxygen fixes (#689)
* doxygen warning fixes

* run doxygen -u, add speeduino logo to src tree for doxygen

* increase DOT_GRAPH_MAX_NODES

so we generate the complete call graph for loop() and setup()
2021-10-21 08:03:29 +11:00
Josh Stewart ef59fbabf0 First complete (Basic!) SD logging 2021-10-13 17:10:05 +11:00
Josh Stewart 793482a27b Big chunk of SD logging work. 2021-10-13 11:53:46 +11:00
Josh Stewart 93de5eecda Initial work on common SDFat library.
Implements much of the layout and settings from #543
2021-10-04 00:09:53 +11:00
shiznit304 a7281808a6
camelCaseFix (#643) 2021-09-17 00:07:54 +10:00
Vitor Moreno B. Sales b0e311b3e4
202108 fixes (#659)
Added correct pin out for SPI flash using BlackPill

Fix fsIntIndex size
2021-09-14 11:23:32 +10:00
shiznit304 46e0742b79
Added VVT Min Coolant Condition (#649)
The VVT Minimum coolant condition

Update auxiliaries.ino

Co-authored-by: Josh Stewart <josh@noisymime.org>
2021-09-10 16:34:19 +10:00
Vitor Moreno B. Sales b5c6127028
Add delay option for idle advance (#601)
* Make idle advance respect delay

Also increased resolution to half second.

Remove code duplication, removed unnecessary math

* Add a new configurable delay

* Fix copy paste error

Co-authored-by: Josh Stewart <josh@noisymime.org>
2021-07-19 18:03:07 +10:00
Vitor Moreno B. Sales cd9092517c
Allow negative angle on flat shift (#600) 2021-07-19 09:35:42 +10:00
Vitor Moreno B. Sales 118e3d40a5
Enhanced programmable outputs (#589)
* Enhanced programmable outputs

Added possibility to set minimum programmable output time.

Added names for the comparators to make it more user friendly, TS will complain about the change for existing tune.

Added more possibilities

Added possibility to set a minimum or a maximum output time

Added possibility to combine any number of rules or all of them

I got a lot of requests for this feature.

Keeps the RAM usage the same.

fix

* Fixed maximum timing

* Fix STM32 build
2021-07-19 09:11:04 +10:00
Pasi Kemppainen 0e3514980e
Add RPM switch point for instantaneous map sample method. (#572)
* Add RPM switch point for instantaneous MAP reading

* Add descriptions and other stuff to make PR

* Add suggested changes

* Use RPMdiv 100 for reading switch point

Co-authored-by: Josh Stewart <josh@noisymime.org>
2021-07-19 09:07:44 +10:00