Jump to content

[KSP 1.10.0] Kerbal Simpit: A KSP serial mod for hardware controllers (1.4.1)


stibbons

Recommended Posts

3 hours ago, stibbons said:

Multi-device functionality has been in place for quite a while. :D You need to add a new SerialPort section in the config file, just duplicate the one that's there. I'd like to eventually add an in-game interface for configuring serial connections, but that's still a fair way off unfortunately.

Ohhh, I did miss that one. Now I'm feeling like being under pressure delivering, but this step will take a while. First I want to finish the control part.

@Gizzum: I found some code from an older project. Can you do me a favor, and draw these on your TFT (I hope your syntax is not toooo different, I don't know what library you're using), let's see the lag with drawing lines and dots, and circles:

//SAS-Modus HOLD malen
//Das macht uns in Zukunft die Positionierung einfacher
  int x = 47;
  int y = 55;
  myGLCD.setColor(0, 255, 0);
  myGLCD.setFont(SmallFont);
  myGLCD.print("~", x-2, y-1);
  myGLCD.setFont(BigFont);
  myGLCD.drawCircle(x, y, 7);

//SAS-Modus PROGRADE malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 80;
  myGLCD.setColor(255, 255, 51);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawPixel(x, y);
  myGLCD.drawLine(x-8, y, x-12, y);
  myGLCD.drawLine(x+8, y, x+12, y);

//SAS-Modus RETROGRADE malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 105;
  myGLCD.setColor(255, 255, 51);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawLine(x, y-12, x, y-8);
  myGLCD.drawLine(x+7, y+4, x+10, y+6);
  myGLCD.drawLine(x-7, y+4, x-10, y+6);
  myGLCD.drawLine(x-5, y+5, x+5, y-5);
  myGLCD.drawLine(x-5, y-5, x+5, y+5);

//SAS-Modus NORMAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 130;
  myGLCD.setColor(255, 0, 255);
  myGLCD.drawLine(x-9, y+5, x+8, y+5);
  myGLCD.drawLine(x-9, y+5, x, y-9);
  myGLCD.drawLine(x, 121, x+8, y+5);
  myGLCD.drawPixel(x, y);
  
//SAS-Modus ANTINORMAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 155;
  myGLCD.setColor(255, 0, 255);
  myGLCD.drawLine(x-9, y-5, x+8, y-5);
  myGLCD.drawLine(x-9, y-5, x, y+9);
  myGLCD.drawLine(x, y+9, x+8, y-5);
  myGLCD.drawPixel(x, y);
  myGLCD.drawLine(x, y-12, x, y-5);
  myGLCD.drawLine(x+5, y+2, x+10, y+6);
  myGLCD.drawLine(x-5, y+2, x-10, y+6);

//SAS-Modus RADIAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 180;
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawLine(x-5, y+5, x+5, y-5);
  myGLCD.drawLine(x-5, y-5, x+5, y+5);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(x, y, 3);
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawPixel(x, y);

//SAS-Modus ANTIRADIAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 205;
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawLine(x-8, y+8, x+8, y-8);
  myGLCD.drawLine(x-8, y-8, x+8, y+8);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(x, y, 6);
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawPixel(x, y);

//SAS-Modus TARGET malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 230;
  myGLCD.setColor(255, 90, 255);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRect(x-2, y-8, x+2, y+8);
  myGLCD.fillRect(x-8, y+2, x+8, y-2);
  myGLCD.setColor(255, 90, 255);
  myGLCD.drawPixel(x, y);

//SAS-Modus ANTITARGET malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 255;
  myGLCD.setColor(255, 90, 255);
  myGLCD.drawPixel(x, y);
  myGLCD.drawLine(x, y+9, x, y+7);
  myGLCD.drawLine(x+5, y-5, x+8, y-7);
  myGLCD.drawLine(x-5, y-5, x-8, y-7);

//SAS-Modus MANEUVER malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 280;
  myGLCD.setColor(50, 50, 255);
  myGLCD.drawLine(x-4, y-8, x+4, y-8);
  myGLCD.drawLine(x-4, y+6, x-8, y);
  myGLCD.drawLine(x+4, y+6, x+8, y);
  myGLCD.drawLine(x, y-7, x, y-5);
  myGLCD.drawLine(x-6, y+3, x-3, y+1);
  myGLCD.drawLine(x+6, y+3, x+3, y+1);
  myGLCD.drawPixel(x, y-1);

 

Link to comment
Share on other sites

9 hours ago, Benji said:

Ohhh, I did miss that one. Now I'm feeling like being under pressure delivering, but this step will take a while. First I want to finish the control part.

@Gizzum: I found some code from an older project. Can you do me a favor, and draw these on your TFT (I hope your syntax is not toooo different, I don't know what library you're using), let's see the lag with drawing lines and dots, and circles:


//SAS-Modus HOLD malen
//Das macht uns in Zukunft die Positionierung einfacher
  int x = 47;
  int y = 55;
  myGLCD.setColor(0, 255, 0);
  myGLCD.setFont(SmallFont);
  myGLCD.print("~", x-2, y-1);
  myGLCD.setFont(BigFont);
  myGLCD.drawCircle(x, y, 7);

//SAS-Modus PROGRADE malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 80;
  myGLCD.setColor(255, 255, 51);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawPixel(x, y);
  myGLCD.drawLine(x-8, y, x-12, y);
  myGLCD.drawLine(x+8, y, x+12, y);

//SAS-Modus RETROGRADE malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 105;
  myGLCD.setColor(255, 255, 51);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawLine(x, y-12, x, y-8);
  myGLCD.drawLine(x+7, y+4, x+10, y+6);
  myGLCD.drawLine(x-7, y+4, x-10, y+6);
  myGLCD.drawLine(x-5, y+5, x+5, y-5);
  myGLCD.drawLine(x-5, y-5, x+5, y+5);

//SAS-Modus NORMAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 130;
  myGLCD.setColor(255, 0, 255);
  myGLCD.drawLine(x-9, y+5, x+8, y+5);
  myGLCD.drawLine(x-9, y+5, x, y-9);
  myGLCD.drawLine(x, 121, x+8, y+5);
  myGLCD.drawPixel(x, y);
  
//SAS-Modus ANTINORMAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 155;
  myGLCD.setColor(255, 0, 255);
  myGLCD.drawLine(x-9, y-5, x+8, y-5);
  myGLCD.drawLine(x-9, y-5, x, y+9);
  myGLCD.drawLine(x, y+9, x+8, y-5);
  myGLCD.drawPixel(x, y);
  myGLCD.drawLine(x, y-12, x, y-5);
  myGLCD.drawLine(x+5, y+2, x+10, y+6);
  myGLCD.drawLine(x-5, y+2, x-10, y+6);

//SAS-Modus RADIAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 180;
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawLine(x-5, y+5, x+5, y-5);
  myGLCD.drawLine(x-5, y-5, x+5, y+5);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(x, y, 3);
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawPixel(x, y);

//SAS-Modus ANTIRADIAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 205;
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawLine(x-8, y+8, x+8, y-8);
  myGLCD.drawLine(x-8, y-8, x+8, y+8);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(x, y, 6);
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawPixel(x, y);

//SAS-Modus TARGET malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 230;
  myGLCD.setColor(255, 90, 255);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRect(x-2, y-8, x+2, y+8);
  myGLCD.fillRect(x-8, y+2, x+8, y-2);
  myGLCD.setColor(255, 90, 255);
  myGLCD.drawPixel(x, y);

//SAS-Modus ANTITARGET malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 255;
  myGLCD.setColor(255, 90, 255);
  myGLCD.drawPixel(x, y);
  myGLCD.drawLine(x, y+9, x, y+7);
  myGLCD.drawLine(x+5, y-5, x+8, y-7);
  myGLCD.drawLine(x-5, y-5, x-8, y-7);

//SAS-Modus MANEUVER malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 280;
  myGLCD.setColor(50, 50, 255);
  myGLCD.drawLine(x-4, y-8, x+4, y-8);
  myGLCD.drawLine(x-4, y+6, x-8, y);
  myGLCD.drawLine(x+4, y+6, x+8, y);
  myGLCD.drawLine(x, y-7, x, y-5);
  myGLCD.drawLine(x-6, y+3, x-3, y+1);
  myGLCD.drawLine(x+6, y+3, x+3, y+1);
  myGLCD.drawPixel(x, y-1);

 

There is a demo test sketch that comes with the MCUfriend library...

// All the mcufriend.com UNO shields have the same pinout.
// i.e. control pins A0-A4.  Data D2-D9.  microSD D10-D13.
// Touchscreens are normally A1, A2, D7, D6 but the order varies
//
// This demo should work with most Adafruit TFT libraries
// If you are not using a shield,  use a full Adafruit constructor()
// e.g. Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

#define LCD_CS A3 // Chip Select goes to Analog 3
#define LCD_CD A2 // Command/Data goes to Analog 2
#define LCD_WR A1 // LCD Write goes to Analog 1
#define LCD_RD A0 // LCD Read goes to Analog 0
#define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

#include <SPI.h>          // f.k. for Arduino-1.5.2
#include "Adafruit_GFX.h"// Hardware-specific library
#include <MCUFRIEND_kbv.h>
MCUFRIEND_kbv tft;
//#include <Adafruit_TFTLCD.h>
//Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);

// Assign human-readable names to some common 16-bit color values:
#define	BLACK   0x0000
#define	BLUE    0x001F
#define	RED     0xF800
#define	GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
#endif

void setup(void);
void loop(void);
unsigned long testFillScreen();
unsigned long testText();
unsigned long testLines(uint16_t color);
unsigned long testFastLines(uint16_t color1, uint16_t color2);
unsigned long testRects(uint16_t color);
unsigned long testFilledRects(uint16_t color1, uint16_t color2);
unsigned long testFilledCircles(uint8_t radius, uint16_t color);
unsigned long testCircles(uint8_t radius, uint16_t color);
unsigned long testTriangles();
unsigned long testFilledTriangles();
unsigned long testRoundRects();
unsigned long testFilledRoundRects();
void progmemPrint(const char *str);
void progmemPrintln(const char *str);

void runtests(void);

uint16_t g_identifier;

extern const uint8_t hanzi[];
void showhanzi(unsigned int x, unsigned int y, unsigned char index)
{
    uint8_t i, j, c, first = 1;
    uint8_t *temp = (uint8_t*)hanzi;
    uint16_t color;
    tft.setAddrWindow(x, y, x + 31, y + 31); //设置区域
    temp += index * 128;
    for (j = 0; j < 128; j++)
    {
        c = pgm_read_byte(temp);
        for (i = 0; i < 8; i++)
        {
            if ((c & (1 << i)) != 0)
            {
                color = RED;
            }
            else
            {
                color = BLACK;
            }
            tft.pushColors(&color, 1, first);
            first = 0;
        }
        temp++;
    }
}

void setup(void) {
    Serial.begin(9600);
    uint32_t when = millis();
    //    while (!Serial) ;   //hangs a Leonardo until you connect a Serial
    if (!Serial) delay(5000);           //allow some time for Leonardo
    Serial.println("Serial took " + String((millis() - when)) + "ms to start");
    static uint16_t identifier;
    //    tft.reset();                 //we can't read ID on 9341 until begin()
    g_identifier = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(g_identifier, HEX);
    if (g_identifier == 0x00D3 || g_identifier == 0xD3D3) g_identifier = 0x9481; // write-only shield
    if (g_identifier == 0xFFFF) g_identifier = 0x9341; // serial
//    g_identifier = 0x9329;                             // force ID
    tft.begin(g_identifier);
}

#if defined(MCUFRIEND_KBV_H_)
uint16_t scrollbuf[320];    // my biggest screen is 320x480
#define READGRAM(x, y, buf, w, h)  tft.readGRAM(x, y, buf, w, h)
#else
uint16_t scrollbuf[320];    // Adafruit only does 240x320
// Adafruit can read a block by one pixel at a time
int16_t  READGRAM(int16_t x, int16_t y, uint16_t *block, int16_t w, int16_t h)
{
    uint16_t *p;
    for (int row = 0; row < h; row++) {
        p = block + row * w;
        for (int col = 0; col < w; col++) {
            *p++ = tft.readPixel(x + col, y + row);
        }
    }
}
#endif

void windowScroll(int16_t x, int16_t y, int16_t wid, int16_t ht, int16_t dx, int16_t dy, uint16_t *buf)
{
    if (dx) for (int16_t row = 0; row < ht; row++) {
            READGRAM(x, y + row, buf, wid, 1);
            tft.setAddrWindow(x, y + row, x + wid - 1, y + row);
            tft.pushColors(buf + dx, wid - dx, 1);
            tft.pushColors(buf + 0, dx, 0);
        }
    if (dy) for (int16_t col = 0; col < wid; col++) {
            READGRAM(x + col, y, buf, 1, ht);
            tft.setAddrWindow(x + col, y, x + col, y + ht - 1);
            tft.pushColors(buf + dy, ht - dy, 1);
            tft.pushColors(buf + 0, dy, 0);
        }
}

void loop(void) {
    uint8_t aspect;
    uint16_t pixel;
    char *aspectname[] = {
        "PORTRAIT", "LANDSCAPE", "PORTRAIT_REV", "LANDSCAPE_REV"
    };
    char *colorname[] = { "BLUE", "GREEN", "RED", "GRAY" };
    uint16_t colormask[] = { 0x001F, 0x07E0, 0xF800, 0xFFFF };
    uint16_t dx, rgb, n, wid, ht;
    tft.setRotation(0);
//    for (uint8_t i = 0; i < 2; i++) showhanzi(0, 0, i), delay(1000);
    runtests();
    delay(2000);
    if (tft.height() > 64) {
        for (uint8_t cnt = 0; cnt < 4; cnt++) {
            aspect = (cnt + 0) & 3;
            tft.setRotation(aspect);
            wid = tft.width();
            ht = tft.height();
            testText();
            dx = wid / 32;
            for (n = 0; n < 32; n++) {
                rgb = n * 8;
                rgb = tft.color565(rgb, rgb, rgb);
                tft.fillRect(n * dx, 48, dx, 64, rgb & colormask[aspect]);
            }
            tft.setTextSize(2);
            tft.setTextColor(colormask[aspect], BLACK);
            tft.setCursor(0, 72);
            tft.print(colorname[aspect]);
            tft.setTextColor(WHITE);
            tft.println(" COLOR GRADES");
            tft.setTextColor(WHITE, BLACK);
            tft.setCursor(0, 184);
            tft.println(aspectname[aspect]);
            delay(1000);
            tft.drawPixel(0, 0, YELLOW);
            pixel = tft.readPixel(0, 0);
#if defined(MCUFRIEND_KBV_H_)
            extern const uint8_t penguin[];
            tft.setAddrWindow(wid - 40 - 40, 20 + 0, wid - 1 - 40, 20 + 39);
            tft.pushColors(penguin, 1600, 1);
            tft.setTextColor(WHITE, BLACK);
            tft.println("VERTICAL SCROLL UP");
            uint16_t maxscroll;
            if (tft.getRotation() & 1) maxscroll = wid;
            else maxscroll = ht;
            for (uint16_t i = 1; i <= maxscroll; i++) {
                tft.vertScroll(0, maxscroll, i);
                delay(10);
            }
            tft.vertScroll(0, maxscroll, 0);
            tft.setCursor(0, 200);
            tft.println("VERTICAL SCROLL DN");
            for (uint16_t i = 1; i <= maxscroll; i++) {
                tft.vertScroll(0, maxscroll, 0 - (int16_t)i);
                delay(10);
            }
            delay(1000);
            tft.vertScroll(0, maxscroll, 0);
            if ((aspect & 1) == 0) { //Portrait
                tft.setCursor(0, 200);
                tft.setTextColor(BLUE, BLACK);
                tft.println("ONLY THE COLOR BAND");
                for (uint16_t i = 1; i <= 64; i++) {
                    tft.vertScroll(48, 64, i);
                    delay(20);
                }
                delay(1000);
                tft.vertScroll(0, maxscroll, 0);
            }
#endif
            tft.setCursor(0, 200);
            tft.setTextColor(YELLOW, BLACK);
            if (pixel == YELLOW) {
                tft.println("SOFTWARE SCROLL    ");
#if 0
                for (int16_t i = 45, dx = 2, dy = 1; i > 0; i -= dx) {
                    windowScroll(24, 8, 90, 40, dx, dy, scrollbuf);
                }
#else
                // scroll a whole width of the screen
                n = (wid > 320) ? 320 : wid;
                for (int16_t i = n, dx = 4, dy = 0; i > 0; i -= dx) {
                    windowScroll(0, 200, n, 16, dx, dy, scrollbuf);
                }
#endif
            }
            else if (pixel == CYAN)
                tft.println("readPixel() reads as BGR");
            else if ((pixel & 0xF8F8) == 0xF8F8)
                tft.println("readPixel() should be 24-bit");
            else {
                tft.print("readPixel() reads 0x");
                tft.println(pixel, HEX);
            }
            delay(5000);
        }
    }
    tft.println("INVERT DISPLAY");
    tft.invertDisplay(true);
    delay(2000);
    tft.invertDisplay(false);
}

typedef struct {
    PGM_P msg;
    uint32_t ms;
} TEST;
TEST result[12];

#define RUNTEST(n, str, test) { result[n].msg = PSTR(str); result[n].ms = test; delay(500); }

void runtests(void)
{
    uint8_t i, len = 24, cnt;
    uint32_t total;
    RUNTEST(0, "FillScreen               ", testFillScreen());
    RUNTEST(1, "Text                     ", testText());
    RUNTEST(2, "Lines                    ", testLines(CYAN));
    RUNTEST(3, "Horiz/Vert Lines         ", testFastLines(RED, BLUE));
    RUNTEST(4, "Rectangles (outline)     ", testRects(GREEN));
    RUNTEST(5, "Rectangles (filled)      ", testFilledRects(YELLOW, MAGENTA));
    RUNTEST(6, "Circles (filled)         ", testFilledCircles(10, MAGENTA));
    RUNTEST(7, "Circles (outline)        ", testCircles(10, WHITE));
    RUNTEST(8, "Triangles (outline)      ", testTriangles());
    RUNTEST(9, "Triangles (filled)       ", testFilledTriangles());
    RUNTEST(10, "Rounded rects (outline)  ", testRoundRects());
    RUNTEST(11, "Rounded rects (filled)   ", testFilledRoundRects());

    tft.fillScreen(BLACK);
    tft.setTextColor(GREEN);
    tft.setCursor(0, 0);
    uint16_t wid = tft.width();
    if (wid > 176) {
        tft.setTextSize(2);
#if defined(MCUFRIEND_KBV_H_)
        tft.print("MCUFRIEND ");
#if MCUFRIEND_KBV_H_ != 0
        tft.print(0.01 * MCUFRIEND_KBV_H_, 1);
#else
        tft.print("for");
#endif
        tft.println(" UNO");
#else
        tft.println("Adafruit-Style Tests");
#endif
    } else len = wid / 6 - 8;
    tft.setTextSize(1);
    total = 0;
    for (i = 0; i < 12; i++) {
        PGM_P str = result[i].msg;
        char c;
        if (len > 24) {
            if (i < 10) tft.print(" ");
            tft.print(i);
            tft.print(": ");
        }
        uint8_t cnt = len;
        while ((c = pgm_read_byte(str++)) && cnt--) tft.print(c);
        tft.print(" ");
        tft.println(result[i].ms);
        total += result[i].ms;
    }
    tft.setTextSize(2);
    tft.print("Total:");
    tft.print(0.000001 * total);
    tft.println("sec");
    g_identifier = tft.readID();
    tft.print("ID: 0x");
    tft.println(tft.readID(), HEX);
    tft.print("Reg(00):0x");
    tft.println(tft.readReg(0x00), HEX);
    tft.print("F_CPU:");
    tft.print(0.000001 * F_CPU);
#if defined(__OPTIMIZE_SIZE__)
    tft.println("MHz -Os");
#else
    tft.println("MHz");
#endif

    delay(10000);
}

// Standard Adafruit tests.  will adjust to screen size

unsigned long testFillScreen() {
    unsigned long start = micros();
    tft.fillScreen(BLACK);
    tft.fillScreen(RED);
    tft.fillScreen(GREEN);
    tft.fillScreen(BLUE);
    tft.fillScreen(BLACK);
    return micros() - start;
}

unsigned long testText() {
    unsigned long start;
    tft.fillScreen(BLACK);
    start = micros();
    tft.setCursor(0, 0);
    tft.setTextColor(WHITE);  tft.setTextSize(1);
    tft.println("Hello World!");
    tft.setTextColor(YELLOW); tft.setTextSize(2);
    tft.println(123.45);
    tft.setTextColor(RED);    tft.setTextSize(3);
    tft.println(0xDEADBEEF, HEX);
    tft.println();
    tft.setTextColor(GREEN);
    tft.setTextSize(5);
    tft.println("Groop");
    tft.setTextSize(2);
    tft.println("I implore thee,");
    tft.setTextSize(1);
    tft.println("my foonting turlingdromes.");
    tft.println("And hooptiously drangle me");
    tft.println("with crinkly bindlewurdles,");
    tft.println("Or I will rend thee");
    tft.println("in the gobberwarts");
    tft.println("with my blurglecruncheon,");
    tft.println("see if I don't!");
    return micros() - start;
}

unsigned long testLines(uint16_t color) {
    unsigned long start, t;
    int           x1, y1, x2, y2,
                  w = tft.width(),
                  h = tft.height();

    tft.fillScreen(BLACK);

    x1 = y1 = 0;
    y2    = h - 1;
    start = micros();
    for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    x2    = w - 1;
    for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    t     = micros() - start; // fillScreen doesn't count against timing

    tft.fillScreen(BLACK);

    x1    = w - 1;
    y1    = 0;
    y2    = h - 1;
    start = micros();
    for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    x2    = 0;
    for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    t    += micros() - start;

    tft.fillScreen(BLACK);

    x1    = 0;
    y1    = h - 1;
    y2    = 0;
    start = micros();
    for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    x2    = w - 1;
    for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    t    += micros() - start;

    tft.fillScreen(BLACK);

    x1    = w - 1;
    y1    = h - 1;
    y2    = 0;
    start = micros();
    for (x2 = 0; x2 < w; x2 += 6) tft.drawLine(x1, y1, x2, y2, color);
    x2    = 0;
    for (y2 = 0; y2 < h; y2 += 6) tft.drawLine(x1, y1, x2, y2, color);

    return micros() - start;
}

unsigned long testFastLines(uint16_t color1, uint16_t color2) {
    unsigned long start;
    int           x, y, w = tft.width(), h = tft.height();

    tft.fillScreen(BLACK);
    start = micros();
    for (y = 0; y < h; y += 5) tft.drawFastHLine(0, y, w, color1);
    for (x = 0; x < w; x += 5) tft.drawFastVLine(x, 0, h, color2);

    return micros() - start;
}

unsigned long testRects(uint16_t color) {
    unsigned long start;
    int           n, i, i2,
                  cx = tft.width()  / 2,
                  cy = tft.height() / 2;

    tft.fillScreen(BLACK);
    n     = min(tft.width(), tft.height());
    start = micros();
    for (i = 2; i < n; i += 6) {
        i2 = i / 2;
        tft.drawRect(cx - i2, cy - i2, i, i, color);
    }

    return micros() - start;
}

unsigned long testFilledRects(uint16_t color1, uint16_t color2) {
    unsigned long start, t = 0;
    int           n, i, i2,
                  cx = tft.width()  / 2 - 1,
                  cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    n = min(tft.width(), tft.height());
    for (i = n; i > 0; i -= 6) {
        i2    = i / 2;
        start = micros();
        tft.fillRect(cx - i2, cy - i2, i, i, color1);
        t    += micros() - start;
        // Outlines are not included in timing results
        tft.drawRect(cx - i2, cy - i2, i, i, color2);
    }

    return t;
}

unsigned long testFilledCircles(uint8_t radius, uint16_t color) {
    unsigned long start;
    int x, y, w = tft.width(), h = tft.height(), r2 = radius * 2;

    tft.fillScreen(BLACK);
    start = micros();
    for (x = radius; x < w; x += r2) {
        for (y = radius; y < h; y += r2) {
            tft.fillCircle(x, y, radius, color);
        }
    }

    return micros() - start;
}

unsigned long testCircles(uint8_t radius, uint16_t color) {
    unsigned long start;
    int           x, y, r2 = radius * 2,
                        w = tft.width()  + radius,
                        h = tft.height() + radius;

    // Screen is not cleared for this one -- this is
    // intentional and does not affect the reported time.
    start = micros();
    for (x = 0; x < w; x += r2) {
        for (y = 0; y < h; y += r2) {
            tft.drawCircle(x, y, radius, color);
        }
    }

    return micros() - start;
}

unsigned long testTriangles() {
    unsigned long start;
    int           n, i, cx = tft.width()  / 2 - 1,
                        cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    n     = min(cx, cy);
    start = micros();
    for (i = 0; i < n; i += 5) {
        tft.drawTriangle(
            cx    , cy - i, // peak
            cx - i, cy + i, // bottom left
            cx + i, cy + i, // bottom right
            tft.color565(0, 0, i));
    }

    return micros() - start;
}

unsigned long testFilledTriangles() {
    unsigned long start, t = 0;
    int           i, cx = tft.width()  / 2 - 1,
                     cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    start = micros();
    for (i = min(cx, cy); i > 10; i -= 5) {
        start = micros();
        tft.fillTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
                         tft.color565(0, i, i));
        t += micros() - start;
        tft.drawTriangle(cx, cy - i, cx - i, cy + i, cx + i, cy + i,
                         tft.color565(i, i, 0));
    }

    return t;
}

unsigned long testRoundRects() {
    unsigned long start;
    int           w, i, i2, red, step,
                  cx = tft.width()  / 2 - 1,
                  cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    w     = min(tft.width(), tft.height());
    start = micros();
    red = 0;
    step = (256 * 6) / w;
    for (i = 0; i < w; i += 6) {
        i2 = i / 2;
        red += step;
        tft.drawRoundRect(cx - i2, cy - i2, i, i, i / 8, tft.color565(red, 0, 0));
    }

    return micros() - start;
}

unsigned long testFilledRoundRects() {
    unsigned long start;
    int           i, i2, green, step,
                  cx = tft.width()  / 2 - 1,
                  cy = tft.height() / 2 - 1;

    tft.fillScreen(BLACK);
    start = micros();
    green = 256;
    step = (256 * 6) / min(tft.width(), tft.height());
    for (i = min(tft.width(), tft.height()); i > 20; i -= 6) {
        i2 = i / 2;
        green -= step;
        tft.fillRoundRect(cx - i2, cy - i2, i, i, i / 8, tft.color565(0, green, 0));
    }

    return micros() - start;
}

It runs sweet as a nut.  Suggest a good video hosting site and I'll upload it running your code.  If i can get it running that is.  I have basic info at the moment and it seems to handling it.

Edited by Gizzum
Adding to message
Link to comment
Share on other sites

3 hours ago, Gizzum said:

There is a demo test sketch that comes with the MCUfriend library...

It runs sweet as a nut.  Suggest a good video hosting site and I'll upload it running your code.  If i can get it running that is.  I have basic info at the moment and it seems to handling it.

Uhh, I think I don't like this library but I like the TFT to have so few pins. I have something like this one. A little smaller. Oneandahalf the amount of pins  (I assume) let's you use the UTFT library, and it is really clean and simple, from what I did with it.

Any site does the job, I don't care. Thanks for your efforts, btw.

Edited by Benji
Link to comment
Share on other sites

@stibbons: Had some thought on how to format the Apsidetimes for my LCD, onse it works.

Keep in mind, I'm arguing from a RSS standpoint.

Covering the extrem; sending a probe to an orbit similar plutos I get an orbital period of 248 years around the sun. 248 years from Aphelion to next Aphelion. That's 5.683.564.800 seconds. That does not fit inside the integer.

Unsigned long holds 4.294.967.295. Would fit up to neptunes orbit - a bit further out even.

 

But even Eeloo (Stock) has an orbital period of  9.776.696,3 seconds. That's not covered by an unsigned integers range.

 

Perhaps you could handle these times as floats or split them up into years, days, hours, minutes and seconds or just minutes and seconds.

I would prefer float. But I don't mean that we need ms accuracy.

Edited by Benji
clarifying the units
Link to comment
Share on other sites

11 minutes ago, Benji said:

I would prefer float. But I don't mean that we need ms accuracy.

Oh, wow. I hadn't really thought properly about whether outer planets periods would fit properly in to my apsides times data type. And you're right, I also prefer floats to trying to do weird things like splitting in to hours etc. But breaking backward compatibility would mean a new major version, and there's a couple more little things I want to do before I go to that extreme. So right now the best I can promise is maybe a new apsides time channel with floating point accuracy, and a new version 2.0 in the 1-2 month time frame that fixes the apsides times properly and breaks the 1.x channel.

Also, just saw your PR for keywords file. Thank you so much for getting to the bottom of that! :D I don't actually write my code in the Arduino IDE any more, so it's a little too easy for me to miss formatting bugs like that. Will merge it shortly.

EDIT: Added https://trello.com/c/PkEl8T0R/50-change-apsides-time-message-to-use-floats to fix the apsides time data type properly, and I might include a temporary channel in a sooner release? https://trello.com/c/Yd4sFaTq/51-new-float-apsides-time-message

Edited by stibbons
Link to comment
Share on other sites

9 minutes ago, stibbons said:

Also, just saw your PR for keywords file. Thank you so much for getting to the bottom of that! :D I don't actually write my code in the Arduino IDE any more, so it's a little too easy for me to miss formatting bugs like that. Will merge it shortly.

EDIT: Added https://trello.com/c/PkEl8T0R/50-change-apsides-time-message-to-use-floats to fix the apsides time data type properly, and I might include a temporary channel in a sooner release? https://trello.com/c/Yd4sFaTq/51-new-float-apsides-time-message

It's not that much, but I'm happy doing something other, then just writing about things here on the forum.

Wow, that's organized. I normally keep little notes all over my bed, table and floor.

Link to comment
Share on other sites

1 minute ago, Benji said:

Wow, that's organized. I normally keep little notes all over my bed, table and floor.

For personal projects, me too. But this thing grew way too big for me to keep track without a real board long ago. Which is a little scary when I think about it, actually.

I've pushed version 1.1.2 of the Arduino library. Only change is to the keywords.txt. The Arduino library manager should index and have it available within an hour.

Link to comment
Share on other sites

Regarding keywords.txt

 It's strange. It is said there has to be only one tab, but sometimes two, sometimes three are needed to make it work. I think that's why my attempts didn't work and I gave up to soon.

Link to comment
Share on other sites

On 2017-6-27 at 4:58 AM, Benji said:

case APSIDESTIME_MESSAGE:
      if (msgSize == sizeof(apsidesTimeMessage))
      {
        apsidesTimeMessage ApsidesTime;
        ApsidesTime = parseApsidesTime(msg);
          lcd_orbit_info_print_text("Seconds", 1, 0);
          //Converting to km
          lcd_orbit_info_print_int(ApsidesTime.apoapsis, 0, 0);
          //Converting to km
          lcd_orbit_info_print_int(ApsidesTime.periapsis, 2, 0);
      }
    break;

OK, found it. This wasn't working because I screwed up the data type sizes. I had somewhat carelessly defined the structs on both sides as ints. But while C# uses 32 bit ints, the Arduino environment on AVR uses 16 bit ints. That meant the struct sent by the plugin was larger than the Arduino library was expecting, so your if condition will always fail and so your code never runs.

I'm going to update the Arduino library to also use 32 bit signed integers for the apsides times for now. But I also want to quickly audit the other data types and make sure they all match. Will push out another Arduino library update either late this evening or tomorrow, and post here again when it's done.

I think I'm still preferring floats for the Apside times in the next major revision of this project. But fixing the bug preventing the current behaviour from working at all is important.

Edited by stibbons
Link to comment
Share on other sites

10 minutes ago, stibbons said:

I'm going to update the Arduino library to also use 32 bit signed integers for the apsides times for now. But I also want to quickly audit the other data types and make sure they all match. Will push out another Arduino library update either late this evening or tomorrow, and post here again when it's done.

I think I'm still preferring floats for the Apside times in the next major revision of this project. But fixing the bug preventing the current behaviour from working at all is important.

I'm glad to hear that. 32bit integers are sufficient for my Simpit Test in the stock system. I don't plan on flying out kerbins influence, so it's okai for me for now, too. (That can't be proper english, looks weird)

Link to comment
Share on other sites

19 hours ago, stibbons said:

1.1.3 fixes the ApsideTime struct so that apside times can be properly processed by the library.

Can confirm that it's working.

19 hours ago, stibbons said:

Version 1.1.3 of the Arduino library is uploaded and will shortly be available.

Weird and strange seem to be my favourite words these last days. So, the library update process is a bit weird, but only for Simpit, other libraries update normally. If Simpit is updateable I can't simply update it, because there is one Simpit shown as installed and above one Simpit, where I can choose to install the latest version (or an earlier one).

ZVZwdO3.jpg

I install the first entry and I end up with two Simpit libraries in my folder:

BKIu44q.jpg

arduino_803933 is the updated, 1.1.3

Kerbal_Sim_Pit is the outdated, 1.1.1

Than the compiler cries about multiple instances and telling me which instance it's ignoring, etc. Not a big deal, but I wonder if it's something I do wrong or if there are some settings you entered to prevent the user from being able to update. Because normally an update button apears and the outdated version is deleted before the latest is being installed.

 

Ups. Haha, I think I was just shouting SCENE_CHANGE_MESSAGE doesn't work on pure luck, because I didn't register to the SCENE_CHANGE_MESSAGE Chanel.

But I have to, don't I?

Edited by Benji
Link to comment
Share on other sites

5 minutes ago, Benji said:

