OpenCores
URL https://opencores.org/ocsvn/openarty/openarty/trunk

Subversion Repositories openarty

[/] [openarty/] [trunk/] [sw/] [board/] [oledtest.c] - Diff between revs 36 and 39

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 36 Rev 39
Line 227... Line 227...
        if (w <  0) w = 0;
        if (w <  0) w = 0;
        if (h <  0) h = 0;
        if (h <  0) h = 0;
        if (c+w > 95) w = 95-c;
        if (c+w > 95) w = 95-c;
        if (r+h > 63) h = 63-r;
        if (r+h > 63) h = 63-r;
 
 
        // Enable a rectangle to fill
        // Enable the fill rectangle function, rather than just the outline
        while(sys->io_oled.o_ctrl & OLED_BUSY)
        while(sys->io_oled.o_ctrl & OLED_BUSY)
                ;
                ;
        sys->io_oled.o_ctrl = 0x12601;
        sys->io_oled.o_ctrl = 0x12601;
 
 
        //
        //
Line 250... Line 250...
        sys->io_oled.o_b = ((pix      ) & 0x01f)<<25;
        sys->io_oled.o_b = ((pix      ) & 0x01f)<<25;
        sys->io_oled.o_b|= ((pix >> 11) & 0x01f)<<17;
        sys->io_oled.o_b|= ((pix >> 11) & 0x01f)<<17;
        sys->io_oled.o_b|= ((pix >>  5) & 0x03f)<< 8;
        sys->io_oled.o_b|= ((pix >>  5) & 0x03f)<< 8;
        sys->io_oled.o_b|= ((pix      ) & 0x01f)<< 1;
        sys->io_oled.o_b|= ((pix      ) & 0x01f)<< 1;
 
 
        // Make certain we had finished with the port (we should've by now)
        // Make certain we had finished with the port
        while(sys->io_oled.o_ctrl & OLED_BUSY)
        while(sys->io_oled.o_ctrl & OLED_BUSY)
                ;
                ;
 
 
        // and send our new command.  Note that o_a and o_b were already set
        // and send our new command.  Note that o_a and o_b were already set
        // ahead of time, and are only now being sent together with this
        // ahead of time, and are only now being sent together with this
Line 265... Line 265...
        // is clear again.
        // is clear again.
        while(sys->io_oled.o_ctrl & OLED_BUSY)
        while(sys->io_oled.o_ctrl & OLED_BUSY)
                ;
                ;
}
}
 
 
 
/*
 
 * oled_show_image(int *img)
 
 *
 
 * This is a really simply function, for a really simple purpose: it copies
 
 * a full size image to the device.  You'll notice two versions of the routine
 
 * below.  They are roughly identical in what they do.  The first version
 
 * sets up the DMA to transfer the data, one word at a time, from RAM to
 
 * the OLED.  One byte is transferred every at every OLED interrupt.  The other
 
 * version works roughly the same way, but first waits for the OLED port to be
 
 * clear before sending the image.  The biggest difference between the two
 
 * approaches is that, when using the DMA, the routine finishes before the
 
 * DMA transfer is complete, whereas the second version of the routine
 
 * returns as soon as the image transfer is complete.
 
 */
void    oled_show_image(int *img) {
void    oled_show_image(int *img) {
#define USE_DMA
#define USE_DMA
#ifdef  USE_DMA
#ifdef  USE_DMA
                zip->dma.ctrl = DMACLEAR;
 
                zip->dma.rd = img;
 
                zip->dma.wr = &sys->io_oled.o_data;
 
                zip->dma.len= 6144;
                zip->dma.len= 6144;
 
                zip->dma.rd = img;
 
                zip->dma.wr = (int *)&sys->io_oled.o_data;
                zip->dma.ctrl = DMAONEATATIME|DMA_CONSTDST|DMA_OLED;
                zip->dma.ctrl = DMAONEATATIME|DMA_CONSTDST|DMA_OLED;
                // timer_delay(256);
 
                // zip_halt();
 
#else
#else
                for(int i=0; i<6144; i++) {
                for(int i=0; i<6144; i++) {
                        while(sys->io_oled.o_ctrl & OLED_BUSY)
                        while(sys->io_oled.o_ctrl & OLED_BUSY)
                                ;
                                ;
                        sys->io_oled.o_data = img[i];
                        sys->io_oled.o_data = img[i];
Line 396... Line 407...
                sys->io_oled.o_ctrl = 0x2015005f; // Sets column min/max address
                sys->io_oled.o_ctrl = 0x2015005f; // Sets column min/max address
 
 
                while(sys->io_oled.o_ctrl & OLED_BUSY)
                while(sys->io_oled.o_ctrl & OLED_BUSY)
                        ;
                        ;
                sys->io_oled.o_ctrl = 0x2075003f; // Sets row min/max address
                sys->io_oled.o_ctrl = 0x2075003f; // Sets row min/max address
 
                while(sys->io_oled.o_ctrl & OLED_BUSY)
 
                        ;
 
 
                // Now ... finally ... we can send our image.
                // Now ... finally ... we can send our image.
                oled_show_image(splash);
                oled_show_image(splash);
                wait_on_interrupt(SYSINT_DMAC);
                wait_on_interrupt(SYSINT_DMAC);
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.