Go Down

Topic: Artificial Horizon display using a gyro (Read 9109 times) previous topic - next topic

bodmer

About the voltage divider, if i want to get 3.3V at the logic lines when arduino is suplying 5V, then the series resistor should be the 2.2k and 1k to ground.
that gices about 3.4v on logic line to LCD.

No, 1K and 2.2K" to ground.

5*(2.2/(2.2+1))=3.43V which will be fine and is thing the 3.3V +/-0.3V limit for the driver inputs
Formerly Rowboteer (now a broken user profile!)

i3dm

Meant to do it like this:

bodmer

Formerly Rowboteer (now a broken user profile!)

Leonardoxms

Hello guys. I'm trying to make it work with the  ST7735 controller displays.  But I'm getting lots of unwanted pixels on screen as the roll and pitch does its thing.  Any sugestions?
 

bodmer

@Leonardoxms

Are you using the sketch attached to post #27?

What changes have you made?

Are you using this graphics library?

If so, do all the other example sketches work OK?

Which Arduino are you using?

How have you wired the display to your Arduino?
Formerly Rowboteer (now a broken user profile!)

Leonardoxms

Hello.  I´m using arduino pro mini.  I din´t make any changes to the code.  I´m also using the sketch and LIB you suggeted.

I´ve wired this way:

 sclk -13
 mosi -11 
 cs -  9
 dc - 8
 rst - 7 

The display module that I´m using is this one:

http://forum.arduino.cc/index.php?topic=125034.0

thanks

bodmer

#36
Sep 23, 2016, 02:26 pm Last Edit: Sep 23, 2016, 02:27 pm by bodmer
Run the sketch here.

What does it report?

What voltage are you running the pro mini on?

Have you used series resistors in the data/control lines?
Formerly Rowboteer (now a broken user profile!)

Leonardoxms

Report:

TFT driver register values:
===========================
Register 0x01: 0x00
Register 0x04: 0x7C89F0
Register 0x09: 0x610000
Register 0x0A: 0x08
Register 0x0B: 0x00
Register 0x0C: 0x06
Register 0x0D: 0x00
Register 0x0E: 0x00
Register 0x0F: 0x00
Register 0x2E: 0x281400
Register 0xDA: 0x7C
Register 0xDB: 0x89
Register 0xDC: 0xF0
===========================

Looks like driver chip is: ST7735 (empirical value)

I´m running on 5V and I didn´t use resistors in the data/control lines.


Leonardoxms

https://drive.google.com/file/d/0BzKrt8UWkNbRZFJqQlVKQ21GTlk/view?usp=sharing


In the link above, you can see the problem I´m having.


bodmer

The display driver is not 5V tolerant. Put series resistors in the control and data lines as follows:


pro mini digital pin 7 through a 1K2 resistor to display RST
pro mini digital pin 8 through a 1K2 resistor to display DC
pro mini digital pin 9 through a 1K2 resistor to display CS
pro mini digital pin 11 through a 1K2 resistor to display MOSI
pro mini digital pin 13 through a 1K2 resistor to display SCLK
Formerly Rowboteer (now a broken user profile!)

Leonardoxms

Did all that.  Still presenting the same symptoms.   Any other suggestions?   

bodmer

Which version of the Arduino IDE are you using?

Do other example sketches that come with the library work OK?

One problem is that your display shows random pixels on two edges, this is indicative of the wrong setup.  Try different TAB_COLOUR options in User_Setup.h and find which one gets rid of those bad edge pixels. Edit the file, save, recompile and upload the sketch to try each option.
Formerly Rowboteer (now a broken user profile!)

imolodkin

@Leonardoxms

Are you using the sketch attached to post #27?

What changes have you made?

Are you using this graphics library?

If so, do all the other example sketches work OK?

Which Arduino are you using?

How have you wired the display to your Arduino?
Hi!

I use your sketch from post #27 on Uno with ILI9341 2.8'' 320x240 and have  a similar problem with unwanted pixels. I have successfully changed resolution and orientation in the code, already tried different settings in User_Setup to get rid of them. Graphics test sketch running fine. Adafruit library render good image without any troubles, but really slow.

