mike2545

Sunrise/ sun set tables

Oct 6th, 2011
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 5.81 KB | None | 0 0
  1. date = 10*(date >>4) + (date & $0f)
  2.  month = 10*(month >>4) + (month & $0f)                
  3. 'sunrise hour
  4. IF month =1 THEN month_multiplier =0
  5. IF month =2 THEN month_multiplier =31
  6. IF month =3 THEN month_multiplier =59
  7. IF month =4 THEN month_multiplier =90
  8. IF month =5 THEN month_multiplier =120
  9. IF month =6 THEN month_multiplier =151
  10. IF month =7 THEN month_multiplier =181
  11. IF month =8 THEN month_multiplier =212
  12. IF month =9 THEN month_multiplier =243
  13. IF month =10 THEN month_multiplier =273
  14. IF month =11 THEN month_multiplier =304
  15. IF month =12 THEN month_multiplier =334
  16.  
  17. day_of_year = date + month_multiplier
  18. 'sunrise hr
  19. IF month <=6 THEN
  20. Lookup day_of_year,[0,8,8,8,8,8,8,8,8,8,8,8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,_ 'jan
  21. 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,_'Feb
  22. 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,_'mar
  23. 7,7,7,7,7,7,7,7,7,7,7,7,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,_'april
  24. 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,_'may
  25. 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6],sunrise_hour'june
  26. endif
  27.  IF month >=7 THEN
  28. lookup day_of_year-181,[0,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,_'July
  29. 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,_'aug
  30. 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,_'sept
  31. 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,_'oct
  32. 8,8,8,8,8,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,_'nov
  33. 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,8,8,8,8,8,8], sunrise_hour
  34.  endif
  35.  
  36. 'sunrise min
  37. IF month <=6 THEN
  38. lookup day_of_year,[0,01,01,01,02,02,01,01,01,01,01,01,00,00,00,59,59,58,58,57,57,56,55,55,54,53,53,52,51,50,49,48,_'Jan
  39. 47,46,45,44,43,42,41,40,38,37,36,35,33,32,31,29,28,27,25,24,22,21,19,18,16,15,13,12,_'Feb
  40. 10,9,7,6,4,2,1,59,57,56,54,52,51,49,47,46,44,42,41,39,37,36,34,32,30,29,27,25,24,22,20,_'mar
  41. 19,17,15,13,12,10,8,7,5,4,2,0,59,57,56,54,52,51,49,48,46,45,43,42,40,39,37,36,35,33,_  'april
  42. 32,31,29,28,27,26,24,23,22,21,20,19,18,16,15,14,14,13,12,11,10,9,8,8,7,6,6,5,4,4,3,_'may
  43. 3,2,2,1,1,1,0,0,0,0,0,59,59,59,59,59,59,59,0,0,0,0,0,1,1,1,2,2,2,3],sunrise_min'june
  44. endif
  45. IF month >=7 THEN
  46. lookup day_of_year-181,[0,3,4,4,5,6,6,7,7,8,9,9,10,11,12,13,13,14,15,16,17,18,18,19,20,21,22,23,24,25,26,27,_'july
  47. 28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,58,59,_'aug
  48. 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,_'sept
  49. 30,31,33,34,35,36,37,38,39,40,41,42,43,45,46,47,48,49,50,51,52,54,55,56,57,58,59,0,2,3,4,_'oct
  50. 5,7,8,9,10,12,13,14,15,16,18,19,20,21,23,24,25,26,27,29,30,31,32,33,34,35,37,38,39,40,_'Nov
  51. 41,42,43,44,45,46,47,48,49,50,51,51,52,53,54,54,55,56,56,57,58,58,59,59,59,0,0,0,1,1,1],sunrise_min'dec
  52. endif
  53. 'sunset hour (24 hr)
  54. IF month <=6 THEN
  55. lookup day_of_year,[0,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,_'jan
  56. 17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,_'feb
  57. 18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,_'mar
  58. 19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,_'april
  59. 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,_'may
  60. 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21],sunset_hour'june
  61. endif
  62.  IF month >=7 THEN
  63. lookup day_of_year-181,[0,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,20,20,20,20,20,_'july
  64. 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,_'aug
  65. 20,20,20,20,20,20,20,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,_'sept
  66. 19,19,19,19,19,19,19,19,19,19,19,19,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,_'oct
  67. 18,18,18,18,18,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,_'nov
  68. 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17],sunset_hour
  69.  endif
  70. 'sunset minute
  71. IF month <=6 THEN
  72. lookup day_of_year,[0,14,15,15,16,17,18,19,20,21,22,23,24,25,27,28,29,30,31,32,34,35,36,37,38,40,41,42,43,45,46,47,_'jan
  73. 48,50,51,52,54,55,56,57,59,0,1,2,4,5,6,8,9,10,11,12,114,15,16,17,19,20,21,22,_'feb
  74. 23,25,26,27,28,29,30,32,33,34,35,36,37,38,40,41,42,43,44,45,46,47,48,50,51,52,53,54,55,56,57,_'mar
  75. 58,59,1,2,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19,20,21,22,23,25,26,27,28,29,30,_'april
  76. 31,32,33,34,35,36,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,56,57,58,59,0,1,_'may
  77. 1,2,3,4,4,5,6,6,7,7,8,9,9,10,10,10,11,11,11,12,12,12,12,13,13,13,13,13,13,13],sunset_min'june
  78. endif
  79. IF month >=7 THEN
  80. lookup day_of_year-181,[0,13,13,12,12,12,12,12,11,11,10,10,10,9,9,8,7,7,6,5,5,4,3,2,1,1,0,59,58,57,54,55,_'july
  81. 54,52,51,50,49,48,46,45,44,43,41,40,39,37,36,34,33,32,30,29,27,26,24,22,21,19,18,16,15,13,11,_'Aug
  82. 10,8,6,5,3,1,0,58,56,55,53,51,49,48,46,44,42,41,39,37,35,34,32,30,29,27,25,23,22,20,_'sept
  83. 18,16,15,13,11,10,8,6,5,3,1,0,58,57,55,53,52,50,49,47,46,44,43,41,40,39,37,36,34,33,32,_'oct
  84. 30,29,28,27,26,24,23,22,21,20,19,18,17,16,15,14,13,13,12,11,10,10,9,8,8,7,7,6,6,6,_'nov
  85. 5,5,5,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,6,6,7,7,8,8,9,9,10,11,11,12,13],sunset_min
  86. endif
  87. debug "back light bit ", dec backlight_bit,cr
  88. debug "Sunrise", dec sunrise_hour,":",dec sunrise_min,cr
  89. debug "Sunset",dec sunset_hour,":",dec sunset_min ,cr  
  90.  
  91. sunrise_hour =(((sunrise_hour / 10) << 4) + (sunrise_hour // 10))
  92. sunrise_min = (((sunrise_min / 10) << 4) + (sunrise_min // 10))
  93. sunset_hour = (((sunset_hour / 10) << 4) + (sunset_hour // 10))
  94. sunset_min = (((sunset_min / 10) << 4) + (sunset_min // 10))
  95. IF hour = sunrise_hour AND minute = sunrise_min THEN backlight_bit = 1
  96. IF hour = sunset_hour AND minute = sunset_min THEN backlight_bit = 0
  97.  
  98.  
Advertisement
Add Comment
Please, Sign In to add comment