1 /* HT680 Remote control
3 * Copyright (C) 2016 Igor Polovnikov
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
11 static int ht680_callback(bitbuffer_t *bitbuffer) {
12 bitrow_t *bb = bitbuffer->bb;
15 for (uint8_t row = 0;row < bitbuffer->num_rows;row++){
17 if(bitbuffer->bits_per_row[row] == 40 && //Length of packet is 40
18 (b[0] & 0x50) == 0x50 && //Sync mask 01010000
19 (b[1] & 0x0A) == 0x0A && //Address always mask 00001010
20 (b[3] & 0x82) == 0x82 && //Buttons(4,3) always mask 10000010
21 (b[4] & 0x0A) == 0x0A){ //Buttons(2,1) always mask 00001010
22 b[0] = b[0] & 0x0F; //Clear sync
27 for(uint8_t byte = 0; byte < 5; byte++){
28 for(int8_t bit = 7; bit > 0; bit -= 2){
29 switch ((b[byte] >> (bit-1)) & 0x03){
30 case 0x00: *p++ = '0'; break;
31 case 0x01: *p++ = '?'; break; //Invalid code 01
32 case 0x02: *p++ = 'Z'; break; //Floating state Z is 10
33 case 0x03: *p++ = '1'; break;
34 default: *p++ = '!'; break; //Unknown error
40 data = data_make("model", "", DATA_STRING, "HT680 Remote control",
41 "tristate","Tristate code",DATA_STRING, tristate,
42 "address", "Address", DATA_FORMAT, "0x%06X", DATA_INT, (b[0]<<16)+(b[1]<<8)+b[2],
43 "button1", "Button 1", DATA_STRING, (((b[4]>>4) & 0x03) == 3) ? "PRESSED" : "",
44 "button2", "Button 2", DATA_STRING, (((b[4]>>6) & 0x03) == 3) ? "PRESSED" : "",
45 "button3", "Button 3", DATA_STRING, ((((b[3]&0x7D)>>2) & 0x03) == 3) ? "PRESSED" : "",
46 "button4", "Button 4", DATA_STRING, ((((b[3]&0x7D)>>4) & 0x03) == 3) ? "PRESSED" : "",
48 data_acquired_handler(data);
56 static char *output_fields[] = {
69 .name = "HT680 Remote control",
70 .modulation = OOK_PULSE_PWM_RAW,
74 .json_callback = &ht680_callback,