void RWS_TFTLCD_TS::drawButton(int16_t x, int16_t y, int16_t sx, int16_t sy, uint16_t color, uint16_t tcolor, const char *t1, const char *t2, const char *t3, int16_t shade, int16_t dly)
{
  // buttons 30 pixels high are good with a single row of text 
  float scale = 1.0, fade = 1.0;
  uint16_t red, green, blue;

  //draw the button in the base color
  fillRect(x,y,sx,sy,color);

  //shade the button edges
  scale = pow(0.995,shade);
  for(int16_t i = sy/4;i >= 0;i--){
    fade *= scale;
    red = (fade * redComp(color));
    if(red > 255)  red = 0; else if(red > 62) red = 62;
    green = (fade * (greenComp(color)));
    if(green > 255) green = 0; else if(green > 63) green = 63;
    blue = (fade * blueComp(color));
    if(blue > 255) blue = 0; else if(blue > 62) blue = 62;
    unsigned rgb = RGB(red,green,blue);  
    drawRect(x+i, y+i, sx-2*i, sy-2*i, rgb);
    delay(dly);    // slow down for effect
  }
  
  // print text on the button
  setTextSize(2);            // pixels per dot in letter
  setTextColor(tcolor);
  setCursor(x+10,y+8);       // position of upper left corner of letter
  print(t1);
  setTextSize(1);
  setCursor(x+10,y+25);
  print(t2);
  setCursor(x+10,y+36);
  print(t3);
}
示例#2
0
文件: main.c 项目: blaezec/stm32f4
void testtext(uint16_t color)
{
    fillScreen(BLACK);
    setCursor(0, 20);
    setTextColor(color);
    setTextSize(1);
    // write('A');
    printf("Hello World!\n");
    setTextSize(2);
    printf("1234.56\n");
    setTextSize(3);
    printf("0x%X\n",0xDEADBEEF);
}
示例#3
0
SaveButton::SaveButton(int x, int y)
{
	setBackgroundColour(sf::Color::Green);
	setText("Save");
	setTextSize(30);
	setTextColor(sf::Color::Black);
	setPosition(x, y);
}
示例#4
0
void printNewMsg() {
	STOP_TIMEOUT;
	clearMem (WHITE);
	setTextSize(3);
	fillRect(0, 0, 400, (textsize * 8) + Y_PADDING, BLACK);
	setTextColor(WHITE, BLACK);
	setCursor(X_PADDING, Y_PADDING / 2);
	writeString("New Message!");
	setCursor(X_PADDING, (textsize * 8) + Y_PADDING);
	setTextSize(2);
	setTextColor(BLACK, WHITE);
	writeString((char*) (RxBuffer+1));
	refresh();
	setCursor(X_PADDING, 0);
	enqeue ((uint8_t *)(RxBuffer+1));
	memset(RxBuffer,0,201);
}
void Piccolino_OLED::begin(bool use_sram) {
  bool external_vcc = _switchvss == SSD1306_EXTERNALVCC;

  sram = use_sram;
  if(sram) {
    // Initialize RAM
    _v_ram.begin(ADDR_VIDEOBUFFER);
    buff = (byte *)calloc(TMP_BUFFER_SIZE, sizeof(byte));
  } else {
    // Allocate the buffer to 1K
    buff = (byte *)calloc(BUFFER_SIZE, sizeof(byte));
  }
  if(!buff) {
    abort();
  }

  // set pin directions
  // I2C Init
  Wire.begin(); // Is this the right place for this?

  // Init sequence for 128x64 OLED module
  ssd1306_command(SSD1306_DISPLAYOFF);                    // 0xAE
  ssd1306_command(SSD1306_SETDISPLAYCLOCKDIV);            // 0xD5
  ssd1306_command(0x80);                                  // the suggested ratio 0x80
  ssd1306_command(SSD1306_SETMULTIPLEX);                  // 0xA8
  ssd1306_command(0x3F);
  ssd1306_command(SSD1306_SETDISPLAYOFFSET);              // 0xD3
  ssd1306_command(0x0);                                   // offset
  ssd1306_command(SSD1306_SETSTARTLINE | 0x0);            // line #0
  ssd1306_command(SSD1306_CHARGEPUMP);                    // 0x8D
  ssd1306_command(external_vcc ? 0x10 : 0x14);
  ssd1306_command(SSD1306_MEMORYMODE);                    // 0x20
  ssd1306_command(0x00);                                  // 0x0 act like ks0108
  ssd1306_command(SSD1306_SEGREMAP | 0x1);
  ssd1306_command(SSD1306_COMSCANDEC);
  ssd1306_command(SSD1306_SETCOMPINS);                    // 0xDA
  ssd1306_command(0x12);
  ssd1306_command(SSD1306_SETCONTRAST);                   // 0x81
  ssd1306_command(external_vcc ? 0x9F: 0xCF);
  ssd1306_command(SSD1306_SETPRECHARGE);                  // 0xd9
  ssd1306_command(external_vcc ? 0x22 : 0xF1);
  ssd1306_command(SSD1306_SETVCOMDETECT);                 // 0xDB
  ssd1306_command(0x40);
  ssd1306_command(SSD1306_DISPLAYALLON_RESUME);           // 0xA4
  ssd1306_command(SSD1306_NORMALDISPLAY);                 // 0xA6

  clear(); // clear sram ...
  setTextColor(WHITE);
  setTextSize(1);
  update();

  ssd1306_command(SSD1306_DISPLAYON);//--turn on oled panel
}
示例#6
0
void printTime() {
	getTime(&hour, &minute);
	if(hour >=0 || minute >=0){
		timestring[1] = (hour / 10) + 48;
		timestring[2] = (hour % 10) + 48;
		timestring[4] = (minute / 10) + 48;
		timestring[5] = (minute % 10) + 48;
	}
	clearMem (WHITE);
	setTextSize(8);
	setCursor(30, Y_PADDING);
	writeString(timestring);
	setCursor(X_PADDING, textsize * 8);
	setTextSize(3);
	for (i = 0; i < QUEUE_SIZE / 2; i++) {
		write(i + 49);
		write(':');
		writeString((char *) getMsg(i));
		setCursor(X_PADDING, cursor_y + 8 * textsize);
	}
	refresh();
}
示例#7
0
CAndroidFont::CAndroidFont(int size, const char * fontName)
{
//	fontName = NULL;	// ハングするので一旦 //
	// フォント管理クラスを取得(static class)
	jclass cls_fntManage = CJNI::getJNIEnv()->FindClass(JNI_FONTMANAGER_LOAD_PATH);

	// Paint作成函数ID取得
	jmethodID mtd_createPaint = getEnv()->GetStaticMethodID(cls_fntManage, "CreatePaint", "(Ljava/lang/String;)Landroid/graphics/Paint;");

	// エイリアスからフォント名を取得
	const char* fntName = NULL;
	for( int i=0; fontName && ms_fontlist[i].alias; i++ )
	{
		if( !strcmp(ms_fontlist[i].alias, fontName) )
		{
			fntName = ms_fontlist[i].fontname;
		}
	}

	jstring strj = NULL;
	if( fntName ) {
		strj = getEnv()->NewStringUTF(fntName);
	}

	// 指定フォント名でPaintを作成
	jobject local_font = CJNI::getJNIEnv()->CallStaticObjectMethod( cls_fntManage, mtd_createPaint, strj );

	// グローバル的な変数として設定
	m_paint = getEnv()->NewGlobalRef(local_font);

	m_getfontmetrics = getEnv()->GetStaticMethodID(cls_fntManage, "getFontMetrics", "(Landroid/graphics/Paint;)Landroid/graphics/Paint$FontMetrics;");
	m_settextsize	 = getEnv()->GetStaticMethodID(cls_fntManage, "setTextSize", "(Landroid/graphics/Paint;F)V");
	m_setantialias	 = getEnv()->GetStaticMethodID(cls_fntManage, "setAntiAlias", "(Landroid/graphics/Paint;Z)V");
	m_measuretext 	 = getEnv()->GetStaticMethodID(cls_fntManage, "measureText", "(Landroid/graphics/Paint;Ljava/lang/String;)F");
	/*
	{
		char buf[256];
		sprintf(buf, "m_getfontmetrics = %d, m_settextsize = %d, m_setantialias = %d", m_getfontmetrics, m_settextsize, m_setantialias);
		__android_log_write(ANDROID_LOG_DEBUG, "Cpp", buf);
	}
	 */

	// アンチエイリアス設定(PFInterface.javaのdrawTextでの描画時と、ただ文章幅を取得したい場合の幅値が異なるため)  2013/04/11  
	setAntiAlias(true);
	// テキストサイズを設定
	setTextSize(size);

	CJNI::getJNIEnv()->DeleteLocalRef(cls_fntManage);
	CJNI::getJNIEnv()->DeleteLocalRef(strj);
	CJNI::getJNIEnv()->DeleteLocalRef(local_font);
}
示例#8
0
void DisplayModulo::drawSplashScreen() {
    setFillColor(.27,0,.24);
    setLineColor(0,0,0);
    drawRect(0, 0, width(), height());
    setCursor(0, 40);

    setTextSize(1);
    setTextColor(1,1,1);
    print("     MODULO");

    setLineColor(0,0,0,0);
    setFillColor(1,1,1);

    drawLogo(width()/2-18, 10, 35, 26);

}
示例#9
0
//constructor
MGuiEditText::MGuiEditText(const char * text, const MVector2 & position, float size, const MVector4 & color, void (* pointerEvent)(MGuiEditText * editText, MGuiEvent * guiEvent)):
m_charId(0),
m_startSelectionId(0),
m_endSelectionId(0),
m_limitLength(false),
m_maxLength(0),
m_isSingleLine(false)
{
	setParentWindow(NULL);
	setText(text);
	setPosition(position);
	setTextSize(size);
	setNormalColor(color);
	setHighLightColor(color);
	setPressedColor(color);
	setPointerEvent(pointerEvent);

	autoScaleFromText();
}
void MainWindow::createTextToolbar()
{
    qDebug("MainWindow createTextToolbar()");

    toolbarText->setObjectName("toolbarText");

    toolbarText->addWidget(textFontSelector);
    textFontSelector->setCurrentFont(QFont(getSettingsTextFont()));
    connect(textFontSelector, SIGNAL(currentFontChanged(const QFont&)), this, SLOT(textFontSelectorCurrentFontChanged(const QFont&)));

    toolbarText->addAction(actionHash.value(ACTION_textbold));
    actionHash.value(ACTION_textbold)->setChecked(getSettingsTextStyleBold());
    toolbarText->addAction(actionHash.value(ACTION_textitalic));
    actionHash.value(ACTION_textitalic)->setChecked(getSettingsTextStyleItalic());
    toolbarText->addAction(actionHash.value(ACTION_textunderline));
    actionHash.value(ACTION_textunderline)->setChecked(getSettingsTextStyleUnderline());
    toolbarText->addAction(actionHash.value(ACTION_textstrikeout));
    actionHash.value(ACTION_textstrikeout)->setChecked(getSettingsTextStyleStrikeOut());
    toolbarText->addAction(actionHash.value(ACTION_textoverline));
    actionHash.value(ACTION_textoverline)->setChecked(getSettingsTextStyleOverline());

    textSizeSelector->setFocusProxy(prompt);
    textSizeSelector->addItem("6 pt",   6);
    textSizeSelector->addItem("8 pt",   8);
    textSizeSelector->addItem("9 pt",   9);
    textSizeSelector->addItem("10 pt", 10);
    textSizeSelector->addItem("11 pt", 11);
    textSizeSelector->addItem("12 pt", 12);
    textSizeSelector->addItem("14 pt", 14);
    textSizeSelector->addItem("18 pt", 18);
    textSizeSelector->addItem("24 pt", 24);
    textSizeSelector->addItem("30 pt", 30);
    textSizeSelector->addItem("36 pt", 36);
    textSizeSelector->addItem("48 pt", 48);
    textSizeSelector->addItem("60 pt", 60);
    textSizeSelector->addItem("72 pt", 72);
    setTextSize(getSettingsTextSize());
    toolbarText->addWidget(textSizeSelector);
    connect(textSizeSelector, SIGNAL(currentIndexChanged(int)), this, SLOT(textSizeSelectorIndexChanged(int)));

    connect(toolbarText, SIGNAL(topLevelChanged(bool)), this, SLOT(floatingChangedToolBar(bool)));
}
示例#11
0
文件: keyboard.cpp 项目: JIVS/dex-ui
Key::Key() {
  s_xoff = 0;
  s_yoff = 0;
  xpadding = 10;
  ypadding = 10;
  keynum = 0;
  randdelay = ofRandom(20);
  
  setPos(0,0);
  setTextSize(12);
  setString("x");
  debug = false;
  
  // Animation settings
  events.clear();
  newEvent(0, 200, 0, 1); // intro
  newEvent(0, -1, 1, 1); // main
  newEvent(0, 20, 2, 1); // keypress
  currentEvent = events[0];
}
示例#12
0
    bool Label::setProperty(std::string property, const std::string& value)
    {
        property = toLower(property);

        if (property == "configfile")
        {
            load(value);
        }
        else if (property == "text")
        {
            std::string text;
            decodeString(value, text);
            setText(text);
        }
        else if (property == "textcolor")
        {
            setTextColor(extractColor(value));
        }
        else if (property == "textsize")
        {
            setTextSize(atoi(value.c_str()));
        }
        else if (property == "backgroundcolor")
        {
            setBackgroundColor(extractColor(value));
        }
        else if (property == "autosize")
        {
            if ((value == "true") || (value == "True"))
                setAutoSize(true);
            else if ((value == "false") || (value == "False"))
                setAutoSize(false);
            else
                TGUI_OUTPUT("TGUI error: Failed to parse 'AutoSize' property.");
        }
        else // The property didn't match
            return ClickableWidget::setProperty(property, value);

        // You pass here when one of the properties matched
        return true;
    }
void SSD1306_Driver::init() {
	Adafruit_SSD1306::begin(SSD1306_SWITCHCAPVCC);
	setTextColor(WHITE);
	setTextSize(1);
	display();
}
示例#14
0
    bool Checkbox::setProperty(std::string property, const std::string& value)
    {
        property = toLower(property);

        if (property == "configfile")
        {
            load(value);
        }
        else if (property == "checked")
        {
            if ((value == "true") || (value == "True"))
                check();
            else if ((value == "false") || (value == "False"))
                uncheck();
            else
                TGUI_OUTPUT("TGUI error: Failed to parse 'Checked' property.");
        }
        else if (property == "text")
        {
            setText(value);
        }
        else if (property == "textcolor")
        {
            setTextColor(extractColor(value));
        }
        else if (property == "textsize")
        {
            setTextSize(atoi(value.c_str()));
        }
        else if (property == "allowtextclick")
        {
            if ((value == "true") || (value == "True"))
                allowTextClick(true);
            else if ((value == "false") || (value == "False"))
                allowTextClick(false);
            else
                TGUI_OUTPUT("TGUI error: Failed to parse 'AllowTextClick' property.");
        }
        else if (property == "callback")
        {
            ClickableWidget::setProperty(property, value);

            std::vector<sf::String> callbacks;
            decodeList(value, callbacks);

            for (auto it = callbacks.begin(); it != callbacks.end(); ++it)
            {
                if ((*it == "Checked") || (*it == "checked"))
                    bindCallback(Checked);
                else if ((*it == "Unchecked") || (*it == "unchecked"))
                    bindCallback(Unchecked);
                else if ((*it == "SpaceKeyPressed") || (*it == "spacekeypressed"))
                    bindCallback(SpaceKeyPressed);
                else if ((*it == "ReturnKeyPressed") || (*it == "returnkeypressed"))
                    bindCallback(ReturnKeyPressed);
            }
        }
        else // The property didn't match
            return ClickableWidget::setProperty(property, value);

        // You pass here when one of the properties matched
        return true;
    }
示例#15
0
void fbClass::runCommand(std::string command_string)
{
	std::string command;
	std::istringstream iss(command_string);
	std::getline(iss, command, ' ');
	int values_int[10];
	std::string value;
	//printf("Command (fb): %s\n", command_string.c_str());

	if (command == "FILLBOX")
	{
		int i = 0;
		while (std::getline(iss, value, ' '))
		{
			values_int[i++] = atoi(value.c_str());
		}
		if (i >= 4)
		{
			fillBox(values_int[0], values_int[1], values_int[2], values_int[3], values_int[4]);
		}
	}
	else if (command == "SETFADE")
	{
		int i = 0;
		while (std::getline(iss, value, ' '))
		{
			values_int[i++] = atoi(value.c_str());
		}

		if (i >= 7)
		{
			setFade(values_int[0], values_int[1], values_int[2], values_int[3], values_int[4], values_int[5], values_int[6]);
		}
	}
	else if (command == "PUTTEXT") // x y color max_size(-1) alignment(=0) text
	{
		for (int i = 0; i < 5; i++)
		{
			std::getline(iss, value, ' ');
			values_int[i] = atoi(value.c_str());
		}
		std::getline(iss, value, '\n');
		/*float size;
		sscanf(value.c_str(), "%f", &size);*/
		std::getline(iss, value, '\n');

		if (vars->isavailable(value))
			value = vars->getvalue(value);
		/*if (size != factor)
			setTextSize(size);*/

		putText(values_int[0], values_int[1], values_int[2], value, values_int[3], values_int[4]);
	}
	else if (command == "CLEARSCREEN")
	{
		//printf("ClearScreen\n");
		clearScreen();
	}
	else if (command == "SETTEXTSIZE")
	{
		std::getline(iss, value, ' ');
		float val;
		sscanf(value.c_str(), "%f", &val);
		//std::cout << "Value: " << val << std::endl;

		setTextSize(val);
	}
}