package eu.worn.apps.androvac; import android.content.SharedPreferences; import java.util.Calendar; class RoboVac11sRemote { private SharedPreferences preferences; final IRModulation modulation = new EufyIRModulation(); private boolean scheduleEnabled; private int scheduleHour; private int scheduleMinute; 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] = (byte) (scheduleEnabled ? (scheduleHour * 4 + scheduleMinute / 15) : 0xff); msg[5] = (byte) (msg[0] + msg[1] + msg[2] + msg[3] + msg[4]); return msg; } RoboVac11sRemote(SharedPreferences pref) { preferences = pref; scheduleHour = preferences.getInt("scheduleHour", 0); scheduleMinute = preferences.getInt("scheduleMinute", 0); scheduleEnabled = preferences.getBoolean("scheduleEnabled", false); } private void storeSchedule() { SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("scheduleEnabled", scheduleEnabled); editor.putInt("scheduleHour", scheduleHour); editor.putInt("scheduleMinute", scheduleMinute); editor.commit(); } public boolean isScheduleEnabled() { return scheduleEnabled; } public int getScheduleHour() { return scheduleHour; } public int getScheduleMinute() { return scheduleMinute; } public byte[] setSchedule(int hour, int minute) { scheduleHour = hour; scheduleMinute = minute; scheduleEnabled = true; storeSchedule(); return buildMessage((byte) 0xcf); } public byte[] clearSchedule() { scheduleEnabled = false; 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); } }