EloiStree / OpenMacroInput

When keyboard is not enough !!!
4 stars 1 forks source link

.portnomenclature #52

Open EloiStree opened 3 years ago

EloiStree commented 3 years ago

(This post is under construction and is hard to understand until it is done. But this is very useful. Keep it up and you will enjoy the tool)


Open Macro Input is about allowing actions based on open input ways... So Arduino, or else, is a must.

This file extension is my way of doing it.

This file extension allow you to define a serial port to listen. (Serial port can be USB or Bluetooth on Window)

The requirement is that your Arduino communication through port in a specific way.

For Example:

#01010|2492\n

Format:

#Digial Inputs from 0-1|Analogic Inputs from 0-9
#01234|0123\n

The example is saying:

Note: we are talking about index and not "pin". My aim is to have abstraction between hardware and software. For example:

Note: why is it compressed ? Bluetooth and USB has a bandwidth that can be small. The impacts of none compress data:

For example, here is what I use with my "four buttons foot board"

Send by the Arduino #0000|

Translation in the OMI software

<?xml version="1.0" encoding="utf-8"?>
<AnalogDigitalCompressConfig>
  <PortConnections>
    <PortConnection portId="20" patternName="Footboard" />
  </PortConnections>
  <AnalogDigitalCompressPatterns>
     <AnalogDigitalCompressPattern name="Footboard" docUrl="">
      <digit index="0" label="FootRD" />
      <digit index="1" label= "FootLT" />
      <digit index="2" label= "FootRT" />
      <digit index="3" label= "FootLD" />
    </AnalogDigitalCompressPattern>
  </AnalogDigitalCompressPatterns>
</AnalogDigitalCompressConfig>

The code will register the serial port number 20 and convert the index 0-3 to boolean named FootRD-FootLT that you can use as easy as other input like keyboard.

Basic example of what it can look like on Arduino in quick code version:


 int buttonCount =4;
 int buttonPin[] = {33,35,37,39}   ;

void setup() {
  Serial.begin(9600);
  for(int i=0; i< buttonCount;i++){
      pinMode(buttonPin[i], INPUT_PULLUP);
  }
}

void loop() {
  Serial.println("");
  Serial.print("#"); 
  for(int i=0; i< buttonCount;i++){
    int v= digitalRead(buttonPin[i]);
    Serial.print( v==0?"1":"0");
  }
  Serial.print("|");
  delay(10);
}