85 lines
2.5 KiB
Java
85 lines
2.5 KiB
Java
package eu.worn.apps.androvac;
|
|
|
|
import android.content.SharedPreferences;
|
|
|
|
import java.util.Calendar;
|
|
|
|
class RoboVac11sRemote {
|
|
private SharedPreferences preferences;
|
|
|
|
final IRModulation modulation = new EufyIRModulation();
|
|
|
|
private byte schedule = (byte) 0xff;
|
|
|
|
private byte[] buildMessage(byte command) {
|
|
byte msg[] = new byte[6];
|
|
Calendar now = Calendar.getInstance();
|
|
|
|
msg[0] = (byte) 0x68;
|
|
msg[1] = command;
|
|
msg[2] = (byte) now.get(Calendar.HOUR_OF_DAY);
|
|
msg[3] = (byte) now.get(Calendar.MINUTE);
|
|
msg[4] = schedule;
|
|
msg[5] = (byte) (msg[0] + msg[1] + msg[2] + msg[3] + msg[4]);
|
|
|
|
return msg;
|
|
}
|
|
|
|
RoboVac11sRemote(SharedPreferences pref) {
|
|
preferences = pref;
|
|
schedule = (byte) preferences.getInt("schedule", 0xff);
|
|
}
|
|
|
|
private void storeSchedule() {
|
|
SharedPreferences.Editor editor = preferences.edit();
|
|
editor.putInt("schedule", schedule);
|
|
editor.commit();
|
|
}
|
|
|
|
public int getScheduleHour() {
|
|
if (schedule == 0xff)
|
|
return -1;
|
|
else
|
|
return schedule / 4;
|
|
}
|
|
|
|
public int getScheduleMinute() {
|
|
if (schedule == 0xff)
|
|
return -1;
|
|
else
|
|
return (schedule % 4) * 15;
|
|
}
|
|
|
|
public byte[] setSchedule(int hour, int minute) {
|
|
schedule = (byte) (hour * 4 + minute / 15);
|
|
storeSchedule();
|
|
return buildMessage((byte) 0xcf);
|
|
}
|
|
|
|
public byte[] clearSchedule() {
|
|
schedule = (byte) 0xff;
|
|
storeSchedule();
|
|
return buildMessage((byte) 0xdf);
|
|
}
|
|
|
|
byte[] setTime() { return buildMessage((byte) 0xbf); }
|
|
|
|
byte[] cleanAuto() { return buildMessage((byte) 0x5d); }
|
|
byte[] cleanSpot() { return buildMessage((byte) 0x8c); }
|
|
byte[] cleanEdge() { return buildMessage((byte) 0x9c); }
|
|
byte[] cleanRoom() { return buildMessage((byte) 0xad); }
|
|
|
|
byte[] powerStandard() { return buildMessage((byte) 0x1e); }
|
|
byte[] powerMax() { return buildMessage((byte) 0x1c); }
|
|
byte[] powerBoostIQ() { return buildMessage((byte) 0x1d); }
|
|
|
|
byte[] moveForward() { return buildMessage((byte) 0x2f); }
|
|
byte[] moveBackward() { return buildMessage((byte) 0x7f); }
|
|
byte[] moveCCW() { return buildMessage((byte) 0x3f); }
|
|
byte[] moveCW() { return buildMessage((byte) 0x6f); }
|
|
byte[] returnBase() { return buildMessage((byte) 0xef); }
|
|
|
|
byte[] stop() { return buildMessage((byte) 0x4f); }
|
|
|
|
}
|