Exemplo n.º 1
0
void AFSKSetupView::update_freq(rf::Frequency f) {
	char finalstr[10] = {0};
	
	portapack::persistent_memory::set_tuned_frequency(f);
	
	auto mhz = to_string_dec_int(f / 1000000, 4);
	auto hz100 = to_string_dec_int((f / 100) % 10000, 4, '0');

	strcat(finalstr, mhz.c_str());
	strcat(finalstr, ".");
	strcat(finalstr, hz100.c_str());

	this->button_setfreq.set_text(finalstr);
}
Exemplo n.º 2
0
void WhipCalcView::update_result() {
	double length, divider;
	
	divider = ((double)options_type.selected_index_value() / 8.0);
	
	// Metric
	length = (speed_of_light_mps / (double)field_frequency.value()) * divider;
	
	auto m = to_string_dec_int((int)length, 2);
	auto cm = to_string_dec_int(int(length * 100.0) % 100, 2);
	auto mm = to_string_dec_int(int(length * 1000.0) % 10, 1);
	
	text_result_metric.set(m + "m " + cm + "." + mm + "cm");

	// ANT500 elements for crude adjustment
	length /= 0.14;
	if (int(length) <= 4) {
		auto elements = to_string_dec_int((int)length, 1);
		text_result_ant500.set(elements + " " + frac_str[((int(length * 10.0) % 10) + 1) / 3] + "elements");
	} else {
		text_result_ant500.set("-");
	}

	// Imperial
	length = (speed_of_light_fps / (double)field_frequency.value()) * divider;
	
	auto feet = to_string_dec_int((int)length, 3);
	auto inch = to_string_dec_int(int(length * 10.0) % 12, 2);
	auto inch_c = to_string_dec_int(int(length * 100.0) % 10, 1);
	
	text_result_imperial.set(feet + "ft " + inch + "." + inch_c + "in");
}
Exemplo n.º 3
0
void NumberField::paint(Painter& painter) {
    const auto text = to_string_dec_int(value_, length_, fill_char);

    const auto paint_style = has_focus() ? style().invert() : style();

    painter.draw_string(
        screen_pos(),
        paint_style,
        text
    );
}
Exemplo n.º 4
0
void FrequencyField::paint(Painter& painter) {
	const auto mhz = to_string_dec_int(value_ / 1000000, 4);
	const auto hz100 = to_string_dec_int((value_ / 100) % 10000, 4, '0');

	const auto paint_style = has_focus() ? style().invert() : style();

	painter.draw_string(
		screen_pos(),
		paint_style,
		mhz
	);
	painter.draw_string(
		screen_pos() + Point { 4 * 8, 0 },
		paint_style,
		"."
	);
	painter.draw_string(
		screen_pos() + Point { 5 * 8, 0 },
		paint_style,
		hz100
	);
}
Exemplo n.º 5
0
std::string temperature(Temperature temperature) {
	return to_string_dec_int(temperature.celsius(), 3);
}
Exemplo n.º 6
0
std::string pressure(Pressure pressure) {
	return to_string_dec_int(pressure.kilopascal(), 3);
}
Exemplo n.º 7
0
std::string TemperatureWidget::temperature_str(const temperature_t temperature) const {
	return to_string_dec_int(temperature, temp_len - 1) + "C";
}