示例#1
0
/**
 * Fill a box on the lcd
 *
 * @param  sx     Start X
 * @param  sy     Start Y
 * @param  ex     End X
 * @param  ey     End Y
 * @param  color  Color
 */
void lcd_box( char sx, char sy, char ex, char ey, char color )
{
    spi_command( CASET );
    spi_data( sx );
    spi_data( ex );

    spi_command( PASET );
    spi_data( sy );
    spi_data( ey );

    spi_command( RAMWR );
    int len = ( ( ex - sx ) * ( ey - sy ) ) * 2;

    for ( int i = 0; i < len; i++ )
    {
        spi_data( color );
    }
}
示例#2
0
void N6100LCD::set_pixel(uint8_t x, uint8_t y, uint16_t color)
{
    set_area(x, y, x, y);

    spi_data((color >> 4) & 0xFF);
    spi_data(((color & 0x0F) << 4));
    spi_cmd(NOP);

    spi_flush();
}
示例#3
0
/**
 * Initialize the lcd
 */
void lcd_init()
{
    enable_lcd();

    setPin( LCD_PORT, LCD_RST, 0 );
    setPin( LCD_PORT, LCD_RST, 1 );
    ROM_SysCtlDelay( 500 );

    spi_command( SLEEPOUT );
    spi_command( BSTRON );
    spi_command( COLMOD );

    spi_command( MADCTL );
    spi_data( 0xC0 );

    spi_command( SETCON );
    spi_data( 0x40 );
    spi_command( DISPON );
    setPin( LCD_PORT, LCD_CS, 0 );

    lcd_clear();
}
示例#4
0
    //row&=7;
    //spi_command(0x80); //column
    //spi_command(0x40|row); //row
    //rc=0;
    //for(ra=0;ra<11;ra++)
    //{
        //if(s[ra]==0) break;
        //for(rb=0;rb<8;rb++)
        //{
            //rd=s[ra];
            //spi_data(fontdata[rd][rb]);
            //rc++;
        //}
    //}
    //for(;rc<84;rc++) spi_data(0);
//}
//------------------------------------------------------------------------
void show_time ( void )
{
    unsigned int ra;
    unsigned int rb;
    unsigned int rc;
    unsigned int rd;
    unsigned int re;
    unsigned int rf;

    uart_putc(0x30+(tim[0]&0xF));
    uart_putc(0x30+(tim[1]&0xF));
    uart_putc(0x30+(tim[2]&0xF));
    uart_putc(0x30+(tim[3]&0xF));
    uart_putc(0x0D);
    uart_putc(0x0A);

    
    for(rb=0;rb<5;rb++)
    {
        spi_command(0x80); //column
        spi_command(0x40|rb); //row
        if(tim[0]==0) re=0x00;
        else          re=0xFF;
        for(rf=0;rf<6;rf++) spi_data(re);
        for(rf=0;rf<6;rf++) spi_data(0x00);
        for(ra=1;ra<4;ra++)
        {
            rc=clockdata[tim[ra]][rb];
            for(rd=0x8;rd;rd>>=1)
            {
                if(rc&rd) re=0xFF;
                else      re=0x00;
                for(rf=0;rf<6;rf++) spi_data(re);
            }
        }
        //for(rf=0;rf<0x1000;rf++) dummy(rf);
    }
   
}
示例#5
0
void N6100LCD::draw_hline(uint16_t c, uint8_t x, uint8_t y, uint8_t width)
{
    if (width<1 || width>ROW_LENGTH) return;
    set_area(x, y, x+width-1, y);

    for (uint8_t i=0; i<width; ) {
        i += 2;
        spi_data(( c&0xFF0)>>4);                 // R1G1
        spi_data(((c&0x00F)<<4)|((c&0xF00)>>8)); // B1R2
        spi_data(  c&0x0FF );                    // G2B2
    }

    spi_flush();
}
//non-inlined version of rfm12_data
//warning: without the attribute, gcc will inline this even if -Os is set
static void __attribute__ ((noinline)) rfm12_data(uint16_t d) {
	SS_ASSERT();
	#if !(RFM12_SPI_SOFTWARE)
		SPDR = d >> 8;
		while (!(SPSR & (1<<SPIF)));

		SPDR = d & 0xff;
		while (!(SPSR & (1<<SPIF)));
	#else
		spi_data(d >> 8);
		spi_data(d & 0xff);
	#endif
	SS_RELEASE();
}
//non-inlined version of rfm12_read
//warning: without the attribute, gcc will inline this even if -Os is set
static uint16_t __attribute__ ((noinline)) rfm12_read(uint16_t c) {
	uint16_t retval;
	SS_ASSERT();

	#if !(RFM12_SPI_SOFTWARE)
		SPDR = c >> 8;
		while (!(SPSR & (1<<SPIF)));
		retval = SPDR << 8;
		SPDR = c & 0xff;
		while (!(SPSR & (1<<SPIF)));
		retval |= SPDR;
	#else
		retval = spi_data(c >> 8);
		retval <<= 8;
		retval |= spi_data(c & 0xff);
	#endif
	SS_RELEASE();
	return retval;
}
示例#8
0
//------------------------------------------------------------------------
int notmain ( void )
{
    unsigned int ra;
    unsigned int rf;

    uart_init();
    hexstring(0x12345678);
    for(ra=0;ra<10;ra++)
    {
        hexstring(ra);
    }
    spi_init();
    PUT32(GPSET0,1<<7); //reset high
    for(ra=0;ra<0x10000;ra++) dummy(ra);
    PUT32(GPCLR0,1<<7); //reset low
    for(ra=0;ra<0x10000;ra++) dummy(ra);
    PUT32(GPSET0,1<<7); //reset high

    spi_command(0x21); //extended commands
//    spi_command(0xB0); //vop less contrast
    spi_command(0xBF); //vop more contrast
    spi_command(0x04); //temp coef
    spi_command(0x14); //bias mode 1:48
    spi_command(0x20); //extended off
    spi_command(0x0C); //display on

    spi_command(0x80); //column
    spi_command(0x40|5); //row
    for(rf=0;rf<84;rf++) spi_data(0x00);
    tim[0]=0;
    tim[1]=0;
    tim[2]=0;
    tim[3]=0;
    show_time();
    do_nmea();
    hexstring(0x12345678);
    return(0);
}
示例#9
0
int N6100LCD::init(void)
{
    if (MAP_FAILED==gpio_ && gpio_init() < 0) {
        DBG("gpio init failed\n");
        return -1;
    }
    if (spi_ < 0 && spi_init() < 0) {
        DBG("spi init failed\n");
        return -1;
    }

    DBG("gpio = %X\n", gpio_);
    DBG("spi  = %d\n", spi_);

    INP_GPIO(rst_);
    OUT_GPIO(rst_);

    GPIO_CLR(rst_);
    usleep(200*1000);
    GPIO_SET(rst_);
    usleep(200*1000);

    if (type_ == TYPE_EPSON) {
        spi_cmd(DISCTL); // Display control (0xCA)
        spi_data(0x0C);  // 12 = 1100 - CL dividing ratio [don't divide] switching period 8H (default)
        spi_data(0x20);  // nlines/4 - 1 = 132/4 - 1 = 32 duty
        spi_data(0x00);  // No inversely highlighted lines

        spi_cmd(COMSCN); // common scanning direction (0xBB)
        spi_data(0x01);  // 1->68, 132<-69 scan direction

        spi_cmd(OSCON); // internal oscialltor ON (0xD1)
        spi_cmd(SLPOUT); // sleep out (0x94)

        spi_cmd(PWRCTR); // power ctrl (0x20)
        spi_data(0x0F);  // everything on, no external reference resistors

        spi_cmd(DISINV); // invert display mode (0xA7)

        spi_cmd(DATCTL); // data control (0xBC)
        spi_data(0x03);  // Inverse page address, reverse rotation column address, column scan-direction !!! try 0x01
        spi_data(0x00);  // normal RGB arrangement
        spi_data(0x02);  // 16-bit Grayscale Type A (12-bit color)

        spi_cmd(VOLCTR); // electronic volume, this is the contrast/brightness (0x81)
        spi_data(32);  // volume (contrast) setting - fine tuning, original (0-63)
        spi_data(3);   // internal resistor ratio - coarse adjustment (0-7)

        spi_cmd(NOP);
        usleep(100 * 1000);
        spi_cmd(DISON); // display on (0xAF)
      } else if (type_ == TYPE_PHILIPS) {
        spi_cmd(SLEEPOUT); // Sleep Out (0x11)
        spi_cmd(BSTRON);   // Booster voltage on (0x03)
        spi_cmd(DISPON);   // Display on (0x29)

        //spi_cmd(INVON);    // Inversion on (0x20)

        // 12-bit color pixel format:
        spi_cmd(COLMOD);   // Color interface format (0x3A)
        spi_data(0x03);        // 0b011 is 12-bit/pixel mode

        spi_cmd(MADCTL);   // Memory Access Control(PHILLIPS)
        //spi_data(0x08);
        spi_data(0xC0);

        spi_cmd(SETCON);   // Set Contrast(PHILLIPS)
        spi_data(0x3E);

        spi_cmd(NOPP);     // nop(PHILLIPS)
      }

    spi_flush();
    DBG("lcd init ok\n");
    return 0;
}