Beispiel #1
0
void enter_graphic_menu(uint8_t menu_no, uint8_t submenu_no)
{
	char s[20];
	LcdFillLine(1);
	slide_down();										// animacja
	LcdClear();
	if(menu_no==0 && submenu_no==2)						// Menu 1.2
	{
		LcdRectangle(0, 0, 83, 47,TRANSPARENT);			// ramka
		rez=enter_integer(rez,-10,100,2,3, "WART." , "s");	// funkcja obslugi danej pozycji menu
	}
	LcdRectangle(0, 0, 83, 47,TRANSPARENT);				// przykladowy kod po powrocie z funkcji obslugi menu
	LcdClearArea(3,2,13);
	LcdGotoXY(2,3);
	sprintf(s,"MENU %1u.%1u:%d",menu_no + 1, submenu_no, rez);
	LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)s);
	delay_ms(1000);

	LcdFillLine(1);										// powrot do menu
	LcdGotoXY(2,1);
	slide_up();											// animacja
	LcdStr(FONT_1X,FONT_NEGATIVE,"MENU");
	slide_down();										// animacja
	show_graphic_menu(menu_item,submenu_item);			// pokazanie menu
}
Beispiel #2
0
int showMenuItem(void)
{
		char index[4]; 
		char parentMenuName[11]; 
		char childMenuName[11]; 
		const int i = nodeIndexFinder();
		const int x = nodeCounter();
		sprintf(index, "%d/%d", i, x);
				
		if(currentMenuItem-> parent == NULL )
		{
			sprintf(parentMenuName, "Settings");
			sprintf(childMenuName, "%s", currentMenuItem->name);
		}
		else if(currentMenuItem->child == NULL)
		{
			sprintf(parentMenuName, "%s", currentMenuItem->parent->name);
			sprintf(childMenuName, "%s", currentMenuItem->name);
		}
		else
		{
			sprintf(parentMenuName, "%s", currentMenuItem->parent->name);
			sprintf(childMenuName, "%s", currentMenuItem->child->name);
		}
		
		LcdDDRamStartPos(0, 0);
		LcdStr(index);
		LcdDDRamStartPos(0, 5);
		LcdStr(parentMenuName);
		LcdDDRamStartPos(1, 5);
		LcdStr(childMenuName);		
		return 0;
}
Beispiel #3
0
void exit_from_menu(void)
{
	LcdClear();
	LcdFillLine(1);
	LcdGotoXY(1,1);
	LcdStr(FONT_1X,FONT_NEGATIVE,"   LCD DEMO   ");

	LcdFillLine(6);
	LcdGotoXY(1,6);
	LcdStr(FONT_1X,FONT_NEGATIVE,"   LCD DEMO   ");}
