kx155.nas 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. # KX-155 Support
  2. #
  3. # Gary Neely aka 'Buckaroo'
  4. #
  5. # Round-off errors screw-up the textranslate animation used to display digits. This is a problem
  6. # for the NAV and COMM freq display. This seems to affect only decimal place digits. So here I'm using
  7. # a listener to copy the MHz and KHz portions of a freq string to a separate integer values
  8. # used by the animations.
  9. var nav1selstr = props.globals.getNode("/instrumentation/nav[0]/frequencies/selected-mhz-fmt");
  10. var nav1selmhz = props.globals.getNode("/instrumentation/nav[0]/frequencies/display-sel-mhz");
  11. var nav1selkhz = props.globals.getNode("/instrumentation/nav[0]/frequencies/display-sel-khz");
  12. var nav2selstr = props.globals.getNode("/instrumentation/nav[1]/frequencies/selected-mhz-fmt");
  13. var nav2selmhz = props.globals.getNode("/instrumentation/nav[1]/frequencies/display-sel-mhz");
  14. var nav2selkhz = props.globals.getNode("/instrumentation/nav[1]/frequencies/display-sel-khz");
  15. var nav1sbystr = props.globals.getNode("/instrumentation/nav[0]/frequencies/standby-mhz-fmt");
  16. var nav1sbymhz = props.globals.getNode("/instrumentation/nav[0]/frequencies/display-sby-mhz");
  17. var nav1sbykhz = props.globals.getNode("/instrumentation/nav[0]/frequencies/display-sby-khz");
  18. var nav2sbystr = props.globals.getNode("/instrumentation/nav[1]/frequencies/standby-mhz-fmt");
  19. var nav2sbymhz = props.globals.getNode("/instrumentation/nav[1]/frequencies/display-sby-mhz");
  20. var nav2sbykhz = props.globals.getNode("/instrumentation/nav[1]/frequencies/display-sby-khz");
  21. # This initializes the values
  22. var navtemp = split(".",nav1selstr.getValue());
  23. nav1selmhz.setValue(navtemp[0]);
  24. nav1selkhz.setValue(navtemp[1]);
  25. navtemp = split(".",nav2selstr.getValue());
  26. nav2selmhz.setValue(navtemp[0]);
  27. nav2selkhz.setValue(navtemp[1]);
  28. navtemp = split(".",nav1sbystr.getValue());
  29. nav1sbymhz.setValue(navtemp[0]);
  30. nav1sbykhz.setValue(navtemp[1]);
  31. navtemp = split(".",nav2sbystr.getValue());
  32. nav2sbymhz.setValue(navtemp[0]);
  33. nav2sbykhz.setValue(navtemp[1]);
  34. # And these make sure they're updated
  35. setlistener(nav1selstr, func {
  36. var navtemp = split(".",nav1selstr.getValue());
  37. nav1selmhz.setValue(navtemp[0]);
  38. nav1selkhz.setValue(navtemp[1]);
  39. });
  40. setlistener(nav2selstr, func {
  41. var navtemp = split(".",nav2selstr.getValue());
  42. nav2selmhz.setValue(navtemp[0]);
  43. nav2selkhz.setValue(navtemp[1]);
  44. });
  45. setlistener(nav1sbystr, func {
  46. var navtemp = split(".",nav1sbystr.getValue());
  47. nav1sbymhz.setValue(navtemp[0]);
  48. nav1sbykhz.setValue(navtemp[1]);
  49. });
  50. setlistener(nav2sbystr, func {
  51. var navtemp = split(".",nav2sbystr.getValue());
  52. nav2sbymhz.setValue(navtemp[0]);
  53. nav2sbykhz.setValue(navtemp[1]);
  54. });
  55. # Deal with Ident. This defaults to on which is annoying to many,
  56. # so let's make sure it's off.
  57. var init_navs = func {
  58. setprop("/instrumentation/nav[0]/ident",0);
  59. setprop("/instrumentation/nav[1]/ident",0);
  60. }
  61. var comm1sel = props.globals.getNode("/instrumentation/comm[0]/frequencies/selected-mhz");
  62. var comm1sby = props.globals.getNode("/instrumentation/comm[0]/frequencies/standby-mhz");
  63. var comm1selstr = props.globals.getNode("/instrumentation/comm[0]/frequencies/selected-mhz-fmt");
  64. var comm1sbystr = props.globals.getNode("/instrumentation/comm[0]/frequencies/standby-mhz-fmt");
  65. var comm1selmhz= props.globals.getNode("/instrumentation/comm[0]/frequencies/display-sel-mhz");
  66. var comm1selkhz= props.globals.getNode("/instrumentation/comm[0]/frequencies/display-sel-khz");
  67. var comm1sbymhz= props.globals.getNode("/instrumentation/comm[0]/frequencies/display-sby-mhz");
  68. var comm1sbykhz= props.globals.getNode("/instrumentation/comm[0]/frequencies/display-sby-khz");
  69. var comm2sel = props.globals.getNode("/instrumentation/comm[1]/frequencies/selected-mhz");
  70. var comm2sby = props.globals.getNode("/instrumentation/comm[1]/frequencies/standby-mhz");
  71. var comm2selstr = props.globals.getNode("/instrumentation/comm[1]/frequencies/selected-mhz-fmt");
  72. var comm2sbystr = props.globals.getNode("/instrumentation/comm[1]/frequencies/standby-mhz-fmt");
  73. var comm2selmhz= props.globals.getNode("/instrumentation/comm[1]/frequencies/display-sel-mhz");
  74. var comm2selkhz= props.globals.getNode("/instrumentation/comm[1]/frequencies/display-sel-khz");
  75. var comm2sbymhz= props.globals.getNode("/instrumentation/comm[1]/frequencies/display-sby-mhz");
  76. var comm2sbykhz= props.globals.getNode("/instrumentation/comm[1]/frequencies/display-sby-khz");
  77. # Update support vars on comm change
  78. setlistener(comm1sel, func {
  79. var commstr = sprintf("%.2f",comm1sel.getValue()); # String conversion
  80. var commtemp = split(".",commstr); # Split into MHz and KHz
  81. comm1selmhz.setValue(commtemp[0]);
  82. comm1selkhz.setValue(commtemp[1]);
  83. });
  84. setlistener(comm1sby, func {
  85. var commstr = sprintf("%.2f",comm1sby.getValue());
  86. var commtemp = split(".",commstr);
  87. comm1sbymhz.setValue(commtemp[0]);
  88. comm1sbykhz.setValue(commtemp[1]);
  89. });
  90. setlistener(comm2sel, func {
  91. var commstr = sprintf("%.2f",comm2sel.getValue());
  92. var commtemp = split(".",commstr);
  93. comm2selmhz.setValue(commtemp[0]);
  94. comm2selkhz.setValue(commtemp[1]);
  95. });
  96. setlistener(comm2sby, func {
  97. var commstr = sprintf("%.2f",comm2sby.getValue());
  98. var commtemp = split(".",commstr);
  99. comm2sbymhz.setValue(commtemp[0]);
  100. comm2sbykhz.setValue(commtemp[1]);
  101. });
  102. # Set comm support vars to startups
  103. var init_comms = func {
  104. var commstr = "";
  105. var commtemp = 0;
  106. commstr = sprintf("%.2f",comm1sel.getValue());
  107. commtemp = split(".",commstr);
  108. comm1selmhz.setValue(commtemp[0]);
  109. comm1selkhz.setValue(commtemp[1]);
  110. commstr = sprintf("%.2f",comm1sby.getValue());
  111. commtemp = split(".",commstr);
  112. comm1sbymhz.setValue(commtemp[0]);
  113. comm1sbykhz.setValue(commtemp[1]);
  114. commstr = sprintf("%.2f",comm2sel.getValue());
  115. commtemp = split(".",commstr);
  116. comm2selmhz.setValue(commtemp[0]);
  117. comm2selkhz.setValue(commtemp[1]);
  118. commstr = sprintf("%.2f",comm2sby.getValue());
  119. commtemp = split(".",commstr);
  120. comm2sbymhz.setValue(commtemp[0]);
  121. comm2sbykhz.setValue(commtemp[1]);
  122. }
  123. settimer(init_navs, 2);
  124. settimer(init_comms, 2);