ok. so this function under the output section.
void controls() {
if (Connected) {
if (digitalRead(SASPIN)) { //--------- This is how you do main controls
MainControls(SAS, HIGH);
setSASMode(SMSAS); //setting SAS mode
//setNavballMode(NAVBallSURFACE); //setting navball mode
}
else {
//setNavballMode(NAVBallTARGET);
MainControls(SAS, LOW);
}
if (digitalRead(RCSPIN))
MainControls(RCS, HIGH);
else
MainControls(RCS, LOW);
if (digitalRead(CG1PIN)) //--------- This is how you do control groups
ControlGroups(1, HIGH);
else
ControlGroups(1, LOW);
/*
if (getSASMode() == SMPrograde) { //--------- This is how you read SAS modes
//Blink LED, do stuff, etc.
}
if (getNavballMode() == NAVBallTARGET) { //--------- This is how you read navball modes
//Blink LED, do stuff, etc.
}
*/
//This is an example of reading analog inputs to an axis, with deadband and limits
CPacket.Throttle = constrain(map(analogRead(THROTTLEPIN), THROTTLEDB, 1024 - THROTTLEDB, 0, 1000), 0, 1000);
//This is an example of reading analog inputs to an axis, with deadband and limits
//CPacket.Pitch = constrain(map(analogRead(THROTTLEPIN),0,1024,-1000,1000),-1000, 1000);
KSPBoardSendData(details(CPacket));
}
}
Where it calls 'if digitalread rcspin'
that means :
if the digital pin defined as 'whateverpin' is connected to ground (button pressed), the do the following
make 'whatevercommand' have a 1 as its bit
else
make 'whatevercommand' have a 0 as its bit
and then the "maincontrols" function enforces that its binary and not some analog value, and ads it to the packet.
Have I got that right? so each button press command you want to send thru serialio follows that syntax?