Avatar for Mrbbp

Mrbbp

Member since Mar 2017 • Last active Jun 2017
  • 6 conversations
  • 28 comments

I'm newb with espruino, not with arduino, not with js...
But i'm not a coding ninja

Most recent activity

  • in Interfacing
    Avatar for Mrbbp

    i create a post in project category
    http://forum.espruino.com/conversations/­306572/

  • in Projects
    Avatar for Mrbbp

    with the fabulous help of @Gordon
    there is an example code for working with alfazeta 7x7 flipdots panel (around 80€ + shipping)

    /* 5 wires used on pin A8, B7, B6 + a RS485 module
    B6 -> DI from RS485 module
    B7 -> DE, RE pins
    A8 -> RO pin
    + GND
    + 5v
    */
    var TX_ENABLE_PIN = A8;
    var TX_PIN = B6;
    var cpt=0;
    
    var g = Graphics.createArrayBuffer(8,7,1);
    var text = "I love Espruino";
    
    function sendData() {
      if (cpt < -g.stringWidth(text))
        cpt = 7;
      g = Graphics.createArrayBuffer(8,7,1);
      g.setFontDennis8();
      g.drawString(text,cpt,0);
      Serial1.write([0x80,0x87,0xFF],g.buffer,­[0x8F]);
      cpt--;
    }
    
    function onInit() {
      require("FontDennis8").add(Graphics);
      Serial1.setup(9600,{tx:TX_PIN});
      digitalWrite(TX_ENABLE_PIN, 1);
      setInterval(sendData, 150);
    }
    

    and a video demo of code

  • in Interfacing
    Avatar for Mrbbp

    Thanks very much @Gordon

    I've use the digitalWrite(TX_ENABLE_PIN, 1)
    With higher than 9600 baud rate, some frame are lost and display do not completely refresh.
    It does not occur at 9600.

    Alfazeta display are compatible with espruino👏🏼🎉 and with a simple way...
    I love simple things.

  • in Interfacing
    Avatar for Mrbbp

    Ok it works, i've used your idea and tried with other value.
    For 9600 baud, i've added 13
    For 19200 baud, 7

    I'll try with a pin in high

  • in Interfacing
    Avatar for Mrbbp

    No oscilloscope :(
    i've tried with low baudrate: idem

  • in Interfacing
    Avatar for Mrbbp

    Sorry it does not work
    there is no callback on serial therefor you pulse on the TX_ENABLE_PIN ok.
    but initiate the serial with the TX pin ...
    i've tried this

    var TX_ENABLE_PIN = A8;
    var TX_PIN = B6;
    
    function sendData(data) {
        digitalPulse(TX_ENABLE_PIN,1, (data.length+1)*10/19200);
        Serial1.write(data);
        console.log("envoie data", data.toString());
    }
    
    function onInit() {
        Serial1.setup(19200,{tx:TX_PIN});
        setInterval(sendData, 2000, [0x80,0x87,0xFF,0x01,0x01,0x01,0x01,0x7F­,0x7F,0x7F,0x8F]);
    }
    

    is it good or i can't use serial1 with usb plugged?

  • in Interfacing
    Avatar for Mrbbp

    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](http://forum.espruino.com/sea­rch/?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](http://forum.espruino.com/sear­ch/?q=%23define) TX_ENABLE_PIN 3            // define the EIA-485 transmit driver pin
    [#define](http://forum.espruino.com/sear­ch/?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;}
    }
    
  • in Interfacing
    Avatar for Mrbbp

    @Gordon, the 7x7 display is around 80€ wo VAT + 23€ for shipping to France + paypal fee
    there is an USB version for 5€ more.

    the baud rate is 9600 or 19200, 38400, 57600 (physical dipswitch on the board)
    there is no fonts for the display, it's just a screen, you have to draw your font and convert char to bits

    by ex.
    Send all white dots to all connected panels (address 0xFF) and turn dots as soon as data is received.

    0x80 0x87 0xFF 0x7F 0x7F 0x7F 0x7F 0x7F 0x7F 0x7F 0x8F
    

    0x80: header
    0x87: command (show)
    0xff: address (panel)
    7 * 0x7f: display data "b01111111"
    0x8f: end char

    therefor your exemple need to be converted from hex value to 0/1.
    is it good way?

    parseInt(num, baseFrom).toString(baseTo);
    

    regards

    é.

Actions