Jump to content

Oscar_Mike

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Oscar_Mike

  1. Ok - tried the latest library (I think) and it's still happening. Will do some more digging around - I know the 2812 needs pretty accurate timing, so i wonder if there's something crashing on a timer etc. Might try off-boarding the displays to another arduino through wire and see if that helps! edit - tried running the LEDs from an encoder chip through i2c, same dealio.
  2. Ok - tried the latest library (I think) and it's still happening. Will do some more digging around - I know the 2812 needs pretty accurate timing, so i wonder if there's something crashing on a timer etc. Might try off-boarding the displays to another arduino through wire and see if that helps!
  3. I've just started initial forays into the world of a Kerbal SimPit, and I'm quite excited by it all, especially after finding that the previous serialIO plugin was no longer supported, but that this one was in development - hurrah! I've poked around with arduinos before, but nothing of any great significance, and I suspect that is where I'm coming unstuck. I've hooked up a small OLED panel to display the altitude and apsides messages, and an 2812 LED bar to show the state of the action groups. Either on their own work fine, but if i have them both enabled then the arduino crashes, restarts, and never quite connects properly again. My first thought was a memory issue, but it seems to have enough spare. Second thought was a conflict between the OLED and the LED, but running them both on a separate sketch with no simpit seems to work, even with a serial write function. Code is as follows: #include <KerbalSimpit.h> #include <Adafruit_NeoPixel.h> #include <Adafruit_SSD1306.h> #define OLED_RESET 4 Adafruit_SSD1306 display(OLED_RESET); #if (SSD1306_LCDHEIGHT != 64) #error("Height incorrect, please fix Adafruit_SSD1306.h!"); #endif #define LEDPIN 6 Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, LEDPIN, NEO_GRB + NEO_KHZ800); int XPin = A0; int YPin = A1; int XValue = 0; int YValue = 0; int XGame, YGame; int displayAltitude; long displayApsides; KerbalSimpit mySimpit(Serial); void setup() { strip.begin(); strip.show(); display.begin(SSD1306_SWITCHCAPVCC, 0x3c); Serial.begin(115200); display.clearDisplay(); display.setTextSize(2); display.setTextColor(WHITE); display.setCursor(0,0); display.println(" Load "); display.println(" Kerbal"); display.display(); delay(1000); while (!mySimpit.init()) { display.setCursor(0,0); display.println("Connecting"); display.display(); } display.setCursor(0,0); display.clearDisplay(); display.println("Initialised"); display.display(); delay(1000); mySimpit.inboundHandler(messageHandler); mySimpit.registerChannel(ALTITUDE_MESSAGE); mySimpit.registerChannel(APSIDES_MESSAGE); mySimpit.registerChannel(ACTIONSTATUS_MESSAGE); } void loop() { XValue = analogRead(XPin); YValue = analogRead(YPin); XGame = map(XValue,0,680,-32000,32000); YGame = map(YValue,0,680,32000,-32000); rotationMessage rotationMsg; rotationMsg.mask=1|2|4; rotationMsg.yaw=XGame; rotationMsg.pitch=YGame; rotationMsg.roll=0; mySimpit.send(ROTATION_MESSAGE,rotationMsg); mySimpit.update(); updateDisplay(); } void messageHandler(byte messageType, byte message[], byte messageSize) { clearpixels(); switch(messageType) { case ALTITUDE_MESSAGE: if (messageSize == sizeof(altitudeMessage)) { altitudeMessage myAltitude; myAltitude = parseAltitude(message); displayAltitude = myAltitude.sealevel; } break; case APSIDES_MESSAGE: if (messageSize == sizeof(apsidesMessage)) { apsidesMessage myApsides; myApsides = parseApsides(message); displayApsides = myApsides.apoapsis; } break; case ACTIONSTATUS_MESSAGE: byte testip = message[0]; //Test action groups if(testip & ABORT_ACTION) { strip.setPixelColor(6,50,50,50); } if(testip & BRAKES_ACTION) { strip.setPixelColor(5,0,50,50); } if(testip & SAS_ACTION) { strip.setPixelColor(4,50,0,50); } if(testip & RCS_ACTION) { strip.setPixelColor(3,50,50,0); } if(testip & LIGHT_ACTION) { strip.setPixelColor(2,0,0,50); } if(testip & GEAR_ACTION) { strip.setPixelColor(1,0,50,0); } if(testip & STAGE_ACTION) { strip.setPixelColor(0,50,0,0); } strip.show(); break; } } void clearpixels(){ for (int i = 0 ; i < 16; i++){ strip.setPixelColor(i,0,0,0); } } void updateDisplay(){ display.clearDisplay(); display.setCursor(0,0); display.print("Alt: "); display.println(displayAltitude); display.print("Aps: "); display.println(displayApsides); display.print("RAM: "); display.println(freeRam()); display.display(); } int freeRam () { extern int __heap_start, *__brkval; int v; return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval); } Can anyone see something blindingly obvious that I'm doing stupidly (or rather, that would cause problems, no doubt there's lots of stupid stuff in there). Similarly if there is a better place to post queries please just shout TIA!
×
×
  • Create New...