Members | Sign In
Chippernut Forums > Shift Light v2.4
avatar

Multiple shift points?

posted Aug 29, 2016 01:33:21 by LuxLuxmykanthan
Is it possible to set two shift points rather than 1?
1 shift point for ideal RPM and 2nd for redline?
[Last edited Aug 29, 2016 01:33:34]
page   1
1 reply
avatar
Jonduino said Aug 29, 2016 21:06:37
Yes --

https://github.com/chippernut/ShiftLightV2_41/blob/master/ShiftLightV2_41.ino

Check out line #350 in the code. This initiates the evaluation of the current RPM against the stored "Shift RPM" you setup in the menu. Lines 350 - 372 evaluate when the current RPM is lower than the shift RPM. Lines 373 - 390 are what happens as soon as you go over the "SHIFT RPM" --

if (rpm < shift_rpm){
... All the code regarding gradation of the pixels goes here.

} else {

unsigned long currentMillis = millis();

if(currentMillis - previousMillis > shiftinterval) {
previousMillis = currentMillis;
flashbool = !flashbool;

if (flashbool == true)
for(int i=0; i<NUMPIXELS; i++) {
strip.setPixelColor(i, flclr1);
}
else
for(int i=0; i<NUMPIXELS; i++) {
strip.setPixelColor(i, flclr2);
}
strip.show();
}




So, you'd have to modify and add another condition to this IF statement... and add another variable into the mix.. The easiest way is to hard-code it, more complicated is to create a new menu item and make it configurable through the menu system, which isn't terrible.. but time consuming.

In the below (UNTESTED) example, when the rpm gets above 4500 rpm, it will turn all LEDs a solid color (the first shift color assigned in menu), when rpm gets above the SHIFT RPM, it flashes the shift-colors as normal.



if (rpm < shift_rpm && rpm < 4500){
// ... All the code regarding gradation of the pixels goes here.

} else if (rpm < shift_rpm && rpm > 4500){

//... Hard-coded "ideal" shiftpoint

for(int i=0; i<NUMPIXELS; i++) {
strip.setPixelColor(i, flclr1);
}
strip.show();


} else {

unsigned long currentMillis = millis();

if(currentMillis - previousMillis > shiftinterval) {
previousMillis = currentMillis;
flashbool = !flashbool;

if (flashbool == true)
for(int i=0; i<NUMPIXELS; i++) {
strip.setPixelColor(i, flclr1);
}
else
for(int i=0; i<NUMPIXELS; i++) {
strip.setPixelColor(i, flclr2);
}
strip.show();
}




Login below to reply: