Implement MQTT publish in HardwareRevX
Change-Id: I7b6955a662716f83dd8daf34128a353efa26bf80
This commit is contained in:
parent
be0aafaffc
commit
b09d4f7331
1 changed files with 43 additions and 35 deletions
|
@ -85,12 +85,18 @@ void HardwareRevX::debugPrint(std::string aDebugMessage){
|
|||
Serial.print(aDebugMessage.c_str());
|
||||
}
|
||||
|
||||
void HardwareRevX::sendIR(){
|
||||
|
||||
}
|
||||
void HardwareRevX::sendIR() {}
|
||||
|
||||
void HardwareRevX::MQTTPublish(const char *topic, const char *payload) {
|
||||
|
||||
#ifdef ENABLE_WIFI
|
||||
if (client.connected()) {
|
||||
client.publish(topic, payload);
|
||||
} else {
|
||||
debugPrint("MQTT Client Not Connected When Attempting Publish.");
|
||||
}
|
||||
#else
|
||||
debugPrint("Attempting To Publish MQTT with wifi Disabled!");
|
||||
#endif
|
||||
}
|
||||
|
||||
void HardwareRevX::initLVGL() {
|
||||
|
@ -116,7 +122,8 @@ void HardwareRevX::initLVGL() {
|
|||
lv_indev_drv_register(&indev_drv);
|
||||
}
|
||||
|
||||
void HardwareRevX::handleDisplayFlush(lv_disp_drv_t *disp, const lv_area_t *area,
|
||||
void HardwareRevX::handleDisplayFlush(lv_disp_drv_t *disp,
|
||||
const lv_area_t *area,
|
||||
lv_color_t *color_p) {
|
||||
uint32_t w = (area->x2 - area->x1 + 1);
|
||||
uint32_t h = (area->y2 - area->y1 + 1);
|
||||
|
@ -409,8 +416,8 @@ void HardwareRevX::setupWifi(){
|
|||
}
|
||||
|
||||
void HardwareRevX::startTasks() {
|
||||
if(xTaskCreate(&HardwareRevX::updateBatteryTask,
|
||||
"Battery Percent Update",1024,nullptr,5,&batteryUpdateTskHndl) != pdPASS){
|
||||
if (xTaskCreate(&HardwareRevX::updateBatteryTask, "Battery Percent Update",
|
||||
1024, nullptr, 5, &batteryUpdateTskHndl) != pdPASS) {
|
||||
debugPrint("ERROR Could not Create Battery Update Task!");
|
||||
}
|
||||
}
|
||||
|
@ -432,8 +439,7 @@ void HardwareRevX::loopHandler(){
|
|||
// Update Backlight brightness
|
||||
static int fadeInTimer = millis(); // fadeInTimer = time after setup
|
||||
if (millis() <
|
||||
fadeInTimer +
|
||||
backlight_brightness) { // Fade in the backlight brightness
|
||||
fadeInTimer + backlight_brightness) { // Fade in the backlight brightness
|
||||
ledcWrite(5, millis() - fadeInTimer);
|
||||
} else { // Dim Backlight before entering standby
|
||||
if (standbyTimer < 2000)
|
||||
|
@ -460,13 +466,14 @@ void HardwareRevX::loopHandler(){
|
|||
|
||||
// TODO Create batter change notification for UI
|
||||
|
||||
// if (battery_ischarging || (!battery_ischarging && battery_voltage > 4350)) {
|
||||
// if (battery_ischarging || (!battery_ischarging && battery_voltage >
|
||||
// 4350)) {
|
||||
// lv_label_set_text(objBattPercentage, "");
|
||||
// lv_label_set_text(objBattIcon, LV_SYMBOL_USB);
|
||||
// } else {
|
||||
// // Update status bar battery indicator
|
||||
// // lv_label_set_text_fmt(objBattPercentage, "%d%%", battery_percentage);
|
||||
// if (battery_percentage > 95)
|
||||
// // lv_label_set_text_fmt(objBattPercentage, "%d%%",
|
||||
// battery_percentage); if (battery_percentage > 95)
|
||||
// lv_label_set_text(objBattIcon, LV_SYMBOL_BATTERY_FULL);
|
||||
// else if (battery_percentage > 75)
|
||||
// lv_label_set_text(objBattIcon, LV_SYMBOL_BATTERY_3);
|
||||
|
@ -481,7 +488,8 @@ void HardwareRevX::loopHandler(){
|
|||
|
||||
// Keypad Handling
|
||||
customKeypad.getKey(); // Populate key list
|
||||
for (int i = 0; i < LIST_MAX; i++) { // Handle multiple keys (Not really necessary in this case)
|
||||
for (int i = 0; i < LIST_MAX;
|
||||
i++) { // Handle multiple keys (Not really necessary in this case)
|
||||
if (customKeypad.key[i].kstate == PRESSED ||
|
||||
customKeypad.key[i].kstate == HOLD) {
|
||||
standbyTimer =
|
||||
|
@ -490,9 +498,9 @@ void HardwareRevX::loopHandler(){
|
|||
Serial.println(customKeypad.key[i].kchar);
|
||||
// Send IR codes depending on the current device (tabview page)
|
||||
if (currentDevice == 1) {
|
||||
IrSender.sendRC5(IrSender.encodeRC5X(0x00, keyMapTechnisat[keyCode / ROWS][keyCode % ROWS]));
|
||||
}
|
||||
else if (currentDevice == 2){
|
||||
IrSender.sendRC5(IrSender.encodeRC5X(
|
||||
0x00, keyMapTechnisat[keyCode / ROWS][keyCode % ROWS]));
|
||||
} else if (currentDevice == 2) {
|
||||
IrSender.sendSony((keyCode / ROWS) * (keyCode % ROWS), 15);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue