Exemple #1
0
void ICACHE_FLASH_ATTR magnet_timer_cb() {
	vec3s16 field;
	ak8963_get_field(&field);
	field.x -= calib_bias.x;
	field.y -= calib_bias.y;
	field.z -= calib_bias.z;
	//os_printf("Measurement: { x = %d, y = %d, z = %d }\r\n", (int16_t)(field.x), (int16_t)(field.y), (int16_t)(field.z));
	angles2f north = vec3s16_to_angles2f(field);
	//os_printf("North: { yaw = %d, pitch = %d }\r\n", (int16_t)(north.yaw * 180 / PI), (int16_t)(north.pitch * 180 / PI));
	ak8963_set_opmode(AK8963_SINGLE, AK8963_16BIT);

	ssd1306_clear();
	compass_draw(north.yaw);
	ssd1306_line(70, 0, 70, 63, true);
	ssd1306_text_small(75, 24, "Inclin.:");
	char incdeg[6];
	os_sprintf(incdeg, "%d°", (int16_t)(north.pitch * 180 / PI));
	ssd1306_text_small(75, 32, incdeg);
	ssd1306_flip();
}
Exemple #2
0
struct compass *
compass_new(struct container *co)
{
	struct compass *this=g_new0(struct compass, 1);
	struct point p;
	p.x=10;
	p.y=10;
	this->gr=co->gra->overlay_new(co->gra, &p, 60, 80);
	this->bg=this->gr->gc_new(this->gr);
	this->gr->gc_set_foreground(this->bg, 0, 0, 0);
	this->white=this->gr->gc_new(this->gr);
	this->gr->gc_set_foreground(this->white, 0xffff, 0xffff, 0xffff);
	this->gr->gc_set_linewidth(this->white, 2);
	this->green=this->gr->gc_new(this->gr);
	this->gr->gc_set_foreground(this->green, 0x0, 0xffff, 0x0);
	this->gr->gc_set_linewidth(this->green, 2);
	
	this->font=this->gr->font_new(this->gr, 200);
	compass_draw(this, co);
	return this;	
}