Esempio n. 1
0
void drawClock(int hours, int minutes, int seconds) {
  //get current cursor positon
  uint32_t prev_xPos = GetXPos();
  uint32_t prev_yPos = GetYPos();

  //move the curser to the top left
  GotoXY(0,0);
  //show hours
  if (hours <= 9) {
    DisplayInteger(0);
  }
  DisplayInteger(hours);
  DisplayChar(':');

  //show minutes
  if (minutes <= 9) {
    DisplayInteger(0);
  }
  DisplayInteger(minutes);
  DisplayChar(':');

  //show seconds
  if (seconds <= 9) {
    DisplayInteger(0);
  }
  DisplayInteger(seconds);
  
  //reset the cursor to it's previous position
  GotoXY(prev_xPos, prev_yPos);
}
Esempio n. 2
0
void printTripHystory(signed int point)
{
	int temp;

	LCD_clear();
	temp = point + '0';

	strcpy(st, "TRIP [0]");
	st[6] = point + '0';
	PrintLCD(0,0,st);

 	delay_sec();

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.000e+1");	// rq trip code
	gSciTxBuf[8] = temp;

	SendSciString( gSciTxBuf );
	delay_sec();
	if( getSciMsg(st)) printLCD(0,10,st); // disp code
	else DisplayChar( 0 , 10, '-');

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.500e+1");   // trip time
	gSciTxBuf[8] = temp;
	SendSciString( gSciTxBuf );
	delay_sec(); 
	if( getSciMsg(st)) printLCD(2,0,st); // time
	else DisplayChar( 2 , 1, '-');

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.600e+1");   // rq trip message
	gSciTxBuf[8] = temp;
	SendSciString( gSciTxBuf );
	delay_sec(); 
	if( getSciMsg(st)) printLCD(1,0,st); // disp message
	else DisplayChar( 1 , 1, '-');

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.400e+1");   // trip VDC
	gSciTxBuf[8] = temp;
	SendSciString( gSciTxBuf );
	delay_sec(); 
	if( getSciMsg(st)) printLCD(3,0,st); // debug
	else{
		strcpy(st," -    ");   
		printLCD(3,0,st);
	}

	sci_rx_msg_start = sci_rx_msg_end = 0;
	strcpy(gSciTxBuf,"9:4:903:0.100e+1");   // trip data
	gSciTxBuf[8] = temp;
	SendSciString( gSciTxBuf );
	delay_sec(); 
	if( getSciMsg(st)) printLCD(3,10,st); // debug
	else DisplayChar( 3 , 10, '-');
}
Esempio n. 3
0
void SelectMenuPage1()			// System 설정 메뉴
{
	BUTTON KeyIn;

	int loopCtrl =1;
	int selection = 1;

	LCD_Clear();
	strcpy(st, " - MAIN MENU -   1/2");
	PrintLCD(0,0,st);

	DisplayChar(1, 0, '1');
	strcpy(st, " EDIT CTRL DATA   ");
	PrintLCD(1,2,st);

	DisplayChar(2, 0, '2');
	strcpy(st, " TRIP RECORD VIEW  ");
	PrintLCD(2,2,st);

	DisplayChar(3, 0, '3');
	strcpy(st, " SYSTEM RESET     ");
	PrintLCD(3,2,st);


	while( loopCtrl )
	{
		KeyIn = GetKey();
	
		Cursor(selection,0,CURSOR_BLINK);
		if( KeyIn == BTN_DOWN ){
			if(selection >= 3 ){
				machine_state = STATE_SET_MODE2;
				return;
			}
			else selection ++;
		}
		else if( KeyIn == BTN_UP ){
			if(selection > 1 ) selection --;
		}
		else if (( KeyIn == BTN_RIGHT)|| (KeyIn == BTN_ESC)){ 
			machine_state = STATE_SET_MODE2;
			return;
		} 
		else if ( KeyIn == BTN_STOP){
			machine_state = STATE_MONITOR_MODE;
			return;
		}
		else if( KeyIn == BTN_SET){
			if(		 selection == 1) 	Machine_state = STATE_EDIT_MODE;
			else if( selection == 2)	machine_state = STATE_TRIP_MODE;
			else						machine_state = STATE_RESET_MODE;
			return;
		}	
	}
}
Esempio n. 4
0
void TripCodeDataProc()			// EEPROM TRIP ERROR DATA LOAD
{
	BUTTON KeyIn;
	int loopCtrl=1;
	signed int point = 0;
	int change=1;
	LCD_Clear();
	strcpy(st, "TRIP [0]");
	PrintLCD(0,0,st);

	strcpy(st, "          ");
	PrintLCD(0,10,st);

	DisplayChar(1, 0, '1');
	strcpy(st, " TRIP DESCIPTION ");
	PrintLCD(1,2,st);

	DisplayChar(2, 0, '2');
	strcpy(st, " RECORD DATE  ");
	PrintLCD(2,2,st);

	strcpy(st, "VDC=      ");
	PrintLCD(3,0,st);

	strcpy(st, "DATA=     ");
	PrintLCD(3,10,st);

	printTripHystory(0);

	Cursor(0,6,CURSOR_BLINK);				

	while( loopCtrl){

		KeyIn = GetKey();

		if( KeyIn == BTN_SET )	printTripHystory( point );
		else if( KeyIn  == BTN_STOP){
			machine_state = STATE_SET_MODE;
			loopCtrl = 0;
			return ;
		}
		else if( KeyIn == BTN_DOWN)	point --;
		else if( KeyIn == BTN_UP)	point++;
		else 						change = 0;

		if		(point > 9) point = 0;
		else if	(point < 0 ) point = 9;

		if(change){
			DisplayChar(0,6,point+'0');
			Cursor(0,6,CURSOR_BLINK);				
		}
		else change = 1;
	}
}
Esempio n. 5
0
void
cyg_hal_plf_screen_putc(void *__ch_data, char ch)
{
    CYGARC_HAL_SAVE_GP();

	switch( ch )
	{
	case '\n':
		NewLine();
		return;

	case '\r':
		XPos = 0;
		MoveCursor();
		return;

	case '\b':
		if( XPos == 0 ) return;
		XPos--;
		MoveCursor();
		return;

	case '\t':
		do
		{
			DisplayChar(' ');
		} while( (XPos % 8) != 0 );
		return;

	case 0x0c:
		ClearScreen();
		XPos = YPos = 0;
		MoveCursor();
		return;		

	case 1:
		ScrollUp(1);
		XPos = 0;
		YPos = ScreenLength-1;
		return;

	case 2:
		ScrollDown(1);
		XPos = 0;
		YPos = 0;
		return;
	
		
	default:
		DisplayChar(ch);
		return;
	}

    CYGARC_HAL_RESTORE_GP();
}
Esempio n. 6
0
void SelectMenuPage2()
{
	BUTTON KeyIn;
	int loopCtrl =1;
	int selection = 1;

	LCD_Clear();
	strcpy(st, " - MAIN MENU -   2/2");
	PrintLCD(0,0,st);

	DisplayChar(1, 0, '4');
	strcpy(st, " DATE & TIME SET  ");
	PrintLCD(1,2,st);

	DisplayChar(2, 0, '5');
	strcpy(st, " RECORD CLEAR ALL ");
	PrintLCD(2,2,st);

	DisplayChar(3, 0, '6');
	strcpy(st, " SYSTEM INIT      ");
	strcpy(st, " POSION VALUE TEST");
	PrintLCD(3,2,st);

	while( loopCtrl )
	{
		Cursor(selection,0,CURSOR_BLINK);
		KeyIn = GetKey();
	
		if( KeyIn == BTN_DOWN ){
			if(selection >= 3 ){
				machine_state = STATE_SET_MODE;
				return;
			}
			else selection ++;
		}
		else if( KeyIn == BTN_UP ){
			if(selection > 1 ) selection --;
		}
		else if ( (KeyIn == BTN_ESC) || (KeyIn == BTN_RIGHT)){ 
			machine_state = STATE_SET_MODE;
			return;
		} 
		else if ( KeyIn == BTN_STOP){
			machine_state = STATE_MONITOR_MODE;
			return;
		}
		else if( KeyIn == BTN_SET){
			if(		 selection == 1) Machine_state = STATE_TIME_MODE;
			// else if( selection == 2)	machine_state = STATE_TRIP_MODE;
			// else						machine_state = STATE_RESET_MODE;
			return;
		}	
	}
}
Esempio n. 7
0
void DisplayString(u8 *s,u8 x,u8 y,u8 Reverse)
{
	u8 a[10],i;
	if(Reverse)
	{
		i=0;
		while(*s){a[i]=*s;s++;i++;}
		s=swap(a,sizeof(a));
	}
	while (*s) 
	{ 
		if(Reverse)
			{DisplayChar_Reverse(*s,x,y);}
		else
			{DisplayChar(*s,x,y);}
		if(++x>=30)
		{
			x=0;
			if(++y>=20)
			{
			  y=0;
			}
		}
		s++;
    }
}
Esempio n. 8
0
BOOL TTYTerm::ProcessChars (LPSTR szChars, int nNumChars)
{
		int   i ;
    LPSTR lpCurrChar ;

		for(i=0, lpCurrChar=szChars; i<nNumChars; i++,lpCurrChar++)
		{
    		DisplayChar (*lpCurrChar) ;
		}
    return (TRUE) ;
}
Esempio n. 9
0
void CScreenDevice::DisplayChar (char chChar)
{
	// TODO: Insert mode
	
	if (' ' <= (unsigned char) chChar)
	{
		DisplayChar (chChar, m_nCursorX, m_nCursorY, m_Color);

		CursorRight ();
	}
}
Esempio n. 10
0
void CScreenDevice::Rotor (unsigned nIndex, unsigned nCount)
{
	static const char chChars[] = "-\\|/";

	nIndex %= ROTORS;
	nCount &= 4-1;

	unsigned nPosX = m_nWidth - (nIndex + 1) * m_CharGen.GetCharWidth ();

	DisplayChar (chChars[nCount], nPosX, 0, HIGH_COLOR);
}
Esempio n. 11
0
/****** Display ********************************************************
 *
 * Get string and display each of its characters.
 * COLx and ROWy identify the LCD pixel position for the start of
 * the character to be displayed.
***********************************************************************/
void Display(uint16 color, uint8 *str)
{
   ROWy = (str[0] * 24) - 19;     // LCD pixel position for start of char.
   COLx = (str[1] * 12) - 7;
   str = str + 2;                 // Skip over row and column bytes
   while (*str != 0)
   {
      DisplayChar(color, *str);
      COLx += 12;                 // Move to right one char. position
      str++;
   }
}
Esempio n. 12
0
void lcd_display_number(unsigned int x,
                        unsigned int y,
                        unsigned long num,
                        unsigned char num_len )
{
        unsigned char t,temp;
        unsigned char enshow=0;          // ´Ë±äÁ¿ÓÃÀ´È¥µô×î¸ßλµÄ0

        for(t=0;t<num_len;t++)
        {
                temp=(num/mypow(10,num_len-t-1))%10;
                if(enshow==0&&t<(num_len-1))
                {
                        if(temp==0)
                        {
                                DisplayChar(' ',x+t,y);
                                continue;
                        }else enshow=1;

                }
                DisplayChar(temp+'0',x+t,y);
        }
}
Esempio n. 13
0
int
main ()
{
	void *p = &main;
	char *arg = p - (*(int *)(p - 8));
	int flags = (*(int *)(p - 12));
		if (strlen(arg) <= 0)
	{
		return 1;
	}

	while(arg[0]==' ' || arg[0]=='\t') arg++;

	if (strlen(arg) > 256)
	return !(errnum = ERR_WONT_FIT);

	if (open(arg))
	{
		read ((unsigned long long)(unsigned int)(char *) RAW_ADDR (BASE_FONT_ADDR), -1, 0xedde0d90);
		close();

		if (InitFont())
		{
				unsigned long long ch;
				arg=skip_to(0,arg);
				if (! safe_parse_maxint(&arg,&ch))
					return 0;
				ch &= 0xffff;
			if (ch)
			{
				ReadCharDistX(ch);
				int dwOffset;
				WORD bytesPerLine = 0;
				dwOffset = ReadCharDotArray(ch, &bytesPerLine);
				DisplayChar(_fl_header.YSize, bytesPerLine, (char *)BASE_FONT_ADDR + dwOffset);
				return 0;
			}
		}
		return 1;
	}
	else
	{
		printf ("load fontfile failed!\n");
		return 0;
	}
}
Esempio n. 14
0
/****** Display ********************************************************
 *
 * Get string and display each of its characters.
 * COLx and ROWy identify the LCD pixel position for the start of
 * the character to be displayed.
***********************************************************************/
void Display(int background, char *str)
{
   ROWy = (str[0] * 24) - 19;     // LCD pixel position for start of char.
   COLx = (str[1] * 12) - 7;
  
   //char startR = str[0];  
   //char startC = str[1];
   //Box(startR, startC, startR, startC+3, background); // 

   str = str + 2;                 // Skip over row and column bytes
   while (*str != 0)
   {
      DisplayChar(background, *str);
      COLx += 12;                 // Move to right one char. position
      str++;
   }
}
Esempio n. 15
0
void CheckSumErrorProc()
{
	BUTTON KeyIn;
	int loopCtrl =1;
	strcpy(st, " BACKUP RESTORE OK?");
	strcpy(st, " INIT RESTORE OK?  ");
	PrintLCD(0,0,st);
	strcpy(st, " YES     NO     ");
	PrintLCD(2,3,st);

	while(loopCtrl){
		KeyIn = GetKey();

		if ( KeyIn == BTN_ESC){
			if(Flag_Set == 1 && Flag_Start == 1)		DisplayChar(2, Flag_Set + 1, ' ' );
			else if(Flag_Set == 2 && Flag_Start == 1)	DisplayChar(2, Flag_Set + 8, ' ' );

			if(Flag_Start != 3)	Flag_Set++;
		}
		else if ( KeyIn == BTN_RIGHT){
			if(Flag_Set == 1 && Flag_Start == 1) DisplayChar(2, Flag_Set + 1, ' ' );
			else if(Flag_Set == 2 && Flag_Start == 1) DisplayChar(2, Flag_Set + 8, ' ' );
			if(Flag_Start != 3)	Flag_Set--;
		}
		else if ( KeyIn == BTN_STOP){
			machine_state = STATE_EDIT_MODE;
			return;
		}
		else if ( KeyIn == BTN_RUN){
			Flag_Btn = 2;
			if(Flag_Set == 1 && Flag_Start != 3)
			{
				Flag_Start = 3;
				strcpy(Trip_Message, "                    ");
				Lcd_Clear();
				Lcd_x_posi = 0, Lcd_y_posi = 0;
				if(Flag_Page == 3)
					strcpy(gSciTxBuf,"9:4:907:0.000e-0");
				else if(Flag_Page == 4)
					strcpy(gSciTxBuf,"9:4:907:1.000e-0");
				SendSciString( gSciTxBuf );
			}
		}
		if(Flag_Set > 2)	 Flag_Set = 1;
		else if(Flag_Set < 1) Flag_Set = 2;
	
		if(Flag_Set == 1 && Flag_Start == 1) 		DisplayChar(2, Flag_Set + 1, '*' );
		else if(Flag_Set == 2 && Flag_Start == 1)	DisplayChar(2, Flag_Set + 8, '*' );
	}
}
Esempio n. 16
0
void DrawString (const char *string, uint16 *screen, uint8 x, uint8 y)
{
	uint16 *Screen = screen + 2 + x + y * 320;
	int len = strlen (string);
	int max_chars = 320 / (font_width - 1);
	int char_count = 0;
	int i;

	for (i = 0; i < len; i++, char_count++)
	{
		if (char_count >= max_chars || string [i] < 32)
		{
			Screen -= (font_width - 1) * max_chars;
			Screen += font_height * 320/*pitch*/;
			if (Screen >= screen + 320/*pitch*/ * 240)
				break;
			char_count -= max_chars;
		}
		if (string [i] < 32)
			continue;
		DisplayChar (Screen, string [i]);
		Screen += (font_width - 1);// * sizeof (uint16); 
	}
}
Esempio n. 17
0
void DisplayString(char *s)
{
     while (*s) { DisplayChar(*s); s++; }
}
Esempio n. 18
0
void CRLF()
{
     DisplayChar('\r');
     DisplayChar('\n');
}
Esempio n. 19
0
void DisplayChar(char ch)
{
     int *p;
     int nn;
     ACB *j;

     j = GetACBPtr();
     switch(ch) {
     case '\r':  j->CursorCol = 0; UpdateCursorPos(); break;
     case '\n':  IncrementCursorRow(); break;
     case 0x91:
          if (j->CursorCol < j->VideoCols-1) {
             j->CursorCol++;
             UpdateCursorPos();
          }
          break;
     case 0x90:
          if (j->CursorRow > 0) {
               j->CursorRow--;
               UpdateCursorPos();
          }
          break;
     case 0x93:
          if (j->CursorCol > 0) {
               j->CursorCol--;
               UpdateCursorPos();
          }
          break;
     case 0x92:
          if (j->CursorRow < j->VideoRows-1) {
             j->CursorRow++;
             UpdateCursorPos();
          }
          break;
     case 0x94:
          if (j->CursorCol==0)
             j->CursorRow = 0;
          j->CursorCol = 0;
          UpdateCursorPos();
          break;
     case 0x99:  // delete
          p = CalcScreenLocation();
          for (nn = j->CursorCol; nn < j->VideoCols-1; nn++) {
              p[nn-j->CursorCol] = p[nn+1-j->CursorCol];
          }
          p[nn-j->CursorCol] = GetCurrAttr() | AsciiToScreen(' ');
          break;
     case 0x08: // backspace
          if (j->CursorCol > 0) {
              j->CursorCol--;
              p = CalcScreenLocation();
              for (nn = j->CursorCol; nn < j->VideoCols-1; nn++) {
                  p[nn-j->CursorCol] = p[nn+1-j->CursorCol];
              }
              p[nn-j->CursorCol] = GetCurrAttr() | AsciiToScreen(' ');
          }
          break;
     case 0x0C:   // CTRL-L
          ClearScreen();
          HomeCursor();
          break;
     case '\t':
          DisplayChar(' ');
          DisplayChar(' ');
          DisplayChar(' ');
          DisplayChar(' ');
          break;
     default:
          p = CalcScreenLocation();
          *p = GetCurrAttr() | AsciiToScreen(ch);
          IncrementCursorPos();
          break;
     }
}
Esempio n. 20
0
//long buildCounter = 0;
//__________________________________________________________________
void	_HYSequencePane::BuildPane (bool setport)
{
	if (setport) 
	{	
		StartDraw();		
		EraseAll();
	}
	if (columnStrings.lLength)
	{
		long visWidth  = _HYCanvas::GetMaxW()-headerWidth-5,
			 visHeight = _HYCanvas::GetMaxH()-5,
			 rowCount = speciesIndex.lLength,
			 slotHeight = GetSlotHeight(),h,v,lastColor = -1, selectionIndex = 0,
			 c;
		if (settings.width&HY_COMPONENT_V_SCROLL) visWidth-=HY_SCROLLER_WIDTH;
		if (settings.width&HY_COMPONENT_H_SCROLL) visHeight-=HY_SCROLLER_WIDTH;
		if (startColumn<0)
			startColumn = 0;
		if (startRow<0)
			startRow = 0;
		if (setport)
		{
			endColumn = startColumn+visWidth/charWidth;
			h = (endColumn-startColumn)/5;
			endColumn = startColumn+(visWidth-h)/charWidth;
			endRow = startRow+visHeight/slotHeight;
		}
		if (endColumn>columnStrings.lLength)
			endColumn = columnStrings.lLength;
		if (endRow>rowCount)
			endRow = rowCount;
		
		_HYRect		r = {0,0,visHeight,visWidth+headerWidth,1},
					backCharRect;
		
		_HYColor    blackC      = {0,0,0}, 
					charColor   = {0,0,0}, 
					whiteC	    = {255,255,255},
					selectColor = highlightColor;

		if (setport)
			SetColor	(backColor);
		else
		{
			selectColor = (_HYColor){160,160,160};
			SetColor	  (whiteC);
		}
		
		FillRect	(r);
					
		SetColor (blackC);
		BuildHeaders();
		if (numbers)
		{
			r.left = 0;
			r.right = visWidth+headerWidth;
			r.bottom = (GetSlotHeight()+1);
			SetColor (headerColor);
			FillRect(r);
			if (setport)
			{
				SetColor (blackC);
				r.top = r.bottom;
				DrawLine 	(r);
			}
		}
		
		if (setport)
		{
			r.left = r.right = headerWidth;
			r.top = 0;
			r.bottom = visHeight;
			DrawLine	(r);
		}
		r.left = r.right = headerWidth;
		r.top = 0;
		r.bottom = visHeight;
		h = HY_SEQUENCE_PANE_CHAR_SPACING/2+headerWidth;
		visWidth+=headerWidth;
		for (c = startColumn; c < endColumn; c++,h+=charWidth)
		{
			if (h+charWidth>visWidth)
			{
				endColumn = c;
				break;
			}
			
			bool isColumnSelected = false;
			
			if (selectionIndex<selection.lLength)
			{
				rowCount = selection.lData[selectionIndex];
				while ((rowCount<c)&&(selectionIndex<selection.lLength))
				{
					selectionIndex++;
					rowCount = selection.lData[selectionIndex];
				}
				
				if (c==rowCount)
				{
					if (!invertColors)
					{
						_HYRect invR;
						invR.top    = (GetSlotHeight()+1)+1;
						invR.bottom = visHeight-1;
						invR.right  = h+charWidth;
						invR.left   = h;
						
						if (c&&(c%blockWidth==0))
							invR.right+=2;
						else
							if (c+1==endColumn)
								invR.right+=3;
							
						charColor = GetColor();
						SetColor (selectColor);
						FillRect (invR);
						SetColor (charColor);
						
					}
					selectionIndex++;
					isColumnSelected = true;
				}
			}
			
			if (c && (c%blockWidth==0) && (setport|| c>startColumn) )
			{
				SetColor (blackC);
				if (numbers)
				{
					_String number (c);
					#ifdef __MAC__
						rowCount = h-2-GetVisibleStringWidth(number);
					#else
						rowCount = h-2-GetVisibleStringWidth(number, font);	
					#endif
					if (rowCount>headerWidth)
						DisplayText (number,slotHeight-3,rowCount,true);
				}
				if (setport)
				{
					r.left = r.right = h;
					DrawLine (r);
				}
				SetColor (charColor);
				h+=2;
			}
			
			if (numbers)
				v = slotHeight+(GetSlotHeight()+1);
			else
				v = slotHeight;
				
			_String 	  *thisString = (_String*)columnStrings(c);
			
			unsigned char topChar = showDots?thisString->sData[speciesIndex.lData[0]]:0;
			
			//if (!setport)
				//SetColor (blackC);
			
			backCharRect = (_HYRect)
			{
				v-slotHeight+1,h-1,v+1,h+charWidth-1,0
			};
			if ((c+1)%blockWidth == 0)
				backCharRect.right++;
			
			for (long r = startRow; r < endRow; r++,v+=slotHeight)
			{
				unsigned char thisC = thisString->sData[speciesIndex.lData[r]];
				long	 myColor	= colorMap[thisC];
				
				if (r && thisC==topChar)
					thisC = '.';
				
				//if (setport)
				{
					if (invertColors && !isColumnSelected)
					{
						charColor = LongToHYColor (characterColors.lData[myColor]);
						if ((long)charColor.R+charColor.G+charColor.B > 100)
						{
							SetColor (charColor);
							FillRect 	(backCharRect);
						}
						backCharRect.top    += slotHeight;
						backCharRect.bottom += slotHeight;
						SetColor	(blackC);
					}
					else
						if (colorMap[thisC]!=lastColor)
						{
							lastColor = colorMap[thisC];
							charColor = LongToHYColor(characterColors.lData[lastColor]);
							SetColor (charColor);
						}
				}
				DisplayChar (thisC,v,h);
			}
		}
		
		if ((!setport)&&(c%blockWidth == 0))
		{
			SetColor (blackC);
			if (numbers)
			{
				_String number (c);
				#ifdef __MAC__
					rowCount = h-2-GetVisibleStringWidth(number);
				#else
					rowCount = h-2-GetVisibleStringWidth(number, font);	
				#endif
				if (rowCount>headerWidth)
					DisplayText (number,slotHeight-3,rowCount,true);
			}
		}
		SetColor (blackC);
		r.left = 0;
		r.right = visWidth;
		
			
		if (settings.width&HY_COMPONENT_BORDER_B)
		{
			r.top = r.bottom = visHeight-1;
			if (setport) DrawLine(r);
		}
		
	}
	if (setport) 
		EndDraw();
}
Esempio n. 21
0
void keyboardHandler(struct isrregs *r) {
  //first setup our static variables
  static Escapes escapes = {
    0, //E0
    0, //E1
    0, //LSHIFT
    0, //RSHIFT
    0, //LCTRL
    0, //RCTRL
    0, //LALT
    0, //RALT
  };

  static keyLEDs leds = {
    0, //scroll
    0, //caps
    0, //num
  };

  //receive byte from keyboard
  KeyScanCode scancode = getKeyboardOutput();

  //first determine if the key being pressed is an escape
  static uint8_t escapeCode = ESCAPE_NONE;

  if (!scancode.released) {
    switch (scancode.keycode) {

    case KEY_CAPSLOCK:
      if (leds.caps) {
	leds.caps = 0;
      }
      else {
	leds.caps = 1;
      }
      updateKeyboardLEDs(leds);
      return;

    case KEY_NUMLOCK:
      if (leds.num) {
	leds.num = 0;
      }
      else {
	leds.num = 1;
      }
      updateKeyboardLEDs(leds);
      return;

    case KEY_SCROLL:
      if (leds.scroll) {
	leds.scroll = 0;
      }
      else {
	leds.scroll = 1;
      }
      updateKeyboardLEDs(leds);
      return;

    case KEY_LSHIFT:
      escapes.LSHIFT = 1;
      return;

    case KEY_RSHIFT:
      escapes.RSHIFT = 1;
      return;

    case KEY_LCTRL:
      escapes.LCTRL = 1;
      return;

    case KEY_LALT:
      escapes.LALT = 1;
      return;
    }
    

    escapeCode = ESCAPE_NONE;
    //determine what escape code we should be registering
    if (escapes.LSHIFT || escapes.RSHIFT) {
      escapeCode = ESCAPE_SHIFT;
      if (leds.caps) {
	escapeCode = ESCAPE_SHIFT_CAPS;
      }
    }
    else {
      if (leds.caps) {
	escapeCode = ESCAPE_CAPS;
      }
    }

    //override all other codes if we get E0 or E1
    if (escapes.E0) {
      escapeCode = ESCAPE_E0;
    }

    if (escapes.E1) {
      escapeCode = ESCAPE_E1;
    }

    //if the value isn't an escape, register that we pressed down the given key
    KEYPRESS_INDEX(scancode.keycode, escapeCode) = 1;

    //check to see if an ascii value can be displayed
    if (KEY_INDEX(scancode.keycode, escapeCode)) {
      DisplayChar(KEY_INDEX(scancode.keycode, escapeCode));
    }
    else {
      //DisplayInteger(scancode.keycode);
      //DisplayChar(':');
      //DisplayInteger(KEY_INDEX(scancode.keycode, escapeCode));
      //DisplayChar(':');
      //DisplayInteger(escapeCode);
      //DisplayChar(' ');
    }
  }
  else {
    switch (scancode.keycode) {

    case KEY_ESCAPE0:
    case KEY_ESCAPE0_OLD:
      escapes.E0 = 1;
      return;

    case KEY_ESCAPE1:
    case KEY_ESCAPE1_OLD:
      escapes.E1 = 1;
      return;

    case KEY_LSHIFT:
      escapes.LSHIFT = 0;
      return;

    case KEY_RSHIFT:
      escapes.RSHIFT = 0;
      return;

    case KEY_LCTRL:
      escapes.LCTRL = 0;
      return;

    case KEY_LALT:
      escapes.LALT = 0;
      return;
    }
    
    KEYPRESS_INDEX(scancode.keycode, escapeCode) = 0;
  } 
  
  //upon finishing, we reset the escapes to zero
  escapes.E0 = 0;
  escapes.E1 = 0;
  

  return;
}
Esempio n. 22
0
//__________________________________________________________________
void	_HYSequencePane::HScrollPane (long dx)
{
	#ifndef __HYPHY_GTK__
	if (abs(dx)>=endColumn-startColumn-5)
	#endif
	{
		startColumn+=dx;
		BuildPane();
		_MarkForUpdate();
		return;
	}
	
	long visWidth = _HYCanvas::GetMaxW()-headerWidth-5,
		 visHeight = _HYCanvas::GetMaxH()-5,
		 slotHeight = GetSlotHeight(),h,v,lastColor = -1,adx,
		 loopStart,loopEnd,selectionIndex = 0;
	
	if (settings.width&HY_COMPONENT_V_SCROLL) visWidth-=HY_SCROLLER_WIDTH;
	if (settings.width&HY_COMPONENT_H_SCROLL) visHeight-=HY_SCROLLER_WIDTH;

	if (dx>0)
	{
		if (endColumn+dx>columnStrings.lLength)
			dx = columnStrings.lLength-endColumn;
		adx = dx;
		v = (startColumn+dx)/blockWidth-startColumn/blockWidth;
		if (startColumn&&(startColumn%blockWidth==0)) v++;
		if ((startColumn+dx)&&((startColumn+dx)%blockWidth==0)) v--;
	}
	else
	{
		if  (startColumn<-dx)
			dx=-startColumn;
		adx = -dx;
		v = startColumn/blockWidth-(startColumn+dx)/blockWidth;
		if (startColumn&&(startColumn%blockWidth==0)) v--;
		if ((startColumn+dx)&&((startColumn+dx)%blockWidth==0)) v++;
	}
	if (!dx)
		return;
			
	StartDraw();
	
	h = adx*charWidth+2*v;
	_HYRect		r = {0,0,visHeight,0,1},
				backCharRect;
				
	visWidth+=headerWidth;

	startColumn+=dx;
	endColumn+=dx;

	if (dx>0)
	{
		r.left = headerWidth+1;
		r.right = visWidth;
		_SlideRect (r,0,-h);
	}
	else
	{
		r.left = headerWidth+1;
		r.right = visWidth;
		_SlideRect (r,0,h);
	}
	

	if (dx>0)
	{
		r.right = visWidth;
		r.left = r.right-h;
	}
	else
	{
		r.left = headerWidth+1;
		r.right = headerWidth+h+1;
	}
	SetColor	(backColor);
	FillRect	(r);
	_HYColor    blackC = {0,0,0}, 
				charColor = {0,0,0},
				selectColor = highlightColor;
				
	r.top = 0;
	if (numbers)
	{
		r.bottom = (GetSlotHeight()+1);
		SetColor(headerColor);
		FillRect(r);
		r.top = r.bottom;
	}
	else
		r.top = r.bottom = 0;
	SetColor	(blackC);

	if (settings.width&HY_COMPONENT_BORDER_T)
		DrawLine 	(r);

	if (settings.width&HY_COMPONENT_BORDER_B)
	{
		r.top = r.bottom = visHeight-1;
		DrawLine (r);
	}
	r.top = 0;
	if (dx<0)
	{		
		if (numbers)
		{
			SetColor (headerColor);
			r.bottom = (GetSlotHeight()+1);
			r.left = 0;
			r.right = headerWidth;	
			FillRect (r);
		}
		h = HY_SEQUENCE_PANE_CHAR_SPACING/2+headerWidth;
	}
	else
	{
		h = HY_SEQUENCE_PANE_CHAR_SPACING/2+headerWidth;
		for (v=startColumn;v<endColumn-dx;v++,h+=charWidth)
			if (v&&(v%blockWidth)==0)
				h+=2;
	}
	r.bottom = visHeight;
	loopStart = dx>0?endColumn-dx:startColumn;
	loopEnd =  dx>0?endColumn:startColumn-dx;
	
	if (loopStart<0) loopStart = 0;
	if (loopEnd<0) loopEnd = 0;
	if (loopStart>columnStrings.lLength) loopStart = columnStrings.lLength;
	if (loopEnd>columnStrings.lLength) loopEnd = columnStrings.lLength;
	
	for (long c = loopStart; c < loopEnd; c++,h+=charWidth)
	{
		bool isColumnSelected = false;
		if (selectionIndex<selection.lLength)
		{
			visWidth = selection.lData[selectionIndex];
			while ((visWidth<c)&&(selectionIndex<selection.lLength))
			{
				selectionIndex++;
				visWidth = selection.lData[selectionIndex];
			}
			if (c==visWidth)
			{
				if (!invertColors)
				{
					_HYRect invR;
					invR.top = (GetSlotHeight()+1)+1;
					invR.bottom = visHeight-1;
					invR.right = h+charWidth;
					invR.left = h-2;
					if (c&&(c%blockWidth==0))
						invR.right+=2;
					/*else
						if ((c+1==loopEnd)&&(dx>0))
							invR.right+=3;
					*/
					charColor = GetColor();
					SetColor (selectColor);
					FillRect (invR);
					SetColor (charColor);					
				}
				selectionIndex++;
				isColumnSelected = true;
			}
		}
		if (c&&(c%blockWidth==0))
		{
			SetColor (blackC);
			if (numbers)
			{
				_String number (c);
				
				#ifdef __MAC__
					visWidth = h-2-GetVisibleStringWidth(number);
				#else
					visWidth = h-2-GetVisibleStringWidth(number, font);
				#endif
				
				if (visWidth>headerWidth)
					DisplayText (number,slotHeight-3,visWidth,true);
			}
			r.left = r.right = h;
			DrawLine (r);
			SetColor (charColor);
			h+=2;
		}
		if (numbers)
			v = slotHeight+(GetSlotHeight()+1);
		else
			v = slotHeight;
		
		_String *thisString = (_String*)columnStrings(c);
		unsigned char topChar = showDots?thisString->sData[speciesIndex.lData[0]]:0;
		
		backCharRect = (_HYRect)
		{
			v-slotHeight+1,h-1,v+1,h+charWidth-1,0
		};
		if ((c+1)%blockWidth == 0)
			backCharRect.right++;
			
		for (long r = startRow; r < endRow; r++,v+=slotHeight)
		{
			/*unsigned char thisC = thisString->sData[speciesIndex.lData[r]];
			if (r&&(thisC==topChar))
				thisC = '.';
			if (colorMap[thisC]!=lastColor)
			{
				lastColor = colorMap[thisC];
				charColor = LongToHYColor(characterColors.lData[lastColor]);
				SetColor (charColor);
			}
			DisplayChar (thisC,v,h);*/
			unsigned char thisC = thisString->sData[speciesIndex.lData[r]];
			long	 myColor	= colorMap[thisC];
			
			if (r && thisC==topChar)
				thisC = '.';
			
			if (invertColors && !isColumnSelected)
			{
				charColor = LongToHYColor (characterColors.lData[myColor]);
				if ((long)charColor.R+charColor.G+charColor.B > 100)
				{
					SetColor (charColor);
					FillRect 	(backCharRect);
				}
				backCharRect.top += slotHeight;
				backCharRect.bottom += slotHeight;
				SetColor	(blackC);
			}
			else
				if (colorMap[thisC]!=lastColor)
				{
					lastColor = colorMap[thisC];
					charColor = LongToHYColor(characterColors.lData[lastColor]);
					SetColor (charColor);
				}
			DisplayChar (thisC,v,h);
		}
	}
	
	if (numbers&&(dx<0))
	{
		loopEnd--;
		v = loopEnd%blockWidth;
		visWidth = blockWidth-log(double(loopEnd+blockWidth-1))/log((double)blockWidth);

		if (adx<blockWidth)
		{
			loopStart = (startColumn-dx)%blockWidth;
			if ((startColumn-dx)/blockWidth!=startColumn/blockWidth)
			// scrolled thru a block divider
			{
				if (loopStart==0)
					h += (blockWidth-v-1)*charWidth;
				else
					h = 0;
			}
			else
			{
				if (loopStart>visWidth)
					h += (blockWidth-v-1)*charWidth;
				else
					h = 0;
			}
		}
		else
		{
			loopStart = (startColumn-dx)%blockWidth;
			
			if (loopStart) 
				if (loopStart>=visWidth)
					h -= (loopStart-blockWidth)*charWidth;
				else
					h = 0;

		}
		
		if (h)
		{
			_String number (v?((loopEnd/blockWidth)+1)*blockWidth:loopEnd);
			SetColor (blackC);
			#ifdef __MAC__
				visWidth = h-2-GetVisibleStringWidth(number);
			#else
				visWidth = h-2-GetVisibleStringWidth(number, font);
			#endif
			while ((visWidth < headerWidth)&&(number.sLength))
			{
				number.Trim (1,-1);
				#ifdef __MAC__
					visWidth = h-2-GetVisibleStringWidth(number);
				#else
					visWidth = h-2-GetVisibleStringWidth(number, font);
				#endif
			}
			if (number.sLength)
				DisplayText (number,slotHeight-3,visWidth,true);
		}
	}
	
	EndDraw();	
	if (messageRecipient)
		messageRecipient->ProcessEvent(generateScrollEvent(0,0));
	_MarkForUpdate();
}
Esempio n. 23
0
void PrintLCD(int row,int offset,char *string)
{
	while (*string && ( offset <  20)){
		DisplayChar(row,offset++,*string++);
	}
}
Esempio n. 24
0
void CScreenDevice::Write (char chChar)
{
	switch (m_nState)
	{
	case ScreenStateStart:
		switch (chChar)
		{
		case '\b':
			CursorLeft ();
			break;

		case '\t':
			Tabulator ();
			break;

		case '\n':
			NewLine ();
			break;

		case '\r':
			CarriageReturn ();
			break;

		case '\x1b':
			m_nState = ScreenStateEscape;
			break;

		default:
			DisplayChar (chChar);
			break;
		}
		break;

	case ScreenStateEscape:
		switch (chChar)
		{
		case 'M':
			ReverseScroll ();
			m_nState = ScreenStateStart;
			break;

		case '[':
			m_nState = ScreenStateBracket;
			break;

		default:
			m_nState = ScreenStateStart;
			break;
		}
		break;

	case ScreenStateBracket:
		switch (chChar)
		{
		case '?':
			m_nState = ScreenStateQuestionMark;
			break;

		case 'A':
			CursorUp ();
			m_nState = ScreenStateStart;
			break;

		case 'B':
			CursorDown ();
			m_nState = ScreenStateStart;
			break;

		case 'C':
			CursorRight ();
			m_nState = ScreenStateStart;
			break;

		case 'H':
			CursorHome ();
			m_nState = ScreenStateStart;
			break;

		case 'J':
			ClearDisplayEnd ();
			m_nState = ScreenStateStart;
			break;

		case 'K':
			ClearLineEnd ();
			m_nState = ScreenStateStart;
			break;

		case 'L':
			InsertLines (1);
			m_nState = ScreenStateStart;
			break;

		case 'M':
			DeleteLines (1);
			m_nState = ScreenStateStart;
			break;

		case 'P':
			DeleteChars (1);
			m_nState = ScreenStateStart;
			break;

		default:
			if ('0' <= chChar && chChar <= '9')
			{
				m_nParam1 = chChar - '0';
				m_nState = ScreenStateNumber1;
			}
			else
			{
				m_nState = ScreenStateStart;
			}
			break;
		}
		break;

	case ScreenStateNumber1:
		switch (chChar)
		{
		case ';':
			m_nState = ScreenStateSemicolon;
			break;

		case 'L':
			InsertLines (m_nParam1);
			m_nState = ScreenStateStart;
			break;

		case 'M':
			DeleteLines (m_nParam1);
			m_nState = ScreenStateStart;
			break;

		case 'P':
			DeleteChars (m_nParam1);
			m_nState = ScreenStateStart;
			break;

		case 'X':
			EraseChars (m_nParam1);
			m_nState = ScreenStateStart;
			break;

		case 'h':
		case 'l':
			if (m_nParam1 == 4)
			{
				InsertMode (chChar == 'h');
			}
			m_nState = ScreenStateStart;
			break;
			
		case 'm':
			SetStandoutMode (m_nParam1);
			m_nState = ScreenStateStart;
			break;

		default:
			if ('0' <= chChar && chChar <= '9')
			{
				m_nParam1 *= 10;
				m_nParam1 += chChar - '0';

				if (m_nParam1 > 99)
				{
					m_nState = ScreenStateStart;
				}
			}
			else
			{
				m_nState = ScreenStateStart;
			}
			break;
		}
		break;

	case ScreenStateSemicolon:
		if ('0' <= chChar && chChar <= '9')
		{
			m_nParam2 = chChar - '0';
			m_nState = ScreenStateNumber2;
		}
		else
		{
			m_nState = ScreenStateStart;
		}
		break;

	case ScreenStateQuestionMark:
		if ('0' <= chChar && chChar <= '9')
		{
			m_nParam1 = chChar - '0';
			m_nState = ScreenStateNumber3;
		}
		else
		{
			m_nState = ScreenStateStart;
		}
		break;

	case ScreenStateNumber2:
		switch (chChar)
		{
		case 'H':
			CursorMove (m_nParam1, m_nParam2);
			m_nState = ScreenStateStart;
			break;

		case 'r':
			SetScrollRegion (m_nParam1, m_nParam2);
			m_nState = ScreenStateStart;
			break;

		default:
			if ('0' <= chChar && chChar <= '9')
			{
				m_nParam2 *= 10;
				m_nParam2 += chChar - '0';

				if (m_nParam2 > 199)
				{
					m_nState = ScreenStateStart;
				}
			}
			else
			{
				m_nState = ScreenStateStart;
			}
			break;
		}
		break;

	case ScreenStateNumber3:
		switch (chChar)
		{
		case 'h':
		case 'l':
			if (m_nParam1 == 25)
			{
				SetCursorMode (chChar == 'h');
			}
			m_nState = ScreenStateStart;
			break;

		default:
			if ('0' <= chChar && chChar <= '9')
			{
				m_nParam1 *= 10;
				m_nParam1 += chChar - '0';

				if (m_nParam1 > 99)
				{
					m_nState = ScreenStateStart;
				}
			}
			else
			{
				m_nState = ScreenStateStart;
			}
			break;
		}
		break;

	default:
		m_nState = ScreenStateStart;
		break;
	}
}
Esempio n. 25
0
/*!
 * @brief  Displays the given string.
 *   
 * Displays the given string on the VIM-828 display. The string length should be between 1 - 8 characters.
 * The allowed characters are 0-9, A-Z, space (' ') and decimal point ('.').
 *
 * Clears the previously displayed string before displaying the new string.
 *
 * @param[in]   hDevice             Device handle obtained from adi_LCD_Init().
 * @param[in]   Screen              LCD screen on which to display the measurement.
 * @param[in]   DisplayString       String to be displayed.
 *
 * @return      Status
 *                - #ADI_LCDVIM828_ERR_BAD_DEVICE_HANDLE [D]  Invalid device handle parameter.
 *                - #ADI_LCDVIM828_ERR_NOT_INITIALIZED   [D]  Device has not been previously configured for use.
 *                - #ADI_LCDVIM828_ERR_NULL_POINTER      [D]  The measurement string NULL.
 *                - #ADI_LCDVIM828_ERR_BAD_CHAR          [D]  One or more characters in the measurement string cannot be displayed.
 *                - #ADI_LCDVIM828_SUCCESS                    Call completed successfully.
 *
 * @sa adi_LCDVIM828_ClearDisplay()
 */
ADI_LCDVIM828_RESULT_TYPE adi_LCDVIM828_DisplayString(ADI_LCD_DEV_HANDLE    const  hDevice, 
                                                      ADI_LCD_SCREEN_TYPE   const Screen, 
                                                      uint8_t               const DisplayString[])
{
    int32_t     i;
    int32_t     j;
    int32_t     numDp = 0;
    uint8_t     tempDisplayString[ADI_LCDVIM828_NUM_SEGMENTS];
    uint8_t     charDP[] = {0,0,0,0,0,0,0,0}; /* Records the position of a decimal point */
    bool_t      addDP;
    uint32_t    charOffset;  /* Holds the offset of character in the mapping table */
    
#ifdef ADI_DEBUG
    if(DisplayString == NULL)
    {
        return ADI_LCDVIM828_ERR_NULL_POINTER;
    }
#endif /* ADI_DEBUG */
    
    /* Use a temporary variable so that the original string is not modified */
    for (i = 0; i < ADI_LCDVIM828_NUM_SEGMENTS; i++)
    {
        tempDisplayString[i] = DisplayString[i];

        if(tempDisplayString[i] == '.')
        {
            /* count the decimal points */
            numDp++;
        }
    }

    /* Clear the measurement display first */
    adi_LCDVIM828_ClearDisplay(hDevice, Screen);
    
    charOffset = LCDVIM828_SPACE_ASCII_TO_INDEX;
    
    /* Handle decimal point(s) display  
     *  cases:
     *  - numeric value with one decimal point (0.1)
     *  - decimal point in first position (.1)
     *  - multiple decimal points (0..1)
     */
    if ((numDp == 1) && (tempDisplayString[0] == '.'))
    {
        /* decimal in first position */
        tempDisplayString[0] = ' ';
        charDP[0] = 1;
    }
    else if (numDp == 1)
    {
        /* one decimal point not in first position (assume numeric value) 
         * shift the display characters after the decimal 
         */
        for (i = 1; i < ADI_LCDVIM828_NUM_SEGMENTS; i++)
        {
            if (tempDisplayString[i] == '.')
            {
                /* record the position and shift */
                charDP[i-1] = 1;
            
                for (j = i; j < ADI_LCDVIM828_NUM_SEGMENTS; j++)
                {
                    if (tempDisplayString[j + 1] == '\0')
                    {
                        tempDisplayString[j] = ' ';
                    }
                    else
                    {
                        tempDisplayString[j] = tempDisplayString[j + 1];
                    }
                }
                break;
            }
        }
    }
    else if (numDp > 1)
    {
        /* multiple decimal points - display as is */
        for (i = 0; i < ADI_LCDVIM828_NUM_SEGMENTS; i++)
        {
            if (tempDisplayString[i] == '.')
            {
               /* record the position */
               charDP[i] = 1;
               tempDisplayString[i] = ' ';
            }        
        }
    }
             
    /* Display the given string */
    for(i = 0; i < ADI_LCDVIM828_NUM_SEGMENTS;  i++)
    {
        /* Check if a decimal point is used */
        if(charDP[i])
        {
            addDP = true;
        }
        /* Check if character is valid and assign offset */
        if ((tempDisplayString[i] >= '0') && (tempDisplayString[i] <= '9'))
        {
            charOffset = LCDVIM828_ASCII_NUMBER_TO_INDEX;   
        }
        else if((tempDisplayString[i] >= 'A') && (tempDisplayString[i] <= 'Z'))
        {
            charOffset = LCDVIM828_UPPERCASE_ASCII_TO_INDEX;   
        }
        else if(tempDisplayString[i]=='-')
        {
            charOffset = LCDVIM828_MINUS_ASCII_TO_INDEX;   
        }
        else if(tempDisplayString[i]==' ')
        {
            charOffset = LCDVIM828_SPACE_ASCII_TO_INDEX;   
        }
        else
        {
            return ADI_LCDVIM828_ERR_BAD_CHAR;
        }

        DisplayChar(hDevice, Screen, &SegmentRegInfo[i], (tempDisplayString[i] - charOffset), addDP);
            
        addDP = false;
    }
    
    return ADI_LCDVIM828_SUCCESS;
}
Esempio n. 26
0
void TimeDataSetProc()			// 시간 설정
{
	BUTTON KeyIn;
	char ChangeCode = 0;
	int loopCtrl = 1;
	signed int point=0;
	int i;

	machine_state = STATE_TIME_MODE;
	LCD_Clear();
	strcpy(st, "DATE & TIME SETTING ");
	PrintLCD(0,0,st);

	strcpy(gSciTxBuf,"9:4:906:0.000e-0");
	SendSciString( gSciTxBuf );
	sci_rx_msg_start = sci_rx_msg_end = 0;
	delay_ms(100); 
	delay_ms(100); 
	getSciMsg(st); printLCD(1,0,st);
	printLCD(3,0,st);

	for( i = 0; i< 12 ; i++ ) Code[i] = st[ DATE_POS[i]];
	Cursor(3,DATE_POS[point],DISPLAY_CURSE_BLINK_ON);
	
	while(loopCtrl){

		ChangeCode = 1;

		KeyIn = GetKey();

		if		( KeyIn == BTN_UP  ) (Code[point])++;
		else if ( KeyIn == BTN_DOWN) (Code[point])--;
		else if ( KeyIn == BTN_ESC)		point--;
		else if	(KeyIn == BTN_RIGHT) 	point ++;
		else if ( KeyIn == BTN_STOP){
			machine_state = STATE_SET_MODE;
			return;
		}
		else if ( KeyIn == BTN_SAVE){

			strcpy(gSciTxBuf,"9:4:904:0.");
			strcpy(&(gSciTxBuf[10]),Code);
			SendSciString( gSciTxBuf );
			delay_ms(50);

			strcpy(gSciTxBuf,"9:4:904:1.");
			strcpy(&(gSciTxBuf[10]),&Code[6]);
			SendSciString( gSciTxBuf );
			strcpy(gSciTxBuf,"9:4:906:0.000e-0");
			SendSciString( gSciTxBuf );

			sci_rx_msg_start = sci_rx_msg_end = 0;
			delay_ms(50); getSciMsg(st); printLCD(1,0,st);
		}
		else if ( KeyIn == BTN_SET){
			strcpy(gSciTxBuf,"9:4:906:0.000e-0");
			SendSciString( gSciTxBuf );
			sci_rx_msg_start = sci_rx_msg_end = 0;
			delay_ms(100); 
			delay_ms(100); 
			getSciMsg(st); printLCD(1,0,st);
			printLCD(3,0,st);
		
			for( i = 0; i< 12 ; i++ ) Code[i] = st[ DATE_POS[i]];
			Cursor(3,DATE_POS[point],DISPLAY_CURSE_BLINK_ON);
		}
		else ChangeCode = 0;

		if		(point > 11) 	point = 0;
		else if (point < 0 )	point = 11;
	
		if		(Code[point] > '9') Code[point] = '0';
		else if	(Code[point] < '0') Code[point] = '9';
	
		if(ChangeCode == 1)
		{
			DisplayChar(3,DATE_POS[point],Code[point]);
			Cursor(3,DATE_POS[point],DISPLAY_CURSE_BLINK_ON);
		}
	}
}
Esempio n. 27
0
void EditCodeDataProc()
{
	BUTTON KeyIn;

	int i;
	int loopCtrl = 1;
	int changeCode;

	LCD_Clear();

	strcpy(st,msgEditAddr); PrintLCD(0,0,st); 

	SerialPortSetup();	
	for ( i = 0; i< 9;i++) Code[i] = '0';
	Code[7] = '+';

	CodeID = 0;
	Cursor(CODE_POS[CodeId][0],CODE_POS[CodeId][1],CURSOR_BLINK);					

	while( loopCtrl)
	{

		KeyIn = GetKey();
	
		changeCode = 1;
		Cursor(CODE_POS[CodeID][0],CODE_POS[CodeID][1],DISPLAY_CURSE_BLINK_ON);//CURSOR_OFF);

		if ( KeyIn == BTN_ESC){
			if(CodeId == 0) CodeID = 8 ;
			else			CodeID -- ;
		}	
		else if ( KeyIn == BTN_SET){
			for( i = 1 ; i< 4; i++ ) clear_line(i);
			CopyCode2TxMsg(SCI_CMD_READ_DATA);

		//--- write data
			gSciTxBuf[9]  ='.';	gSciTxBuf[10] ='0'; gSciTxBuf[11] ='0';	gSciTxBuf[12] ='0'; 
		//--- exponent part
			gSciTxBuf[13] ='e'; gSciTxBuf[14] ='+'; gSciTxBuf[15] ='0'; 

		//--- print code discription
			gSciTxBuf[8]  ='1';
			sci_rx_msg_start = sci_rx_msg_end = 0;
			SendSciString( gSciTxBuf );
			delay_ms(100);
			i = getSciMsg(st); 
			if(i) printLCD(2,0,st);
			else {
				strcpy(st,"NO Received Data");				
				printLCD(1,0,st);
			}

			gSciTxBuf[8]  ='2';
			sci_rx_msg_start = sci_rx_msg_end = 0;
			// for(clearcnt = 0; clearcnt <40; clearcnt++) sci_rx_msg_box[clearcnt] = 0;
			SendSciString( gSciTxBuf ); 
			delay_ms(100); 
			i = getSciMsg(st); 
			if(i) printLCD(3,0,st);
			else {
				strcpy(st,"NO Received Data");				
				printLCD(3,0,st);
			}
		}
		else if ( KeyIn == BTN_SAVE ){	
			lcd_x_posi=0; lcd_y_posi=1;
			CopyCode2TxMsg(SCI_CMD_WRITE_ROM); 
			SendSciString( gSciTxBuf );
			delay_ms(50); getSciMsg(st); printLCD(1,0,st); // debug
		}
		else if ( KeyIn == BTN_DOWN){
			if(CodeID == 7 ){
				if( Code[CodeID] == '+') Code[CodeID] = '-';
				else                     Code[CodeID] = '+';
			}
			else {
				if      ( Code[CodeID] > '9') Code[CodeID] = '9';
				else if ( Code[CodeID] <= '0') Code[CodeID] = '9';
				else 						  Code[CodeID]--;
			}
		}
		else if ( KeyIn == BTN_UP ){
			if(CodeID == 7 ){
				if( Code[CodeID] == '+') Code[CodeID] = '-'; 
				else					 Code[CodeID] = '+';	 
			}
			else {
				if     ( Code[CodeID] <  '0') 	 	Code[CodeID] = '0';
				else if( Code[CodeID] >= '9') 	 	Code[CodeID] = '0';
				else 								Code[CodeID]++;
			}
		}
		else if ( KeyIn == BTN_RIGHT){		
			if(CodeId == 8) CodeID = 0 ;
			else			CodeID ++ ;	 
		}
		else if ( KeyIn ==  BTN_STOP){
			machine_state = STATE_SET_MODE;
			loopCtrl = 0;
			return;
		}
		else changeCode = 0;
		if(changeCode == 1 ){
			DisplayChar(CODE_POS[CodeID][0],CODE_POS[CodeID][1],Code[CodeID]);
			Cursor(CODE_POS[CodeID][0],CODE_POS[CodeID][1],CURSOR_BLINK);				
		}
	}
}