Announcement

Collapse
No announcement yet.

uOLED 160-G2 and Electric Imp

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • uOLED 160-G2 and Electric Imp

    I'm using an Electric Imp to control the above display. I'm passing commands over a serial connection and ultimately want to display images from the uSD card.I'm having issues when I send some commands. The images and animation on the card display correctly using Serial Commander and in the Arduino environment (sending write commands in Hex rather than using the libraries)Running the following code on the Imp clears the display screen and logs an Ack response (6)
    HTML Code:
    //Code for CLS hardware.uart12.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS); server.log("begin code");  imp.sleep(3); hardware.uart12.write(0xFF);  //CLShardware.uart12.write(0xD7); imp.sleep(0.1);     local result = hardware.uart12.read();        if (result == -1) {        server.log("No data returned.");    } else {        server.log(result);    } server.log("code has run"); imp.configure("4D sytems", [], []);
    
     Running the following code results 'No data returned' being logged, however, the screen saver activates after 5 seconds and re-running the code results in an Ack response (6) being logged
    //Code to initialise SD card hardware.uart12.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS); server.log("begin code"); imp.sleep(3); hardware.uart12.write(0xFF); //Media inithardware.uart12.write(0xB1); imp.sleep(0.1);     local result = hardware.uart12.read();        if (result == -1) {        server.log("No data returned.");    } else {        server.log(result);    }server.log("code has run"); imp.configure("4D sytems", [], []);
    Running the following code to Set sector address at HIword 0x0000 LOword 0x0000 results in 'No data returned' logged, the screen saver stops due to serial communication but does not re-start after 5 seconds and the display requires a re-boot.

    //Code to set sector address hardware.uart12.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS); server.log("begin code"); imp.sleep(3); hardware.uart12.write(0xFF); //Set sector addresshardware.uart12.write(0xB8); hardware.uart12.write(0x00); //HIwordhardware.uart12.write(0x00); hardware.uart12.write(0x00); //LOwordhardware.uart12.write(0x00); imp.sleep(0.1); local result = hardware.uart12.read(); if (result == -1) { server.log("No data returned."); } else { server.log(result); } server.log("code has run"); imp.configure("4D sytems", [], []);

    I've tries putting in delays of up to 0.5 seconds between each serial write to try and solve this, but it made no difference. I have tried using just
    HTML Code:
    hardware.uart12.write(0xFF); //Set sector addresshardware.uart12.write(0xB8);
    
    without sending Hi & LOword parameters but always get 'No data returned' Can anyone make any suggestions?I've also tried the format
    
    hardware.uart12.write(0xFFB1); //Media init
    but it doesn't seem to make any difference. I've also tried swapping the MSB/LSB positions but this always produced 'No data returned'Any help appreciatedDougie

  • #2


    Different commands take different amounts of time to execute.

    Depending on the make/model of uSD card a media init could take almost a second to execute

    You need to write your code to take this into account.

    I'm not familiar with an Electric Imp, so I can't offer ideas on how easy/hard it may be to do that, but from what you've shown it looks like it is possible.
    Mark

    Comment


    • #3


      Hi Support, thanks for the response. I'll experiment with delays and see if it makes a difference.

      Dougie

      Comment


      • #4
        Hi SupportIt's all in the timings, as you say. It looks like my SD card needs half a second between pairs of writes in order to function properly. In addition if I choked the serial line and did a reset to clear it I was neglecting to do another Media Init before trying to Set Sector. The code below clears the screen and ultimately displays the image I select.I'll be working on this and will probably post again when it's more developed, the aim is to display images etc by selecting them from a web page. The server.log sections just let me know through the Imp interface that the code has started and ended, as well as getting an Ack indication.Thanks againDougie
        HTML Code:
        hardware.uart12.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS); //configure serial communications
        
        server.log("begin code");
        
        imp.sleep(3);
        
        hardware.uart12.write(0xFF); //CLS
        hardware.uart12.write(0xD7);
        
        hardware.uart12.write(0xFF); //Media init
        hardware.uart12.write(0xB1);
        
        imp.sleep(0.5)
        
        hardware.uart12.write(0xFF); //Set sector address
        hardware.uart12.write(0xB8);
        imp.sleep(0.5)
        hardware.uart12.write(0x00); //HIword
        hardware.uart12.write(0x00);
        imp.sleep(0.5)
        hardware.uart12.write(0x00); //LOword
        hardware.uart12.write(0x00);
        imp.sleep(0.5)
        
        hardware.uart12.write(0xFF); //Display image
        hardware.uart12.write(0xB3)
        imp.sleep(0.5);
        hardware.uart12.write(0x00); //x
        hardware.uart12.write(0x00);
        hardware.uart12.write(0x00); //y
        hardware.uart12.write(0x00);
        imp.sleep(0.1);
        
            local result = hardware.uart12.read();
            
            if (result == -1) {
                server.log("No data returned.");
            } else {
                server.log(result);
            }
        
        
        server.log("code has run");
        
        imp.configure("4D sytems", [], []);

        Comment

        Working...
        X