You are reading a single comment by @Mrbbp and its replies. Click here to read the full conversation.
  • i do not put it online, for share (i'm lazy guy), i give it here...
    the code is a bit confuse... it show all the alphabet char...
    but draws a transition between chars (line by line with 20ms between each frame)...
    but sure the code is working and draws chars on flipdot :)

    [#include](https://forum.espruino.com/search/?q=%23include) <SoftwareSerial.h>
    
    int compteurG = 0;
    int compteur = 0;
    int a = 0;
    int ncar = 27;
    boolean drapo = false;
    byte lettreA[7], lettreB[7];
    
    // assemble message
    byte msg [11] = {
      0x80,    // start byte
      0x87,    // send byte and refresh
      0xFF,    // to all display adress
      0x01,    // first data thingy to display, is non printable ASCII
      0x01,
      0x01,
      0x01,
      0x01,
      0x01,
      0x01,
      0x8F     // end byte
    };
    
    byte charSet[][7] = {
      {0x0, 0x0, 0x18, 0x14, 0x14, 0x2e, 0x0},
    {0x8, 0x14, 0x14, 0xc, 0x34, 0xa, 0x0},
    {0x0, 0x0, 0x18, 0x4, 0x4, 0x3a, 0x0},
    {0x8, 0x8, 0x8, 0xc, 0xa, 0x1c, 0x0},
    {0x0, 0x0, 0x18, 0x1c, 0x4, 0x1a, 0x0},
    {0x10, 0x28, 0x18, 0x8, 0xc, 0xa, 0x4},
    {0x18, 0x1c, 0x10, 0x38, 0x14, 0x14, 0x8},
    {0x8, 0x14, 0x14, 0xc, 0x14, 0x32, 0x0},
    {0x8, 0x0, 0x8, 0x8, 0xc, 0x32, 0x0},
    {0x8, 0x0, 0xc, 0x8, 0x18, 0xc, 0xc},
    {0x0, 0x24, 0x14, 0xc, 0x14, 0x22, 0x0},
    {0x8, 0x14, 0x14, 0x14, 0x8, 0x34, 0x0},
    {0x0, 0x0, 0x0, 0x34, 0x2a, 0x2a, 0x0},
    {0x0, 0x0, 0x0, 0x18, 0x14, 0x36, 0x0},
    {0x0, 0x0, 0x58, 0x34, 0x24, 0x1a, 0x0},
    {0x0, 0x0, 0x1c, 0x14, 0x1e, 0x24, 0x4},
    {0x0, 0x0, 0x1c, 0x14, 0x3c, 0x12, 0x10},
    {0x0, 0x0, 0x1c, 0xc, 0xc, 0x37, 0x0},
    {0x0, 0x0, 0x8, 0x14, 0x12, 0x2c, 0x0},
    {0x8, 0x3c, 0x8, 0x8, 0x8, 0x34, 0x0},
    {0x0, 0x0, 0x0, 0x14, 0x14, 0x1e, 0x0},
    {0x0, 0x0, 0x0, 0x34, 0x14, 0xa, 0x0},
    {0x0, 0x0, 0x2a, 0x2a, 0x2a, 0x15, 0x0},
    {0x0, 0x0, 0x14, 0x8, 0x14, 0x22, 0x0},
    {0x0, 0xa, 0xa, 0xc, 0xc, 0xa, 0x4},
    {0x0, 0x0, 0x3c, 0x10, 0x8, 0x3c, 0x0},
      {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}
    };
    
    [#define](https://forum.espruino.com/search/?q=%23define) TX_ENABLE_PIN 3            // define the EIA-485 transmit driver pin
    [#define](https://forum.espruino.com/search/?q=%23define) LED_PIN 13
    
    // SoftwareSerial rs485(RO, DI);
    SoftwareSerial rs485(4, 2); // pins on rs485 module ->
    
    void setup() {
      pinMode(TX_ENABLE_PIN, OUTPUT);  // driver output enable
      rs485.begin (19200);              // vitesse com
      Serial.begin(9600);
      pinMode(LED_PIN, OUTPUT);
      // si pas de print softwareSerial ne fonctionne pas
      Serial.println("7x7 flipdots from Alfazeta");
    }
    
    void loop() {
      digitalWrite (TX_ENABLE_PIN, HIGH);     // enable transmit driver
      digitalWrite (LED_PIN, HIGH);
      
      // change les lettres tous les 7 tours
      // remplit les buffers de lettre pour anim de transition de caractère
      if (compteurG%7 == 0) {
        for (int i=0;i<7;i++){
          lettreA[i] = charSet[compteur%ncar][i];     // caractère avant
          lettreB[i] = charSet[(compteur+1)%ncar][i]; // caractère après
        }
        compteur++; // compteur du caractère à afficher dans charSet
      }
      
      for (int i = 3; i <= a%7+3; i++) { // nbr bits trame
        msg[i] = lettreB[i-3];
      }
      for (int i = a%7+4; i < 10; i++) { // nbr bits trame
        msg[i] = lettreA[i-3];
      }
      // envoie la séquence msg[] à l'afficheur
      for (int i = 0; i < 11; i++) {
        rs485.write(msg[i]);                // flip display print
        //Serial.print(msg[i],HEX);
        //Serial.print(" ");
      }
      //Serial.println();
      
      // gestion du buffer
      while (!(UCSR0A & (1 << UDRE0)))  // Wait for empty transmit buffer
        UCSR0A |= 1 << TXC0;  // mark transmission not complete
      while (!(UCSR0A & (1 << TXC0)));   // Wait for the transmission to complete
    
      digitalWrite(TX_ENABLE_PIN, LOW);       // disable transmit driver
      digitalWrite(LED_PIN, LOW);
    
      if (compteurG % 7 == 0) {
        // si lettre affichée au complet
        delay(700);
      } else {
        // si en cours de transition de lettre
        delay(20);
      }
    
      if (compteurG >= 7) { compteurG = 0; } else { compteurG ++;}
      if (a >= 7) { a = 0; } else { a ++;}
      if (compteur > ncar) { compteur = 0;}
    }
    
About

Avatar for Mrbbp @Mrbbp started