Horizont TFT
hallo,
ich habe mal wieder ein problem
da muss ich eingestehen das mir dafür das wissen fehlt.
wenn mir da jemand helfen würde, auch gegen absprache entgeld.
was ich machen möchte.
anzeige gyro als horizont.
ich weiß da gibt es in internet, das st aber alles nur für rollen gut.
ich möchte pitch und roll
display größe tft spi 320x240
das ganze mit einer vernünftigen geschwindigkeit auf dem display.
arduino schein da probleme zu haben ( selbst ein teensy 3,6 )
warum
? keine anhnung
am libsten wäre mir eine horizont kugel die in der mitte bleibt und sich bewegt ( 2 farben )
aber wenn das nicht geht ein quadraht in der größe bestimmt wird und wo sich der horizont bewegt.
danke für hilfe oder so
hier ein code gekürzt ( auf laufen getestet mit arduino und teensy 3,6)
ratlos
ich habe mal wieder ein problem



da muss ich eingestehen das mir dafür das wissen fehlt.
wenn mir da jemand helfen würde, auch gegen absprache entgeld.
was ich machen möchte.
anzeige gyro als horizont.
ich weiß da gibt es in internet, das st aber alles nur für rollen gut.
ich möchte pitch und roll
display größe tft spi 320x240
das ganze mit einer vernünftigen geschwindigkeit auf dem display.
arduino schein da probleme zu haben ( selbst ein teensy 3,6 )
warum

am libsten wäre mir eine horizont kugel die in der mitte bleibt und sich bewegt ( 2 farben )
aber wenn das nicht geht ein quadraht in der größe bestimmt wird und wo sich der horizont bewegt.
danke für hilfe oder so
hier ein code gekürzt ( auf laufen getestet mit arduino und teensy 3,6)
quote
#include "spi.h"grüße
#include "adafruit_gfx.h"
#include "adafruit_ili9341.h"
#define tft_dc 10
#define tft_cs 4
#define tft_rst 14
#define tft_mosi 11
#define tft_clk 13
#define tft_miso 12
adafruit_ili9341 tft = adafruit_ili9341(tft_cs, tft_dc);
#define hor 342 // horizon vector linie laenge
int xx = 160 ; // eigen für anzeige linie usw
int yy = 120 ;// eigen für anzeige linie usw
#define xc 160 // mitte of horizon
#define yc 120 // mitte of horizon
#define deg2rad 0.0174532925
int last_roll = 0; // horizon graphic lauf
int last_pitch = 0; // horizon graphic lauf
// #########################################################################
void setup() {
tft.begin();
tft.setrotation(3);
tft.fillrect(0, 0, xx*2, yy*2, ili9341_blue);
tft.fillrect(0, yy, xx*2, yy*2, ili9341_green);
delay(40) ,
drawhorizon(0, 0);
}
void loop() {
int roll = random(361) - 180; // zum testen auf dem tft
int pitch = random (161) - 80; // zum testen auf dem tft
updatehorizon(roll, pitch);
}
// #########################################################################
// update horizon new roll (angle in range -180 +180)
// #########################################################################
void updatehorizon(int roll, int pitch)
{
int delta_pitch = 0;
int pitch_error = 0;
int delta_roll = 0;
while ((last_pitch != pitch) || (last_roll != roll)) // wenn winkel geaendert wurde
{
delta_pitch = 0;
delta_roll = 0;
if (last_pitch < pitch) {
delta_pitch = 1;
pitch_error = pitch - last_pitch;
}
if (last_pitch > pitch) {
delta_pitch = -1;
pitch_error = last_pitch - pitch;
}
if (last_roll < roll) delta_roll = 1;
if (last_roll > roll) delta_roll = -1;
if (delta_roll == 0) {
if (pitch_error > 1) delta_pitch *= 2;
}
drawhorizon(last_roll + delta_roll, last_pitch + delta_pitch); // cm uebergabe roll und pitch vom gyro
}
}
// #########################################################################
void drawhorizon(int roll, int pitch)
{
// calculate coordinates line start
float sx = cos(roll * deg2rad);
float sy = sin(roll * deg2rad);
int16_t x0 = sx * hor ;
int16_t y0 = sy * hor ;
int16_t xd = 0;
int16_t yd = 1; // weiss linienbreite
int16_t xdn = 0;
int16_t ydn = 0;
if (roll > 45 && roll < 135) { xd = -1; yd = 0; }
if (roll >= 135) { xd = 0; yd = -1; }
if (roll < -45 && roll > -135) {xd = 1; yd = 0; }
if (roll <= -135) { xd = 0; yd = -1; }
if ((roll != last_roll) || (pitch != last_pitch))
{
xdn = 7 * xd;
ydn = 7 * yd;
tft.drawline(xc - x0 - xdn, yc - y0 - ydn - pitch, xc + x0 - xdn, yc + y0 - ydn - pitch, ili9341_blue);
tft.drawline(xc - x0 + xdn, yc - y0 + ydn - pitch, xc + x0 + xdn, yc + y0 + ydn - pitch, ili9341_green);
xdn = 6 * xd;
ydn = 6 * yd;
tft.drawline(xc - x0 - xdn, yc - y0 - ydn - pitch, xc + x0 - xdn, yc + y0 - ydn - pitch, ili9341_blue);
tft.drawline(xc - x0 + xdn, yc - y0 + ydn - pitch, xc + x0 + xdn, yc + y0 + ydn - pitch, ili9341_green);
xdn = 5 * xd;
ydn = 5 * yd;
tft.drawline(xc - x0 - xdn, yc - y0 - ydn - pitch, xc + x0 - xdn, yc + y0 - ydn - pitch, ili9341_blue);
tft.drawline(xc - x0 + xdn, yc - y0 + ydn - pitch, xc + x0 + xdn, yc + y0 + ydn - pitch, ili9341_green);
xdn = 4 * xd;
ydn = 4 * yd;
tft.drawline(xc - x0 - xdn, yc - y0 - ydn - pitch, xc + x0 - xdn, yc + y0 - ydn - pitch, ili9341_blue);
tft.drawline(xc - x0 + xdn, yc - y0 + ydn - pitch, xc + x0 + xdn, yc + y0 + ydn - pitch, ili9341_green);
xdn = 3 * xd;
ydn = 3 * yd;
tft.drawline(xc - x0 - xdn, yc - y0 - ydn - pitch, xc + x0 - xdn, yc + y0 - ydn - pitch, ili9341_blue);
tft.drawline(xc - x0 + xdn, yc - y0 + ydn - pitch, xc + x0 + xdn, yc + y0 + ydn - pitch, ili9341_green);
}
xdn = 2 * xd;
ydn = 2 * yd;
tft.drawline(xc - x0 - xdn, yc - y0 - ydn - pitch, xc + x0 - xdn, yc + y0 - ydn - pitch, ili9341_blue);
tft.drawline(xc - x0 + xdn, yc - y0 + ydn - pitch, xc + x0 + xdn, yc + y0 + ydn - pitch, ili9341_green);
xdn = 1 * xd;
ydn = 1 * yd;
tft.drawline(xc - x0 - xd, yc - y0 - yd - pitch, xc + x0 - xd, yc + y0 - yd - pitch, ili9341_blue);
tft.drawline(xc - x0 + xd, yc - y0 + yd - pitch, xc + x0 + xd, yc + y0 + yd - pitch, ili9341_green);
last_roll = roll;
last_pitch = pitch;
}
ratlos
echtzeit-3d?
geht schon, wenn die qualität nicht super und die polys sich in grenzen halten, aber: niemalsnicht mit ner billigkrücke von display.
da brauchste was, das auch in der lage ist, schnell zu zeichnen.
das zauberwort heisst grafikspeicher!
den haben diese dinger einfach nicht- nen würfel flüssig rotieren zu lassen, kannst du schlichtweg vergessen.
und ne kugel schon mal gar nicht-die hat dann noch etliche polygone mehr.
die dinger können ja nicht mal nen text halbwegs flüssig scrollen....
geht schon, wenn die qualität nicht super und die polys sich in grenzen halten, aber: niemalsnicht mit ner billigkrücke von display.
da brauchste was, das auch in der lage ist, schnell zu zeichnen.
das zauberwort heisst grafikspeicher!
den haben diese dinger einfach nicht- nen würfel flüssig rotieren zu lassen, kannst du schlichtweg vergessen.
und ne kugel schon mal gar nicht-die hat dann noch etliche polygone mehr.
die dinger können ja nicht mal nen text halbwegs flüssig scrollen....
Arduino Forum > International > Deutsch (Moderator: uwefed) > Horizont TFT
arduino
Comments
Post a Comment