Beispiel #4
0
void exit_from_graphic_menu()
{
	uint8_t i;

	slide_up();											// animacja
	LcdClear();											// powrot do trybu normalnego
	LcdFillLine(1);
	LcdGotoXY(1,1);
	LcdStr(FONT_1X,FONT_NEGATIVE,"   LCD DEMO   ");
	LcdFillLine(6);
	LcdGotoXY(1,6);
	LcdStr(FONT_1X,FONT_NEGATIVE,"   LCD DEMO   ");
}
void NumberEditRepaint()
{
	if (text)
	{
		LcdGotoXYFont(1, 1);
		LcdStr(FONT_1X, text);
	}

	printRX2(value, 2);

	LcdGotoXYFont(1, 6);
	LcdStr(FONT_1X, "+-");
	printR(GetCurDelta(), FONT_1X);
}
Beispiel #6
0
void enter_menu(uint8_t menu_no, uint8_t submenu_no)
{
	char s[20];
	if(menu_no==0 && submenu_no==2)						// Menu 1.2
		rez=enter_integer(rez,-10,100,1,3, "WARTOSC" , "s");
	LcdClearLine(3);
	LcdGotoXY(1,3);
	sprintf(s,"ENTER %1u.%1u:%d",menu_no + 1, submenu_no, rez);
	LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)s);
	delay_ms(1000);
	LcdClearLine(3);
}
void printIntFixed(int32_t value, uint8_t font, uint8_t aMinDigits, uint8_t aFixedPoint)
{
	sprintIntFormat(value, aMinDigits, '0');
	addCommaToBuffer(aFixedPoint);
	LcdStr(font, Buffer);
}
void printIntFormat(int32_t value, uint8_t font, uint8_t aMinDigits, uint8_t aEmptyChar)
{
	sprintIntFormat(value, aMinDigits, aEmptyChar);
	LcdStr(font, Buffer);
}
void formatPrintX2(uint8_t y, char* aBuffer, float aValue, const char*const* aSuffix, uint8_t aSuffixCount, int8_t aSuffixMin)
{
	char* startBuffer = aBuffer;
	float mul = 1;
	int8_t iSuffix = 0;

	if(aValue<0)
	{
		LcdSingleBar  ( 0, y*8+2, 2, 5, PIXEL_ON);
		aValue = -aValue;
	}

	if(aValue>=1)
	{
		for(iSuffix = -aSuffixMin; iSuffix<(int8_t)aSuffixCount; iSuffix++)
		{
			float mul1 = mul*1000;
			if(aValue<mul1)
				goto FormatValue;
			mul = mul1; 
		}

		*aBuffer++ = 'i';
		*aBuffer++ = 'n';
		*aBuffer++ = 'f';
		iSuffix = -aSuffixMin;
		goto AddSufix;
	}else
	{
		for(iSuffix = -aSuffixMin; iSuffix>0; iSuffix--)
		{
			if(aValue>=mul)
				break;
			mul *= 1e-3f;
		}
	}


FormatValue:;
	aValue /= mul;

	{
		int value;

		if(aValue>=200)
		{
			value = (int)(aValue+0.5f);
			char c = (value/1000);
			if(c)
				*aBuffer++ = '0'+c;
			*aBuffer++ = '0'+((value/100)%10);
			*aBuffer++ = '0'+(char)((value/10)%10);
			*aBuffer++ = '0'+(char)(value%10);
		} else
		if(aValue>=20)
		{
			value = (int)(aValue*10+0.5f);
			char c = (value/1000);
			if(c)
				*aBuffer++ = '0'+c;
			*aBuffer++ = '0'+(value/100)%10;
			*aBuffer++ = '0'+(char)((value/10)%10);
			*aBuffer++ = '.';
			*aBuffer++ = '0'+(char)(value%10);
		} else
		if(aValue>=9)
		{
			value = (int)(aValue*100+0.5f);
			char c = (value/1000);
			if(c)
				*aBuffer++ = '0'+c;
			*aBuffer++ = '0'+(value/100)%10;
			*aBuffer++ = '.';
			*aBuffer++ = '0'+(char)((value/10)%10);
			*aBuffer++ = '0'+(char)(value%10);
		} else
		{
			value = (int)(aValue*1000+0.5f);
			char c = (value/1000);
			*aBuffer++ = '0'+c;
			*aBuffer++ = '.';
			*aBuffer++ = '0'+(value/100)%10;
			*aBuffer++ = '0'+(char)((value/10)%10);
			*aBuffer++ = '0'+(char)(value%10);
		}
	}

AddSufix:;
	*aBuffer = 0;
	LcdGotoXYFont(2, y+1);
	LcdStr(FONT_2X, startBuffer);

	LcdGotoXYFont(12, y+1);
	LcdStr(FONT_1X, aSuffix[iSuffix]);
}
void printL(float aValue, uint8_t font)
{
	formatPrint(Buffer, aValue, strInductor, sizeof(strInductor)/sizeof(strInductor[0]), -3);
	LcdStr(font, Buffer);	
}
void printF(float aValue)
{
	formatPrint(Buffer, aValue, strFrequency, sizeof(strFrequency)/sizeof(strFrequency[0]), -1);
	LcdStr(FONT_1X, Buffer);	
}
void printT(float aValue)
{
	formatPrint(Buffer, aValue, strTime, sizeof(strTime)/sizeof(strTime[0]), -2);
	LcdStr(FONT_1X, Buffer);	
}
void printV(float aValue)
{
	formatPrint(Buffer, aValue, strVoltage, sizeof(strVoltage)/sizeof(strVoltage[0]), -2);
	LcdStr(FONT_1X, Buffer);	
}
void printR(float aValue, uint8_t font)
{
	formatPrint(Buffer, aValue, strResistor, sizeof(strResistor)/sizeof(strResistor[0]), -1);
	LcdStr(font, Buffer);	
}
void printC(float aValue, uint8_t font)
{
	formatPrint(Buffer, aValue, strCapacitor, sizeof(strCapacitor)/sizeof(strCapacitor[0]), -4);
	LcdStr(font, Buffer);	
}
Beispiel #16
0
void mainPcd8544()
{
  //STM_EVAL_LEDInit(LED3);
  //STM_EVAL_LEDToggle(LED3);
  //QuadEncInit();
  
  LcdInit();

  LcdClear();
  LcdGotoXYFont ( 2, 2 );
  LcdStr( FONT_1X, "1234" );
  LcdUpdate();
  
/*
  HwLcdInit();

  while (1)
  {
    HwLcdPinRst(1);
    HwLcdPinDC(1);
    HwLcdPinCE(1);
    HwLcdSend(0xEEEE);
    Delay(2);
    HwLcdPinRst(0);
    HwLcdPinDC(0);
    HwLcdPinCE(0);
    Delay(2);
  }
*/
  for(int i=0; 1; i++)
  {
    LcdClear();
    LcdGotoXYFont ( 1, 1 );
    printInt(i, FONT_1X);
    LcdUpdate();
    Delay(100);
  }

  while (1)
  {
    STM_EVAL_LEDToggle(LED3);
    LcdClear();

    if(QuadEncButton())
    {
      LcdGotoXYFont ( 1, 1 );
      LcdStr(FONT_1X, "PRESSED!");
    }
    
    LcdGotoXYFont ( 1, 3 );
    LcdStr(FONT_1X, "Q=");
    printInt(QuadEncValue(), FONT_2X);
    
    LcdUpdate();

    Delay(20);
  }
/*
  while (1)
  {

    //uint16_t temp_lo = PressureRead(0x20);
    //uint16_t temp_hi = PressureRead(0x0F);
    STM_EVAL_LEDToggle(LED3);
    LcdClear();
    LcdGotoXYFont ( 1, 3 );
    LcdStr(FONT_1X, "P=");
    printInt(PressureReadPressure(), FONT_1X);
    LcdGotoXYFont ( 1, 5 );
    LcdStr(FONT_1X, "T=");
    printIntFixed(PressureReadTemp(), FONT_1X, 3, 1);
    LcdUpdate();

    Delay(200);
  }
*/

}
Beispiel #17
0
int16_t enter_integer(int16_t val, int16_t min, int16_t max, uint8_t x, uint8_t y, char *var_name, char *var_unit )
{
	  int16_t temp_val;
	  char s[10];
	  volatile Key_t key;
	  char *format;

	  if(min>0 && max>0)						// wprowadzane beda wartosci dodatnie
	  {
		  if (max<10) format="%01d";
		  else if(max<100) format = "%02d";
		  else if(max<1000) format = "%03d";
		  else if(max<10000) format = "%04d";
		  else format = "%05d";
	  }
	  else										// moze sie zdazyc wartosc ujemna
	  {
		  if (max<10) format="%+02d";
		  else if(max<100) format = "%+03d";
		  else if(max<1000) format = "%+04d";
		  else if(max<10000) format = "%+05d";
		  else format = "%+06d";
	  }
	  temp_val=val;
	  LcdGotoXY(x,y);
	  LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name);
	  LcdStr(FONT_1X, FONT_POSITIVE,": ");
	  sprintf(s,format,temp_val);
	  LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s);
	  LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit);
	  do
	  {
	    key=getkey();
	    switch(key)
	    {
	      case KEY_UP:
	        if(temp_val++ >= max)
	          temp_val=min;
	        LcdGotoXY(x,y);
	        LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name);
	        LcdStr(FONT_1X, FONT_POSITIVE,": ");
	  	    sprintf(s,format,temp_val);
	        LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s);
	        LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit);
	        break;
	      case KEY_DN:
	        if(--temp_val< min)
	          temp_val=max;
	        LcdGotoXY(x,y);
	        LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name);
	        LcdStr(FONT_1X, FONT_POSITIVE,": ");
	        sprintf(s,format,temp_val);
	        LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s);
	        LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit);

	        break;
	    }

	    LcdGotoXY(x,y);
	    LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name);
		LcdStr(FONT_1X, FONT_POSITIVE,": ");
		sprintf(s,format,temp_val);
		/*if(TDelay>500)									//miganie wartosci wprowadzanej
	      LcdStr(FONT_1X,FONT_POSITIVE,(unsigned char*)s);				//
	    else*/											//
		  LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s);				//
		LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit);
	  }while(key!=KEY_OK/* & key!=KEY_ESC*/);
