Просмотр исходного кода

Added the ability to quickly change the temperature unit by holding the OK key

Victor 3 лет назад
Родитель
Сommit
2ee4c28448
3 измененных файлов с 8 добавлено и 1 удалено
  1. 3 1
      Sensors.c
  2. 1 0
      sensors/HTU21x.c
  3. 4 0
      views/General_view.c

+ 3 - 1
Sensors.c

@@ -624,8 +624,10 @@ UnitempStatus unitemp_sensor_updateData(Sensor* sensor) {
         UNITEMP_DEBUG("Sensor %s update status %d", sensor->name, sensor->status);
     }
 
-    if(app->settings.temp_unit == UT_TEMP_FAHRENHEIT && sensor->status == UT_SENSORSTATUS_OK)
+    if(app->settings.temp_unit == UT_TEMP_FAHRENHEIT && sensor->status == UT_SENSORSTATUS_OK) {
         uintemp_celsiumToFarengate(sensor);
+    }
+
     if(sensor->status == UT_SENSORSTATUS_OK) {
         sensor->temp += sensor->temp_offset / 10.f;
         if(app->settings.pressure_unit == UT_PRESSURE_MM_HG) {

+ 1 - 0
sensors/HTU21x.c

@@ -89,6 +89,7 @@ UnitempStatus unitemp_HTU21x_update(Sensor* sensor) {
             sensor->hum = ((0.001907 * (raw ^ 0x02)) - 6);
         }
         temp_hum = !temp_hum;
+        if(temp_hum) return UT_SENSORSTATUS_EARLYPOOL;
         return UT_SENSORSTATUS_OK;
     }
 

+ 4 - 0
views/General_view.c

@@ -542,6 +542,10 @@ static bool _input_callback(InputEvent* event, void* context) {
             return true;
         }
     }
+    //Обработка длинного нажатия "Ок"
+    if(event->key == InputKeyOk && event->type == InputTypeLong) {
+        app->settings.temp_unit = !app->settings.temp_unit;
+    }
 
     return true;
 }