I hope you could help me. Thanks in advance!

bodmer

#43
Oct 30, 2016, 12:39 pm Last Edit: Oct 30, 2016, 12:40 pm by bodmer
@imolodkin

The redraw technique used works best on small displays but if you make the following changes to the post #27 sketch then it should fix your missing pixels.  If it does not then post your sketch so I can run it and see what changes you have made.


Near the start of sketch change the line as follows:

Code: [Select]
#define HOR 400    // Horizon vector line length ### was 172


Then use this adapted drawHorizon() function:

Code: [Select]
// #########################################################################
// Draw the horizon with a new roll (angle in range -180 to +180)
// #########################################################################

void drawHorizon(int roll, int pitch)
{
  // Calculate coordinates for 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;
  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 = 6 * xd;
    ydn = 6 * yd;
    tft.drawLine(XC - x0 - xdn, YC - y0 - ydn - pitch, XC + x0 - xdn, YC + y0 - ydn - pitch, SKY_BLUE);
    tft.drawLine(XC - x0 + xdn, YC - y0 + ydn - pitch, XC + x0 + xdn, YC + y0 + ydn - pitch, BROWN);
    xdn = 5 * xd;
    ydn = 5 * yd;
    tft.drawLine(XC - x0 - xdn, YC - y0 - ydn - pitch, XC + x0 - xdn, YC + y0 - ydn - pitch, SKY_BLUE);
    tft.drawLine(XC - x0 + xdn, YC - y0 + ydn - pitch, XC + x0 + xdn, YC + y0 + ydn - pitch, BROWN);
    xdn = 4 * xd;
    ydn = 4 * yd;
    tft.drawLine(XC - x0 - xdn, YC - y0 - ydn - pitch, XC + x0 - xdn, YC + y0 - ydn - pitch, SKY_BLUE);
    tft.drawLine(XC - x0 + xdn, YC - y0 + ydn - pitch, XC + x0 + xdn, YC + y0 + ydn - pitch, BROWN);
   
    xdn = 3 * xd;
    ydn = 3 * yd;
    tft.drawLine(XC - x0 - xdn, YC - y0 - ydn - pitch, XC + x0 - xdn, YC + y0 - ydn - pitch, SKY_BLUE);
    tft.drawLine(XC - x0 + xdn, YC - y0 + ydn - pitch, XC + x0 + xdn, YC + y0 + ydn - pitch, BROWN);
  }
  xdn = 2 * xd;
  ydn = 2 * yd;
  tft.drawLine(XC - x0 - xdn, YC - y0 - ydn - pitch, XC + x0 - xdn, YC + y0 - ydn - pitch, SKY_BLUE);
  tft.drawLine(XC - x0 + xdn, YC - y0 + ydn - pitch, XC + x0 + xdn, YC + y0 + ydn - pitch, BROWN);

  tft.drawLine(XC - x0 - xd, YC - y0 - yd - pitch, XC + x0 - xd, YC + y0 - yd - pitch, SKY_BLUE);
  tft.drawLine(XC - x0 + xd, YC - y0 + yd - pitch, XC + x0 + xd, YC + y0 + yd - pitch, BROWN);

  tft.drawLine(XC - x0, YC - y0 - pitch,   XC + x0, YC + y0 - pitch,   TFT_WHITE);

  last_roll = roll;
  last_pitch = pitch;

}


Since the larger display has ~ 4x the number of pixels to draw I would expect the code to run 4x slower than for a 160 x 128 display and thus the text/numbers will flicker when it is redrawn.
Formerly Rowboteer (now a broken user profile!)

imolodkin

#44
Nov 01, 2016, 06:21 pm Last Edit: Nov 01, 2016, 06:34 pm by imolodkin
Your patch works perfectly, thank you!!!!!! Speed is acceptable, no flickering.
But there are still random artifacts on the left and top sides.  They were before my changes too, but only with this library. Do you have any suggestions?

Go Up