//	  if(key==KEY_ESC)
//	    temp_val=0xff;				// zwracanie przez funkcje wartosci 0xff oznacza ze nacisnieto ESC
	  LcdGotoXY(x,y);
      LcdStr(FONT_1X, FONT_POSITIVE, (unsigned char*)var_name);
      LcdStr(FONT_1X, FONT_POSITIVE,": ");
	  sprintf(s,format,val);
      LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)s);
      LcdStr(FONT_1X, FONT_POSITIVE,(unsigned char*)var_unit);

	  return(temp_val);
}
Beispiel #18
0
void  show_menu(uint8_t menu_no, uint8_t submenu_no)
{
	LcdClearLine(2);
	LcdGotoXY(1,2);
	LcdStr(FONT_1X,FONT_POSITIVE, (unsigned char*)menu_strings[submenu_item][menu_item]);
}
Beispiel #19
0
void graphic_menu()
{
	Key_t key;
	uint8_t x_size, y_size, exit;
	volatile uint8_t i;
	menu_item=0;
	submenu_item=0;
	exit=0;
	y_size = sizeof(menu_strings)/sizeof(menu_strings[0]);			// ilosc podmenu
	x_size = sizeof(menu_strings[0])/sizeof(menu_strings[0][0]);	// ilosc menu

	LcdFillLine(1);
	LcdGotoXY(2,1);
	LcdStr(FONT_1X,FONT_NEGATIVE,"MENU");
	slide_down();													// anmacja

	show_graphic_menu(menu_item, submenu_item);						// pokazanie menu
	do
	{
		key=getkey();
		if(key==KEY_DN)													// menu(submenu) +
		{
			if(submenu_item==0)											// jezelipoziom glowny menu
			{
				if((++menu_item)==x_size) menu_item=0;					// menu +
			}
			else														// jezeli poziom podmenu
				if((++submenu_item)==y_size) submenu_item=y_size - 1;	// submenu max
				if((menu_strings[submenu_item][menu_item])=="") submenu_item--;	// puste submenu
			show_graphic_menu(menu_item, submenu_item);
		}
		else if(key==KEY_UP)											// menu(submenu) -
		{
			if(submenu_item==0)											// jezeli poziom glowny menu
			{
				if((--menu_item)<0) menu_item=x_size-1;					// menu -
			}
			else														// jezeli poziom podmenu
				if((--submenu_item)==0) submenu_item=1;					// submenu = 1
			show_graphic_menu(menu_item, submenu_item);
		}
		else if(key==KEY_OK)											// ENTER
		{
			if(submenu_item==0)											// jezeli poziom glowny menu
				if(menu_strings[1][menu_item]!="")						// jezeli menu poziada jakies podmenu
				{
					submenu_item++;										// submenu + ( w zasadzie submenu = 1)
					slide_up();											// animacja
					slide_down();										//
					show_graphic_menu(menu_item, submenu_item);
				}
				else													// jezeli menu nie posiada zadnych podmenu
				{
					slide_up();											// animacja
					enter_graphic_menu(menu_item, submenu_item);		// wejscie w obsluge menu
				}
			else														// jezeli poziom podmenu
			{
				slide_up();												// animacja
				enter_graphic_menu(menu_item, submenu_item);			// wejscie w obsluge podmenu
			}
		}
		if(key==KEY_L)													// ESC
		{
			if(submenu_item>0)											// jezeli poziom podmenu
				submenu_item=0;											// wyjscie do poziomu glownego menu
			else														// jezeli poziom glowny menu
				exit=1;													// wyjscie z obslugi menu
			if(exit==0)
			{
				slide_up();												// animacja
				slide_down();											//
				show_graphic_menu(menu_item, submenu_item);
			}
		}
	}while(exit==0);													// koniec procedury
	exit_from_graphic_menu();
}
Beispiel #20
0
void show_graphic_menu(uint8_t menu_no, uint8_t submenu_no)
{
	volatile uint8_t i,j;
	volatile uint8_t x_size, y_size;
	int a;

	i=1;
	y_size = sizeof(menu_strings)/sizeof(menu_strings[0]);			// makzymalna ilosc podmenu
	x_size = sizeof(menu_strings[0])/sizeof(menu_strings[0][0]);	// ilosc menu
	a=0;
	do																// rzeczywista ilosc podmenu
	{																//
		a=strlen(menu_strings[i][menu_no]);							//
	}while(a>0 && i++ < (y_size - 1) );									//
	y_size=i;														//

	LcdFillLine(1);
	LcdGotoXY(2,1);
	LcdStr(FONT_1X,FONT_NEGATIVE,"MENU");

	for(i=2;i<7;i++) LcdClearLine(i);								// wyczyszczenie sektora wyswietlajacego pozycje menu
	if(submenu_no==0)												// jezeli menu glowne
	{
		i=0;
		if (menu_no<5)	j=0;										// jezeli ilosc pozycji przekracza wielkosc ekranu
		else j=menu_no-4;											// to menu trzeba przewijac
		do
		{
			LcdClearLine(i+2);
			LcdGotoXY(2, i+2);
			if(j==menu_no)											// podswietlanie wybranego menu
				LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)menu_strings[0][j]);	//
			else
				LcdStr(FONT_1X,FONT_POSITIVE,(unsigned char*)menu_strings[0][j]);
			j++;
		}while((++i)!=x_size && i < 6);
		LcdRectangle(0, 0, 83, 47,TRANSPARENT);						// rysowanie ramki
		LcdVerticalScrollBar(((menu_no*100)/(x_size-1)),79,8,83,47);// i suwaka pionowego
	}
	else if(submenu_no>0)											// jezeli podmenu
	{
		i=0;
		if (submenu_no<5)	j=1;									// jezeli ilosc pozycji podmenu przekracza romiar ekranu
		else j=submenu_no-4;										// to menu trzeba przewijac

		do
		{
			i++;
			LcdGotoXY(2,1);
			LcdStr(FONT_1X,FONT_NEGATIVE,"MENU>");
			LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)menu_strings[0][menu_no]);
			LcdClearArea(i + 1,2,14);
			LcdGotoXY(2,i + 1);
			if(j==submenu_no)										// podswietlanie wybranej pozycji menu
				LcdStr(FONT_1X,FONT_NEGATIVE,(unsigned char*)menu_strings[j][menu_no]);
			else
				LcdStr(FONT_1X,FONT_POSITIVE,(unsigned char*)menu_strings[j][menu_no]);
			j++;
		}while(j!=y_size && i < 6);
		LcdRectangle(0, 0, 83, 47,TRANSPARENT);								// ramka
		LcdVerticalScrollBar((100 * (submenu_no-1)/(y_size-2)),79,8,83,47); // suwak
	}
}