MCPcopy Create free account
hub / github.com/Blueforcer/awtrix3 / generateNotification

Method generateNotification

src/DisplayManager.cpp:753–1029  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

751}
752
753bool DisplayManager_::generateNotification(uint8_t source, const char *json)
754{
755 // source: 0=MQTT, 1=HTTP
756 DynamicJsonDocument doc(6144);
757 DeserializationError error = deserializeJson(doc, json);
758 if (error)
759 {
760 DEBUG_PRINTLN(error.c_str());
761 doc.clear();
762 return false;
763 }
764
765 Notification newNotification;
766
767 newNotification.progress = doc.containsKey("progress") ? doc["progress"].as<int>() : -1;
768
769 if (doc.containsKey("progressC"))
770 {
771 auto progressC = doc["progressC"];
772 newNotification.pColor = getColorFromJsonVariant(progressC, 0x00FF00);
773 }
774 else
775 {
776 newNotification.pColor = 0x00FF00;
777 }
778
779 if (doc.containsKey("progressBC"))
780 {
781 auto progressBC = doc["progressBC"];
782 newNotification.pbColor = getColorFromJsonVariant(progressBC, 0xFFFFFF);
783 }
784 else
785 {
786 newNotification.pbColor = 0xFFFFFF;
787 }
788
789 if (doc.containsKey("background"))
790 {
791 auto background = doc["background"];
792 newNotification.background = getColorFromJsonVariant(background, 0);
793 }
794 else
795 {
796 newNotification.background = 0x000000;
797 }
798
799 if (doc.containsKey("draw"))
800 {
801 newNotification.drawInstructions = doc["draw"].as<String>();
802 }
803 else
804 {
805 newNotification.drawInstructions = "";
806 }
807
808 if (doc.containsKey("effect"))
809 {
810 newNotification.effect = getEffectIndex(doc["effect"].as<String>());

Callers 3

processMqttMessageFunction · 0.80
checkNewYearMethod · 0.80
addHandlerFunction · 0.80

Calls 11

getColorFromJsonVariantFunction · 0.85
getEffectIndexFunction · 0.85
updateEffectSettingsFunction · 0.85
getOverlayFunction · 0.85
parseFragmentsTextFunction · 0.85
utf8asciiFunction · 0.85
lengthMethod · 0.80
rawPublishMethod · 0.80
setCurrentAppMethod · 0.80
clearMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected