Exemplo n.º 1
0
void writeCharToLCD(char c) {
    unsigned char i;
    for(i = 0; i < 5; i++) {
        writeToLCD(LCD5110_DATA, font[c - 0x20][i]);
    }
    writeToLCD(LCD5110_DATA, 0);
}
Exemplo n.º 2
0
void writeBlockToLCD(char *byte, unsigned char length) {
    unsigned char c = 0;
    while(c < length) {
        writeToLCD(LCD5110_DATA, *byte++);
        c++;
    }
}
Exemplo n.º 3
0
void clearBank(unsigned char bank) {
    setAddr(0, bank);
    int c = 0;
    while(c < PCD8544_HPIXELS) {
        writeToLCD(LCD5110_DATA, 0);
        c++;
    }
    setAddr(0, bank);
}
Exemplo n.º 4
0
void clearLCD() {
    setAddr(0, 0);
    int c = 0;
    while(c < PCD8544_MAXBYTES) {
        writeToLCD(LCD5110_DATA, 0);
        c++;
    }
    setAddr(0, 0);
}
Exemplo n.º 5
0
void writeGraphicToLCD(char *byte, unsigned char transform) {
    int c = 0;
    char block[8];

    if(transform & FLIP_V) {
        SPI_LSB_FIRST;
    }
    if(transform & ROTATE) {
        c = 1;
        while(c != 0) {
            (*byte & 0x01) ? (block[7] |= c) : (block[7] &= ~c);
            (*byte & 0x02) ? (block[6] |= c) : (block[6] &= ~c);
            (*byte & 0x04) ? (block[5] |= c) : (block[5] &= ~c);
            (*byte & 0x08) ? (block[4] |= c) : (block[4] &= ~c);
            (*byte & 0x10) ? (block[3] |= c) : (block[3] &= ~c);
            (*byte & 0x20) ? (block[2] |= c) : (block[2] &= ~c);
            (*byte & 0x40) ? (block[1] |= c) : (block[1] &= ~c);
            (*byte & 0x80) ? (block[0] |= c) : (block[0] &= ~c);
            *byte++;
            c <<= 1;
        }
    } else {
        while(c < 8) {
            block[c++] = *byte++;
        }
    }

    if(transform & FLIP_H) {
        c = 7;
        while(c > -1) {
            writeToLCD(LCD5110_DATA, block[c--]);
        }
    } else {
        c = 0;
        while(c < 8) {
            writeToLCD(LCD5110_DATA, block[c++]);
        }
    }
    SPI_MSB_FIRST;
}
Exemplo n.º 6
0
void initLCD() {
    writeToLCD(LCD5110_COMMAND, PCD8544_FUNCTIONSET | PCD8544_EXTENDEDINSTRUCTION);
    writeToLCD(LCD5110_COMMAND, PCD8544_SETVOP | 0x3F);
    writeToLCD(LCD5110_COMMAND, PCD8544_SETTEMP | 0x02);
    writeToLCD(LCD5110_COMMAND, PCD8544_SETBIAS | 0x03);
    writeToLCD(LCD5110_COMMAND, PCD8544_FUNCTIONSET);
    writeToLCD(LCD5110_COMMAND, PCD8544_DISPLAYCONTROL | PCD8544_DISPLAYNORMAL);
}
Exemplo n.º 7
0
main(void) {

    //Configure cache, wait states and peripheral bus clock
    // Configure the device for maximum performance but do not change the PBDIV
    // Given the options, this function will change the flash wait states, RAM
    // wait state and enable prefetch cache but will not change the PBDIV.
    // The PBDIV value is already set via the pragma FPBDIV option above..
    SYSTEMConfig(SYS_FREQ, SYS_CFG_WAIT_STATES | SYS_CFG_PCACHE);

    // Execute LCD initialization sequence
    initializeLCD();

    writeToLCD(CMDREG, 0x0F); // Turn on blinking cursor
    writeString("HELLO!"); // Write string to the LCD
    newLine(); // Set cursor to line two
    writeString("TESTING..."); // Print another string

    while (1) {
    }
}
Exemplo n.º 8
0
bool_t tdisp_lld_init(void) { 
	/* initialise hardware */
	init_board();
	
	/* The first part is the initialing code.
	 * In this part only the lower nibble of the
	 * byte is written directly to the display, thus
	 * without write_cmd, which sends both high and
	 * low nibble.
	 */
	
	/* Give the LCD a little time to wake up */
	gfxSleepMilliseconds(15);
	
	/* clear the RS-line to the display */
	palClearPad(PORT_CTRL, PIN_RS);
// 	#if BUS_4BITS
		/* write three times 0x03 to display (4-bit mode only)
		* with RS = low.
		*/
		writeToLCD(0x03); // 1x
		gfxSleepMilliseconds(20);
		writeToLCD(0x03); // 2x
// 		gfxSleepMilliseconds(20);
		writeToLCD(0x03); // 3x
// 		gfxSleepMilliseconds(20);
		/* Put display in 4-bit mode by
		* write 0x02 to display.
		*/
		writeToLCD(0x02); // 4bit-modus
// 		gfxSleepMilliseconds(20);
// 	#else
		/* write three times 0x30 to display (8-bit mode only)
		* with RS = low.
		*/
// 		writeToLCD(0x30); // 1x
// 		writeToLCD(0x30); // 2x
// 		writeToLCD(0x30); // 3x
// 	#endif	

	/* From this point on, the LCD accepts
	 * bytes sent with highnibbel first and than
	 *the lownibble if working in 4-bit mode.
	 * In 8-bit mode bytes are written in 1 action.
	 */
	
	/* 4-bit modus, 2 lines en 5x7 characters */
	write_cmd(0x28);
// 	gfxSleepMilliseconds(20);
	
	/* set display on, cursor off and no blinking */
	write_cmd(0x0C);
// 	gfxSleepMilliseconds(20);
	/* set cursor increase and direction */
	write_cmd(0x06);
// 	gfxSleepMilliseconds(20);
	
	displaycontrol = TDISP_DISPLAY_ON;
	cursorcontrol = TDISP_CURSOR_INC;
	/* END OF INITIALISATION */

	return TRUE;
}
Exemplo n.º 9
0
// Set the LCD cursor position to line two
void newLine(void) {
    writeToLCD(CMDREG, 0xC0); // Cursor address 0x80 + 0x40 = 0xC0
}
Exemplo n.º 10
0
// Used to write strings to the LCD
void writeString(unsigned char *string) {
    while (*string) { // Keep going until string ends
        writeToLCD(DATAREG, *string++); //Send characters one by one
    }
}
Exemplo n.º 11
0
void main(void) {

    WDTCTL = WDTPW + WDTHOLD;         // disable WDT
    BCSCTL1 = CALBC1_1MHZ;            // 1MHz clock
    DCOCTL = CALDCO_1MHZ;

    P1OUT |= LCD5110_SCE_PIN + LCD5110_DC_PIN;
    P1DIR |= LCD5110_SCE_PIN + LCD5110_DC_PIN;

    // setup USIB
    P1SEL |= LCD5110_SCLK_PIN + LCD5110_DN_PIN;
    P1SEL2 |= LCD5110_SCLK_PIN + LCD5110_DN_PIN;

    UCB0CTL0 |= UCCKPH + UCMSB + UCMST + UCSYNC;  // 3-pin, 8-bit SPI master
    UCB0CTL1 |= UCSSEL_2;                     // SMCLK
    UCB0BR0 |= 0x01;                          // 1:1
    UCB0BR1 = 0;
    UCB0CTL1 &= ~UCSWRST;                     // clear SW

    _delay_cycles(500000);
    initLCD();
    clearLCD();

    // LCD test
    writeStringToLCD("Nokia 5110");

    _delay_cycles(2000000);
    setAddr(0, 0);

    int c = 0x20;
    while(c < (65 + 0x20)) {
        writeCharToLCD(c);
        c++;
    }

    _delay_cycles(2000000);
    clearLCD();

    c = 65 + 0x20;

    while(c < (96 + 0x20)) {
        writeCharToLCD(c);
        c++;
    }

    _delay_cycles(2000000);

    c = 0;
    clearBank(3);
    while(c < 64) {
        writeToLCD(LCD5110_DATA, 0xFF);
        c++;
        _delay_cycles(20000);
    }
    clearBank(4);
    while(c < 100) {
        writeToLCD(LCD5110_DATA, 0xFF);
        c++;
        _delay_cycles(20000);
    }
    clearBank(5);
    while(c < 184) {
        writeToLCD(LCD5110_DATA, 0xFF);
        c++;
        _delay_cycles(20000);
    }

    _delay_cycles(2000000);

    clearBank(3);
    writeGraphicToLCD(testBlock, NONE);
    writeGraphicToLCD(testBlock, FLIP_V);
    writeGraphicToLCD(testBlock, FLIP_H);
    writeGraphicToLCD(testBlock, ROTATE);
    writeGraphicToLCD(testBlock, FLIP_V | ROTATE);
    writeGraphicToLCD(testBlock, FLIP_H | ROTATE);
    writeGraphicToLCD(testBlock, ROTATE_90_CCW);
    writeGraphicToLCD(testBlock, ROTATE_180);

    clearBank(4);
    writeGraphicToLCD(testBlock2, NONE);
    writeGraphicToLCD(testBlock2, FLIP_H);
    writeGraphicToLCD(testBlock2, ROTATE);
    writeGraphicToLCD(testBlock2, ROTATE_90_CCW);



    clearBank(0);
    writeStringToLCD("For details,");
    clearBank(1);
    writeStringToLCD("visit 43oh.com");
    clearBank(2);
}
Exemplo n.º 12
0
void setAddr(unsigned char xAddr, unsigned char yAddr) {
    writeToLCD(LCD5110_COMMAND, PCD8544_SETXADDR | xAddr);
    writeToLCD(LCD5110_COMMAND, PCD8544_SETYADDR | yAddr);
}