Prevent lockup if default values aren't set
This commit is contained in:
parent
a9d61fb01d
commit
61b6025351
|
@ -281,7 +281,7 @@ ISR(TIMER1_COMPA_vect)
|
|||
|
||||
void loop()
|
||||
{
|
||||
uint16_t tmp_rpm = 0;
|
||||
uint16_t tmp_rpm = currentStatus.base_rpm;
|
||||
/* Just handle the Serial UI, everything else is in
|
||||
* interrupt handlers or callbacks from SerialUI.
|
||||
*/
|
||||
|
@ -298,29 +298,32 @@ void loop()
|
|||
}
|
||||
else if (config.mode == LINEAR_SWEPT_RPM)
|
||||
{
|
||||
|
||||
if(micros() > (sweep_time_counter + config.sweep_interval))
|
||||
{
|
||||
sweep_time_counter = micros();
|
||||
if(sweep_direction == ASCENDING)
|
||||
{
|
||||
tmp_rpm = currentStatus.rpm + 1;
|
||||
tmp_rpm = currentStatus.base_rpm + 1;
|
||||
if(tmp_rpm >= config.sweep_high_rpm) { sweep_direction = DESCENDING; }
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp_rpm = currentStatus.rpm - 1;
|
||||
tmp_rpm = currentStatus.base_rpm - 1;
|
||||
if(tmp_rpm <= config.sweep_low_rpm) { sweep_direction = ASCENDING; }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (config.mode == FIXED_RPM)
|
||||
{
|
||||
tmp_rpm = config.fixed_rpm;
|
||||
}
|
||||
currentStatus.base_rpm = tmp_rpm;
|
||||
currentStatus.compressionModifier = calculateCompressionModifier();
|
||||
|
||||
currentStatus.compressionModifier = calculateCompressionModifier();
|
||||
if(currentStatus.compressionModifier >= currentStatus.base_rpm ) { currentStatus.compressionModifier = 0; }
|
||||
|
||||
setRPM( (currentStatus.base_rpm - currentStatus.compressionModifier) );
|
||||
}
|
||||
|
||||
|
@ -350,6 +353,10 @@ uint16_t calculateCompressionModifier()
|
|||
modAngle = crankAngle % 90;
|
||||
compressionModifier = pgm_read_byte(&sin_100_90[modAngle]);
|
||||
break;
|
||||
default:
|
||||
modAngle = (crankAngle % 180) ;
|
||||
compressionModifier = pgm_read_byte(&sin_100_180[modAngle]);
|
||||
break;
|
||||
}
|
||||
|
||||
return compressionModifier;
|
||||
|
|
|
@ -39,7 +39,6 @@ extern volatile uint16_t new_OCR1A;
|
|||
|
||||
bool cmdPending;
|
||||
byte currentCommand;
|
||||
uint16_t numTeeth;
|
||||
|
||||
//! Initializes the serial port and sets up the Menu
|
||||
/*!
|
||||
|
@ -117,8 +116,6 @@ void commandParser()
|
|||
break;
|
||||
|
||||
case 'P': //Send the pattern for the current wheel
|
||||
numTeeth = pgm_read_word(Wheels[config.wheel].wheel_max_edges);
|
||||
|
||||
for(uint16_t x=0; x<Wheels[config.wheel].wheel_max_edges; x++)
|
||||
{
|
||||
if(x != 0) { Serial.print(","); }
|
||||
|
|
|
@ -12,6 +12,7 @@ void loadConfig()
|
|||
//New arduino
|
||||
config.wheel = 5; //36-1
|
||||
currentStatus.rpm = 3000;
|
||||
currentStatus.base_rpm = 3000;
|
||||
config.mode = POT_RPM;
|
||||
|
||||
config.fixed_rpm = 3500;
|
||||
|
@ -63,6 +64,7 @@ void loadConfig()
|
|||
if(config.wheel >= MAX_WHEELS) { config.wheel = 5; }
|
||||
if(config.mode >= MAX_MODES) { config.mode = FIXED_RPM; }
|
||||
if(currentStatus.rpm > 15000) { currentStatus.rpm = 4000; }
|
||||
if(currentStatus.base_rpm > 15000) { currentStatus.base_rpm = 4000; }
|
||||
if(config.compressionType > COMPRESSION_TYPE_8CYL_4STROKE) { config.compressionType = COMPRESSION_TYPE_4CYL_4STROKE; }
|
||||
if(config.compressionRPM > 1000) { config.compressionRPM = 400; }
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue