1. For downloading SimTools plugins you need a Download Package. Get it with virtual coins that you receive for forum activity or Buy Download Package - We have a zero Spam tolerance so read our forum rules first.

    Buy Now a Download Plan!
  2. Do not try to cheat our system and do not post an unnecessary amount of useless posts only to earn credits here. We have a zero spam tolerance policy and this will cause a ban of your user account. Otherwise we wish you a pleasant stay here! Read the forum rules
  3. We have a few rules which you need to read and accept before posting anything here! Following these rules will keep the forum clean and your stay pleasant. Do not follow these rules can lead to permanent exclusion from this website: Read the forum rules.
    Are you a company? Read our company rules

CarDashX : TM1638 sketch for GameDash

Discussion in 'Official Companion Apps' started by vthinsel, Aug 26, 2015.

  1. zigzag49

    zigzag49 Active Member

    Joined:
    May 27, 2014
    Messages:
    251
    Balance:
    563Coins
    Ratings:
    +220 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino
    Salut
    je ne trouve pas les lignes a changers dans le code pour la couleurs des leds et ne c'est pas si mon dash peu le faire , voici le modèle.

    Hello
    I do not find rows changed in the code for color LEDs and it's not so little do my dash, here the model.

    [​IMG]
  2. prodigy

    prodigy Burning revs

    Joined:
    Oct 27, 2013
    Messages:
    457
    Location:
    Croatia
    Balance:
    6,641Coins
    Ratings:
    +398 / 4 / -0
    My Motion Simulator:
    2DOF, 3DOF, AC motor, SCN5, JRK
    @zigzag49

    The code is changed, now you don't need to change the code, just press button number 5 - it will change the LEDs color.
  3. zigzag49

    zigzag49 Active Member

    Joined:
    May 27, 2014
    Messages:
    251
    Balance:
    563Coins
    Ratings:
    +220 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino
    Arfff mean that my dash is not compatible, I do not just change the color because instead of changing it turns off.
    He'll have to change the LEDs directly wanted by green.
    Thank you for your answer.
  4. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    377
    Location:
    FRANCE
    Balance:
    5,179Coins
    Ratings:
    +477 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Hum. If I remember, this kind of TM1638 module is only one color for the LEDS. You need to be carefull with the descritption of the product. Mine comes from dx.com
    As @prodigy says, you can defien how many leds you want to be red by pressing button 5.
  5. zigzag49

    zigzag49 Active Member

    Joined:
    May 27, 2014
    Messages:
    251
    Balance:
    563Coins
    Ratings:
    +220 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino
    That's what I thought, I'll change later.
    Its also explains why at each race beginning, I was forced to press the 5 button to reset the 8 red LEDs because the last was always off.
    Can you tell me or this may change in the code, to ensure that the 8 red LEDs light up either directly?
    Thank you

    C'est bien ce qu'il me semblai , je le changerai plus tard.
    Sa explique aussi pourquoi a chaque debut de course , j'etait obliger d'appuyer sur le bouton 5 pour remettre les 8 leds rouge car la derniere était toujours éteinte.
    Peut tu me dire ou cela peu ce changer dans le code , faire en sorte que les 8 leds rouge soit allumer directement?

    Merci
  6. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    377
    Location:
    FRANCE
    Balance:
    5,179Coins
    Ratings:
    +477 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    It is here :

    //Update LEDS
    switch (rpmstyle) {
    case 0:
    rpmleds = map(carrpm, 0, rpmmax * 1.1, 0, 10); // distributes the rpm level to the 8 leds + 1 for shift change
    break;
    case 1:
    rpmleds = map(carrpm, rpmmax * 0.75, rpmmax * 1.0, 0, 10); // display only 75%-100% RPM range for more accurate gear change
    break;
    }
    //LED coloring: two bytes RED/GREEN
    // 80 40 20 10 08 04 02 01
    for (i = 0;i < rpmleds;i++) {
    if (i>=(8-redleds) || rpmleds>=9)
    { //LED is red
    leds = leds + (1 << i+8);
    }
    else
    { // LED is green
    leds = leds + (1 << i);
    }
    #if defined DEBUG
    Serial.print("LED value: ");
    Serial.println(leds);
    #endif
    }


    rpmleds contain the number of LEDs to light. then we choose the color based on the number of wanted red leds.
    two bytes are needed : first (left) is for red leds, second (right) is for green leds.

    If your display has only one colour, replace the for loop with this simpler one:
    for (i = 0;i < rpmleds;i++) {
    leds = leds + (1 << i+8);
    leds = leds + (1 << i);
    }

    This will light everything possible (should produce some kind of orange in dual colour module)
    • Useful Useful x 1
  7. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    377
    Location:
    FRANCE
    Balance:
    5,179Coins
    Ratings:
    +477 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    You probably didnt install the lib correctly
    • Agree Agree x 1
  8. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    377
    Location:
    FRANCE
    Balance:
    5,179Coins
    Ratings:
    +477 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    • Agree Agree x 1
  9. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    377
    Location:
    FRANCE
    Balance:
    5,179Coins
    Ratings:
    +477 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    I'm still using 1.6.5 Maybe you didnt choose the correct arduino platform. Maybe the bootlaoder is corrupted, or maybe a faulty clone. Can't help more on that. Sorry.
    • Agree Agree x 1
  10. Kirk

    Kirk Member

    Joined:
    May 19, 2014
    Messages:
    92
    Occupation:
    Sr Software Engineer
    Location:
    Texas
    Balance:
    15,087Coins
    Ratings:
    +113 / 2 / -0
    My Motion Simulator:
    2DOF, DC motor
    In Arduino IDE, under "Tools" menu, ensure that both the "Programmer" and "Board" are set correctly.

    Sometimes, when you change the "Board" setting, it'll reset the "Programmer" setting, and then when you switch the "Board" back, it won't correctly update the "Programmer" portion. For most actual Arduino projects, "ArduinoISP" and "Arduino as ISP" are all but synonymous. Things get odd when dealing with "ARM" based Arduino projects, though.

    I too use 1.6.5, as the newer one has bugs related to ARM devices such as ESP8266 that haven't yet been resolved. Might I recommend that if you continue to experience issues, you try backing off to 1.6.5, if for no other reason than to rule out some bugs that are in the newest version?
  11. zigzag49

    zigzag49 Active Member

    Joined:
    May 27, 2014
    Messages:
    251
    Balance:
    563Coins
    Ratings:
    +220 / 2 / -0
    My Motion Simulator:
    2DOF, Arduino
    Thank you for your help all leds are ok but I'll have to buy the real TM1638 to enjoy.:cheers
  12. cazsan

    cazsan Member

    Joined:
    Oct 1, 2015
    Messages:
    40
    Occupation:
    Programmer
    Location:
    France
    Balance:
    410Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    Arduino
    Thank you for your code, I just wonder about the wires, If I well understand the TM1638 is pluged in pins 3, 4 and 5.
    As library constructor declares TM1638(byte dataPin, byte clockPin, byte strobePin, boolean activateDisplay, byte intensity) so 3 is DI0, 4 is clock and 3 is strobe?

    Edit: OK, get it to boot up (showing CardashX) but nothing in the game while pushing buttons... May I have miss any configuration?
    Last edited: Jan 18, 2016
  13. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    377
    Location:
    FRANCE
    Balance:
    5,179Coins
    Ratings:
    +477 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Which game ? Which Gamedash settings ? Gamedash shows good values ?

    Currently preparing a new version with I2C support. Took this opportunity to add ascii-art for pinout:
    +-----+
    +------------| USB |------------+
    | +-----+ |
    B5 | [ ]D13/SCK MISO/D12[ ] | B4
    | [ ]3.3V MOSI/D11[ ] | B3
    | [ ]V.ref ___ SS/D10[ ] | B2
    C0 | [ ]A0 / N \ D9[ ] | B1
    C1 | [ ]A1 / A \ D8[ ] | B0
    C2 | [ ]A2 \ N / D7[ ] | D7
    C3 | [ ]A3 \_0_/ D6[ ] | D6
    ESP-C4 | [X]A4/SDA D5[X] | D5 - TM1638 DATA
    ESP-C5 | [X]A5/SCL D4[X] | D4 - TM1638 CLOCK
    | [ ]A6 INT1/D3[X] | D3 - TM1638 STROBE
    | [ ]A7 INT0/D2[ ] | D2
    | [ ]5V GND[ ] |
    C6 | [ ]RST RST[ ] | C6
    | [ ]GND 5V MOSI GND TX1[ ] | D0
    | [ ]Vin [ ] [ ] [ ] RX1[ ] | D1
    | [ ] [ ] [ ] |
    | MISO SCK RST |
    | NANO-V3 |
    +-------------------------------+

    Edit: ASCII art not friendly with forum ....
  14. cazsan

    cazsan Member

    Joined:
    Oct 1, 2015
    Messages:
    40
    Occupation:
    Programmer
    Location:
    France
    Balance:
    410Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    Arduino
    I'm running the game dash with PCARS as game (well patched) game dash is showing values for dash #1 to #6 (almost).
    The display shows parameters such speed multiplier, number leds activated or selected state for display but it seems it never write values to tm1638..
  15. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    377
    Location:
    FRANCE
    Balance:
    5,179Coins
    Ratings:
    +477 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Check your serial output settings (port, speed) and the output settings
    upload_2016-1-19_9-32-52.png

    You can also use the arduino serial console and send data such as :

    The command will be processed when a new one starts. For example, RPM will be updated on the module once a new command such as S will start
    Serial data to start with max luminosity set (5), speed=95, RPM=4250, gear=2 (last caracter is to finish processing of RPM, can be anything except a digit)
    Y5S95G2R4250R

    If display is not updated using the console, it probably wont with the game launched either.
    • Useful Useful x 1
  16. cazsan

    cazsan Member

    Joined:
    Oct 1, 2015
    Messages:
    40
    Occupation:
    Programmer
    Location:
    France
    Balance:
    410Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    Arduino
    I tried to set values within the Game Dash interface to #1 interface but it did not updated the display. I'll try to send packets using arduino serial console at the end of the day to see if everything works as expected.
    Thank yet for support
  17. cazsan

    cazsan Member

    Joined:
    Oct 1, 2015
    Messages:
    40
    Occupation:
    Programmer
    Location:
    France
    Balance:
    410Coins
    Ratings:
    +7 / 0 / -0
    My Motion Simulator:
    Arduino
    I tried to move the wires with my hand to be sure there are no false contacts but nothing happens.
    Also, I tried to send packet through Arduino serial command and also nothing happens (the display still displays left & right selected state and parameters)..
    Here is really what's happening (yes, I've the 3641AH with red leds but updated the for loop with code shared previously).
  18. vthinsel

    vthinsel Well-Known Member

    Joined:
    Feb 20, 2015
    Messages:
    377
    Location:
    FRANCE
    Balance:
    5,179Coins
    Ratings:
    +477 / 1 / -0
    My Motion Simulator:
    3DOF, SCN6
    Hi !

    Arduino/TM1638 links look good as the display is updated with cardashx text. Good. Are you running a race or a practice session ? We noticed that the current plugin works only in practice session. I'm currently working on a new plugin based on UDP data sent by the game (PC/PS4/XBoxOne)
    Beside that, if when using the arduino console nothing is updated this means the problem is somewhere else. in the arduino code, uncomment the #define DEBUG line and upload the sketch. Then the console should be more interesting. Please note that running a game (PCars) with debug mode will fill the RX/TX buffer making the display behave strangely. DEBUG is to be used only with arduino console
    upload_2016-1-19_22-39-22.png
  19. martin falz

    martin falz Member

    Joined:
    May 13, 2015
    Messages:
    58
    Location:
    Deutschland
    Balance:
    188Coins
    Ratings:
    +11 / 0 / -0
    My Motion Simulator:
    2DOF, Arduino
    hi
    ihave the problem that the arduino make a problem by the sketch.
    i have the files from the first post.
    but when i will the sketch sent to the arduino than said he to me that:
    CarDashX:446: error: 'struct EEPROMClass' has no member named 'readByte'
    CarDashX:447: error: 'struct EEPROMClass' has no member named 'readByte'
    CarDashX.ino: In function 'void loop()':
    CarDashX:497: error: 'struct EEPROMClass' has no member named 'updateByte'
    CarDashX:498: error: 'struct EEPROMClass' has no member named 'updateByte'
    CarDashX:499: error: 'struct EEPROMClass' has no member named 'updateByte'

    What iss the problem what i have????
  20. Kirk

    Kirk Member

    Joined:
    May 19, 2014
    Messages:
    92
    Occupation:
    Sr Software Engineer
    Location:
    Texas
    Balance:
    15,087Coins
    Ratings:
    +113 / 2 / -0
    My Motion Simulator:
    2DOF, DC motor
    I think this might help:
    http://playground.arduino.cc/Code/EEPROMex
    Of particular note, "The library can be downloaded through the Arduino or PlatformIO library manager".
    There is a difference between the EEPROM library and EEPROMex library (which is a separate download).
    • Informative Informative x 1