Than the compiler cries about multiple instances and telling me which instance it's ignoring, etc. Not a big deal, but I wonder if it's something I do wrong or if there are some settings you entered to prevent the user from being able to update. Because normally an update button apears and the outdated version is deleted before the latest is being installed.

Pretty sure that's something I've done wrong. Trying to rename the library didn't go as well as expected. But the `arduino_803933` thing is new to me. :/ I'll revert my change to the library.properties file in the next release. You may need to uninstall and reinstall the library, but should hopefully be fine after that.

 

6 minutes ago, Benji said:

Haha, I think I was just shouting SCENE_CHANGE_MESSAGE doesn't work on pure luck

I still haven't done anything about this, sorry. :( Be done by the weekend.

Link to comment
Share on other sites

52 minutes ago, stibbons said:

I still haven't done anything about this, sorry. :( Be done by the weekend.

Don't rush yourself. I just noticed yesterday, that wouldn't be working, even if it did work in the first place.

Link to comment
Share on other sites

On 27/06/2017 at 8:37 AM, Benji said:

Ohhh, I did miss that one. Now I'm feeling like being under pressure delivering, but this step will take a while. First I want to finish the control part.

@Gizzum: I found some code from an older project. Can you do me a favor, and draw these on your TFT (I hope your syntax is not toooo different, I don't know what library you're using), let's see the lag with drawing lines and dots, and circles:


//SAS-Modus HOLD malen
//Das macht uns in Zukunft die Positionierung einfacher
  int x = 47;
  int y = 55;
  myGLCD.setColor(0, 255, 0);
  myGLCD.setFont(SmallFont);
  myGLCD.print("~", x-2, y-1);
  myGLCD.setFont(BigFont);
  myGLCD.drawCircle(x, y, 7);

//SAS-Modus PROGRADE malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 80;
  myGLCD.setColor(255, 255, 51);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawPixel(x, y);
  myGLCD.drawLine(x-8, y, x-12, y);
  myGLCD.drawLine(x+8, y, x+12, y);

//SAS-Modus RETROGRADE malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 105;
  myGLCD.setColor(255, 255, 51);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawLine(x, y-12, x, y-8);
  myGLCD.drawLine(x+7, y+4, x+10, y+6);
  myGLCD.drawLine(x-7, y+4, x-10, y+6);
  myGLCD.drawLine(x-5, y+5, x+5, y-5);
  myGLCD.drawLine(x-5, y-5, x+5, y+5);

//SAS-Modus NORMAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 130;
  myGLCD.setColor(255, 0, 255);
  myGLCD.drawLine(x-9, y+5, x+8, y+5);
  myGLCD.drawLine(x-9, y+5, x, y-9);
  myGLCD.drawLine(x, 121, x+8, y+5);
  myGLCD.drawPixel(x, y);
  
//SAS-Modus ANTINORMAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 155;
  myGLCD.setColor(255, 0, 255);
  myGLCD.drawLine(x-9, y-5, x+8, y-5);
  myGLCD.drawLine(x-9, y-5, x, y+9);
  myGLCD.drawLine(x, y+9, x+8, y-5);
  myGLCD.drawPixel(x, y);
  myGLCD.drawLine(x, y-12, x, y-5);
  myGLCD.drawLine(x+5, y+2, x+10, y+6);
  myGLCD.drawLine(x-5, y+2, x-10, y+6);

//SAS-Modus RADIAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 180;
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawLine(x-5, y+5, x+5, y-5);
  myGLCD.drawLine(x-5, y-5, x+5, y+5);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(x, y, 3);
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawPixel(x, y);

//SAS-Modus ANTIRADIAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 205;
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.drawLine(x-8, y+8, x+8, y-8);
  myGLCD.drawLine(x-8, y-8, x+8, y+8);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(x, y, 6);
  myGLCD.setColor(0, 255, 255);
  myGLCD.drawPixel(x, y);

//SAS-Modus TARGET malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 230;
  myGLCD.setColor(255, 90, 255);
  myGLCD.drawCircle(x, y, 7);
  myGLCD.setColor(0, 0, 0);
  myGLCD.fillRect(x-2, y-8, x+2, y+8);
  myGLCD.fillRect(x-8, y+2, x+8, y-2);
  myGLCD.setColor(255, 90, 255);
  myGLCD.drawPixel(x, y);

//SAS-Modus ANTITARGET malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 255;
  myGLCD.setColor(255, 90, 255);
  myGLCD.drawPixel(x, y);
  myGLCD.drawLine(x, y+9, x, y+7);
  myGLCD.drawLine(x+5, y-5, x+8, y-7);
  myGLCD.drawLine(x-5, y-5, x-8, y-7);

//SAS-Modus MANEUVER malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 280;
  myGLCD.setColor(50, 50, 255);
  myGLCD.drawLine(x-4, y-8, x+4, y-8);
  myGLCD.drawLine(x-4, y+6, x-8, y);
  myGLCD.drawLine(x+4, y+6, x+8, y);
  myGLCD.drawLine(x, y-7, x, y-5);
  myGLCD.drawLine(x-6, y+3, x-3, y+1);
  myGLCD.drawLine(x+6, y+3, x+3, y+1);
  myGLCD.drawPixel(x, y-1);

 

had to change to code a bit...

#include <Adafruit_GFX.h>
#include <MCUFRIEND_kbv.h>

#define colour1 0x07E0 //0, 255, 0
#define colour2 0xFFE6 //255, 255, 51
#define colour3 0xF81F //255, 0, 255
#define colour4 0x07FF //0, 255, 255
#define colour5 0xFADF //255,90,255
#define colour6 0x319F //50, 50, 255
#define colour7 0x0000 //0, 0, 0
#define BLACK   0xFFFF
// work in line numbers.  Font height in ht
uint16_t ht = 16, top = 2, line, lines = 28, scroll;
MCUFRIEND_kbv myGLCD;
void setup()
{
  myGLCD.reset();
  uint16_t id = myGLCD.readID();
  myGLCD.begin(id);
  myGLCD.setRotation(0);     //LANDSCAPE
  myGLCD.fillScreen(BLACK);
  //SAS-Modus HOLD malen
//Das macht uns in Zukunft die Positionierung einfacher
  int x = 47;
  int y = 55;
  //myGLCD.setColor(0, 255, 0); //colour1
  //myGLCD.setFont(SmallFont);
  myGLCD.setCursor(x-2, y-1);
  myGLCD.print("~");
  //myGLCD.setFont(BigFont);
  myGLCD.drawCircle(x, y, 7, colour1);

//SAS-Modus PROGRADE malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 80;
  //myGLCD.setColor(255, 255, 51); //colour2
  myGLCD.drawCircle(x, y, 7, colour2);
  myGLCD.drawPixel(x, y, colour2);
  myGLCD.drawLine(x-8, y, x-12, y, colour2);
  myGLCD.drawLine(x+8, y, x+12, y, colour2);

//SAS-Modus RETROGRADE malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 105;
  //myGLCD.setColor(255, 255, 51); //colour2
  myGLCD.drawCircle(x, y, 7, colour2);
  myGLCD.drawLine(x, y-12, x, y-8, colour2);
  myGLCD.drawLine(x+7, y+4, x+10, y+6, colour2);
  myGLCD.drawLine(x-7, y+4, x-10, y+6, colour2);
  myGLCD.drawLine(x-5, y+5, x+5, y-5, colour2);
  myGLCD.drawLine(x-5, y-5, x+5, y+5, colour2);

//SAS-Modus NORMAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 130;
  //myGLCD.setColor(255, 0, 255); //colour3
  myGLCD.drawLine(x-9, y+5, x+8, y+5, colour3);
  myGLCD.drawLine(x-9, y+5, x, y-9, colour3);
  myGLCD.drawLine(x, 121, x+8, y+5, colour3);
  myGLCD.drawPixel(x, y, colour3);
  
//SAS-Modus ANTINORMAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 155;
  //myGLCD.setColor(255, 0, 255); //colour3
  myGLCD.drawLine(x-9, y-5, x+8, y-5, colour3);
  myGLCD.drawLine(x-9, y-5, x, y+9, colour3);
  myGLCD.drawLine(x, y+9, x+8, y-5, colour3);
  myGLCD.drawPixel(x, y, colour3);
  myGLCD.drawLine(x, y-12, x, y-5, colour3);
  myGLCD.drawLine(x+5, y+2, x+10, y+6, colour3);
  myGLCD.drawLine(x-5, y+2, x-10, y+6, colour3);

//SAS-Modus RADIAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 180;
  //myGLCD.setColor(0, 255, 255); //colour4
  myGLCD.drawCircle(x, y, 7, colour4);
  myGLCD.drawLine(x-5, y+5, x+5, y-5, colour4);
  myGLCD.drawLine(x-5, y-5, x+5, y+5, colour4);
  //myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(x, y, 3, colour7);
  //myGLCD.setColor(0, 255, 255,);
  myGLCD.drawPixel(x, y, colour4);

//SAS-Modus ANTIRADIAL malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 205;
  //myGLCD.setColor(0, 255, 255); //colour4
  myGLCD.drawCircle(x, y, 7, colour4);
  myGLCD.drawLine(x-8, y+8, x+8, y-8, colour4);
  myGLCD.drawLine(x-8, y-8, x+8, y+8, colour4);
  //myGLCD.setColor(0, 0, 0);
  myGLCD.fillCircle(x, y, 6, colour7);
  //myGLCD.setColor(0, 255, 255);
  myGLCD.drawPixel(x, y, colour7);

//SAS-Modus TARGET malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 230;
  //myGLCD.setColor(255, 90, 255); //colour5
  myGLCD.drawCircle(x, y, 7, colour5);
  //myGLCD.setColor(0, 0, 0);
  myGLCD.fillRect(x-2, y-8, x+2, y+8, colour7);
  myGLCD.fillRect(x-8, y+2, x+8, y-2, colour7);
  //myGLCD.setColor(255, 90, 255);
  myGLCD.drawPixel(x, y, colour5);

//SAS-Modus ANTITARGET malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 255;
  //myGLCD.setColor(255, 90, 255); //colour5
  myGLCD.drawPixel(x, y, colour5);
  myGLCD.drawLine(x, y+9, x, y+7, colour5);
  myGLCD.drawLine(x+5, y-5, x+8, y-7, colour5);
  myGLCD.drawLine(x-5, y-5, x-8, y-7, colour5);

//SAS-Modus MANEUVER malen
//Das macht uns in Zukunft die Positionierung einfacher
//  x = 47;
  y = 280;
  //myGLCD.setColor(50, 50, 255); //colour6
  myGLCD.drawLine(x-4, y-8, x+4, y-8, colour6);
  myGLCD.drawLine(x-4, y+6, x-8, y, colour6);
  myGLCD.drawLine(x+4, y+6, x+8, y, colour6);
  myGLCD.drawLine(x, y-7, x, y-5, colour6);
  myGLCD.drawLine(x-6, y+3, x-3, y+1, colour6);
  myGLCD.drawLine(x+6, y+3, x+3, y+1, colour6);
  myGLCD.drawPixel(x, y-1, colour6);
}
void loop() {
  
}

draws the icons fine but with a big white rectangle over the bottom icons...

Photo here... http://s347.photobucket.com/user/gizzum1275/profile/

I have done a video of the test script from MCUFriend... 

 

The UNO has started to randomly reset itself.  I did have this running fine with Altitude messages and Apsides.  But it will now not even run with that... video here... 

Is this the same experience you had Benji? I gather this is due to the Uno not being man enough to receive and display at the same time??

Edited by Gizzum
wrong url
Link to comment
Share on other sites

40 minutes ago, Gizzum said:

The UNO has started to randomly reset itself.  I did have this running fine with Altitude messages and Apsides.  But it will now not even run with that... video here... 

Is this the same experience you had Benji? I gather this is due to the Uno not being man enough to receive and display at the same time??

Looks similar to what I experienced with KSPSerialIO. But unlike Simpit, SerialIO didn't reconnect.

I'm just guessing here, but it looks like printing TFT stuff isn't for 16 Mhz processors.

 

On the other hand, stibbons said this:

...

Glad it's working! The default RefreshRate parameter is 40ms, and it might be worth tuning that. Decreasing might result in less lag. But if your issue is how quickly the TFT can be refreshed, you might find that increasing the RefreshRate

It's probably worth pointing out that there's no ongoing handshake / synchronisation process in my protocol. The hardware can happily ignore/drop packets if it's not fast enough to process them all. That could easily result in display lag, but will not interrupt communications entirely.

...

 

So lag is to expected, but there shouldn't be disconnections. Assuming I understand all of this correctly. Why the uno resets, I don't know. Perhaps there is something in the logs.

 

Link to comment
Share on other sites

Yeah... played with the refresh rate and at 200 it still bins out.  I dont think the uno is man enough to do it all.  If i reduce the amount it displays then it takes a while longer before resetting.  May have to do seven segment displays for altitude and use the tft for something else...  Or can I just get a better Arduino?

Link to comment
Share on other sites

I just checked, if perhaps I'm getting disconnects with this new (1.1.3 Simpit) version, but it runs good.

 

You can switch to the DUE. That fixed it for me.

I ran into some problems but these were solvable. Mainly converting between 32bit and 16bit integers, and stuff like that. And Arduino IDE compiles way slower for the DUE, it's a bit annoying, but not really bad.

Link to comment
Share on other sites

Oh, and if you use potis and volt-meters you have to tune your code a bit, because the DUE works with 3.3V instead of 5V. digitalWrite(<something>, HIGH) gives you 3.3V. Inputs above will probably melt something.

And you need to change resistors for your LEDs.

Link to comment
Share on other sites

@stibbons, @Gizzum: Did a longer test, had a craft orbit kerbin, did nothing and had two Arduino resets.

The first reset after 4 minutes followed by this in the log:


[ERR 19:00:56.099] Exception handling event toSerial17 in class KSPSerialPort:System.TimeoutException: The operation has timed-out.
  at KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
  at KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data) [0x00000] in <filename unknown>:0 
  at EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1) [0x00000] in <filename unknown>:0 

[EXC 19:00:56.490] TimeoutException: The operation has timed-out.
	KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	(wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
	KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data)
	EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1)
	UnityEngine.Debug:LogException(Exception)
	EventData`2:Fire(Byte, Object)
	KerbalSimpit.Providers.KerbalSimpitResourceProvider:ElectricProvider()
	KerbalSimpit.<EventWorker>c__AnonStorey0:<>m__0()
	KerbalSimpit.KSPit:EventWorker()
[ERR 19:00:56.723] Exception handling event toSerial22 in class KSPSerialPort:System.TimeoutException: The operation has timed-out.
  at KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
  at KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data) [0x00000] in <filename unknown>:0 
  at EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1) [0x00000] in <filename unknown>:0 

[EXC 19:00:56.741] TimeoutException: The operation has timed-out.
	KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	(wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
	KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data)
	EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1)
	UnityEngine.Debug:LogException(Exception)
	EventData`2:Fire(Byte, Object)
	KerbalSimpit.Providers.KerbalSimpitTelemetryProvider:VelocityProvider()
	KerbalSimpit.<EventWorker>c__AnonStorey0:<>m__0()
	KerbalSimpit.KSPit:EventWorker()
[ERR 19:00:56.907] Exception handling event toSerial24 in class KSPSerialPort:System.TimeoutException: The operation has timed-out.
  at KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
  at KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data) [0x00000] in <filename unknown>:0 
  at EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1) [0x00000] in <filename unknown>:0 

[EXC 19:00:56.926] TimeoutException: The operation has timed-out.
	KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	(wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
	KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data)
	EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1)
	UnityEngine.Debug:LogException(Exception)
	EventData`2:Fire(Byte, Object)
	KerbalSimpit.Providers.KerbalSimpitTelemetryProvider:ApsidesTimeProvider()
	KerbalSimpit.<EventWorker>c__AnonStorey0:<>m__0()
	KerbalSimpit.KSPit:EventWorker()
[ERR 19:00:57.842] Exception handling event toSerial9 in class KSPSerialPort:System.TimeoutException: The operation has timed-out.
  at KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
  at KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data) [0x00000] in <filename unknown>:0 
  at EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1) [0x00000] in <filename unknown>:0 

[EXC 19:00:57.849] TimeoutException: The operation has timed-out.
	KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	(wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
	KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data)
	EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1)
	UnityEngine.Debug:LogException(Exception)
	EventData`2:Fire(Byte, Object)
	KerbalSimpit.Providers.KerbalSimpitTelemetryProvider:ApsidesProvider()
	KerbalSimpit.<EventWorker>c__AnonStorey0:<>m__0()
	KerbalSimpit.KSPit:EventWorker()
[ERR 19:00:58.030] Exception handling event toSerial17 in class KSPSerialPort:System.TimeoutException: The operation has timed-out.
  at KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
  at KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data) [0x00000] in <filename unknown>:0 
  at EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1) [0x00000] in <filename unknown>:0 

[EXC 19:00:58.037] TimeoutException: The operation has timed-out.
	KerbalSimpit.IO.Ports.WinSerialStream.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	KerbalSimpit.IO.Ports.SerialPort.Write (System.Byte[] buffer, Int32 offset, Int32 count)
	(wrapper remoting-invoke-with-check) KerbalSimpit.IO.Ports.SerialPort:Write (byte[],int,int)
	KerbalSimpit.Serial.KSPSerialPort.sendPacket (Byte Type, System.Object Data)
	EventData`2[System.Byte,System.Object].Fire (Byte data0, System.Object data1)
	UnityEngine.Debug:LogException(Exception)
	EventData`2:Fire(Byte, Object)
	KerbalSimpit.Providers.KerbalSimpitResourceProvider:ElectricProvider()
	KerbalSimpit.<EventWorker>c__AnonStorey0:<>m__0()
	KerbalSimpit.KSPit:EventWorker()

After a minute or two the Arduino got messages again and showed all values (apo, alt, peri, times to apo and peri) correctly, but the log is still spammed with these messages.

At around 19:16... I had another reset but this time the arduino waited for a connection for 5 minutes, changing scenes didn't help the ppor guy. Then I switched of.

At the end of the log, it's mostly toSerial17, toSerial8, toSerial24 and toSerial9 . But in some odd variations. two times 17 then 1 time 8, 3 times 9, two times 17, and so on.

 

At the end, when the Arduino claimed to wait for a connection, the log got some of these entries: [LOG 19:16:06.739] KerbalSimpit: SYN received on port COM4. Replying.    - about every half second.

Edited by Benji
Link to comment
Share on other sites

OK, now that I'm actually awake and looking at those exceptions properly...

I'm able to reproduce it with a sketch that subscribes to half a dozen channels, and it happens on all three operating systems. Current theory is that it's happening because I've gotten careless and multiple threads are trying to write to the port. Will straighten that out and see how it goes.

Link to comment
Share on other sites

Version 1.2.1 of the plugin is uploaded and should be available soon.

Changes:

  • Serial port wrapper now buffers to an internal queue. This prevents multiple threads from writing to the serial port, which looks to me like the root cause of the TimeoutExceptions that the plugin was throwing with several channels registered. My test setup runs for around an hour without logging any exceptions.
  • I've increased the default RefreshRate in the sample config file to 125. Don't yet have a root cause for why Arduino boards occasionally reset running code that uses my KerbalSimpit library, but I'm hoping the slower refresh rate will help.

I've been testing this release with a small setup consisting of an I2C LCD connected to an Arduino Mega. The Mega subscribes to six channels, and displays an altitude readout on the screen. Somewhere around the one hour mark it seems to be resetting, sending another sync request, and a little while after that the display stops updating. My current theory is memory leaks in the Arduino library, but I'd need to poke at it a fair bit more to figure out what's going on.

1 hour ago, monstah said:

Oh man, where did the last two weeks go?

I don't know, but I'm impressed that you managed to once again appear just as I was committing code for this. :D

 

Link to comment
Share on other sites

I got a mock up to work with Win 7 and a Due, just sending some simple telemetry. Coming from KSPSerialIO, the code structure takes a little change of mindset, but this shows a lot of promise. I consider rebuilding my controller (again), using WS2812 led strips instead of MAX7219 for annuciators and make a matrix keypad that will be used both for the plugin and the Due keyboard library instead of having an old keyboard IC mounted for commands that does not go through the plugin. I will probably do this in stages, and I just agreed taking a few weeks of on a trip with my family, so it can take a while before I get around to bother you with questions and requests.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...