+bool getDemodBuf(uint8_t *buff, size_t *size) {
+ if (buff == NULL) return false;
+ if (size == NULL) return false;
+ if (*size == 0) return false;
+
+ *size = (*size > DemodBufferLen) ? DemodBufferLen : *size;
+
+ memcpy(buff, DemodBuffer, *size);
+ return true;
+}
+
+// option '1' to save DemodBuffer any other to restore
+void save_restoreDB(uint8_t saveOpt)
+{
+ static uint8_t SavedDB[MAX_DEMOD_BUF_LEN];
+ static size_t SavedDBlen;
+ static bool DB_Saved = false;
+ static int savedDemodStartIdx = 0;
+ static int savedDemodClock = 0;
+
+ if (saveOpt == GRAPH_SAVE) { //save
+
+ memcpy(SavedDB, DemodBuffer, sizeof(DemodBuffer));
+ SavedDBlen = DemodBufferLen;
+ DB_Saved=true;
+ savedDemodStartIdx = g_DemodStartIdx;
+ savedDemodClock = g_DemodClock;
+ } else if (DB_Saved) { //restore
+ memcpy(DemodBuffer, SavedDB, sizeof(DemodBuffer));
+ DemodBufferLen = SavedDBlen;
+ g_DemodClock = savedDemodClock;
+ g_DemodStartIdx = savedDemodStartIdx;
+ }
+ return;
+}
+