Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include "my_List.h"
  2. // Do not initialize inputs!
  3. void Init(void)
  4. {
  5. count = 0;
  6. v->Out = 0;
  7. }
  8.  
  9. void Exec(void)
  10. {
  11. if(*v->Enable == 1){
  12. struct item *newItem = (struct item*) malloc(sizeof(struct item));
  13. newItem->value = *v->In;
  14. newItem->index = count;
  15. if(count == 0){
  16. myListHeader = newItem;
  17. myListTail = newItem;
  18. }else{
  19. myListTail->next = newItem;
  20. myListTail = myListTail->next;
  21. }
  22.  
  23. if(count < v->Interval){
  24. v->Out = 0;
  25. }else{
  26.  
  27. myListHeader = myListHeader->next;
  28. free(myListHeader->prev);
  29. myListHeader->prev = NULL;
  30. }
  31. count++;
  32. }
  33. if(count != 0)
  34. v->Out = myListTail->value - myListHeader->value;
  35. else
  36. v->Out = 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement