示例#1
0
文件: PCD8544.c 项目: valfrom/avr
void glcd_write()
{
	uint8_t bank;


	for (bank = 0; bank < PCD8544_MAX_BANKS; bank++) {
		/* Each bank is a single row 8 bits tall */
		uint8_t column;

		if (glcd_bbox_selected->y_min >= (bank+1)*8) {
			continue; /* Skip the entire bank */
		}

		if (glcd_bbox_selected->y_max < bank*8) {
			break;    /* No more banks need updating */
		}

		glcd_command(PCD8544_SET_Y_ADDRESS | bank);
		glcd_command(PCD8544_SET_X_ADDRESS | glcd_bbox_selected->x_min);

		for (column = glcd_bbox_selected->x_min; column <= glcd_bbox_selected->x_max; column++)
		{
			glcd_data( glcd_buffer_selected[PCD8544_MAX_COLS * bank + column] );
		}
	}

	glcd_reset_bbox();

}
示例#2
0
display_image(unsigned char image[1024]){
	uint32_t j;
	unsigned char i,p;
	//displaying contents of .h file
	j=0;
	p=0;
	while(p < 8)
	{
		//set the page
		glcd_setpage(p);

		for(i=0;i<128;i++)
		{
			//select the column form 0 to 127
			glcd_setcolumn(i);

			//send hex value of data to GLCD
			glcd_data(image[j]);
			j++;

		}
		//increment the page number after previous page is filled
		p++;
	}
}
示例#3
0
void glcd_cleardisplay()
{
	unsigned char i,j;
	for(i=0;i<8;i++)
	{
		glcd_setpage(i);
		for(j=0;j<128;j++)
		{
			glcd_setcolumn(j);
			glcd_data(0x00);

		}
	}
}
示例#4
0
void glcd_blank() {
    // Reset the internal buffer
    for (int n = 1; n <= (SCREEN_WIDTH * SCREEN_HEIGHT / 8) - 1; n++) {
        glcd_buffer[n] = 0;
    }

    // Clear the actual screen
    for (int y = 0; y < 8; y++) {
        glcd_command(GLCD_CMD_SET_PAGE | y);

        // Reset column to 0 (the left side)
        glcd_command(GLCD_CMD_COLUMN_LOWER);
        glcd_command(GLCD_CMD_COLUMN_UPPER);

        // We iterate to 132 as the internal buffer is 65*132, not
        // 64*124.
        for (int x = 0; x < 132; x++) {
            glcd_data(0x00);
        }
    }
}
示例#5
0
void glcd_refresh() {
    for (int y = 0; y < 8; y++) {

#ifdef ST7565_DIRTY_PAGES
        // Only copy this page if it is marked as "dirty"
        if (!(glcd_dirty_pages & (1 << y))) continue;
#endif

        glcd_command(GLCD_CMD_SET_PAGE | y);

        // Reset column to the left side.  The internal memory of the
        // screen is 132*64, we need to account for this if the display
        // is flipped.
        //
        // Some screens seem to map the internal memory to the screen
        // pixels differently, the ST7565_REVERSE define allows this to
        // be controlled if necessary.
#ifdef ST7565_REVERSE
        if (!glcd_flipped) {
#else
        if (glcd_flipped) {
#endif
            glcd_command(GLCD_CMD_COLUMN_LOWER | 4);
        } else {
            glcd_command(GLCD_CMD_COLUMN_LOWER);
        }
        glcd_command(GLCD_CMD_COLUMN_UPPER);

        for (int x = 0; x < 128; x++) {
            glcd_data(glcd_buffer[y * 128 + x]);
        }
    }

#ifdef ST7565_DIRTY_PAGES
    // All pages have now been updated, reset the indicator.
    glcd_dirty_pages = 0;
#endif
}

void glcd_init() {

    // Select the chip
    GLCD_CS1 = 0;

    GLCD_RESET = 0;

    // Datasheet says "wait for power to stabilise" but gives
    // no specific time!
    DelayMs(50);

    GLCD_RESET = 1;

    // Datasheet says max 1ms here
    //DelayMs(1);

    // Set LCD bias to 1/9th
    glcd_command(GLCD_CMD_BIAS_9);

    // Horizontal output direction (ADC segment driver selection)
    glcd_command(GLCD_CMD_HORIZONTAL_NORMAL);

    // Vertical output direction (common output mode selection)
    glcd_command(GLCD_CMD_VERTICAL_REVERSE);

    // The screen is the "normal" way up
    glcd_flipped = 0;

    // Set internal resistor.  A suitable middle value is used as
    // the default.
    glcd_command(GLCD_CMD_RESISTOR | 0x3);

    // Power control setting (datasheet step 7)
    // Note: Skipping straight to 0x7 works with my hardware.
    //	glcd_command(GLCD_CMD_POWER_CONTROL | 0x4);
    //	DelayMs(50);
    //	glcd_command(GLCD_CMD_POWER_CONTROL | 0x6);
    //	DelayMs(50);
    glcd_command(GLCD_CMD_POWER_CONTROL | 0x7);
    //	DelayMs(10);

    // Volume set (brightness control).  A middle value is used here
    // also.
    glcd_command(GLCD_CMD_VOLUME_MODE);
    glcd_command(31);

    // Reset start position to the top
    glcd_command(GLCD_CMD_DISPLAY_START);

    // Turn the display on
    glcd_command(GLCD_CMD_DISPLAY_ON);

    // Unselect the chip
    GLCD_CS1 = 1;
}
示例#6
0
//---------------------------------------------------------------------------
// main()
//---------------------------------------------------------------------------
void main(void)
{
	//char num [32] = {0};
	uint32_t ADC_Raw_X[4],ADC_Raw_Y[4];

	hardware_init();	// init hardware via Xware
	//inituart();
	delay();
	delay();

		glcd_init();
		SysCtlDelay(134000);
		glcd_cleardisplay();
		delay();
		unsigned int i;
		unsigned int j = 0;
		unsigned char p = 0;
		unsigned del=1;
	while(1)									// forever loop
	{
			while(p<8)
			{
				glcd_setpage(p);

				for(i=0; i<128; i++)
				{
					glcd_setcolumn(i);
					glcd_data(one[j]);
					j++;
				}

				p++;
			}

			SysCtlDelay(del);
//			glcd_cleardisplay();
			p=0;
			j=0;

			while(p<8)
			{
				glcd_setpage(p);

				for(i=0; i<128; i++)
				{
					glcd_setcolumn(i);
					glcd_data(two[j]);
					j++;
				}

				p++;
			}

			SysCtlDelay(del);
	//		glcd_cleardisplay();
			p=0;
			j=0;

			while(p<8)
			{
				glcd_setpage(p);

				for(i=0; i<128; i++)
				{
					glcd_setcolumn(i);
					glcd_data(three[j]);
					j++;
				}

				p++;
			}

			SysCtlDelay(del);
		//	glcd_cleardisplay();
			p=0;
			j=0;

			while(p<8)
			{
				glcd_setpage(p);

				for(i=0; i<128; i++)
				{
					glcd_setcolumn(i);
					glcd_data(four[j]);
					j++;
				}

				p++;
			}

			SysCtlDelay(del);
//			glcd_cleardisplay();
			p=0;
			j=0;

			while(p<8)
			{
				glcd_setpage(p);

				for(i=0; i<128; i++)
				{
					glcd_setcolumn(i);
					glcd_data(five[j]);
					j++;
				}

				p++;
			}

			SysCtlDelay(del);
	//		glcd_cleardisplay();
			p=0;
			j=0;

			while(p<8)
			{
				glcd_setpage(p);

				for(i=0; i<128; i++)
				{
					glcd_setcolumn(i);
					glcd_data(six[j]);
					j++;
				}

				p++;
			}

			SysCtlDelay(del);
		//	glcd_cleardisplay();
			p=0;
			j=0;

			while(p<8)
			{
				glcd_setpage(p);

				for(i=0; i<128; i++)
				{
					glcd_setcolumn(i);
					glcd_data(seven[j]);
					j++;
				}

				p++;
			}

			SysCtlDelay(del);
//			glcd_cleardisplay();
			p=0;
			j=0;

			while(p<8)
			{
				glcd_setpage(p);

				for(i=0; i<128; i++)
				{
					glcd_setcolumn(i);
					glcd_data(eight[j]);
					j++;
				}

				p++;
			}

			SysCtlDelay(del);
//			glcd_cleardisplay();
			p=0;
			j=0;
		ADCProcessorTrigger(ADC0_BASE, 1);
		ADCProcessorTrigger(ADC1_BASE, 1);

//		while(!ADCIntStatus(ADC0_BASE, 1, false) && !ADCIntStatus(ADC1_BASE, 1, false));
//		{
//		}
//		ADCIntClear(ADC0_BASE, 1);
//		ADCIntClear(ADC1_BASE, 1);

		ADCSequenceDataGet(ADC0_BASE, 1, ADC_Raw_Y);
		ADCSequenceDataGet(ADC1_BASE, 1, ADC_Raw_X);

		X = ((ADC_Raw_X[0] + ADC_Raw_X[1] + ADC_Raw_X[2] + ADC_Raw_X[3])/4);
		Y = ((ADC_Raw_Y[0] + ADC_Raw_Y[1] + ADC_Raw_Y[2] + ADC_Raw_Y[3])/4);

		if(X > 3900)
		{
			del = 1340000;
		}
		else if(X < 200)
		{
			del = 1;
		}
		else
		{
			del = 670000;
		}
	}

}
示例#7
0
文件: st7565.c 项目: blackmort/Mplab
void glcd_refresh() {
    for (int y = 0; y < 8; y++) {

#ifdef ST7565_DIRTY_PAGES
        // Only copy this page if it is marked as "dirty"
        if (!(glcd_dirty_pages & (1 << y))) continue;
#endif

        glcd_command(GLCD_CMD_SET_PAGE | y);

        // Reset column to the left side. The internal memory of the
        // screen is 132*64, we need to account for this if the display
        // is flipped.
        //
        // Some screens seem to map the internal memory to the screen
        // pixels differently, the ST7565_REVERSE define allows this to
        // be controlled if necessary.
#ifdef ST7565_REVERSE
        if (!glcd_flipped) {
#else
        if (glcd_flipped) {
#endif
            glcd_command(GLCD_CMD_COLUMN_LOWER | 4);
        } else {
            glcd_command(GLCD_CMD_COLUMN_LOWER);
        }
        glcd_command(GLCD_CMD_COLUMN_UPPER);

        for (int x = 0; x < 128; x++) {
            glcd_data(glcd_buffer[y * 128 + x]);
        }
    }

#ifdef ST7565_DIRTY_PAGES
    // All pages have now been updated, reset the indicator.
    glcd_dirty_pages = 0;
#endif
}

void glcd_init() {

    // Select the chip
    GLCD_CS1 = 0;

    GLCD_RESET = 0;

    // Datasheet says "wait for power to stabilise" but gives
    // no specific time!
    DelayMs(50);

    GLCD_RESET = 1;
    // Datasheet says max 1ms here
    //DelayMs(1);

    // Set LCD bias to 1/9th
glcd_command(0b11100010); // Reset
glcd_command(0b10100010); // set the LCD bias to 1/9th
glcd_command(0x23); // Voltage Regulator internal Resisitor ratio set(the internal resistor divider set to 3 (from 0..7))
glcd_command(0x2F); // Power Control Set( power control, all internal blocks ON )
glcd_command(0b00000011); // Electronic volume Mode set ???
glcd_command(0x40); // go back to the top left of the display
glcd_command(0x81); // Electronic volume Mode set
glcd_command(0b11111000); // Booster ratio Select Mode Set
glcd_command(0b00000000); // Booster ratio register set ???
glcd_command(0b10100000); // ADC Select( 0xa0:Normal, 0xa1:Reverse )
glcd_command(0b11001000); // Common output Mode Set
glcd_command(0b10101111); // Display ON
glcd_command(0b10100110); // Display Normal/Reverse(Permet d'inverser Blanc/noir)
glcd_command(0xA4); // Display all points (0xa4:Normal display mode, 0xa5:display all points)

    // Unselect the chip
    GLCD_CS1 = 1;
}