Guest User

Untitled

a guest
Jul 15th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.55 KB | None | 0 0
  1. // ******************************************
  2. // Include section
  3.  
  4. // system
  5. #include "project.h"
  6.  
  7. // driver
  8. #include "display.h"
  9. #include "vti_as.h"
  10.  
  11.  // logic
  12. #include "trandi.h"
  13. #include "simpliciti.h"
  14. #include "user.h"
  15. #include "string.h"
  16.  
  17. // ******************************************
  18. // Global Variable section
  19. struct trandi sTrandi;
  20.  
  21. // ******************************************
  22. // Extern section
  23.  
  24. // ******************************************
  25. // @fn          reset_trandi
  26. // @brief       Reset / INIT trandi data.
  27. // @param       none
  28. // @return      none
  29. // ******************************************
  30. void reset_trandi(void)
  31. {
  32.     // Reset state is not active
  33.     sTrandi.mode = TRANDI_MODE_OFF;
  34.  
  35.     strcpy(sTrandi.msg, (u8*)"works now ");
  36. }
  37.  
  38. // ******************************************
  39. // @fn          sx_trandi
  40. // @brief       Button UP does nothing for now...
  41. // @param       u8 line     LINE2
  42. // @return      none
  43. // ******************************************
  44. void sx_trandi(u8 line)
  45. {
  46.  
  47. }
  48.  
  49. // ******************************************
  50. // @fn          display_trandi
  51. // @brief       Display routine.
  52. // @param       u8 line         LINE1
  53. //      u8 update       DISPLAY_LINE_UPDATE_FULL, DISPLAY_LINE_CLEAR
  54. // @return      none
  55. // ******************************************
  56. void display_trandi(u8 line, u8 update)
  57. {
  58.     if (update == DISPLAY_LINE_UPDATE_FULL)
  59.     {
  60.         display_chars(LCD_SEG_L1_3_0, sTrandi.msg, SEG_ON);
  61.         display_symbol(LCD_ICON_HEART, SEG_ON_BLINK_ON);
  62.  
  63.         // Set mode
  64.         sTrandi.mode = TRANDI_MODE_ON;
  65.     }
  66.     else if (update == DISPLAY_LINE_UPDATE_PARTIAL)
  67.     {
  68.         display_chars(LCD_SEG_L1_3_0, sTrandi.msg, SEG_ON);
  69.     }
  70.     else if (update == DISPLAY_LINE_CLEAR)
  71.     {
  72.         display_symbol(LCD_ICON_HEART, SEG_OFF);
  73.  
  74.         reset_trandi();
  75.     }
  76. }
  77.  
  78. // ******************************************
  79. // @fn          is_trandi_active
  80. // @brief       Returns 1 if trandi module is currently active and needs doing random stuff.
  81. // @param       none
  82. // @return      u8      1 = trandi module needs random stuff
  83. // ******************************************
  84. u8 is_trandi_active(void)
  85. {
  86.     return sTrandi.mode == TRANDI_MODE_ON;
  87. }
  88.  
  89.  void do_trandi_random(void)
  90. {
  91.     // Move the text
  92.     u8 firstElem = sTrandi.msg[0];
  93.     u8 len = sizeof(sTrandi.msg) / sizeof(u8);
  94.     u8 i;
  95.     for(i = 0; i < len - 1; i++) sTrandi.msg[i] = sTrandi.msg[i+1];
  96.     sTrandi.msg[len - 1] = firstElem;
  97.  
  98.     // Set display update flag
  99.     display.flag.update_trandi = 1;
  100. }
Add Comment
Please, Sign In to add comment