Android Open Source - lamp Default Bluetooth Lamp






From Project

Back to project page lamp.

License

The source code is released under:

GNU General Public License

If you think the Android project lamp 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

/**    Copyright (C) 2013 Marek Sebera <marek@msebera.cz>
 *//from   w w w. ja  v  a2  s  .com
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 * 
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * */
package cz.tomsuch.lampicka.impl;

import android.graphics.Color;
import cz.tomsuch.lampicka.enums.BluetoothLampBacklightMode;
import cz.tomsuch.lampicka.enums.BluetoothLampCommand;
import cz.tomsuch.lampicka.enums.BluetoothLampEffect;
import cz.tomsuch.lampicka.interfaces.BluetoothLamp;
import cz.tomsuch.lampicka.interfaces.BluetoothLampCommandListener;

/**
 * Implementation of BluetoothLamp interface
 * 
 * @author Marek Sebera <marek@msebera.cz>
 * */
public class DefaultBluetoothLamp implements BluetoothLamp {

  /**
   * Interface (listener) for controller
   * */
  private BluetoothLampCommandListener listener;

  /**
   * Constructor
   * 
   * @param listener
   *            must not be null
   * */
  public DefaultBluetoothLamp(BluetoothLampCommandListener listener) {
    assert (listener != null);
    this.listener = listener;
  }

  @Override
  public void setBacklightEffect(BluetoothLampBacklightMode effect) {
    listener.sendData(String.format("%s %s",
        BluetoothLampCommand.ACTION_BACKLIGHT_SET_EFFECT,
        effect.toString()));
  }

  @Override
  public void getLampId() {
    listener.sendData(BluetoothLampCommand.ACTION_GET_LAMP_ID);
  }

  @Override
  public void getLampInfo() {
    listener.sendData(BluetoothLampCommand.ACTION_GET_LAMP_INFO);
  }

  @Override
  public void setEffect(BluetoothLampEffect effect) {
    listener.sendData(String.format("%s %s",
        BluetoothLampCommand.ACTION_SET_EFFECT, effect));
  }

  @Override
  public void setColorWithCrossFade(int red, int green, int blue) {
    listener.sendData(String.format("%s %d %d %d",
        BluetoothLampCommand.ACTION_SET_COLOR_WITH_CROSS_FADE, red,
        green, blue));
  }

  @Override
  public void setColorWithCrossFade(int color) {
    setColorWithCrossFade(Color.red(color), Color.green(color),
        Color.blue(color));
  }

  @Override
  public void setColorHard(int red, int green, int blue) {
    listener.sendData(String.format("%s %d %d %d",
        BluetoothLampCommand.ACTION_SET_COLOR_HARD, red, green, blue));
  }

  @Override
  public void setColorHard(int color) {
    setColorHard(Color.red(color), Color.green(color), Color.blue(color));
  }

  @Override
  public void getLampVersion() {
    listener.sendData(BluetoothLampCommand.ACTION_GET_LAMP_VERSION);
  }

  @Override
  public void getLampSerial() {
    listener.sendData(BluetoothLampCommand.ACTION_GET_LAMP_SERIAL_NUMBER);
  }

  @Override
  public void getCurrentSettings() {
    listener.sendData(BluetoothLampCommand.ACTION_GET_LAMP_CURRENT_SETTINGS);
  }

  @Override
  public void setColorIntensity(int intensity) {
    listener.sendData(String.format("%s %d",
        BluetoothLampCommand.ACTION_SET_COLOR_INTENSITY, intensity));
  }

}




Java Source Code List

cz.tomsuch.lampicka.AppController.java
cz.tomsuch.lampicka.abstracts.CustomSeekBar.java
cz.tomsuch.lampicka.activities.LampActivity.java
cz.tomsuch.lampicka.activities.LampsActivity.java
cz.tomsuch.lampicka.adapters.BluetoothDevicesAdapter.java
cz.tomsuch.lampicka.enums.BluetoothLampBacklightMode.java
cz.tomsuch.lampicka.enums.BluetoothLampColorSetMode.java
cz.tomsuch.lampicka.enums.BluetoothLampCommand.java
cz.tomsuch.lampicka.enums.BluetoothLampEffect.java
cz.tomsuch.lampicka.impl.DefaultBluetoothLamp.java
cz.tomsuch.lampicka.interfaces.BluetoothInputLineListener.java
cz.tomsuch.lampicka.interfaces.BluetoothLampCommandListener.java
cz.tomsuch.lampicka.interfaces.BluetoothLamp.java
cz.tomsuch.lampicka.interfaces.OnColorChangedListener.java
cz.tomsuch.lampicka.interfaces.PalleteDialogColorListener.java
cz.tomsuch.lampicka.pallete.ColorChooserDialog.java
cz.tomsuch.lampicka.pallete.PalleteDialog.java
cz.tomsuch.lampicka.util.BluetoothDeviceComparator.java
cz.tomsuch.lampicka.util.BluetoothDeviceWrapper.java
cz.tomsuch.lampicka.util.BluetoothSocketListener.java
cz.tomsuch.lampicka.util.ColorPickerView.java
cz.tomsuch.lampicka.util.FixedBluetoothSocket.java
cz.tomsuch.lampicka.util.HorizontalSeekBar.java
cz.tomsuch.lampicka.util.Preferences.java
cz.tomsuch.lampicka.util.VerticalSeekBar.java