Пример #1
0
void lcdDemoFlip(void)
{
	char msgA[]="I Love 8051";
	char msgB[]="Wow is Great!!!";

	unsigned char n;

	lcdInit();				// Set 2 lines, font:5x7

	lcdSetDisplay(LCD_DISPLAY_ON);

	lcdClearScreen();
	lcdSetInputInc();
	lcdSetInputShiftOff();

	for (n=0; n<3; n++)
	{
		lcdClearRow(0);
		lcdSelectRow(0);
		lcdWriteString(msgA);
		lcdClearRow(1);
		lcdSelectRow(1);
		lcdWriteString(msgB);
		delay(DELAYLONG);

		lcdClearRow(0);
		lcdSelectRow(0);
		lcdWriteString(msgB);
		lcdClearRow(1);
		lcdSelectRow(1);
		lcdWriteString(msgA);
		delay(DELAYLONG);
	}
} /* lcdDemoFlip */
Пример #2
0
void main(void)
{
	char msgA[]="I Love 8051";
	char msgB[]="Wow is Great!!!";

	lcdClear();

	lcdWriteCmd(0x0f);		// Display:On, Cursor:On, Blink:On
	lcdWriteCmd(0x38);		// 8-bit, 2 lines, 5x7 font
	lcdWriteCmd(0x06);		// Input mode: Increment, Non-shift

	for (;;)
	{
		lcdClearRow(0);
		lcdSelectRow(0);
		lcdWriteString(msgA);
		lcdClearRow(1);
		lcdSelectRow(1);
		lcdWriteString(msgB);
		delay(DELAYLONG);

		lcdClearRow(0);
		lcdSelectRow(0);
		lcdWriteString(msgB);
		lcdClearRow(1);
		lcdSelectRow(1);
		lcdWriteString(msgA);
		delay(DELAYLONG);
	}

} /* main */
Пример #3
0
void lcdDemoAnimatedChar(void)
{
	char mario[][8]={{0x06, 0x09, 0x09, 0x06, 0x03, 0x1a, 0x05, 0x08},
					 {0x09, 0x09, 0x06, 0x03, 0x1a, 0x05, 0x08, 0x06},
					 {0x09, 0x06, 0x03, 0x1a, 0x05, 0x08, 0x06, 0x09},
					 {0x06, 0x03, 0x1a, 0x05, 0x08, 0x06, 0x09, 0x09},
					 {0x03, 0x1a, 0x05, 0x08, 0x06, 0x09, 0x09, 0x06},
					 {0x1a, 0x05, 0x08, 0x06, 0x09, 0x09, 0x06, 0x03},
					 {0x05, 0x08, 0x06, 0x09, 0x09, 0x06, 0x03, 0x1a},
					 {0x08, 0x06, 0x09, 0x09, 0x06, 0x03, 0x1a, 0x05}};

	char msgA[]="Wow8051";
	char msgB[]="Wow is Great!!!";

	unsigned char n;

	lcdInit();				// Set 2 lines, font:5x7

	lcdSetDisplay(LCD_DISPLAY_ON);

//	lcdMakeRawFont(0, 0x01, 0x02, 0x04, 0x08, 0x10, 0x11, 0x0a, 0x11);
//	lcdMakeRawFont(0, 0x04, 0x0b, 0x04, 0x07, 0x1a, 0x04, 0x08, 0x10);
//	lcdMakeRawFont(1, 0x06, 0x09, 0x09, 0x06, 0x03, 0x1a, 0x05, 0x08);

	/* Setup all 8 self-made special characters */
	for (n=0; n<8; n++)
	{
		lcdMakeFont(n, mario[n]);
	}

	lcdClearScreen();
	lcdSetInput(LCD_INPUT_INC);

#ifdef	DEBUG_USRCHAR
	/* try to show all 8 pre-programmed special characters */
	for (n=0; n<8; n++)
	{
		lcdWriteData(n);
	}
#endif

#ifndef	DEBUG_USRCHAR
	lcdWriteData(' ');
	lcdWriteData(' ');
	lcdWriteString(msgA);

	lcdSelectRow(1);
	lcdWriteString(msgB);
	
	for (n=0; n<8; n++)
	{
		lcdSelectRow(0);
		lcdWriteData(n);
		delay(DELAYLONG);
	}
#endif
} /* lcdDemoAnimatedChar */
Пример #4
0
int main(void)
{
	int a = 23,b = 45;
	uint8_t *name = "Wassup!!!";
	lcdInit();
	lcdWriteString("Hey Ravi",LINE1);
	lcdWriteChar('A',LINE2);
	return 0;
}
Пример #5
0
void main(void)
{
	char msgA[]="My name Carol";
	char msgB[]="Good Day!";	

	lcdClear();

	lcdWriteCmd(0x0F);
	lcdWriteCmd(0x38);			 //8 bit,2 lines, 5x7 font;
	lcdWriteCmd(0x06);

	lcdWriteString(msgA);
	lcdSelectRow(1);
	lcdWriteString(msgB);

	for (;;);

} /* main */
Пример #6
0
void main(void)
{
	lcdInit();

	lcdSetInputMode(1,0);
	lcdWriteString("April Sin is a good girl");

	for (;;);

} /* main */
Пример #7
0
char continuityTest()
{
	char str[20];

	if( terminalPresent == TRUE )
		printf( "Continuity Test\n" );
	lcdSetDDRAMAddress( 0x00 );
	sprintf( str, "Continuity Test" );
	lcdWriteString( str );	
	lcdSetDDRAMAddress( 0x40 );
 	sprintf( str, " " );
	lcdWriteString( str );
	oneSecond();
	oneSecond();
	oneSecond();
	oneSecond();
	oneSecond();

	return TRUE;
}
Пример #8
0
 void main (void)
 {
 	lcdInit();								// Clear Screen, Display ON, Cursor ON, Blinking ON
											// Use 8-bit, 2 Lines, Font 5x7

	lcdSetInputMode(1,0);					// Cursor INC, No Shift

	for(;;)
	{
		lcdClearRow(0);
		lcdWriteString("April is a girl");
		lcdClearRow(1);
		lcdWriteString("Ha! Ha!");
		delay(50000);
		
		lcdClearRow(0);
		lcdWriteString("Ha! Ha!");	
		lcdClearRow(1);
		lcdWriteString("April is a girl");	
		delay(50000);
	}
 } /* main */
Пример #9
0
void main(void)
{
	char font0[]={0x06, 0x09, 0x09, 0x06, 0x03, 0x1a, 0x05, 0x08};

	char msgA[]="Wow8051";
	char msgB[]="Wow is Great!!!";

	lcdInit();				// Set 2 lines, font:5x7

	lcdSetDisplayMode(LCD_DMODE_DISPLAY_ON | 
					  LCD_DMODE_CURSOR_ON  |
					  LCD_DMODE_CURSOR_BLINK_ON);

//	lcdMakeRawFont(0, 0x01, 0x02, 0x04, 0x08, 0x10, 0x11, 0x0a, 0x11);

//	lcdMakeRawFont(0, 0x04, 0x0b, 0x04, 0x07, 0x1a, 0x04, 0x08, 0x10);
//	lcdMakeRawFont(1, 0x06, 0x09, 0x09, 0x06, 0x03, 0x1a, 0x05, 0x08);

	lcdMakeFont(0, font0);

	lcdClearScreen();
	lcdSetInputMode(LCD_INPUT_INC, LCD_INPUT_SHIFT_OFF);

	lcdWriteData(0);
	lcdWriteData(1);
	lcdWriteData(' ');
	lcdWriteString(msgA);
	lcdWriteData(' ');
	lcdWriteData(1);
	lcdWriteData(0);

	lcdSelectRow(1);
	lcdWriteString(msgB);

	for (;;);

} /* main */
Пример #10
0
void main (void)
{
	lcdInit();							// Clear Screen, Display ON, Cursor ON, Blinking ON
										// Use 8-bit, 2 Lines, Font 5x7

	lcdSetInput(LCD_MODE_INPUT_INC		 |
				LCD_MODE_INPUT_SHIFT_OFF);
	
	for (;;)
	{
		lcdClearRow(0);
		delay(30000);

		lcdWriteString("I am LCD");
		delay(30000);
	}

} /* main */
Пример #11
0
void printADCData(){ 
            int result = readADCData(); // Read data from ADC
            int resultInMeters = readADCMeter(); //Read data and convert to meters
            if(resultInMeters > 15 && resultInMeters){
                latestReadMeterValue = resultInMeters;
            }  
            if(updateLcdIRData){ // Check LCD refresh rate and print to LCD
                updateLcdIRData = 0;
                lcdSetCursor(0x00);
                //lcdWriteString("Raw:");
                //lcdWriteToDigitBCD(result,4,0);
                //lcdSetCursor(0x09);
                //lcdWriteString("=>");
                lcdWriteToDigitBCD(resultInMeters,3,0); // Write the adc data in meters to LCD
                lcdWriteString("cm");
                
            }
            // Restart the ADC conversion
            startADCConversion();    
}
Пример #12
0
void main (void)
{
	unsigned char n;

	lcdInit();							// Clear Screen, Display ON, Cursor ON, Blinking ON
										// Use 8-bit, 2 Lines, Font 5x7

	lcdSetInput(LCD_MODE_INPUT_INC |
				LCD_MODE_INPUT_SHIFT_OFF);
		
	for (;;)
	{
		for(n=0; n<0xf; n++)
		{
			lcdClearRow(1);
			lcdWriteCmd(0x80 | 0x40 | n);

			lcdWriteString("April");
			delay(10000);
		}
	}

} /* main */
Пример #13
0
static void _hStart()
{
	char s[7];
	if (KEY4)	// MENU
	{
		arm(OFF);
		loadPage(PAGE_MENU);
		return;
	}
	
	if (KEYINIT || KEYREFRESH)
	{
		if (Config.ArmingMode)
			arm(ON);
		
		if (State.Armed)
		{
			lcdSetPos(3, 30);
			lcdSelectFont(&font12x16);
			lcdWriteString_P(strARMED);
			lcdSelectFont(NULL);
			return;
		}
		else
		{
			lcdSetPos(0, 5);
			lcdSelectFont(&font12x16);
			lcdWriteString_P(strHeader);
			lcdSelectFont(NULL);
			lcdSetPos(2, 0);
			lcdWriteString_P(scrStart);
		}
	}
	
	if (!State.Armed)
	{
		lcdSetPos(2, 84);
		if (State.SelfLevel)
			writePadded_P(strON, 3);
		else		
			writePadded_P(strOFF, 3);
	
		lcdSetPos(3, 0);
		if (State.Error)
		{
			lcdWriteString_P(strError);
			lcdWriteChar(32);
			if (State.Error & ERR_NOT_CALIBRATED)
				lcdWriteString_P(strSensorNotCal);
			else 
			{
				lcdWriteString_P(PSTR("no "));
				const char* s;
				if ((State.Error & ERR_NO_RX) == ERR_NO_RX)
					s = PSTR("RX");
				else if (State.Error & ERR_NO_ROLL)
					s = strRoll;
				else if (State.Error & ERR_NO_PITCH)
					s = strPitch;
				else if (State.Error & ERR_NO_YAW)
					s = strYaw;
				else 
					s = strThro;
				lcdWriteString_P(s);
				lcdWriteString_P(PSTR(" input"));
			}
		}	
		else
			lcdWriteString_P(PSTR("Ready for departure!"));
	
		// battery level
		lcdSetPos(4, 13*6);
		utoa(BATT / 10, s, 10);
		lcdWriteString(s);
		lcdWriteChar('.');
		utoa(BATT % 10, s, 10);
		writePadded(s, 3);
	
		// roll angle
		writeValue(5, 13*6, (int16_t)ANGLE[ROL], 7, -1);
	
		// pitch angle
		writeValue(6, 13*6, (int16_t)ANGLE[PIT], 7, -1);
	}	
}
Пример #14
0
static void writePadded(char *s, uint8_t len)
{
	lcdWriteString(s);
	writeSpace(len - strlen(s));
}
Пример #15
0
void main(void)
{
	char msgA[] = {0x49, 0x20, 0x4C, 0x6F, 0x76, 0x65, 0x20, 0x38, 0x30, 0x35, 0x31, 0};
	
	char msgB[] = {'I', ' ', 'L', 'o', 'v', 'e', ' ', '8', '0', '5', '1', 0};
	
	char msgC[] = "I Love 8051";
	
	char msgD[] = "Hello World!"; 

	lcdClear();
	
	lcdWriteCmd(0x0F);						// Display: ON, Cursor: ON, Blink: ON
	lcdWriteCmd(0x38);						// 8-bit, 2 lines, 5x7 font
	lcdWriteCmd(0x06);						// Input mode: Increment, Non-shift

	lcdWriteString(msgC);
	lcdSelectRow(1);
//	lcdWriteCmd(0x80 | 0x40);
	lcdWriteString(msgD);

//	for (n=0; *(msgD+n)!=0; n++)
//	{
//		lcdWriteData( *(msgD+n) );
//	}

//	for (n=0; msgD[n]!=0; n++)
//	{
//		lcdWriteData( msgD[n] );
//	}

//	for (n=0; n<11; n++)
//	{
//		lcdWriteData( msgB[n] );
//	}

//	lcdWriteData('I');
//	lcdWriteData(' ');
//	lcdWriteData('L');
//	lcdWriteData('o');
//	lcdWriteData('v');
//	lcdWriteData('e');
//	lcdWriteData(' ');
//	lcdWriteData('8');
//	lcdWriteData('0');
//	lcdWriteData('5');
//	lcdWriteData('1');
//
//	lcdWriteData(0x7E);
//	lcdWriteData(0xF6);
//	lcdWriteData('3');
//	lcdWriteData(0xFA);
//	lcdWriteData(0xFB);

//	lcdWriteData(0x49);						// " I "
//	lcdWriteData(0x20);						// "   "
//	lcdWriteData(0x4C);						// " L "
//	lcdWriteData(0x6F);						// " o "
//	lcdWriteData(0x76);						// " v "
//	lcdWriteData(0x65);						// " e "
//	lcdWriteData(0x20);						// "   "
//	lcdWriteData(0x38);						// " 8 "
//	lcdWriteData(0x30);						// " 0 "
//	lcdWriteData(0x35);						// " 5 "
//	lcdWriteData(0x31);						// " 1 "

	for (;;);
}/* main */
Пример #16
0
void main (void)
{
    char temp;
    char str[20];
    int i;

    for( i=0; i < 32; i++ ) lcdString[i] = 0x20;
    timer0Count = messageCount = i = 0;
    irqCount = 0;
    toggle = FALSE;
    P0_0 = 0;
    inIndex = outIndex = 0;
    terminalPresent = TRUE;

    systemInit();

    // These next 5 instructions should init trhe chip after power up
    // according to datasheet page 45 - Initializing by instruction.
    // Except the SetDDRAM instruction, but I can't get anything going
    // without it (!!!)
    lcdSetDDRAMAddress( 0x00 );	// Why do I need this before lcdinit()?
    lcdInit();					// Send 3 Function Set commands
    lcdSetFunction();			// Now the real Function Set
    lcdDisplayOnOff( OFF );		// etc.
    lcdClearDisplay();

    // LCD should now be initialized
    lcdSetEntryMode( 1, 0 );	// Cursor position increment, no dsiplay shift
    lcdDisplayOnOff( ON );
    lcdCursorOnOff( OFF );
    lcdBlinkOnOff( OFF );

    startInterrupts();

    lcdSetDDRAMAddress( 0x00 );
    sprintf( str, "   EMBEEDED TEST" );
    lcdWriteString( str );
    lcdSetDDRAMAddress( 0x40 );
    sprintf( str, "     powered by:" );
    lcdWriteString( str );

    oneSecond();
    oneSecond();
    oneSecond();
    lcdSetDDRAMAddress( 0x00 );
    sprintf( str, "Overton Instruments" );
    lcdWriteString( str );
    lcdSetDDRAMAddress( 0x40 );
    sprintf( str, "** OI - microATE **" );
    lcdWriteString( str );

    oneSecond();
    oneSecond();
    oneSecond();

    temp = readThumbwheels();
    testMode = temp & 0xf0;
    testMode >>= 4;
    testMode &= 0x0f;
    testSelect = temp & 0x0f;

    if( ( testMode == 9 ) && ( testSelect == 9 ) )
    {
        // Run system configuration menu
        // Call System_config_menu
        printf( "System Config Menu\n" );
    }

    nextUnit = FALSE;
    if( terminalPresent == TRUE )
    {
        printf( "NDS Test Fixture, Code Ver: %s\n", VERSION );
    }

    lcdClearDisplay();
    startButton = FALSE;
    stopButton = FALSE;
    fixtureReady = FALSE;
    dutPresent = FALSE;
    lcdSetDDRAMAddress( 0x00 );
    lcdWriteString( "Install DUT and" );
    lcdSetDDRAMAddress( 0x40 );
    lcdWriteString( "press Start" );

    oneSecond();
    oneSecond();
    oneSecond();

    while(1)
    {
        if( ( startButton == TRUE ) && ( stopButton == FALSE ) )
        {
            if( ( fixtureReady == TRUE ) && ( dutPresent == TRUE ) )
            {
                printf( "Present and Ready\n" );
                if( continuityTest() == TRUE )
                {
                    lcdSetDDRAMAddress( 0x40 );
                    lcdWriteString( "      PASSED!" );
                }
                else
                {
                    lcdSetDDRAMAddress( 0x40 );
                    lcdWriteString( "         FAIL" );
                }
                startButton = FALSE;
                fixtureReady = FALSE;
                dutPresent = FALSE;
            }
            else
            {
                runLEDOnOff( ON );
                passLEDOnOff( ON );
                failLEDOnOff( ON );
                oneSecond();
                runLEDOnOff( OFF );
                passLEDOnOff( OFF );
                failLEDOnOff( OFF );
                oneSecond();
            }
        }

        // Reset IRQ if port pin has gone high again
        if( ( irq0 == TRUE ) && ( P3_2 == ON ) )
        {
            ext0Enable();
            irq0 = FALSE;
        }
    }
}
Пример #17
0
void main(void) {
    char packet[] = {'T', 'e', 's', 't'};

    unsigned char i = 0;
    unsigned char packet_size = sizeof (packet) / sizeof (packet[0]);
    unsigned char cArray[10]
            = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'};

    // temporary local array
    unsigned char writtenArray[10];

    // local variables for all test cases and their initialisation
    unsigned char chData;
    unsigned char *pReadArray;
    unsigned char *pWriteArray;
    unsigned char j = 0;
    unsigned char i = 0;
    pReadArray = pWriteArray = writtenArray;

    /* Configure the oscillator for the device */
    ConfigureOscillator();

    /* Initialize I/O and Peripherals for application */
    InitApp();

    //  LCD test
    TRISAbits.RA2 = 0; // our chip select pin needs to be an output so that we can toggle it
    CS = 1; // set CS pin to high, meaning we are sending any information to the MCP23S17 chip

    // configure SPI: the MCP23S17 chip's max frequency is 10MHz, let's use 10MHz/64 (Note FOSC=10Mhz, our external oscillator)
    OpenSPI1(SPI_FOSC_64, MODE_10, SMPEND); // frequency, master-slave mode, sampling type
    // set LCD pins DB0-DB7 as outputs
    setIODIR(IODIRB_ADDRESS, 0x00);
    // set RS and E LCD pins as outputs
    setIODIR(IODIRA_ADDRESS, 0x00);
    // RS=0, E=0
    setGPIO(IODIRA_ADDRESS, 0x00);
    // Function set: 8 bit, 2 lines, 5x8
    lcdCommand(0b00111111);
    // Cursor or Display Shift
    lcdCommand(0b00001111);
    // clear display
    lcdCommand(0b00000001);
    // entry mode
    lcdCommand(0b00000110);

    // send characters
    lcdWriteString((unsigned char *) "Waiting..."); // using the string function
    lcdGoTo(0x40); // go to line two
    /*lcdChar('S'); // using the single character function
    lcdChar('P');
    lcdChar('I');
    lcdChar(' ');
    lcdChar('L');
    lcdChar('i');
    lcdChar('b');
    lcdChar('r');
    lcdChar('a');
    lcdChar('r');
    lcdChar('y');
*/
    ///////////////////////////////////////////////////
    /* TODO <INSERT USER APPLICATION CODE HERE> */
    /*
    while(1)
    {
        i = 0;
        
        do {
            UARTIntPutChar(packet[i++]);
        } while (i < packet_size);

        while (!vUARTIntStatus.UARTIntTxBufferEmpty);

        Delay10KTCYx(1000);
    }
     */
    TRISD = 0;
    PORTD = 0;

    while (1) {
/*
        for (j = 0; j < 100; j++) {
            i = 0;
            do {
                if (vUARTIntStatus.UARTIntTxBufferEmpty)
                    UARTIntPutChar(cArray[i++]);
            } while (i < 10);
        }
*/
        if (!(vUARTIntStatus.UARTIntRxError) &&
                !(vUARTIntStatus.UARTIntRxOverFlow) &&
                !(vUARTIntStatus.UARTIntRxBufferEmpty)) {
            if (UARTIntGetChar(&chData)) {
                PORTD = chData;
                lcdChar(chData);
            }
        }
    }
}
Пример #18
0
/*
 * Clear display and write a string
 */
void lcdClearAndWriteString(char * s) {
	lcdClear();
	lcdWriteString(s);
}
Пример #19
0
void print_hello_world(){
    char hello_cstr[] = "Hello World";
    lcdWriteString(hello_cstr);
}