Parcourir la source

Fix Event dates on Opus cards

DocSystem il y a 1 an
Parent
commit
dbd97cbac0
2 fichiers modifiés avec 9 ajouts et 10 suppressions
  1. 2 2
      api/calypso/cards/opus.c
  2. 7 8
      scenes/metroflip_scene_calypso.c

+ 2 - 2
api/calypso/cards/opus.c

@@ -117,9 +117,9 @@ CalypsoApp* get_opus_event_structure() {
     OpusEventStructure->container->size = app_elements_count;
 
     OpusEventStructure->container->elements[0] =
-        make_calypso_final_element("EventDate", 14, "Event date", CALYPSO_FINAL_TYPE_DATE);
+        make_calypso_final_element("EventDateStamp", 14, "Event date", CALYPSO_FINAL_TYPE_DATE);
     OpusEventStructure->container->elements[1] =
-        make_calypso_final_element("EventTime", 11, "Event time", CALYPSO_FINAL_TYPE_TIME);
+        make_calypso_final_element("EventTimeStamp", 11, "Event time", CALYPSO_FINAL_TYPE_TIME);
     OpusEventStructure->container->elements[2] =
         make_calypso_final_element("EventUnknownX", 19, "Unknown X", CALYPSO_FINAL_TYPE_NUMBER);
     OpusEventStructure->container->elements[3] = make_calypso_bitmap_element(

+ 7 - 8
scenes/metroflip_scene_calypso.c

@@ -1526,27 +1526,26 @@ static NfcCommand metroflip_scene_navigo_poller_callback(NfcGenericEvent event,
                             }
                         }
 
-                        // EventDate + EventTime
-                        event_key = "EventDate";
+                        // EventDateStamp
+                        event_key = "EventDateStamp";
                         int positionOffset = get_calypso_node_offset(
                             event_bit_representation, event_key, OpusEventStructure);
                         int start = positionOffset,
                             end = positionOffset +
                                   get_calypso_node_size(event_key, OpusEventStructure) - 1;
-                        uint64_t date_timestamp =
-                            (bit_slice_to_dec(event_bit_representation, start, end) +
-                             (float)epoch) +
-                            3600;
+                        int decimal_value = bit_slice_to_dec(event_bit_representation, start, end);
+                        uint64_t date_timestamp = (decimal_value * 24 * 3600) + epoch + 3600;
                         datetime_timestamp_to_datetime(
                             date_timestamp, &card->opus->events[i - 1].date);
 
-                        event_key = "EventTime";
+                        // EventTimeStamp
+                        event_key = "EventTimeStamp";
                         positionOffset = get_calypso_node_offset(
                             event_bit_representation, event_key, OpusEventStructure);
                         start = positionOffset,
                         end = positionOffset +
                               get_calypso_node_size(event_key, OpusEventStructure) - 1;
-                        int decimal_value = bit_slice_to_dec(event_bit_representation, start, end);
+                        decimal_value = bit_slice_to_dec(event_bit_representation, start, end);
                         card->opus->events[i - 1].date.hour = (decimal_value * 60) / 3600;
                         card->opus->events[i - 1].date.minute = ((decimal_value * 60) % 3600) / 60;
                         card->opus->events[i - 1].date.second = ((decimal_value * 60) % 3600) % 60;