Update message ids and read disp-mode on startup
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
This commit is contained in:
parent
fd4ba21a0a
commit
9e7d897f74
2 changed files with 28 additions and 2 deletions
|
@ -34,8 +34,10 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define DEVICE4_MSG_R_BRIGHTNESS 0x03
|
#define DEVICE4_MSG_R_BRIGHTNESS 0x03
|
||||||
|
#define DEVICE4_MSG_W_BRIGHTNESS 0x04
|
||||||
|
#define DEVICE4_MSG_R_DISP_MODE 0x07
|
||||||
#define DEVICE4_MSG_W_DISP_MODE 0x08
|
#define DEVICE4_MSG_W_DISP_MODE 0x08
|
||||||
|
|
||||||
#define DEVICE4_MSG_R_GLASSID 0x15
|
#define DEVICE4_MSG_R_GLASSID 0x15
|
||||||
#define DEVICE4_MSG_R_DP7911_FW_VERSION 0x16
|
#define DEVICE4_MSG_R_DP7911_FW_VERSION 0x16
|
||||||
#define DEVICE4_MSG_R_DSP_VERSION 0x18
|
#define DEVICE4_MSG_R_DSP_VERSION 0x18
|
||||||
|
@ -139,6 +141,7 @@ struct device4_t {
|
||||||
|
|
||||||
bool active;
|
bool active;
|
||||||
uint8_t brightness;
|
uint8_t brightness;
|
||||||
|
uint8_t disp_mode;
|
||||||
|
|
||||||
device4_event_callback callback;
|
device4_event_callback callback;
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,7 +124,15 @@ static bool recv_payload_msg(device4_type* device, uint8_t msgid, uint8_t len, u
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(data, packet.data + 1, len);
|
const uint16_t data_len = packet.length - 18;
|
||||||
|
|
||||||
|
if (len <= data_len) {
|
||||||
|
memcpy(data, packet.data + 1, len);
|
||||||
|
} else {
|
||||||
|
memcpy(data, packet.data + 1, data_len);
|
||||||
|
memset(data + data_len, 0, len - data_len);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,6 +242,21 @@ device4_type* device4_open(device4_event_callback callback) {
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!send_payload_action(device, DEVICE4_MSG_R_DISP_MODE, 0, NULL)) {
|
||||||
|
perror("Requesting display mode failed!\n");
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!recv_payload_msg(device, DEVICE4_MSG_R_DISP_MODE, 1, &device->disp_mode)) {
|
||||||
|
perror("Receiving display mode failed!\n");
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
printf("Brightness: %d\n", device->brightness);
|
||||||
|
printf("Disp-Mode: %d\n", device->disp_mode);
|
||||||
|
#endif
|
||||||
|
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue