示例#1
0
void DrawDateTime(void)
{
  // clean date&time area
  FillMyBuffer(STARTING_ROW, WATCH_DRAW_SCREEN_ROW_NUM, 0x00);

  SetFont(DEFAULT_HOURS_FONT);  
  gRow = DEFAULT_HOURS_ROW;
  gColumn = DEFAULT_HOURS_COL;
  gBitColumnMask = DEFAULT_HOURS_COL_BIT;
  DrawHours(DRAW_OPT_BITWISE_OR);

  gRow = DEFAULT_MINS_ROW;
  gColumn = DEFAULT_MINS_COL;
  gBitColumnMask = DEFAULT_MINS_COL_BIT;
  DrawMins(DRAW_OPT_BITWISE_OR);
  
  if (GetProperty(PROP_TIME_SECOND)) DrawSecs();
  else if (Charging()) DrawBatteryOnIdleScreen(3, 9, MetaWatch5);
  else
  {
    if (!GetProperty(PROP_24H_TIME_FORMAT))
    {
      gRow = DEFAULT_AM_PM_ROW;
      gColumn = DEFAULT_AM_PM_COL;
      gBitColumnMask = DEFAULT_AM_PM_COL_BIT;
      SetFont(DEFAULT_AM_PM_FONT);
      DrawString((RTCHOUR > 11) ? "PM" : "AM", DRAW_OPT_BITWISE_OR);
    }

    gRow = GetProperty(PROP_24H_TIME_FORMAT) ? DEFAULT_DOW_24HR_ROW : DEFAULT_DOW_12HR_ROW;
    gColumn = DEFAULT_DOW_COL;
    gBitColumnMask = DEFAULT_DOW_COL_BIT;
    SetFont(DEFAULT_DOW_FONT);

    DrawString((tString *)DaysOfTheWeek[niLang][RTCDOW], DRAW_OPT_BITWISE_OR);

    //add year when time is in 24 hour mode
    if (GetProperty(PROP_24H_TIME_FORMAT))
    {
      gRow = DEFAULT_DATE_YEAR_ROW;
      gColumn = DEFAULT_DATE_YEAR_COL;
      gBitColumnMask = DEFAULT_DATE_YEAR_COL_BIT;
      SetFont(DEFAULT_DATE_YEAR_FONT);

      unsigned char Year = RTCYEARH;
      DrawChar(BCD_H(Year) + ZERO, DRAW_OPT_BITWISE_OR);
      DrawChar(BCD_L(Year) + ZERO, DRAW_OPT_BITWISE_OR);
      Year = RTCYEARL;
      DrawChar(BCD_H(Year) + ZERO, DRAW_OPT_BITWISE_OR);
      DrawChar(BCD_L(Year) + ZERO, DRAW_OPT_BITWISE_OR);
    }

    //Display month and day
    //Watch controls time - use default date position
    unsigned char DayFirst = GetProperty(PROP_DDMM_DATE_FORMAT);
    char Rtc[2];
    Rtc[DayFirst ? 0 : 1] = RTCDAY;
    Rtc[DayFirst ? 1 : 0] = RTCMON;

    gRow = DEFAULT_DATE_FIRST_ROW;
    gColumn = DEFAULT_DATE_FIRST_COL;
    gBitColumnMask = DEFAULT_DATE_FIRST_COL_BIT;
    SetFont(DEFAULT_DATE_MONTH_FONT);
    
    DrawChar(BCD_H(Rtc[0]) + ZERO, DRAW_OPT_BITWISE_OR);
    DrawChar(BCD_L(Rtc[0]) + ZERO, DRAW_OPT_BITWISE_OR);
    
    //Display separator
    SetFont(DEFAULT_DATE_SEPARATOR_FONT);
    DrawChar(DayFirst ? '.' : '/', DRAW_OPT_BITWISE_OR);
    
    //Display day second
    gRow = DEFAULT_DATE_SECOND_ROW;
    gColumn = DEFAULT_DATE_SECOND_COL;
    gBitColumnMask = DEFAULT_DATE_SECOND_COL_BIT;
    SetFont(DEFAULT_DATE_DAY_FONT);
    
    DrawChar(BCD_H(Rtc[1]) + ZERO, DRAW_OPT_BITWISE_OR);
    DrawChar(BCD_L(Rtc[1]) + ZERO, DRAW_OPT_BITWISE_OR);
  }
  
  SendMyBufferToLcd(STARTING_ROW, WATCH_DRAW_SCREEN_ROW_NUM);
}
示例#2
0
void DrawWatchStatusScreen(void)
{
  FillMyBuffer(0, LCD_ROW_NUM, 0);
  CopyColumnsIntoMyBuffer(RadioOn() ? pRadioOnIcon : pRadioOffIcon,
                          3,
                          STATUS_ICON_SIZE_IN_ROWS,
                          LEFT_STATUS_ICON_COLUMN,
                          STATUS_ICON_SIZE_IN_COLUMNS);
  // Connection status
  CopyColumnsIntoMyBuffer(Connected(CONN_TYPE_MAIN) ? pConnectedIcon : pDisconnectedIcon,
                          3,
                          STATUS_ICON_SIZE_IN_ROWS,
                          CENTER_STATUS_ICON_COLUMN,
                          STATUS_ICON_SIZE_IN_COLUMNS);

  gRow = 31;
  gColumn = 5;
  gBitColumnMask = BIT4;
  SetFont(MetaWatch5);

//  if (PairedDeviceType() == DEVICE_TYPE_BLE)
//  {
//    if (Connected(CONN_TYPE_HFP) && Connected(CONN_TYPE_MAP)) DrawString("DUO", DRAW_OPT_BITWISE_OR);
//    else DrawString("BLE", DRAW_OPT_BITWISE_OR);
//  }
//  else if (PairedDeviceType() == DEVICE_TYPE_SPP) DrawString("BR", DRAW_OPT_BITWISE_OR);

  if (PairedDeviceType() == DEVICE_TYPE_SPP)
  {
    DrawString(Connected(CONN_TYPE_SPP) && QuerySniffState() == Active ? "ACT" : "BR",
      DRAW_OPT_BITWISE_OR);
  }
#if SUPPORT_BLE
  else if (PairedDeviceType() == DEVICE_TYPE_BLE)
  {
    DrawString(Connected(CONN_TYPE_BLE) && CurrentInterval(INTERVAL_STATE) == SHORT ? "ACT" :
      (Connected(CONN_TYPE_HFP) && Connected(CONN_TYPE_MAP) ? "DUO" : "BLE"),
      DRAW_OPT_BITWISE_OR);
  }
#endif

  DrawBatteryOnIdleScreen(6, 9, MetaWatch7);

  // Add Wavy line
  gRow += 12;
  CopyRowsIntoMyBuffer(pWavyLine, gRow, NUMBER_OF_ROWS_IN_WAVY_LINE);
  CopyColumnsIntoMyBuffer(pIconWatch, 54, 21, 0, 2); //54, 21, 2, 2);

  /* add the firmware version */
  gColumn = 2;
  gRow = 56;
  gBitColumnMask = BIT2;
  DrawString("SW: ", DRAW_OPT_BITWISE_OR);
  DrawString((char *)VERSION, DRAW_OPT_BITWISE_OR);
  DrawString(" (", DRAW_OPT_BITWISE_OR);
  DrawChar(BUILD[0], DRAW_OPT_BITWISE_OR);
  DrawChar(BUILD[1], DRAW_OPT_BITWISE_OR);
  DrawChar(BUILD[2], DRAW_OPT_BITWISE_OR);
  DrawChar(')', DRAW_OPT_BITWISE_OR);
  
  gColumn = 2;
  gRow = 65;
  gBitColumnMask = BIT2;
  DrawString("HW: REV ", DRAW_OPT_BITWISE_OR);
  DrawChar(GetMsp430HardwareRevision(), DRAW_OPT_BITWISE_OR);

  DrawLocalAddress(1, 80);
  
  SendMyBufferToLcd(STARTING_ROW, LCD_ROW_NUM);
}
示例#3
0
/**
**  Draw text with font at x,y clipped/unclipped.
**
**  ~    is special prefix.
**  ~~   is the ~ character self.
**  ~!   print next character reverse.
**  ~<   start reverse.
**  ~>   switch back to last used color.
**
**  @param x     X screen position
**  @param y     Y screen position
**  @param font  Font number
**  @param text  Text to be displayed.
**  @param clip  Flag to clip the text.
**
**  @return      The length of the printed text.
*/
static int DoDrawText(int x, int y, CFontFamily *fontFamily,
	bool isPlainText, const std::string &text, bool clip)
{
	int w;
	int width;
	CFontColor *rev;
	char *color;
	const char *p;
	void (*DrawChar)(const CGraphic *, int, int, int, int, int, int);
	int ipr;
	int c;
	CGraphic *g;
	int utf8;
	size_t pos;

	if (clip) {
		DrawChar = VideoDrawCharClip;
	} else {
		DrawChar = VideoDrawChar;
	}

	if (!UseOpenGL) {
		g = fontFamily->G;
	} else {
		g = fontFamily->FontColorGraphic(FontColor);
	}

	rev = NULL;
	width = 0;
	pos = 0;
	while (GetUTF8(text, pos, utf8)) {
		if (utf8 == '~' && !isPlainText) {
			switch (text[pos]) {
				case '\0':  // wrong formatted string.
					DebugPrint("oops, format your ~\n");
					return width;
				case '~':
					++pos;
					break;
				case '!':
					rev = FontColor;
					FontColor = ReverseTextColor;
					if (UseOpenGL) {
						g = fontFamily->FontColorGraphic(FontColor);
					}
					++pos;
					continue;
				case '<':
					LastTextColor = FontColor;
					FontColor = ReverseTextColor;
					if (UseOpenGL) {
						g = fontFamily->FontColorGraphic(FontColor);
					}
					++pos;
					continue;
				case '>':
					rev = LastTextColor;  // swap last and current color
					LastTextColor = FontColor;
					FontColor = rev;
					if (UseOpenGL) {
						g = fontFamily->FontColorGraphic(FontColor);
					}
					++pos;
					continue;

				default:
					p = text.c_str() + pos;
					while (*p && *p !='~') {
						++p;
					}
					if (!*p) {
						DebugPrint("oops, format your ~\n");
						return width;
					}
					color = new char[p - (text.c_str() + pos) + 1];
					memcpy(color, text.c_str() + pos, p - (text.c_str() + pos));
					color[p - (text.c_str() + pos)] = '\0';
					pos = p - text.c_str() + 1;
					LastTextColor = FontColor;
					CFontColor *fc = CFontColor::Get(color);
					if (fc) {
						FontColor = fc;
						if (UseOpenGL) {
							g = fontFamily->FontColorGraphic(fc);
						}
					}
					delete[] color;
					continue;
			}
		}

		c = utf8 - 32;
		Assert(c >= 0);

		ipr = fontFamily->G->GraphicWidth / fontFamily->G->Width;
		if (c >= 0 && c < ipr * fontFamily->G->GraphicHeight / fontFamily->G->Height) {
			w = fontFamily->CharWidth[c];
			DrawChar(g, (c % ipr) * fontFamily->G->Width, (c / ipr) * fontFamily->G->Height,
				w, fontFamily->G->Height, x + width, y);
		} else {
			w = fontFamily->CharWidth[0];
			DrawChar(g, 0, 0, w, fontFamily->G->Height, x + width, y);
		}
		width += w + 1;
		if (rev) {
			FontColor = rev;
			if (UseOpenGL) {
				g = fontFamily->FontColorGraphic(FontColor);
			}
			rev = NULL;
		}
	}

	return width;
}
示例#4
0
void kGUIText::DrawSectionRot(int sstart,int slen,float x,float y,float angle,kGUIColor color,float alpha)
{
	kGUIFace *face=kGUIFont::GetFace(GetFontID());
	int glyph_index;
	int font_height,font_above,font_below;
	FT_Face ftface;
	int size;
	FT_Glyph   glyph2;
	FT_Matrix  matrix;
	FT_BitmapGlyph  bit;
	float dx,dy,adv;
	float advsin,advcos;
	float fax,fay;	/* rotated font above */
	unsigned int ch;	/* current character */
	unsigned int nb;	/* number of bytes for current character */

	ftface=face->GetFace();
	size=GetFontSize();
	if(!size)
		return;
	assert(size>0,"Cannot print size 0\n");

	font_height=face->GetPixHeight(size);
	font_above = face->GetPixAscHeight(size);
	font_below = face->GetPixDescHeight(size);
	kGUI::SelectFont(face,size);

	matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
	matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L );
	matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L );
	matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L );

	adv=0;
	advsin=sin(angle);
	advcos=cos(angle);
	fax=sin(angle-(2*PI)*0.025f)*font_above;
	fay=-(cos(angle-(2*PI)*0.025f)*font_above);

	/* todo, handle underline */

	while(slen>0)
	{
		ch=GetChar(sstart,&nb);
		if(!ch)
			return;
		sstart+=nb;
		slen-=nb;

		/* todo, handle tabs, handle encoding  */
		glyph_index = FT_Get_Char_Index( ftface, ch );
		if(glyph_index>0)
		{
			FT_Load_Glyph(ftface,glyph_index,FT_LOAD_DEFAULT);
			FT_Get_Glyph( ftface->glyph, &glyph2 );
			FT_Glyph_Transform( glyph2, &matrix, 0 );
			FT_Glyph_To_Bitmap( &glyph2, ft_render_mode_normal,0, 1);
			
			/* draw to screen using writepixel */
			bit = (FT_BitmapGlyph)glyph2;

			dx=x+((advcos*adv)+fax);
			dy=y-((advsin*adv)+fay);
			DrawChar( (char *)bit->bitmap.buffer,
						dx + bit->left,
						dy -bit->top,
						bit->bitmap.width, bit->bitmap.rows,
						color,alpha);

			adv+=ftface->glyph->advance.x/64.0f;
			adv+=m_letterspacing;
			FT_Done_Glyph(glyph2);
		}
	}
	if(m_underline)
		kGUI::DrawLine(x+fax,y-fay,x+((advcos*adv)+fax),y-((advsin*adv)+fay),color,alpha);
}
/**
  * @brief  Displays one character.
  * @param  Xpos: start column address
  * @param  Ypos: the Line where to display the character shape
  * @param  Ascii: character ascii code, must be between 0x20 and 0x7E
  * @retval None
  */
void BSP_LCD_DisplayChar(uint16_t Xpos, uint16_t Ypos, uint8_t Ascii)
{
  DrawChar(Xpos, Ypos, &DrawProp[ActiveLayer].pFont->table[(Ascii-' ') *\
              DrawProp[ActiveLayer].pFont->Height * ((DrawProp[ActiveLayer].pFont->Width + 7) / 8)]);
}
示例#6
0
int RunSettingsMenu() {
	static int index = 0;
	static int spy = 72;
	int done = 0, y, i;

	g_dirty = 1;
	while (!done) {
		// Parse input
		readkey();
		if (parsekey(DINGOO_B))
			done = 1;

		if (parsekey(DINGOO_UP, 1)) {
			if (index > 0) {
				index--;
				spy -= 16;
			} else {
				index = SETTINGS_MENUSIZE - 1;
				spy = 72 + 16*index;
			}
		}

		if (parsekey(DINGOO_DOWN, 1)) {
			if (index < SETTINGS_MENUSIZE - 1) {
				index++;
				spy += 16;
			} else {
				index = 0;
				spy = 72;
			}
		}

		if (parsekey(DINGOO_A)) {
			done = settings_menu[index].command();
		}

		// Must draw bg only when needed
		// Draw stuff
		if (g_dirty) {
			draw_bg(g_bg);
			
			//Draw Top and Bottom Bars
			DrawChar(gui_screen, SP_SELECTOR, 0, 37);
			DrawChar(gui_screen, SP_SELECTOR, 81, 37);
			DrawChar(gui_screen, SP_SELECTOR, 0, 225);
			DrawChar(gui_screen, SP_SELECTOR, 81, 225);
			DrawText(gui_screen, "B - Go Back", 235, 225);
			DrawChar(gui_screen, SP_LOGO, 12, 9);
			
			// Draw selector
			DrawChar(gui_screen, SP_SELECTOR, 56, spy);
			DrawChar(gui_screen, SP_SELECTOR, 77, spy);

			DrawText(gui_screen, "Settings", 8, 37);

			// Draw menu
			for (i = 0, y = 72; i < SETTINGS_MENUSIZE; i++, y += 16) {
				DrawText(gui_screen, settings_menu[i].name, 60, y);
			}

			// Draw info
			DrawText(gui_screen, settings_menu[index].info, 8, 225);

			g_dirty = 0;
		}

		SDL_Delay(16);

		// Update real screen
		FCEUGUI_Flip();
	}

	// Must update emulation core and drivers
	UpdateEMUCore(g_config);
	FCEUD_DriverReset();

	// Clear screen
	dingoo_clear_video();

	g_dirty = 1;
}