Jump to content

TygurDuck

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by TygurDuck

  1. I do not get how to access the resourceMessage struct. I want to see my total and available LF (all really, but lets start with that.) Although I follow the example of altitude its just not doing anything. Code below. Lots of stuff wrong, I am sure. All I really need is to see how to access the resource information. Do I have to use Altnerate Resource Panel for it to work at all? #include <KerbalSimpit.h> KerbalSimpit mySimpit(Serial); int DS_pin = 11; int STCP_pin = 8; int SHCP_pin = 12; boolean registers[10]; void setup() { // put your setup code here, to run once: Serial.begin(115200); pinMode(DS_pin,OUTPUT); pinMode(STCP_pin,OUTPUT); pinMode(SHCP_pin,OUTPUT); pinMode(LED_BUILTIN,OUTPUT); //digitalWrite(LED_BUILTIN,HIGH); for(int i = 0; i<10; i++) { registers = LOW; writereg(); } while(!mySimpit.init()); { digitalWrite(LED_BUILTIN,HIGH); delay(100); digitalWrite(LED_BUILTIN,LOW); } digitalWrite(LED_BUILTIN,HIGH); mySimpit.inboundHandler(messageHandler); mySimpit.registerChannel(LF_MESSAGE); //mySimpit.registerChannel(ALTITUDE_MESSAGE); } void writereg() { digitalWrite(STCP_pin, LOW); for(int i = 9; i>=0; i--) { digitalWrite(SHCP_pin, LOW); digitalWrite(DS_pin, registers); digitalWrite(SHCP_pin, HIGH); } digitalWrite(STCP_pin, HIGH); } void loop() { // put your main code here, to run repeatedly: mySimpit.update(); } void messageHandler(byte messageType, byte msg[], byte msgSize) { if (msgSize == sizeof(resourceMessage)) { resourceMessage myLF; myLF = parseResource(msg); //float percentLF = myLF.available / myLF.total; if (myLF.available < 10) { digitalWrite(LED_BUILTIN,LOW); delay(100); digitalWrite(LED_BUILTIN,HIGH); delay(100); digitalWrite(LED_BUILTIN,LOW); delay(100); digitalWrite(LED_BUILTIN,HIGH); delay(100); digitalWrite(LED_BUILTIN,LOW); delay(100); digitalWrite(LED_BUILTIN,HIGH); delay(100); digitalWrite(LED_BUILTIN,LOW); delay(100); digitalWrite(LED_BUILTIN,HIGH); delay(300); digitalWrite(LED_BUILTIN,LOW); delay(300); digitalWrite(LED_BUILTIN,HIGH); delay(300); digitalWrite(LED_BUILTIN,LOW); delay(300); digitalWrite(LED_BUILTIN,HIGH); delay(300); digitalWrite(LED_BUILTIN,LOW); delay(300); digitalWrite(LED_BUILTIN,HIGH); delay(100); digitalWrite(LED_BUILTIN,LOW); delay(100); digitalWrite(LED_BUILTIN,HIGH); delay(100); digitalWrite(LED_BUILTIN,LOW); delay(100); digitalWrite(LED_BUILTIN,HIGH); delay(100); digitalWrite(LED_BUILTIN,LOW); delay(100); } } }
×
×
  • Create New...