SlotForum banner
1 - 5 of 13 Posts

· Registered
Joined
·
230 Posts
I may not understand your issue completely but I would have thought that the simplest solution to your problem would be to move the LEDs around so that LED 0 is where LED 9 is and vice versa.

For the second issue, I have a feeling that there is a configuration screen for colour in the Arduino setup screens but I would need to check.

If not, you can definitely solve both problems in the sketch, if you know someone clever enough to programme it. I might be able to help but there is no guarantee that I could. I'm very much a 'press buttons until it works' type of programmer.
 

· Registered
Joined
·
230 Posts
Ok. A couple of things. Have a look at the Arduino configuration post that is pinned at the top of the Race Coordinator forum page. It is everything I have managed to find on RC and Arduino; and it also explains how I programmed the sketch for my requirements. It is NOT a masterclass in programming but it was how I got it to work. Dave tells me that there are several things wrong with it and he's the expert in it all, so if he pitches in with something, you know that it is correct.

Having looked at the sketch again, there is a section for configuration for fuel. This is the section:



case extFuel:
// Fuel
#ifdef WITH_FUEL_STUTTER
{
SERIAL_PRINTLN("*Got extFuel");

byte lane = inBuffer[2] TXT_TO_INT_CONVERSION;
if (lane < FUEL_NUM_LANES) {
byte level = inBuffer[3] TXT_TO_INT_CONVERSION;

SERIAL_PRINT("Got fuel for lane ");
SERIAL_PRINT(lane);
SERIAL_PRINT(" and value ");
SERIAL_PRINTLN(level);

if (level == 0 && !fuelOOF[lane]) {
// Assume power is on, setting time to 0 will cause it
// to turn off
fuelOOF[lane] = true;
fuelTimeUs[lane] = 0;
fuelPowerOn[lane] = true;
}
else if (level > 0) {
// This will turn power back on if its not already
fuelOOF[lane] = false;
}
}
}
#endif
break;

So, my reading of this is that you should be able to turn on your specific LEDs based on the value of 'level's. I'm guessing that those values range from 0 to 255, so, every time 'level' drops in value by 25(ish) another light goes off (or on). Eg if level == 255, then all 10 LEDs are lit; if level == 230, then light only 9, etc.

You should be able to figure out the way to light the correct LEDs from the code in the RaceState section, along the lines of this:


case 2:
// Initial countdown Start
{
lightOn = false;
int LED = 4 - (inBuffer[3] TXT_TO_INT_CONVERSION);
if (LED < 0)
{
for (int i = 0; i < 5; i++)
{
rgbLedStrings[0].leds = CRGB::Black;
rgbLedStrings[1].leds = CRGB::Black;
}
}
if (LED == 4)
{
rgbLedStrings[1].leds[4] = CRGB::Red;
rgbLedStrings[0].leds[4] = CRGB::Red;
}
if (LED == 3)
{
rgbLedStrings[1].leds[3] = CRGB::Red;
rgbLedStrings[0].leds[3] = CRGB::Red;
}
if (LED == 2)
{
rgbLedStrings[1].leds[2] = CRGB::Red;
rgbLedStrings[0].leds[2] = CRGB::Red;
}
if (LED == 1)
{
rgbLedStrings[1].leds[1] = CRGB::Red;
rgbLedStrings[0].leds[1] = CRGB::Red;
}
if (LED == 0)
{
rgbLedStrings[1].leds[0] = CRGB::Red;
rgbLedStrings[0].leds[0] = CRGB::Red;
}
}

break;

For the colour of the lanes, that (I think!) should be a lot simpler, as these will not change and are not dependent on any information coming from Race Coordinator. It should be a case of telling the Arduino which LEDs directly to light and with which colour. Eg if lane ==1 {rgbLedStrings[1].leds[10,11,12....19] = CRGB::Blue;} says, if lane 1, then set LEDs 10 to 19 to blue.

Have a look at this first and come back to me with any specific questions you have because I know how difficult it can be trying to interpret things that other people say, when they are generalising. I can't test this myself, as I don't have an analogue setup but I can perhaps give you some code and more pointers.

Connal
 

· Registered
Joined
·
230 Posts
You're welcome.

Rereading your post, I think the second part of my reply is probably not required. If I understand correctly, you want the colour of the fuel LEDs to be the colour of the lane. If that's so, then you will need to combine the lane and the level variables, to colour the LED of the lane. eg, if lane = 1 and value = 100, then light all the lane 1 LEDs red (assuming Dave is correct that the fuel range is 0-100 and not 0-255, as I said); if lane = 2 and value = 90, then light 9 of the 10 LEDs white.

If I get a chance I'll have a play, as well
 

· Registered
Joined
·
230 Posts
It would be the same. Once you go away from the built-in config of RC, then you have to use code: and to change the colour of the LEDs, you need to identify which lane and which LED you want to update. So, as far as the programming is concerned, it makes no difference if the order is 0 to 9 or 9 to 0.
 
1 - 5 of 13 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top