コード例 #1
0
ファイル: gps.c プロジェクト: JanusErasmus/stm-dicovery-clock
void handleTime(char * gpgga)
{
	char *argv[7];
	uint8_t argc = parseNMEA(gpgga, argv, 7);

	if(argc < 5)
		return;

	argv[0][4] = 0;
	gpsMinute = t_atoi(&argv[0][2]);

	argv[0][2] = 0;
	gpsHour = t_atoi(argv[0]);

	static uint8_t flag = 0;
	if(flag)
		GPIO_ResetBits(GPIOC, GPIO_Pin_9);
	else
		GPIO_SetBits(GPIOC, GPIO_Pin_9);

	flag = !flag;

	d_print(gpsHour);
	t_print(":");
	d_print(gpsMinute);
	t_print("\n");
}
コード例 #2
0
ファイル: gps.c プロジェクト: JanusErasmus/stm-dicovery-clock
void handleSatelites(char * gpgsv)
{
	char *argv[9];
	uint8_t argc = parseNMEA(gpgsv, argv, 9);

	if(argc < 8)
		return;

//	t_print(argv[2]);  //Satellites  in view
//	t_print(" ");
//	t_print(argv[3]);	//PRN number
//	t_print(" ");
	t_print(argv[4]);	//elivation
//	t_print(" ");
//	t_print(argv[5]);	//azimuth
//	t_print(" ");
//	t_print(argv[6]);	//SNR
	t_print("\n");
	if( t_atoi(argv[4]) > 1)
	{
		gpsOK = 1;
		GPIO_SetBits(GPIOC, GPIO_Pin_8);
	}
	else
	{
		gpsOK = 0;
		GPIO_ResetBits(GPIOC, GPIO_Pin_8);
	}
}
コード例 #3
0
ファイル: table.cpp プロジェクト: bigfatbrowncat/zetes
void litehtml::table_grid::add_cell( element* el )
{
	table_cell cell;
	cell.el = el;
	cell.colspan	= t_atoi(el->get_attr(_t("colspan"), _t("1")));
	cell.rowspan	= t_atoi(el->get_attr(_t("rowspan"), _t("1")));
	cell.borders	= el->get_borders();

	while( is_rowspanned( (int) m_cells.size() - 1, (int) m_cells.back().size() ) )
	{
		m_cells.back().push_back(table_cell());
	}

	m_cells.back().push_back(cell);
	for(int i = 1; i < cell.colspan; i++)
	{
		table_cell empty_cell;
		m_cells.back().push_back(empty_cell);
	}
}
コード例 #4
0
void rtc_setTime(char * argv[], int argc)
{


	if(argc > 4)
	{
		t_print("Setting time\n");

		mHour = t_atoi(argv[0]);
		mMinute = t_atoi(argv[1]);

		s_DateStructVar.Day = t_atoi(argv[2]);
		s_DateStructVar.Month = t_atoi(argv[3]);
		s_DateStructVar.Year = t_atoi(argv[4]);

		uint32_t CounterValue = ((mHour * 3600)+ (mMinute * 60));

		RTC_WaitForLastTask();
		RTC_SetCounter(CounterValue);
		RTC_WaitForLastTask();

		BKP_WriteBackupRegister(BKP_DR2,s_DateStructVar.Day);
		BKP_WriteBackupRegister(BKP_DR3,s_DateStructVar.Month);
		BKP_WriteBackupRegister(BKP_DR4,s_DateStructVar.Year);
	}
	else if(argc > 1)
	{
		mHour = t_atoi(argv[0]);
		mMinute = t_atoi(argv[1]);

		uint32_t CounterValue = ((mHour * 3600)+ (mMinute * 60));

		RTC_WaitForLastTask();
		RTC_SetCounter(CounterValue);
		RTC_WaitForLastTask();
	}

	t_print("Time: ");

	d_print(mHour);
	t_print(":");
	d_print(mMinute);
	t_print(":");
	d_print(mSecond);
	t_print(" ");
	d_print(s_DateStructVar.Day);
	t_print("-");
	d_print(s_DateStructVar.Month);
	t_print("-");
	d_print(s_DateStructVar.Year);
	t_print("\n");
}
コード例 #5
0
ファイル: media_query.cpp プロジェクト: CarterTsai/litehtml
litehtml::media_query::ptr litehtml::media_query::create_from_string(const tstring& str, const std::shared_ptr<document>& doc)
{
	media_query::ptr query = std::make_shared<media_query>();

	string_vector tokens;
	split_string(str, tokens, _t(" \t\r\n"), _t(""), _t("("));

	for(string_vector::iterator tok = tokens.begin(); tok != tokens.end(); tok++)
	{
		if((*tok) == _t("not"))
		{
			query->m_not = true;
		} else if(tok->at(0) == _t('('))
		{
			tok->erase(0, 1);
			if(tok->at(tok->length() - 1) == _t(')'))
			{
				tok->erase(tok->length() - 1, 1);
			}
			media_query_expression expr;
			string_vector expr_tokens;
			split_string((*tok), expr_tokens, _t(":"));
			if(!expr_tokens.empty())
			{
				trim(expr_tokens[0]);
				expr.feature = (media_feature) value_index(expr_tokens[0], media_feature_strings, media_feature_none);
				if(expr.feature != media_feature_none)
				{
					if(expr_tokens.size() == 1)
					{
						expr.check_as_bool = true;
					} else
					{
						trim(expr_tokens[1]);
						expr.check_as_bool = false;
						if(expr.feature == media_feature_orientation)
						{
							expr.val = value_index(expr_tokens[1], media_orientation_strings, media_orientation_landscape);
						} else
						{
							tstring::size_type slash_pos = expr_tokens[1].find(_t('/'));
							if( slash_pos != tstring::npos )
							{
								tstring val1 = expr_tokens[1].substr(0, slash_pos);
								tstring val2 = expr_tokens[1].substr(slash_pos + 1);
								trim(val1);
								trim(val2);
								expr.val = t_atoi(val1.c_str());
								expr.val2 = t_atoi(val2.c_str());
							} else
							{
								css_length length;
								length.fromString(expr_tokens[1]);
								if(length.units() == css_units_dpcm)
								{
									expr.val = (int) (length.val() * 2.54);
								} else if(length.units() == css_units_dpi)
								{
									expr.val = (int) (length.val() * 2.54);
								} else
								{
									if(doc)
									{
										doc->cvt_units(length, doc->container()->get_default_font_size());
									}
									expr.val = (int) length.val();
								}
							}
						}
					}
					query->m_expressions.push_back(expr);
				}
			}
		} else
		{
			query->m_media_type = (media_type) value_index((*tok), media_type_strings, media_type_all);

		}
	}

	return query;
}