Android Open Source - HexNanoController_Android Channel






From Project

Back to project page HexNanoController_Android.

License

The source code is released under:

Code license GNU GPL v2 http://www.gnu.org/licenses/gpl.html Content license CC BY-NC-SA 4.0 http://creativecommons.org/licenses/by-nc-sa/4.0/

If you think the Android project HexNanoController_Android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.hexairbot.hexmini.modal;
//  w w w.j a  v  a2  s. c o  m
import com.dd.plist.NSArray;
import com.dd.plist.NSDictionary;
import com.dd.plist.NSNumber;
import com.dd.plist.NSString;

public class Channel {
  public final static String CHANNEL_NAME_AILERON  = "Aileron";
  public final static String CHANNEL_NAME_ELEVATOR = "Elevator";
  public final static String CHANNEL_NAME_RUDDER   = "Rudder";
  public final static String CHANNEL_NAME_THROTTLE = "Throttle";
  public final static String CHANNEL_NAME_AUX1     = "AUX1";
  public final static String CHANNEL_NAME_AUX2     = "AUX2";
  public final static String CHANNEL_NAME_AUX3     = "AUX3";
  public final static String CHANNEL_NAME_AUX4     = "AUX4";
  
  public final static String NAME                    = "Name";
  public final static String IS_REVERSED             = "IsReversed";
  public final static String TRIM_VALUE              = "TrimValue";
  public final static String OUTPUT_ADJUSTABLE_RANGE = "OutputAdjustableRange";
  public final static String DEFAULT_OUTPUT_VALUE    = "DefaultOutputValue";

  private NSDictionary data;
  private int idx;
  private String name;
  private float value;
  private float defaultOutputValue;
  private float outputAdjustabledRange;
  private float trimValue;
  private boolean isReversed;
  private ApplicationSettings ownerSettings;
  
  public Channel(ApplicationSettings settings, int idx){
    ownerSettings = settings;
    this.idx = idx;
    NSArray channels = (NSArray)settings.getData().objectForKey(ApplicationSettings.CHANNELS);
    data = (NSDictionary)channels.objectAtIndex(idx);
    
    name       = ((NSString)data.objectForKey(NAME)).getContent();
    isReversed = ((NSNumber)data.objectForKey(IS_REVERSED)).boolValue();
    trimValue  = ((NSNumber)data.objectForKey(TRIM_VALUE)).floatValue();
    outputAdjustabledRange = ((NSNumber)data.objectForKey(OUTPUT_ADJUSTABLE_RANGE)).floatValue();
    defaultOutputValue =  ((NSNumber)data.objectForKey(DEFAULT_OUTPUT_VALUE)).floatValue();
  }
  
  float clip(float value, float min, float max) {
    if(value>max)
      return max;
    if(value<min)
      return min;
    return value;
  }
  
  public int getIdx() {
    return idx;
  }
  
  public void setIdx(int idx){
    this.idx = idx;
  }

  public String getName() {
    return name;
  }
  

  public float getValue() {
    return value;
  }

  public void setValue(float value) {    
    this.value = clip(value, -1.0f, 1.0f);
    float outputValue = clip(value + trimValue, -1.0f, 1.0f); 
    if (isReversed) {
      outputValue = -outputValue;
    }
      
    outputValue *= outputAdjustabledRange;
      
    Transmitter.sharedTransmitter().setChannel(idx, outputValue);
    
  }

  public float getDefaultOutputValue() {
    return defaultOutputValue;
  }

  public void setDefaultOutputValue(float defaultOutputValue) {
    this.defaultOutputValue = defaultOutputValue;
    data.put(DEFAULT_OUTPUT_VALUE, defaultOutputValue);
  }

  public float getOutputAdjustabledRange() {
    return outputAdjustabledRange;
  }

  public void setOutputAdjustabledRange(float outputAdjustabledRange) {
    this.outputAdjustabledRange = outputAdjustabledRange;
    data.put(OUTPUT_ADJUSTABLE_RANGE, outputAdjustabledRange);
  }

  public float getTrimValue() {
    return trimValue;
  }

  public void setTrimValue(float trimValue) {
    this.trimValue = trimValue;
    data.put(TRIM_VALUE, trimValue);
  }

  public boolean isReversed() {
    return isReversed;
  }

  public void setReversed(boolean isReversed) {
    this.isReversed = isReversed;
    data.put(IS_REVERSED, isReversed);
  }

  public ApplicationSettings getOwnerSettings() {
    return ownerSettings;
  }

  public void setOwnerSettings(ApplicationSettings ownerSettings) {
    this.ownerSettings = ownerSettings;
  }
}




Java Source Code List

.FileHelper.java
.Input.java
.Output.java
.Serializable.java
com.hexairbot.hexmini.HelpActivity.java
com.hexairbot.hexmini.HexMiniApplication.java
com.hexairbot.hexmini.HudActivity.java
com.hexairbot.hexmini.HudViewControllerDelegate.java
com.hexairbot.hexmini.HudViewController.java
com.hexairbot.hexmini.SettingsDialogDelegate.java
com.hexairbot.hexmini.SettingsDialog.java
com.hexairbot.hexmini.SettingsViewControllerDelegate.java
com.hexairbot.hexmini.SettingsViewController.java
com.hexairbot.hexmini.ViewController.java
com.hexairbot.hexmini.adapter.SettingsViewAdapter.java
com.hexairbot.hexmini.ble.BleConnectinManagerDelegate.java
com.hexairbot.hexmini.ble.BleConnectinManager.java
com.hexairbot.hexmini.ble.BluetoothLeService.java
com.hexairbot.hexmini.gestures.EnhancedGestureDetector.java
com.hexairbot.hexmini.modal.ApplicationSettings.java
com.hexairbot.hexmini.modal.Channel.java
com.hexairbot.hexmini.modal.OSDCommon.java
com.hexairbot.hexmini.modal.Transmitter.java
com.hexairbot.hexmini.sensors.DeviceOrientationChangeDelegate.java
com.hexairbot.hexmini.sensors.DeviceOrientationManager.java
com.hexairbot.hexmini.sensors.DeviceSensorManagerWrapper.java
com.hexairbot.hexmini.sensors.SensorManagerWrapper.java
com.hexairbot.hexmini.services.ConnectStateManager.java
com.hexairbot.hexmini.services.IpcControlService.java
com.hexairbot.hexmini.services.IpcProxy.java
com.hexairbot.hexmini.services.NavData.java
com.hexairbot.hexmini.services.OnIpcConnectChangedListener.java
com.hexairbot.hexmini.services.VIConfig.java
com.hexairbot.hexmini.ui.Button.java
com.hexairbot.hexmini.ui.Image.java
com.hexairbot.hexmini.ui.Indicator.java
com.hexairbot.hexmini.ui.Sprite.java
com.hexairbot.hexmini.ui.Text.java
com.hexairbot.hexmini.ui.ToggleButton.java
com.hexairbot.hexmini.ui.UIRenderer.java
com.hexairbot.hexmini.ui.control.CustomSeekBar.java
com.hexairbot.hexmini.ui.control.ViewPagerIndicator.java
com.hexairbot.hexmini.ui.gl.GLSprite.java
com.hexairbot.hexmini.ui.joystick.AcceleratorJoystick.java
com.hexairbot.hexmini.ui.joystick.AnalogueJoystick.java
com.hexairbot.hexmini.ui.joystick.JoystickBase.java
com.hexairbot.hexmini.ui.joystick.JoystickFactory.java
com.hexairbot.hexmini.ui.joystick.JoystickListener.java
com.hexairbot.hexmini.util.DebugHandler.java
com.hexairbot.hexmini.util.FontUtils.java
com.hexairbot.hexmini.util.SystemUiHiderBase.java
com.hexairbot.hexmini.util.SystemUiHiderHoneycomb.java
com.hexairbot.hexmini.util.SystemUiHider.java
com.hexairbot.hexmini.util.SystemUtil.java
com.hexairbot.hexmini.util.TextureUtils.java
fix.android.opengl.GLES20.java