Hi gang,
I've got this code that does a lot of stuff, running on a '1284P.
Having a problem getting it to compile. Seems to be related to a couple of lines in one tab that convert a floating point number into an array. I need it as an array so it can be sent to a GPS/GSM module to send out as a text message.
I have the same formatting in two tabs. One place it works as expected, the other it does not.
In d2_volts_pressure, 3 instances of this:
float v1 = analogRead (v1Pin) * (5 / 1023.) * 10.0904; // check voltage divider nominal level 48v
//Serial.print ("v1 (48V, need >47V to be good, and not fall below 44V) = ");
//Serial.println (v1);
v1int = (unsigned int)(v1 * 100.0); // assuming v1int will have 4 digits
String tempConv1 = String(v1int); // construct string representation
tempConv1.toCharArray(v1char, 5); // string representation is 4 chars plus null terminator, copy 4 characters, ignore null terminator
and also this
pressureint = (unsigned int)(pressure * 10.0); // assuming v1int will have 4 digits
String pressureConv = String(pressureint); // construct string representation
pressureConv.toCharArray(Pressurechar, 5); // string representation is 4 chars plus null terminator, copy 4 characters, ignore null terminator
Those all convert fine and get texted out okay as values like 15.47, 12.38, 47.25 for the first 3, and 150.0 for the pressure.
In the d4_temp0_2 tab, I've got the same thing 3 more times, attempting to send out values like 125.0 and 250.0
temp0Int = (unsigned int)(TemperatureF0 * 10.0); // assuming TemperatureF will have 4 digits
String heatConv0 = String(temp0Int); // construct string representation
heatConv0.toCharArray(TemperatureF0char, 5); // string representation is 4 chars plus null terminator, copy 4 characters, ignore null terminator
When the d4 tab is commented out, everything runs great.
When the tab is left in, I get this set of errors in IDE 1.0.6 and a similar set in 1.6.9:
d4_temp0_2.ino: In function 'void loop()':
d4_temp0_2:160: error: jump to case label
d4_temp0_2:155: error: crosses initialization of 'String heatConv0'
d4_temp0_2:313: error: jump to case label
d4_temp0_2:308: error: crosses initialization of 'String heatConv1'
d4_temp0_2:155: error: crosses initialization of 'String heatConv0'
and in 1.6.9:
C:\Users\CrossRoadsFencing.CrossRoads\Documents\ArduinoStuff\Tom Bijou 1284P truck controller\Controller2Rev16e\d4_temp0_2.ino: In function 'void loop()':
d4_temp0_2:160: error: jump to case label [-fpermissive]
case 4:
^
d4_temp0_2:155: error: crosses initialization of 'String heatConv0'
String heatConv0 = String(temp0Int); // construct string representation
^
d4_temp0_2:313: error: jump to case label [-fpermissive]
case 5:
^
d4_temp0_2:308: error: crosses initialization of 'String heatConv1'
String heatConv1 = String(temp1Int); // construct string representation
^
d4_temp0_2:155: error: crosses initialization of 'String heatConv0'
String heatConv0 = String(temp0Int); // construct string representation
^
Using library SPI at version 1.0 in folder: C:\Arduino 1.6.9\hardware\arduino\avr\libraries\SPI
exit status 1
jump to case label [-fpermissive]
Any ideas on how to fix this? I've tried making all the variables unique, even the case statement numbering (hence 4-5-6 vs 1-2-3, altho the code is in different switch:case areas and shouldn't matter), nothing I can think of helps.
Thanks
Controller2Rev16f.zip (15.4 KB)