water.dbg 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. XDEF Water
  2. XREF __SEG_END_SSTACK,grow_lights,PORT_T,display_string,disp,is_watering,PORT_S,PORT_P,sprinkler_event,word_out,SPRINKLER_ARR,byte_out,sprinkler_arr_i
  3. Constants: Section
  4. ;STEP_ARR dc.b $0A,$12,$14,$0C,$0 ;array sequence to spin motor
  5. ARRAY_LENGTH dc.b $04
  6. Variables: Section
  7. Water: ;push register and accumulator values for retention
  8. PSHA
  9. PSHB
  10. PSHD
  11. PSHX
  12. PSHY
  13. ;get out of here if we should not be watering (don't do anything with sprinkler) or the display
  14. LDAB is_watering
  15. CMPB #$FF
  16. LBNE Return
  17. ;sprinkler stuff
  18. LDAB sprinkler_event ;check the event flag
  19. CMPB #$FF ;all 1's indicates that the event has fired, if it's not equal, show watering
  20. LBNE ShowWatering ;still display the watering... message
  21. ;handle sprinkle event
  22. LDAB sprinkler_arr_i ;check which array position we are at
  23. INCB ;go to next index
  24. STAB sprinkler_arr_i ; ^
  25. CMPB #8 ;check if we have reached the end of the array
  26. BLT Continue ;continue if not at the end of the array
  27. MOVB #$00,sprinkler_arr_i ;reset the array index to the beginning
  28. LDAB #$00
  29. Continue:
  30. LDX #SPRINKLER_ARR
  31. ABX
  32. STX word_out
  33. LDAA 0,X
  34. STAA PORT_P
  35. STAB byte_out
  36. CLR sprinkler_event
  37. ;...
  38. ShowWatering:
  39. ;print the temperature
  40. movb #'W',disp
  41. movb #'a',disp+1
  42. movb #'t',disp+2
  43. movb #'e',disp+3
  44. movb #'r',disp+4
  45. movb #'i',disp+5
  46. movb #'n',disp+6
  47. movb #'g',disp+7
  48. movb #'.',disp+8
  49. movb #'.',disp+9
  50. movb #'.',disp+10
  51. movb #' ',disp+11
  52. movb #' ',disp+12
  53. movb #' ',disp+13
  54. movb #' ',disp+14
  55. movb #' ',disp+15
  56. ;next line
  57. movb #' ',disp+16
  58. movb #' ',disp+17
  59. movb #' ',disp+18
  60. movb #' ',disp+19
  61. movb #' ',disp+20
  62. movb #' ',disp+21
  63. movb #' ',disp+22
  64. movb #' ',disp+23
  65. movb #' ',disp+24
  66. movb #' ',disp+25
  67. movb #' ',disp+26
  68. movb #' ',disp+27
  69. movb #' ',disp+28
  70. movb #' ',disp+29
  71. movb #' ',disp+30
  72. movb #' ',disp+31
  73. movb #0,disp+32 ;string terminator, acts like '\0'
  74. LDD #disp ;both of these steps are necessary to
  75. jsr display_string ;print to the LCD screen
  76. Return: ;restore registers and accumulators
  77. PULY
  78. PULX
  79. PULD
  80. PULB
  81. PULA
  82. RTS