Exemplo n.º 1
0
void PCF8814_GFX::Update() {
  for(int p = 0; p < 9; p++){
    if(yUpdateMin >= ((p+1) *8)) {
      continue;
    }
    if(yUpdateMax < p*8){
      break;
    }
    WriteLCD(LCD_C, SetYAddr | p); 
		
    int col = xUpdateMin;
    int maxcol = xUpdateMax;
			
    WriteLCD(LCD_C, SetXAddr4 | (col - (16 * (col/16))));
    WriteLCD(LCD_C, SetXAddr3 | (col / 16));
		
    for(; col <= maxcol; col++){
      WriteLCD(LCD_D, LCDCache[(LCD_X * p) + col]);
    }
		
  }
  xUpdateMin = LCD_X - 1;	
  xUpdateMax = 0;
  yUpdateMin = LCD_Y -1;
  yUpdateMax = 0;
}
Exemplo n.º 2
0
void InitializeLCD(int Index) {
	if (Index == ChoosePort) {
		SetByte(0, LCD_Read);			// Start all control lines low, float databus
		WriteLCD(LCD_FunctionSet|TwoLine|FiveByElevenFont);
		WriteLCD(LCD_DisplayControl|EnableDisplay);
		WriteLCD(LCD_ClearDisplay);
		SetDelay(1600);					// Insert 1.6 msec after a ClearDisplay
		SignOnLCD();
		}
	}
Exemplo n.º 3
0
Arquivo: lcd.c Projeto: mjburger/lab1
void LCDMoveCursor(unsigned char x, unsigned char y) {

	// TODO: Write the propoer control instruction to move the cursor to the specified
	// (x,y) coordinate. This operation should be performance as a single control
	// control instruction, i.e. a single call the WriteLCD() function.
        int count_y = 0;
        if(x == 1) {
            WriteLCD(0xC0,0,40);
        }

        while(count_y != y) {
            WriteLCD(0x14, 0, 40);
            count_y++;
        }
        
}
Exemplo n.º 4
0
Arquivo: lcd.c Projeto: mjburger/lab1
void LCDPrintChar(char c) {

	// TODO: Write the ASCII character provide as input to the LCD display ensuring
	// the proper delay is utilized.
        WriteLCD(c,1,46);

}
Exemplo n.º 5
0
/* -------------------------------------------------------------------------- */
void WriteChar( SCHR row, SCHR col, const SCHR chr )
{
	SCHR i = 0;
		
	for( i = 0; i < 5; i++ ){
		WriteLCD( row, ( 8 * col ) + i, pgm_read_byte( &Font[chr-' '][i] ) );
	}
}
Exemplo n.º 6
0
int main()
{
	char test;
	char cs;
	char pkt[83];
	char print[] = "Sixteen LCD char";
	char aorp;
	double height;
	struct packet packet_GGA;
	int temp;
	int time[3]      = {0, 0, 0};
	int latitude[3]  = {0, 0, 0};
	int longitude[3] = {0, 0, 0};

	while(1){
		test=getchar();																/*Gets first character from serial stream             */

		*LEDs = *Switches;
		temp  = *LEDs;

		if(checksum(test,cs,pkt)){													/*Pipes all the fun stuff to checksum and parse f'ns  */
			parse_GGA(pkt, &packet_GGA);												/*See gpsparse.h library for full view of functions   */
			temp = (temp & 0x01);
			if (temp == 1){
				sprintf(print, "Lat:%s%c", packet_GGA.latitude, packet_GGA.ns[0]);
				WriteLCD(print);
				sprintf(print, "Lon:%s%c", packet_GGA.longitude, packet_GGA.ew[0]);
				WriteLCD(print);
			};
			if (temp == 0){
				aorp = GMT_to_MST(time, packet_GGA.time);
				sprintf(print, "Time: %d:%02d:%02d%cM", time[0], time[1], time[2], aorp);
				WriteLCD(print);
				height = m_to_ft(packet_GGA.ant_ht);
				sprintf(print, "Elev: %5.2f ft", height);
				WriteLCD(print);
			};
			lat_to_deg(packet_GGA.latitude, latitude);
			long_to_deg(packet_GGA.longitude, longitude);
			printf("Latitude :  %d deg, %d.%05d min\n", latitude[0], latitude[1], latitude[2]);
			printf("Longitude: %d deg, %d.%05d min\n", longitude[0], longitude[1], longitude[2]);
		}
	};
	return 0;
}
Exemplo n.º 7
0
void PrintLCD_p(const char *progmem_s)
{
  register char c;

  while ( (c = pgm_read_byte(progmem_s++)) ) 
  {
    WriteLCD(c);
  }
}
Exemplo n.º 8
0
void SetCharLCD_p(unsigned char AsciiCode, const char *progmem_s)
{
	unsigned char i;
	
	CommandLCD( 0x40|(AsciiCode<<3));
	for(i=0;i<=7;i++)
	{
		WriteLCD(pgm_read_byte(progmem_s++));
	}
}
Exemplo n.º 9
0
Arquivo: lcd.c Projeto: mjburger/lab1
void LCDInitialize(void) {

	// Setup D, RS, and E to be outputs (0).
        LCD_TRIS_D7 = 0; 
        LCD_TRIS_D6  =0;
        LCD_TRIS_D5  =0;
        LCD_TRIS_D4  =0;
        LCD_TRIS_RS  =0;
        LCD_TRIS_E   =0;


	// Initilization sequence utilizes specific LCD commands before the general configuration
	// commands can be utilized. The first few initialization commands cannot be done using the
	// WriteLCD function. Additionally, the specific sequence and timing is very important.
	// Enable 4-bit interface

	// Function Set (specifies data width, lines, and font.

	// 4-bit mode initialization is complete. We can now configure the various LCD
	// options to control how the LCD will function.
        LCD_D = (LCD_D & 0x0FFF) | 0x0000;
        LCD_RS=0;
        LCD_E=0;
        DelayUs(15000);
        LCD_D=(LCD_D & 0x0FFF) | 0x3000;
        EnableLCD(LCD_WRITE_CONTROL, 4100);
        LCD_D=(LCD_D & 0x0FFF) | 0x3000;
        EnableLCD(LCD_WRITE_CONTROL, 100);


	// TODO: Display On/Off Control
	// Turn Display (D) Off
        WriteLCD(0x08, 0, 40);
	// TODO: Clear Display
        LCDClear();
	// TODO: Entry Mode Set
	// Set Increment Display, No Shift (i.e. cursor move)
        WriteLCD(0x06, 0, 40);
	// TODO: Display On/Off Control
	// Turn Display (D) On, Cursor (C) Off, and Blink(B) Off
        WriteLCD(0x0C, 0, 40);
}
Exemplo n.º 10
0
/* -------------------------------------------------------------------------- */
void ClearLCD( void )
{
	USHT col = 0;
	USHT row = 0;

	for( row = 0; row < 8; row++ ){
		for( col = 0; col < 128; col++ ){
			WriteLCD( row, col, 0x00 );
		}
	}
}
Exemplo n.º 11
0
int main(void) {
    
    //--------------
    // Initialization 
    char LCDinit[] = {0x33,0x32,0x28,0x01,0x0c,0x06,0x00}; //Array holding initialization string for LCD
    char Msg1[] = {0x84,'C','U','N','T','\0'};
    char Msg2[] = {0xC5,'R','P','S','\0'};
    char Msg3[10];          // Msg for displaying RPS to LCD (size 10 in case dealing with large numbers)
    InitApp();              // Initialize Ports
    DisplayLCD(LCDinit,1);  // Initialize LCD

    //--------------
    // Message on LCD
    DisplayLCD(Msg1,0);     // Display message on LCD
    DisplayLCD(Msg2,0);     // Display message 2

    //--------------
    // Initialize encoder variables
    CHA = PORTBbits.RB5;    // Initialize channel A
    CHB = PORTBbits.RB4;    // Initialize channel B
    OLD_ROT = 0;            // Initialize state of rotation
    CCWTurn = 0;            // Initialize CCW count
    CWTurn = 0;             // Initialize CW count
    RPS = 0.0;              // Initialize RPS value
    CHAcount = 0;           // Channel A counter

    //--------------
    // Setup PWM cycle to motor
    PR2 = 0x9B;             // Open pwm1 at period = 1 ms
    CCP1CONbits.DC1B1 = 0;  // Set duty cycle of pwm1
    CCP1CONbits.DC1B0 = 0;  // ...
    CCPR1L = 0b00000100;    // ...

    //-------------
    // Set timer and interrupts
    TMR0count = 0;          // Set counter for TMR0
    WriteTimer0(EncoderCount);// Load Timer0
    InitInterrupts();       // Initialize timer interrupts for Port B encoder
    

    //--------------
    // Loop phase: Display RPS on LCD
    while(1)
    {
        WaitHalfSec();
        WriteLCD(0xC0,5,RPS,Msg3);      // Display RPS on LCD
    }


    //--------------
    // Exit main
    CloseTimer0();
    return (EXIT_SUCCESS);
}
Exemplo n.º 12
0
void PCF8814_GFX::Clear(void){
  unsigned int i;
  WriteLCD(LCD_C,0x40); // Y = 0
  WriteLCD(LCD_C,0xb0);
  WriteLCD(LCD_C,0x10); // X = 0
  WriteLCD(LCD_C,0x0);
  WriteLCD(LCD_C,0xae); // disable display;
  for(i=0;i<864;i++)
    WriteLCD(LCD_D,0x00);
  WriteLCD(LCD_C,0xaf); // enable display;
}
Exemplo n.º 13
0
void SignOnLCD(void) {
// I have tested this up to a 4 line by 20 character display
	int i;
	for (i=0; i<20; i++) WriteLCD(LCD_ReadWriteData|Line1[i]);
	WriteLCD(LCD_SetDDRAMAddr|0x40);
	for (i=0; i<20; i++) WriteLCD(LCD_ReadWriteData|Line2[i]);
	WriteLCD(LCD_SetDDRAMAddr|0x14);
	for (i=0; i<20; i++) WriteLCD(LCD_ReadWriteData|Line3[i]);
	WriteLCD(LCD_SetDDRAMAddr|0x54);
	for (i=0; i<20; i++) WriteLCD(LCD_ReadWriteData|Line4[i]);
	SendBytes(ChoosePort);
	}
Exemplo n.º 14
0
void PCF8814_GFX::Initialise() {
  digitalWrite(PIN_RESET, LOW);
  digitalWrite(PIN_RESET, HIGH);
  WriteLCD(LCD_C, 0x23); // CONTRAST?
  WriteLCD(LCD_C, 0x2F); // Charge pump ON
  WriteLCD(LCD_C, 0x24); // Vop MSB *Don't change*
  WriteLCD(LCD_C, 0x90); // Vop LSB *Here you can change contrast*
  WriteLCD(LCD_C, 0xA4); // A4 = normal display mode, A5 = all pixels ON
  WriteLCD(LCD_C, 0xAF); // Display ON

  Clear(); // clear LCD
  WriteLCD(LCD_C,0xa7); // invert display
  delay(500);// 1/2 Sec delay
  WriteLCD(LCD_C,0xa6); // normal display (non inverted)
  delay(1000);				// 1 Sec delay
}
Exemplo n.º 15
0
/* -------------------------------------------------------------------------- */
void DrawBMP( const uint8_t* bmp, UCHR mode )
{
	USHT col = 0;
	USHT row = 0;

	for( row = 0; row < 8; row++ ){
		for( col = 0; col < 128; col++ ){
			switch( mode ){
				case _NORMAL_:					/* 通常表示					  */
					WriteLCD( row, col, pgm_read_byte( bmp ) );
					break;
				case _REVERSAL_:				/* 反転表示					  */
					WriteLCD( row, col, ~( pgm_read_byte( bmp ) ) );
					break;
				default:						/* その他(→エラー表示)	  */
					WriteAlignString( 0, "ERROR!!", _ALIGN_CENTER_ );
					break;
			}
			bmp++;	
		}
	}
	
}
Exemplo n.º 16
0
/* Parses GPS Packet, prints to LCD, sleeps for 750ms */
void task2(void* pdata)
{
  while (1)
  {
	  parse_GGA(pkt, &packet_GGA);

	  if (temp == 1){
		  sprintf(print, "Lat:%s%c", packet_GGA.latitude, packet_GGA.ns[0]);
		  WriteLCD(print);
		  sprintf(print, "Lon:%s%c", packet_GGA.longitude, packet_GGA.ew[0]);
		  WriteLCD(print);
	  };
	  if (temp == 0){
		  aorp = GMT_to_MST(time, packet_GGA.time);
		  sprintf(print, "Time: %d:%02d:%02d%cM", time[0], time[1], time[2], aorp);
		  WriteLCD(print);
		  height = m_to_ft(packet_GGA.ant_ht);
		  sprintf(print, "Elev: %5.2f ft", height);
		  WriteLCD(print);
	  };

	  OSTimeDlyHMSM(0, 0, 1, 0);
  }
}
Exemplo n.º 17
0
/*!
  \brief
  LCD String ausgeben optional mit Zeilenumbruch

  \param  string auszugebender String
  \param  wrap Zeilenumbruch ja oder nein
*/
void PrintLCD(char *string, unsigned char wrap)
{
  unsigned char i = 0;
  while (string[i] != 0x00)
  {
    if (cursorLCD >= LCD_CHARS)
    {
      if (wrap)
        SetCursorLCD(0, lineLCD+1);
      else
        break;
    }
    WriteLCD(string[i]);
    i++;
  }
}
Exemplo n.º 18
0
/*
void DisplayReverse()
{
   WriteLCD(0xa7);
}

void DisplayAllPointsON()
{
   WriteLCD(0xa5);
}
*/
void DisplayAllPointsOFF()     //normal display
{
   WriteLCD(0xa4);
}
Exemplo n.º 19
0
/*void DisplayOFF()
{
   WriteLCD(0xae);
}
*/
void DisplayNormal()
{
   WriteLCD(0xa6);
}
Exemplo n.º 20
0
void DisplayON()
{
   WriteLCD(0xaf);
} 
Exemplo n.º 21
0
bool G15::Write( const uint32_t iData, G15DisplayState throwaway )
{
	unsigned char data[160*43];
	memcpy(data, OpenITGLCD, 160*43);

	// for now, just shows bars on the LCD to indicate lights
	for (unsigned i = 0; i < 32; i++)
	{
		if ( iData & (1 << i) )
		{
			for (unsigned j = 0; j < 43; j++)
			{
				for( unsigned col = 5*i; col < (5*i)+5; col++ )
				{
					data[j*160 + col] ^= 1;
				}
			}
		}
	}

	// pad lights (P1 Left,Right,Up,Down): 8 9 10 11
	// pad lights (P2 Left,Right,Up,Down): 12 13 14 15

	// P1 Left
	if (iData & (1 << 8))
	{
		LCDFill( data, 15, 84, 12, 13 );
	}
	// P1 Right
	if (iData & (1 << 9))
	{
		LCDFill( data, 15, 110, 12, 13 );
	}
	// P1 Up
	if (iData & (1 << 10))
	{
		LCDFill( data, 0, 97, 12, 14 );
	}
	// P1 Down
	if (iData & (1 << 11))
	{
		LCDFill( data, 29, 97, 12, 14 );
	}

	// P2 Left
	if (iData & (1 << 12))
	{
		LCDFill( data, 15, 123, 12, 13 );
	}
	// P2 Right
	if (iData & (1 << 13))
	{
		LCDFill( data, 15, 148, 12, 13 );
	}
	// P2 Up
	if (iData & (1 << 14))
	{
		LCDFill( data, 0, 135, 12, 14 );
	}
	// P2 Down
	if (iData & (1 << 15))
	{
		LCDFill( data, 29, 135, 12, 14 );
	}

	return WriteLCD(data);
}
Exemplo n.º 22
0
int main(void)
{

    ind = 0;
	// Setup functions for operation
	CP0Init();
	INTInitialize();
	ADCSetup();
	SetupButtons();
	SetupIO();
	SetupT1CountINT();
	SetupTimer2_3PWM();
        //SetupUART(115200);
        NU32_EnableUART2Interrupt();


	// Wait until LCD screen comes up
	wait(1000);	wait(1000);	wait(1000); wait(1000);
	LCDConfig();
	LCDSetup();


        ClearLCDScreen();

        char msg[32];
        sprintf(msg,"UART demo. Press A to start");
	WriteLCD(1,msg);

        int button = 1;
        while(button == 1) {
            button = BUTTON_A;
        }
        wait(1000);
        while(button == 0)
        {
            button = BUTTON_A;
        }
        wait(1000);
        
        // send dollar signs to enter command mode
        char send1[] = "$$$";
        SerialTransmit(send1);

        wait(1000);wait(1000);wait(1000);
        // print message and wait for press
/*        ClearLCDScreen();
        wait(1000);wait(1000);wait(1000);
        sprintf(msg,"command mode. press A");
	WriteLCD(1,msg);
        wait(1000);wait(1000);wait(1000);
        button = 1;
        while(button == 1) {
            button = BUTTON_A;
        }
        wait(1000);
        while(button == 0)
        {
            button = BUTTON_A;
        }
        wait(1000);
        wait(1000);
*/
        while(next == 0);
        next = 0;

        char send2[] = "GB\n";
        SerialTransmit(send2);

        while(1)
        {
            ClearLCDScreen();
            WriteLCD(0,string);
            wait(10000);
            wait(10000);
            wait(10000);
        }

        // receive response from chip
        char temp[4];
        SerialReceive(temp, 4, CHAR_MODE);
        
//        // print response to lcd
//        ClearLCDScreen();
//        WriteLCD(1,temp);
        

        
        char temp2[32];
        SerialReceive(temp2, 32, HEX_MODE);

        ClearLCDScreen();
        WriteLCD(1,temp2);


 /*
  * Software State machine
  *     POR:
  *         Try to connect
  *
  *
  */

        return 0;
}
Exemplo n.º 23
0
int main(void)
{
	int delay;
	d2 = 0;
	d1 = 0;
	state = 0;
	reset = 1;
	adc1 = 0;
	adc2 = 0;
	led = 0;
	pwm = 0;
	double volt1 = 0.0;
	double volt2 = 0.0;

	// Setup functions for operation
	CP0Init();
	INTInitialize();
	ADCSetup();
	SetupButtons();
	SetupIO();
	SetupT1CountINT();
	SetupTimer2_3PWM();

	// Wait until LCD screen comes up
	wait(1000);	wait(1000);	wait(1000); wait(1000);
	LCDConfig();
	LCDSetup();

	

	// Start the timer
	T1CONbits.ON = 1;

	while(1)
	{
    		if(reset == 1)
		{
			ClearLCDScreen();
			sprintf(string,"A = Cmd button");
			WriteLCD(1,string);
			reset = 0;
			state = 0;
		}
		else
		{
			switch(state)
			{
				case 0:
					if(state_init[0] != 0)
						state_init[0] = 0;
					wait(100);
					break;
				case 1:
					if(state_init[0] != 1)
					{
						state_init[0] = 1;
						if(state_init[1] == 0)
							state_init[1] = 1;
						else
							state_init[1] = 0;
					}
					wait(100);
					break;
				case 2:
					if(state_init[0] != 2)
					{
						state_init[0] = 2;
						if(state_init[2] == 0)
							state_init[2] = 1;
						else
							state_init[2] = 0;
					}
					wait(100);
					break;
				case 3:
					if(state_init[0] != 3)
					{
						state_init[0] = 3;
						if(state_init[3] == 0)
							state_init[3] = 1;
						else
							state_init[3] = 0;
					}
					wait(100);
					break;
				case 4:
					if(state_init[0] != 4)
					{
						state_init[0] = 4;
						if(state_init[4] == 0)
							state_init[4] = 1;
						else
							state_init[4] = 0;
					}
					wait(100);
					break;
				default:
					wait(100);
					break;
			}
			if(state_init[1] == 0 && state_init[2] == 0 && state_init[3] == 0)
				sprintf(string,"LB=0;RB=0;WPER=0");
			else if(state_init[1] == 1 && state_init[2] == 0 && state_init[3] == 0)
				sprintf(string,"LB=1;RB=0;WPER=0");
			else if(state_init[1] == 0 && state_init[2] == 1 && state_init[3] == 0)
				sprintf(string,"LB=0;RB=1;WPER=0");
			else if(state_init[1] == 1 && state_init[2] == 1 && state_init[3] == 0)
				sprintf(string,"LB=1;RB=1;WPER=0");
			else if(state_init[1] == 0 && state_init[2] == 0 && state_init[3] == 1)
				sprintf(string,"LB=0;RB=0;WPER=1");
			else if(state_init[1] == 1 && state_init[2] == 0 && state_init[3] == 1)
				sprintf(string,"LB=1;RB=0;WPER=1");
			else if(state_init[1] == 0 && state_init[2] == 1 && state_init[3] == 1)
				sprintf(string,"LB=0;RB=1;WPER=1");
			else if(state_init[1] == 1 && state_init[2] == 1 && state_init[3] == 1)
				sprintf(string,"LB=1;RB=1;WPER=1");

			if(state != -1)// && state != 0)
			{
				wait(100);
				WriteLCD(2,string);
			}
		}		
	}
	return 0;
}
Exemplo n.º 24
0
void PowerControlSet()  //This command sets the on-chip power supply function ON/OFF.
{
   WriteLCD(0x2f);
}
Exemplo n.º 25
0
void PageAddressSet()
{
   WriteLCD(0xb0);	  //

}
Exemplo n.º 26
0
Arquivo: lcd.c Projeto: mjburger/lab1
void LCDClear(void) {

	// TODO: Write the proper control instruction to clear the screen ensuring
	// the proper delay is utilized.
        WriteLCD(0x01,0,1640);
}